From 0576046d024a4eefba2dd7e43706e1d78270fa40 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 17 Apr 2018 16:29:32 -0700 Subject: when changing cover photo, show existing --- Zotlabs/Module/Cover_photo.php | 1 + view/theme/redbasic/css/style.css | 4 ++++ view/tpl/cover_photo.tpl | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 56e35f912..d76c1b408 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -355,6 +355,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $o .= replace_macros($tpl,array( '$user' => \App::$channel['channel_address'], + '$existing' => get_cover_photo(local_channel(),'array',PHOTO_RES_COVER_850), '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), '$title' => t('Change Cover Photo'), diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index a9dcc292a..6e516b21e 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -1795,3 +1795,7 @@ dl.bb-dl > dd > li { position: absolute; text-shadow: -2px 0 1px #fff, 0 2px 1px#fff, 2px 0 1px #fff, 0 -2px 1px #fff; } + +.cover-photo-review { + margin-bottom: 10px; +} diff --git a/view/tpl/cover_photo.tpl b/view/tpl/cover_photo.tpl index 829a3a556..92efcdf02 100755 --- a/view/tpl/cover_photo.tpl +++ b/view/tpl/cover_photo.tpl @@ -86,10 +86,11 @@

{{$title}}

- + {{if $existing}} + {{t('Cover Photo')}} + {{/if}}
-
-- cgit v1.2.3 From 393cd46a82bd4c00c72e8734df2d1fa62928cc06 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 17 Apr 2018 20:08:14 -0700 Subject: public stream tag enhancements --- Zotlabs/Module/Pubstream.php | 8 +++++- Zotlabs/Widget/Pubtagcloud.php | 40 ++++++++++++++++++++++++++ include/taxonomy.php | 64 ++++++++++++++++++++++++++++++++++++++++++ view/pdl/mod_pubstream.pdl | 4 +++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Widget/Pubtagcloud.php diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 45487e3a4..e8a0146c4 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -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)) . "' " : ''); diff --git a/Zotlabs/Widget/Pubtagcloud.php b/Zotlabs/Widget/Pubtagcloud.php new file mode 100644 index 000000000..af288cf9a --- /dev/null +++ b/Zotlabs/Widget/Pubtagcloud.php @@ -0,0 +1,40 @@ +

' . (($recent) ? t('Trending') : t('Tags')) . '

'; + foreach($r as $rr) { + $o .= '#'.$rr[0].' ' . "\r\n"; + } + $o .= '
'; + } + + 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 = '') { diff --git a/view/pdl/mod_pubstream.pdl b/view/pdl/mod_pubstream.pdl index 95f069031..7911f6dfd 100644 --- a/view/pdl/mod_pubstream.pdl +++ b/view/pdl/mod_pubstream.pdl @@ -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] -- cgit v1.2.3 From a806c68713baebcc8ca3353e01031593b2f571a4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 17 Apr 2018 20:27:36 -0700 Subject: fine tuning the public stream tag results --- Zotlabs/Widget/Pubtagcloud.php | 2 +- include/taxonomy.php | 9 --------- view/pdl/mod_pubstream.pdl | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Zotlabs/Widget/Pubtagcloud.php b/Zotlabs/Widget/Pubtagcloud.php index af288cf9a..b21586db0 100644 --- a/Zotlabs/Widget/Pubtagcloud.php +++ b/Zotlabs/Widget/Pubtagcloud.php @@ -31,7 +31,7 @@ class Pubtagcloud { - $limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 50); + $limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 75); return pubtagblock($net_firehose,$site_firehose, $limit, $trending); diff --git a/include/taxonomy.php b/include/taxonomy.php index 6011ca80c..97cbe03d7 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -368,15 +368,6 @@ function pub_tagadelic($net,$site,$limit,$recent,$type) { } - - - - - - - - - function dir_tagadelic($count = 0, $hub = '') { $count = intval($count); diff --git a/view/pdl/mod_pubstream.pdl b/view/pdl/mod_pubstream.pdl index 7911f6dfd..abb1a4931 100644 --- a/view/pdl/mod_pubstream.pdl +++ b/view/pdl/mod_pubstream.pdl @@ -1,5 +1,5 @@ [region=aside] -[widget=pubtagcloud][var=trending]15[/var][var=limit]20[/var][/widget] +[widget=pubtagcloud][var=trending]8[/var][var=limit]20[/var][/widget] [widget=pubtagcloud][/widget] [/region] [region=right_aside] -- cgit v1.2.3 From 6903dbcc0dd01e86f853fdd0cba680ece05aa937 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 17 Apr 2018 21:48:43 -0700 Subject: re-use directory safemode setting for public stream tag filtering since a handful of well-known tags skews the results wildly. Added 'bot' to the list just because it's noisy. A site can customise or nullify this feature if they desire. --- Zotlabs/Widget/Pubtagcloud.php | 3 ++- include/taxonomy.php | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Widget/Pubtagcloud.php b/Zotlabs/Widget/Pubtagcloud.php index b21586db0..826e3e6ae 100644 --- a/Zotlabs/Widget/Pubtagcloud.php +++ b/Zotlabs/Widget/Pubtagcloud.php @@ -28,12 +28,13 @@ class Pubtagcloud { $site_firehose = false; } + $safemode = get_xconfig(get_observer_hash(),'directory','safemode',1); $limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 75); - return pubtagblock($net_firehose,$site_firehose, $limit, $trending); + return pubtagblock($net_firehose,$site_firehose, $limit, $trending, $safemode); return ''; } diff --git a/include/taxonomy.php b/include/taxonomy.php index 97cbe03d7..59998be83 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -312,10 +312,10 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags -function pubtagblock($net,$site,$limit,$recent = 0,$type = TERM_HASHTAG) { +function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_HASHTAG) { $o = ''; - $r = pub_tagadelic($net,$site,$limit,$since,$type); + $r = pub_tagadelic($net,$site,$limit,$since,$safemode,$type); $link = z_root() . '/pubstream'; if($r) { @@ -329,13 +329,12 @@ function pubtagblock($net,$site,$limit,$recent = 0,$type = TERM_HASHTAG) { return $o; } -function pub_tagadelic($net,$site,$limit,$recent,$type) { +function pub_tagadelic($net,$site,$limit,$recent,$safemode,$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 "; } @@ -348,6 +347,16 @@ function pub_tagadelic($net,$site,$limit,$recent,$type) { if($recent) $sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' "; + + if($safemode) { + $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); + if($unsafetags) { + stringify_array_elms($unsafetags,true); + $sql_extra .= " and not term.term in ( " . implode(",",$unsafetags) . ") "; + } + } + + // Fetch tags $r = q("select term, count(term) as total from term left join item on term.oid = item.id where term.ttype = %d -- cgit v1.2.3 From 0f5ae5cac8770e27e815ac6558862a0fd321446d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 17 Apr 2018 21:55:00 -0700 Subject: also add the noisy 'rss' tag --- include/taxonomy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/taxonomy.php b/include/taxonomy.php index 59998be83..c46f60e46 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -349,7 +349,7 @@ function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) { if($safemode) { - $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); + $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); if($unsafetags) { stringify_array_elms($unsafetags,true); $sql_extra .= " and not term.term in ( " . implode(",",$unsafetags) . ") "; -- cgit v1.2.3 From fc7d9c235cf845e687095d4f30d32eca4c12bc4a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 17 Apr 2018 22:23:28 -0700 Subject: minor code optimisation --- include/taxonomy.php | 15 +++++---------- include/text.php | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/taxonomy.php b/include/taxonomy.php index c46f60e46..f65cdd941 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -174,8 +174,7 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re if(! is_array($authors)) $authors = array($authors); - stringify_array_elms($authors,true); - $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") "; + $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; } if($owner) { @@ -227,8 +226,7 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0 if(! is_array($authors)) $authors = array($authors); - stringify_array_elms($authors,true); - $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") "; + $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; } if($owner) { @@ -280,8 +278,7 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags if(! is_array($authors)) $authors = array($authors); - stringify_array_elms($authors,true); - $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") "; + $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") "; } if($owner) { @@ -351,8 +348,7 @@ function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) { if($safemode) { $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); if($unsafetags) { - stringify_array_elms($unsafetags,true); - $sql_extra .= " and not term.term in ( " . implode(",",$unsafetags) . ") "; + $sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") "; } } @@ -621,9 +617,8 @@ function get_things($profile_hash,$uid) { if(! in_array($rr['obj_obj'],$profile_hashes)) $profile_hashes[] = $rr['obj_obj']; } - stringify_array_elms($profile_hashes); if(! $profile_hash) { - $exp = explode(',',$profile_hashes); + $exp = stringify_array($profile_hashes,true); $p = q("select profile_guid as hash, profile_name as name from profile where profile_guid in ( $exp ) "); if($p) { foreach($r as $rr) { diff --git a/include/text.php b/include/text.php index 13c4bb819..bc44f22f3 100644 --- a/include/text.php +++ b/include/text.php @@ -2324,6 +2324,23 @@ function stringify_array_elms(&$arr, $escape = false) { $arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'"; } + +/** + * @brief Similar to stringify_array_elms but returns a string. If $escape is true, dbesc() each element before adding quotes. + * + * @param array $arr + * @param boolean $escape (optional) default false + * @return string + */ +function stringify_array($arr, $escape = false) { + if($arr) { + stringify_array_elms($arr); + return(implode(',',$arr)); + } + return EMPTY_STR; +} + + /** * @brief Indents a flat JSON string to make it more human-readable. * -- cgit v1.2.3