1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<?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, filer and cid results
if(x($_GET,'search') || x($_GET,'file') || (! x($_GET,'pf') && x($_GET,'cid'))) {
$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'),
'icon' => '',
'url'=>z_root() . '/' . $cmd . '?f=&order=comment' . $filter,
'sel'=> $commentord_active,
'title' => t('Order by last commented date'),
];
$tabs[] = [
'label' => t('Posted Date'),
'icon' => '',
'url'=>z_root() . '/' . $cmd . '?f=&order=post' . $filter,
'sel'=> $postord_active,
'title' => t('Order by last posted date'),
];
$tabs[] = array(
'label' => t('Date Unthreaded'),
'icon' => '',
'url' => z_root() . '/' . $cmd . '?f=&order=unthreaded' . $filter,
'sel' => $unthreaded_active,
'title' => t('Order unthreaded by date'),
);
$arr = ['tabs' => $tabs];
call_hooks('network_tabs', $arr);
$o = '';
if($arr['tabs']) {
$content = replace_macros(get_markup_template('common_pills.tpl'), [
'$pills' => $arr['tabs'],
]);
$o = replace_macros(get_markup_template('common_widget.tpl'), [
'$title' => t('Activity Order'),
'$content' => $content,
]);
}
return $o;
}
}
|