-
Notifications
You must be signed in to change notification settings - Fork 15
/
items.php
executable file
·210 lines (179 loc) · 7.07 KB
/
items.php
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/*
* This file is part of FEED ON FEEDS - http://feedonfeeds.com/
*
* items.php - displays right hand side "frame"
*
*
* Copyright (C) 2004-2007 Stephen Minutillo
* [email protected] - http://minutillo.com/steve/
*
* Distributed under the GPL - see LICENSE
*
*/
include_once 'fof-main.php';
include_once 'fof-render.php';
$feed = (isset($_GET['feed'])) ? $_GET['feed'] : NULL;
$what = (isset($_GET['what'])) ? $_GET['what'] : NULL;
$when = (isset($_GET['when'])) ? $_GET['when'] : NULL;
$how = (isset($_GET['how'])) ? $_GET['how'] : NULL;
$howmany = (isset($_GET['howmany'])) ? $_GET['howmany'] : NULL;
$search = (isset($_GET['search'])) ? $_GET['search'] : NULL;
$order = (isset($_GET['order'])) ? $_GET['order'] : NULL;
/* ignore invalid orderings */
if (!in_array($order, array('asc', 'desc'))) {
$order = NULL;
}
/* default to viewing unread items */
if (empty($what)) {
$what = 'unread';
/* default to page view only if we defaulted on what to view */
if (empty($how)) {
$how = 'paged';
}
}
$which = (isset($_GET['which'])) ? $_GET['which'] : NULL;
if (isset($how) && $how == 'paged' && !isset($which)) {
$which = 0;
}
/* Sort items as specified in url parameters, or view settings,
or as per user preferences, or descending if something is really amiss.
*/
$view_settings = fof_db_view_settings_get(fof_current_user(), fof_db_get_tag_name_map(explode(' ', $what)), $feed);
if (empty($order)) {
if (!empty($view_settings['order'])) {
$order = $view_settings['order'];
} else {
$order = $fof_prefs_obj->get('order');
}
}
if (empty($order)) {
$order = 'desc';
}
$itemcount = 0;
$statement = fof_db_get_item_count(fof_current_user(), $what, $feed, $search);
while (($row = fof_db_get_row($statement)) !== false) {
// fof_log('feed:' . $row['feed_id'] . ' count:' . $row['count']);
$itemcount += $row['count'];
}
$title = fof_view_title($feed, $what, $when, $which, $howmany, $search, $itemcount);
// Placeholder to push content down:
?>
<div id="item-display-controls" class="banner ontop">
<ul class="inline-list">
<?php
$item_controls = '';
/* the current view settings */
$qv = array('feed' => $feed,
'what' => $what,
'when' => $when,
'how' => $how,
'howmany' => $howmany,
'search' => $search);
$set_view_button = '♥';
$item_controls .= ' <li id="view-settings-button" class="hide-on-mobile">';
if (!empty($search)) {
$item_controls .= '<span class="unavailable" title="Sorry, collections of items which involve search terms cannot currently store custom orderings.">';
$item_controls .= $set_view_button;
$item_controls .= '</span>';
} else if (!empty($view_settings['order']) && $view_settings['order'] == $order) {
$item_controls .= '<span class="custom" title="The current sort order is already remembered for this collection of items.">';
$item_controls .= $set_view_button;
$item_controls .= '</span>';
} else if ($order == $fof_prefs_obj->get('order') && empty($view_settings['order'])) {
$item_controls .= '<span class="default" title="Your default sort order is already being used for this collection of items.">';
$item_controls .= $set_view_button;
$item_controls .= '</span>';
} else {
$view_settings_store_js = htmlentities('view_order_set(' . implode(',', array(json_encode($what), json_encode($feed), json_encode($order))) . ');return false;', ENT_QUOTES);
$item_controls .= '<span class="remember">';
$item_controls .= '<a href="#" title="Remember this ordering, whenever you view this collection of items. (A collection is a unique combination of feed and/or tags.)" onclick="' . $view_settings_store_js . '">';
$item_controls .= $set_view_button;
$item_controls .= '</a>';
$item_controls .= '</span>';
}
$item_controls .= '</li>';
$item_controls .= ' <li class="orderby hide-on-mobile">';
if ($order == 'asc') {
$item_controls .= '<a href="' . fof_url('.', array_merge($qv, array('order' => 'desc'))) . '">';
}
$item_controls .= '[new to old]';
if ($order == 'asc') {
$item_controls .= '</a>';
}
$item_controls .= "</li>\n";
$item_controls .= ' <li class="orderby hide-on-mobile">';
if ($order == 'desc') {
$item_controls .= '<a href="' . fof_url('.', array_merge($qv, array('order' => 'asc'))) . '">';
}
$item_controls .= '[old to new]';
if ($order == 'desc') {
$item_controls .= '</a>';
}
$item_controls .= "</li>\n";
$item_controls .= ' <li><a href="#" onclick="flag_all();mark_read();return false;"><strong>Mark all read</strong></a></li>';
$item_controls .= ' <li class="hide-on-mobile"><a href="#" onclick="flag_all();return false;">Flag all</a></li>';
$item_controls .= ' <li class="hide-on-mobile"><a href="#" onclick="unflag_all();return false;">Unflag all</a></li>';
$item_controls .= ' <li class="hide-on-mobile"><a href="#" onclick="toggle_all();return false;">Toggle all</a></li>';
$item_controls .= ' <li class="hide-on-mobile"><a href="#" onclick="mark_read();return false;"><strong>Mark flagged read</strong></a></li>';
$item_controls .= ' <li class="hide-on-mobile"><a href="#" onclick="mark_unread();return false;">Mark flagged unread</a></li>';
$item_controls .= ' <li class="hide-on-mobile"><a href="#" onclick="show_all();return false;">Show all</a></li>';
$item_controls .= ' <li class="hide-on-mobile"><a href="#" onclick="hide_all();return false;">Hide all</a></li>';
$item_controls .= ' <li><a href="#" onclick="untag_all();return false;">Untag all</a></li>';
echo $item_controls;
?>
</ul>
</div>
<div id="item-display-controls-spacer" class="banner">
<ul class="inline-list">
<?php echo $item_controls; ?>
</ul>
</div>
<div id="display-summary"><?php echo $title; ?></div>
<?php
if ($fof_prefs_obj->get('keyboard')) {
?>
<div id="keyboard-legend" class="hide">
<span style="font-variant:small-caps;">Keyboard Commands</span>
<dl>
<dt>?</dt><dd>Toggle this display.</dd>
<dt>H</dt><dd>Toggle folding of all visible items.</dd>
<dt>h</dt><dd>Toggle folding of current item.</dd>
<dt>s</dt><dd>Toggle starring of current item.</dd>
<dt>f</dt><dd>Flag current item.</dd>
<dt>F</dt><dd>Flag current and all previous items.</dd>
<dt>U</dt><dd>Unflag all items.</dd>
<dt>j</dt><dd>Scroll current item, flag if at end of item, move to next item.</dd>
<dt>J</dt><dd>Flag current item, move to next.</dd>
<dt>n</dt><dd>Skip to next item.</dd>
<dt>p</dt><dd>Skip to previous item.</dd>
<dt>N</dt><dd>Skip to last item.</dd>
<dt>P</dt><dd>Skip to first item.</dd>
<dt>r</dt><dd>Refresh sidebar.</dd>
<dt>⏎</dt><dd>Open current item.</dd>
</dl>
</div>
<?php
}
?>
<!-- close this form to fix first item! -->
<form id="itemform" name="items" action="view-action.php" method="post" onSubmit="return false;">
<input type="hidden" name="action" />
<input type="hidden" name="return" />
<?php
$links = fof_get_nav_links($feed, $what, $when, $which, $howmany, $search, $itemcount);
$links = ($links ? '<div class="pagination-nav">' : '') . $links . ($links ? "</div>\n" : '');
echo $links;
$items = fof_get_items(fof_current_user(), $feed, $what, $when, $which, $howmany, $order, $search);
if (!empty($items)) {
foreach ($items as $item) {
fof_render_item($item, true);
}
} else {
echo "<p><i>No items found.</i></p>\n";
}
?>
</form>
<?php
echo $links;
?>