mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:55:15 +00:00
public stream tag enhancements
This commit is contained in:
parent
0576046d02
commit
393cd46a82
4 changed files with 115 additions and 1 deletions
|
@ -34,6 +34,8 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
|||
}
|
||||
|
||||
$mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : '');
|
||||
$hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : '');
|
||||
|
||||
|
||||
if(strpos($mid,'b64.') === 0)
|
||||
$decoded = @base64url_decode(substr($mid,4));
|
||||
|
@ -133,7 +135,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
|||
'$order' => 'comment',
|
||||
'$file' => '',
|
||||
'$cats' => '',
|
||||
'$tags' => '',
|
||||
'$tags' => $hashtags,
|
||||
'$dend' => '',
|
||||
'$mid' => $mid,
|
||||
'$verb' => '',
|
||||
|
@ -170,6 +172,10 @@ class Pubstream extends \Zotlabs\Web\Controller {
|
|||
$page_mode = 'client';
|
||||
|
||||
|
||||
if(x($hashtags)) {
|
||||
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
|
||||
}
|
||||
|
||||
$net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : '');
|
||||
$net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : '');
|
||||
|
||||
|
|
40
Zotlabs/Widget/Pubtagcloud.php
Normal file
40
Zotlabs/Widget/Pubtagcloud.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
class Pubtagcloud {
|
||||
|
||||
function widget($arr) {
|
||||
|
||||
$trending = ((array_key_exists('trending',$arr)) ? intval($arr['trending']) : 0);
|
||||
if((observer_prohibited(true))) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
||||
if(! intval(get_config('system','open_pubstream',1))) {
|
||||
if(! get_observer_hash()) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
}
|
||||
|
||||
$site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false);
|
||||
$net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true);
|
||||
|
||||
if(! ($site_firehose || $net_firehose)) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
||||
if($net_firehose) {
|
||||
$site_firehose = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 50);
|
||||
|
||||
return pubtagblock($net_firehose,$site_firehose, $limit, $trending);
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
|
@ -312,6 +312,70 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
|
|||
|
||||
|
||||
|
||||
function pubtagblock($net,$site,$limit,$recent = 0,$type = TERM_HASHTAG) {
|
||||
$o = '';
|
||||
|
||||
$r = pub_tagadelic($net,$site,$limit,$since,$type);
|
||||
$link = z_root() . '/pubstream';
|
||||
|
||||
if($r) {
|
||||
$o = '<div class="tagblock widget"><h3>' . (($recent) ? t('Trending') : t('Tags')) . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function pub_tagadelic($net,$site,$limit,$recent,$type) {
|
||||
|
||||
|
||||
$item_normal = item_normal();
|
||||
$count = intval($limit);
|
||||
|
||||
|
||||
if($site) {
|
||||
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
|
||||
}
|
||||
else {
|
||||
$sys = get_sys_channel();
|
||||
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
|
||||
$sql_extra = item_permissions_sql($sys['channel_id']);
|
||||
}
|
||||
|
||||
if($recent)
|
||||
$sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' ";
|
||||
|
||||
// Fetch tags
|
||||
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
|
||||
where term.ttype = %d
|
||||
and otype = %d and item_type = %d
|
||||
$sql_extra $uids $item_normal
|
||||
group by term order by total desc %s",
|
||||
intval($type),
|
||||
intval(TERM_OBJ_POST),
|
||||
intval(ITEM_TYPE_POST),
|
||||
((intval($count)) ? "limit $count" : '')
|
||||
);
|
||||
|
||||
if(! $r)
|
||||
return array();
|
||||
|
||||
return Zotlabs\Text\Tagadelic::calc($r);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function dir_tagadelic($count = 0, $hub = '') {
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
[region=aside]
|
||||
[widget=pubtagcloud][var=trending]15[/var][var=limit]20[/var][/widget]
|
||||
[widget=pubtagcloud][/widget]
|
||||
[/region]
|
||||
[region=right_aside]
|
||||
[widget=notifications][/widget]
|
||||
[widget=newmember][/widget]
|
||||
|
|
Loading…
Reference in a new issue