mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:35:12 +00:00
Create catcloud widget and provide a type option which can include 'cards' or 'articles'
This commit is contained in:
parent
1aba495a1c
commit
6bf2c64aa2
2 changed files with 56 additions and 6 deletions
46
Zotlabs/Widget/Catcloud.php
Normal file
46
Zotlabs/Widget/Catcloud.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
class Catcloud {
|
||||
|
||||
function widget($arr) {
|
||||
|
||||
if((! \App::$profile['profile_uid']) || (! \App::$profile['channel_hash']))
|
||||
return '';
|
||||
|
||||
$limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50);
|
||||
|
||||
if(array_key_exists('type',$arr)) {
|
||||
switch($arr['type']) {
|
||||
|
||||
case 'cards':
|
||||
|
||||
if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_pages'))
|
||||
return '';
|
||||
|
||||
return card_catblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash']);
|
||||
|
||||
case 'articles':
|
||||
|
||||
if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_pages'))
|
||||
return '';
|
||||
|
||||
return article_catblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash']);
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(! perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_stream'))
|
||||
return '';
|
||||
|
||||
return catblock(\App::$profile['profile_uid'], $limit, '', \App::$profile['channel_hash']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -212,8 +212,9 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0
|
|||
if(! perm_is_allowed($uid,get_observer_hash(),'view_pages'))
|
||||
return array();
|
||||
|
||||
$item_normal = " and item.item_hidden = 0 and item.item_deleted = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
|
||||
and item.item_blocked = 0 and item.obj_type != 'http://purl.org/zot/activity/file' ";
|
||||
|
||||
$item_normal = item_normal();
|
||||
$sql_options = item_permissions_sql($uid);
|
||||
$count = intval($count);
|
||||
|
||||
|
@ -236,15 +237,16 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0
|
|||
|
||||
|
||||
// Fetch tags
|
||||
|
||||
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
|
||||
where term.uid = %d and term.ttype = %d
|
||||
and otype = %d and item_type = %d and item_private = 0
|
||||
and otype = %d and item_type = %d
|
||||
$sql_options $item_normal
|
||||
group by term order by total desc %s",
|
||||
intval($uid),
|
||||
intval($type),
|
||||
intval(TERM_OBJ_POST),
|
||||
intval($restrict),
|
||||
intval(ITEM_TYPE_CARD),
|
||||
((intval($count)) ? "limit $count" : '')
|
||||
);
|
||||
|
||||
|
@ -263,7 +265,9 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
|
|||
return array();
|
||||
|
||||
|
||||
$item_normal = item_normal();
|
||||
$item_normal = " and item.item_hidden = 0 and item.item_deleted = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
|
||||
and item.item_blocked = 0 and item.obj_type != 'http://purl.org/zot/activity/file' ";
|
||||
|
||||
$sql_options = item_permissions_sql($uid);
|
||||
$count = intval($count);
|
||||
|
||||
|
@ -288,13 +292,13 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
|
|||
// Fetch tags
|
||||
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
|
||||
where term.uid = %d and term.ttype = %d
|
||||
and otype = %d and item_type = %d and item_private = 0
|
||||
and otype = %d and item_type = %d
|
||||
$sql_options $item_normal
|
||||
group by term order by total desc %s",
|
||||
intval($uid),
|
||||
intval($type),
|
||||
intval(TERM_OBJ_POST),
|
||||
intval($restrict),
|
||||
intval(ITEM_TYPE_ARTICLE),
|
||||
((intval($count)) ? "limit $count" : '')
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue