diff options
Diffstat (limited to 'Zotlabs/Widget')
-rw-r--r-- | Zotlabs/Widget/Activity_filter.php | 106 | ||||
-rw-r--r-- | Zotlabs/Widget/Activity_order.php | 121 |
2 files changed, 227 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php new file mode 100644 index 000000000..e56d13fc1 --- /dev/null +++ b/Zotlabs/Widget/Activity_filter.php @@ -0,0 +1,106 @@ +<?php + +namespace Zotlabs\Widget; + +class Activity_filter { + + function widget($arr) { + + if(! local_channel()) + return ''; + + $cmd = \App::$cmd; + + $tabs = []; + + if(feature_enabled(local_channel(),'personal_tab')) { + if(x($_GET,'conv')) { + $conv_active = (($_GET['conv'] == 1) ? 'active' : ''); + } + + $tabs[] = [ + 'label' => t('Personal Posts'), + 'icon' => 'user-circle', + 'url' => z_root() . '/' . $cmd . '/?f=&conv=1', + 'sel' => $conv_active, + 'title' => t('Show posts that mention or involve me'), + ]; + } + + if(feature_enabled(local_channel(),'star_posts')) { + if(x($_GET,'star')) { + $starred_active = (($_GET['star'] == 1) ? 'active' : ''); + } + + $tabs[] = [ + 'label' => t('Starred Posts'), + 'icon' => 'star', + 'url'=>z_root() . '/' . $cmd . '/?f=&star=1', + 'sel'=>$starred_active, + 'title' => t('Show posts that i have starred'), + ]; + } + + if(feature_enabled(local_channel(),'groups')) { + $groups = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + intval(local_channel()) + ); + + if($groups) { + foreach($groups as $g) { + if(x($_GET,'gid')) { + $group_active = (($_GET['gid'] == $g['id']) ? 'active' : ''); + } + + $tabs[] = [ + 'label' => $g['gname'], + 'icon' => 'users', + 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $g['id'], + 'sel' => $group_active, + 'title' => sprintf(t('Show posts related to the %s privacy group'), $g['gname']), + ]; + } + } + } + + if(feature_enabled(local_channel(),'filing')) { + $terms = q("select distinct term from term where uid = %d and ttype = %d order by term asc", + intval(local_channel()), + intval(TERM_FILE) + ); + + if($terms) { + foreach($terms as $t) { + if(x($_GET,'file')) { + $file_active = (($_GET['file'] == $t['term']) ? 'active' : ''); + } + + $tabs[] = [ + 'label' => $t['term'], + 'icon' => 'folder', + 'url' => z_root() . '/' . $cmd . '/?f=&file=' . $t['term'], + 'sel' => $file_active, + 'title' => sprintf(t('Show posts that i have filed to %s'), $t['term']), + ]; + } + } + } + + $arr = ['tabs' => $tabs]; + + call_hooks('network_tabs', $arr); + + $tpl = get_markup_template('common_pills.tpl'); + + if($arr['tabs']) { + return replace_macros($tpl, [ + '$title' => t('Activity Filters'), + '$tabs' => $arr['tabs'], + ]); + } + else { + return ''; + } + } + +} diff --git a/Zotlabs/Widget/Activity_order.php b/Zotlabs/Widget/Activity_order.php new file mode 100644 index 000000000..c973e3809 --- /dev/null +++ b/Zotlabs/Widget/Activity_order.php @@ -0,0 +1,121 @@ +<?php + +namespace Zotlabs\Widget; + +class Activity_order { + + function widget($arr) { + + if(! local_channel()) + return ''; + + if(! feature_enabled(local_channel(),'order_tab')) { + set_pconfig(local_channel(), 'mod_network', 'order', 0); + return ''; + } + + $commentord_active = ''; + $postord_active = ''; + $unthreaded_active = ''; + + if(x($_GET, 'order')) { + switch($_GET['order']){ + case 'post': + $postord_active = 'active'; + set_pconfig(local_channel(), 'mod_network', 'order', 1); + break; + case 'comment': + $commentord_active = 'active'; + set_pconfig(local_channel(), 'mod_network', 'order', 0); + break; + case 'unthreaded': + $unthreaded_active = 'active'; + set_pconfig(local_channel(), 'mod_network', 'order', 2); + break; + default: + $commentord_active = 'active'; + } + } + else { + $order = get_pconfig(local_channel(), 'mod_network', 'order', 0); + switch($order) { + case 0: + $commentord_active = 'active'; + break; + case 1: + $postord_active = 'active'; + break; + case 2: + $unthreaded_active = 'active'; + break; + default: + $commentord_active = 'active'; + } + } + + // override order for search results and filer results + if(x($_GET,'search') || x($_GET,'file')) { + $unthreaded_active = 'active'; + $commentord_active = $postord_active = 'disabled'; + } + + $cmd = \App::$cmd; + + $filter = ''; + + if(x($_GET,'cid')) + $filter .= '&cid=' . $_GET['cid']; + + if(x($_GET,'gid')) + $filter .= '&gid=' . $_GET['gid']; + + if(x($_GET,'star')) + $filter .= '&star=' . $_GET['star']; + + if(x($_GET,'conv')) + $filter .= '&conv=' . $_GET['conv']; + + if(x($_GET,'file')) + $filter .= '&file=' . $_GET['file']; + + + // tabs + $tabs = []; + + $tabs[] = [ + 'label' => t('Commented Date'), + 'url'=>z_root() . '/' . $cmd . '?f=&order=comment' . $filter, + 'sel'=> $commentord_active, + 'title' => t('Sort by Comment Date'), + ]; + $tabs[] = [ + 'label' => t('Posted Date'), + 'url'=>z_root() . '/' . $cmd . '?f=&order=post' . $filter, + 'sel'=> $postord_active, + 'title' => t('Sort by Post Date'), + ]; + $tabs[] = array( + 'label' => t('Date Unthreaded'), + 'url' => z_root() . '/' . $cmd . '?f=&order=unthreaded' . $filter, + 'sel' => $unthreaded_active, + 'title' => t('Activity Stream - by date'), + ); + + $arr = ['tabs' => $tabs]; + + call_hooks('network_tabs', $arr); + + $tpl = get_markup_template('common_pills.tpl'); + + if($arr['tabs']) { + return replace_macros($tpl, [ + '$title' => t('Order Activity by'), + '$tabs' => $arr['tabs'], + ]); + } + else { + return ''; + } + } + +} |