]>
Commit | Line | Data |
---|---|---|
e9e95dae | 1 | <?php |
3dd46f19 | 2 | define('TTRSS_SESSION_NAME', 'ttrss_m_sid'); |
0d3adafe | 3 | |
3518718b AD |
4 | function mobile_feed_has_icon($id) { |
5 | $filename = "../".ICONS_DIR."/$id.ico"; | |
42096f52 | 6 | |
3518718b AD |
7 | return file_exists($filename) && filesize($filename) > 0; |
8 | } | |
42096f52 | 9 | |
b1bd222c AD |
10 | function render_flat_feed_list($link) { |
11 | $owner_uid = $_SESSION["uid"]; | |
12 | ||
13 | $result = db_query($link, "SELECT id, | |
14 | title, | |
15 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
16 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
17 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
18 | AND owner_uid = '$owner_uid') as unread | |
19 | FROM ttrss_feeds | |
20 | WHERE | |
21 | ttrss_feeds.hidden = false AND | |
22 | ttrss_feeds.owner_uid = '$owner_uid' AND | |
23 | parent_feed IS NULL | |
24 | ORDER BY unread DESC,title"); | |
25 | ||
26 | print '<ul id="home" title="Feeds" selected="true">'; | |
27 | ||
28 | // print "<li><a href='#cat-actions'>".__('Actions...')."</a></li>"; | |
29 | ||
30 | while ($line = db_fetch_assoc($result)) { | |
31 | $id = $line["id"]; | |
32 | $unread = $line["unread"]; | |
33 | ||
34 | // $unread = rand(0, 100); | |
35 | ||
36 | if ($unread > 0) { | |
37 | $line["title"] = $line["title"] . " ($unread)"; | |
38 | $class = ''; | |
39 | } else { | |
40 | $class = 'oldItem'; | |
41 | } | |
42 | ||
43 | if (mobile_feed_has_icon($id)) { | |
44 | $icon_url = "../".ICONS_URL."/$id.ico"; | |
45 | } else { | |
46 | $icon_url = "../images/blank_icon.gif"; | |
47 | } | |
48 | ||
49 | print "<li class='$class'><a href='feed.php?id=$id'>" . | |
50 | "<img class='tinyIcon' src='$icon_url'/>". | |
51 | $line["title"] . "</a></li>"; | |
52 | } | |
53 | ||
54 | print "</ul>"; | |
55 | ||
56 | ||
57 | ||
58 | } | |
59 | ||
3518718b AD |
60 | function render_category($link, $cat_id) { |
61 | $owner_uid = $_SESSION["uid"]; | |
42096f52 | 62 | |
e2b7a855 | 63 | if ($cat_id >= 0) { |
85233b8e | 64 | |
e2b7a855 AD |
65 | if ($cat_id != 0) { |
66 | $cat_query = "cat_id = '$cat_id'"; | |
3518718b | 67 | } else { |
e2b7a855 | 68 | $cat_query = "cat_id IS NULL"; |
0d3adafe | 69 | } |
e2b7a855 AD |
70 | |
71 | $result = db_query($link, "SELECT id, | |
72 | title, | |
73 | (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries | |
74 | WHERE feed_id = ttrss_feeds.id AND unread = true | |
75 | AND ttrss_user_entries.ref_id = ttrss_entries.id | |
76 | AND owner_uid = '$owner_uid') as unread | |
77 | FROM ttrss_feeds | |
78 | WHERE | |
79 | ttrss_feeds.hidden = false AND | |
80 | ttrss_feeds.owner_uid = '$owner_uid' AND | |
81 | parent_feed IS NULL AND | |
82 | $cat_query | |
83 | ORDER BY unread DESC,title"); | |
84 | ||
85 | $title = getCategoryTitle($link, $cat_id); | |
86 | ||
87 | print "<ul id='cat-$cat_id' title='$title' myBackLabel='Feeds' | |
bf974b02 | 88 | myBackHref='home.php'>"; |
e2b7a855 AD |
89 | |
90 | // print "<li><a href='#cat-actions'>".__('Actions...')."</a></li>"; | |
91 | ||
92 | while ($line = db_fetch_assoc($result)) { | |
93 | $id = $line["id"]; | |
94 | $unread = $line["unread"]; | |
3e94601e | 95 | |
e2b7a855 AD |
96 | // $unread = rand(0, 100); |
97 | ||
98 | if ($unread > 0) { | |
99 | $line["title"] = $line["title"] . " ($unread)"; | |
100 | $class = ''; | |
101 | } else { | |
102 | $class = 'oldItem'; | |
103 | } | |
104 | ||
105 | if (mobile_feed_has_icon($id)) { | |
106 | $icon_url = "../".ICONS_URL."/$id.ico"; | |
107 | } else { | |
108 | $icon_url = "../images/blank_icon.gif"; | |
109 | } | |
110 | ||
111 | print "<li class='$class'><a href='feed.php?id=$id&cat=$cat_id'>" . | |
112 | "<img class='tinyIcon' src='$icon_url'/>". | |
113 | $line["title"] . "</a></li>"; | |
0d3adafe | 114 | } |
e2b7a855 AD |
115 | |
116 | print "</ul>"; | |
117 | } else if ($cat_id == -1) { | |
118 | ||
17fd15be AD |
119 | $title = __('Special'); |
120 | ||
e2b7a855 AD |
121 | print "<ul id='cat--1' title='$title' myBackLabel='Feeds' |
122 | myBackHref='index.php' myBackTarget='_self'>"; | |
123 | ||
124 | foreach (array(-4, -1,-2,-3) as $id) { | |
125 | $title = getFeedTitle($link, $id); | |
126 | $unread = getFeedUnread($link, $id, false); | |
127 | ||
128 | if ($unread > 0) { | |
129 | $title = $title . " ($unread)"; | |
130 | $class = ''; | |
131 | } else { | |
132 | $class = 'oldItem'; | |
eead4d26 | 133 | } |
8e3f7217 | 134 | |
e2b7a855 AD |
135 | print "<li class='$class'> |
136 | <a href='feed.php?id=$id&cat_id=-1'>$title</a></li>"; | |
137 | } | |
8e3f7217 | 138 | |
17fd15be AD |
139 | print "</ul>"; |
140 | } else if ($cat_id == -2) { | |
141 | ||
142 | $title = __('Labels'); | |
143 | ||
144 | print "<ul id='cat--2' title='$title' myBackLabel='Feeds' | |
145 | myBackHref='index.php' myBackTarget='_self'>"; | |
146 | ||
147 | $result = db_query($link, "SELECT id, caption FROM ttrss_labels2 | |
148 | WHERE owner_uid = '$owner_uid'"); | |
149 | ||
150 | $label_data = array(); | |
151 | ||
152 | while ($line = db_fetch_assoc($result)) { | |
153 | ||
154 | $id = -$line["id"] - 11; | |
155 | ||
156 | $unread = getFeedUnread($link, $id); | |
157 | $title = $line["caption"]; | |
158 | ||
159 | if ($unread > 0) { | |
160 | $title = $title . " ($unread)"; | |
161 | $class = ''; | |
162 | } else { | |
163 | $class = 'oldItem'; | |
164 | } | |
165 | ||
166 | print "<li class='$class'> | |
3e94601e | 167 | <a href='feed.php?id=$id&cat=-2'>$title</a></li>"; |
17fd15be AD |
168 | |
169 | } | |
e2b7a855 AD |
170 | print "</ul>"; |
171 | } | |
0d3adafe AD |
172 | } |
173 | ||
3518718b AD |
174 | function render_categories_list($link) { |
175 | $owner_uid = $_SESSION["uid"]; | |
2f468537 | 176 | |
2f468537 | 177 | |
3518718b | 178 | print '<ul id="home" title="Feeds" selected="true">'; |
eead4d26 | 179 | |
3518718b AD |
180 | foreach (array(-1, -2) as $id) { |
181 | $title = getCategoryTitle($link, $id); | |
182 | $unread = getFeedUnread($link, $id, true); | |
183 | if ($unread > 0) { | |
184 | $title = $title . " ($unread)"; | |
185 | $class = ''; | |
eead4d26 | 186 | } else { |
3518718b | 187 | $class = 'oldItem'; |
c878bc01 | 188 | } |
2f468537 | 189 | |
3518718b | 190 | print "<li class='$class'><a href='cat.php?id=$id'>$title</a></li>"; |
2f468537 AD |
191 | } |
192 | ||
3518718b AD |
193 | $result = db_query($link, "SELECT |
194 | ttrss_feed_categories.id, | |
195 | ttrss_feed_categories.title, | |
196 | COUNT(ttrss_feeds.id) AS num_feeds | |
197 | FROM ttrss_feed_categories, ttrss_feeds | |
198 | WHERE ttrss_feed_categories.owner_uid = $owner_uid | |
199 | AND ttrss_feed_categories.id = cat_id | |
200 | AND hidden = false | |
201 | GROUP BY ttrss_feed_categories.id, | |
202 | ttrss_feed_categories.title | |
203 | ORDER BY ttrss_feed_categories.title"); | |
2f468537 | 204 | |
3518718b | 205 | $cat_ids = array(); |
2f468537 | 206 | |
3518718b | 207 | while ($line = db_fetch_assoc($result)) { |
fc46ab83 | 208 | |
3518718b | 209 | if ($line["num_feeds"] > 0) { |
2f468537 | 210 | |
3518718b | 211 | $unread = getFeedUnread($link, $line["id"], true); |
2f468537 | 212 | $id = $line["id"]; |
510ac75f | 213 | |
3518718b AD |
214 | if ($unread > 0) { |
215 | $line["title"] = $line["title"] . " ($unread)"; | |
216 | $class = ''; | |
510ac75f | 217 | } else { |
3518718b | 218 | $class = 'oldItem'; |
510ac75f | 219 | } |
2f468537 | 220 | |
2f468537 | 221 | |
3518718b AD |
222 | print "<li class='$class'><a href='cat.php?id=$id'>" . |
223 | $line["title"] . "</a></li>"; | |
ab1486d5 | 224 | |
3518718b | 225 | array_push($cat_ids, $id); |
2f468537 | 226 | |
2f468537 | 227 | } |
2f468537 AD |
228 | } |
229 | ||
2f468537 | 230 | |
3518718b AD |
231 | $result = db_query($link, "SELECT COUNT(*) AS nf FROM ttrss_feeds WHERE |
232 | cat_id IS NULL and owner_uid = '$owner_uid'"); | |
42096f52 | 233 | |
3518718b | 234 | $num_feeds = db_fetch_result($result, 0, "nf"); |
42096f52 | 235 | |
3518718b AD |
236 | if ($num_feeds > 0) { |
237 | $unread = getFeedUnread($link, 0, true); | |
238 | $title = "Uncategorized"; | |
42096f52 | 239 | |
3518718b AD |
240 | if ($unread > 0) { |
241 | $title = "$title ($unread)"; | |
242 | $class = ''; | |
42096f52 | 243 | } else { |
3518718b | 244 | $class = 'oldItem'; |
42096f52 AD |
245 | } |
246 | ||
3518718b | 247 | array_push($cat_ids, 0); |
eead4d26 | 248 | |
3518718b AD |
249 | print "<li class='$class'><a href='cat.php?id=0'>$title</a></li>"; |
250 | } | |
42096f52 | 251 | |
3518718b AD |
252 | print "</ul>"; |
253 | } | |
24ac6776 | 254 | |
3e092346 | 255 | function render_headlines_list($link, $feed_id, $cat_id) { |
24ac6776 | 256 | |
3518718b AD |
257 | $feed_id = $feed_id; |
258 | $limit = 30; | |
259 | $filter = ''; | |
3e092346 | 260 | $is_cat = false; |
3518718b | 261 | $view_mode = 'adaptive'; |
d9aad400 | 262 | |
3518718b | 263 | /* do not rely on params below */ |
d9aad400 | 264 | |
3518718b AD |
265 | $search = ''; |
266 | $search_mode = ''; | |
267 | $match_on = ''; | |
268 | ||
269 | $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, | |
270 | $view_mode, $is_cat, $search, $search_mode, $match_on); | |
541890fb | 271 | |
3518718b AD |
272 | $result = $qfh_ret[0]; |
273 | $feed_title = $qfh_ret[1]; | |
42096f52 | 274 | |
b1bd222c AD |
275 | if ($cat_id) { |
276 | $cat_title = getCategoryTitle($link, $cat_id); | |
3e092346 | 277 | |
b1bd222c AD |
278 | print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\" |
279 | myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>"; | |
280 | } else { | |
281 | print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\" | |
282 | myBackLabel='Feeds' myBackHref='home.php'>"; | |
283 | } | |
24ac6776 | 284 | |
3518718b AD |
285 | while ($line = db_fetch_assoc($result)) { |
286 | $id = $line["id"]; | |
3e94601e | 287 | $real_feed_id = $line["feed_id"]; |
f70f7e28 | 288 | |
3518718b AD |
289 | if (sql_bool_to_bool($line["unread"])) { |
290 | $class = ''; | |
f70f7e28 | 291 | } else { |
3518718b | 292 | $class = 'oldItem'; |
f70f7e28 AD |
293 | } |
294 | ||
3e94601e AD |
295 | if (mobile_feed_has_icon($real_feed_id)) { |
296 | $icon_url = "../".ICONS_URL."/$real_feed_id.ico"; | |
297 | } else { | |
298 | $icon_url = "../images/blank_icon.gif"; | |
299 | } | |
300 | ||
301 | print "<li class='$class'><a href='article.php?id=$id&feed=$feed_id&cat=$cat_id'> | |
302 | <img class='tinyIcon' src='$icon_url'>"; | |
3518718b AD |
303 | print $line["title"]; |
304 | print "</a></li>"; | |
4a596be6 | 305 | |
42096f52 AD |
306 | } |
307 | ||
3518718b AD |
308 | print "</ul>"; |
309 | ||
42096f52 AD |
310 | } |
311 | ||
3e092346 | 312 | function render_article($link, $id, $feed_id, $cat_id) { |
0809065e | 313 | |
3518718b AD |
314 | $query = "SELECT title,link,content,feed_id,comments,int_id, |
315 | marked,unread,published, | |
316 | ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, | |
317 | author | |
318 | FROM ttrss_entries,ttrss_user_entries | |
319 | WHERE id = '$id' AND ref_id = id AND owner_uid = " . | |
320 | $_SESSION["uid"] ; | |
0809065e | 321 | |
3518718b | 322 | $result = db_query($link, $query); |
0809065e | 323 | |
3e092346 | 324 | if (db_num_rows($result) != 0) { |
0809065e | 325 | |
3e092346 | 326 | $line = db_fetch_assoc($result); |
0809065e | 327 | |
3e092346 AD |
328 | $tmp_result = db_query($link, "UPDATE ttrss_user_entries |
329 | SET unread = false,last_read = NOW() | |
330 | WHERE ref_id = '$id' | |
331 | AND owner_uid = " . $_SESSION["uid"]); | |
0809065e | 332 | |
3e092346 AD |
333 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
334 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
335 | } else { | |
336 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
337 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
338 | } | |
339 | ||
340 | $title = $line["title"]; | |
341 | $article_link = $line["link"]; | |
342 | ||
343 | $feed_title = getFeedTitle($link, $feed_id, false); | |
344 | ||
345 | print "<div class=\"panel\" id=\"article-$id\" title=\"$title\" | |
346 | selected=\"true\" | |
347 | myBackLabel='$feed_title' myBackHref='feed.php?id=$feed_id&cat=$cat_id'>"; | |
348 | ||
bf974b02 | 349 | print "<h2><a target='_blank' href='$link'>$title</a></h2>"; |
3e092346 AD |
350 | |
351 | print "<fieldset>"; | |
352 | ||
bf974b02 | 353 | /* print "<div class=\"row\">"; |
3e092346 | 354 | print "<label id='title'><a target='_blank' href='$article_link'>$title</a></label>"; |
bf974b02 | 355 | print "</div>"; */ |
3e092346 AD |
356 | |
357 | $is_starred = (sql_bool_to_bool($line["marked"])) ? "true" : "false"; | |
358 | $is_published = (sql_bool_to_bool($line["published"])) ? "true" : "false"; | |
359 | ||
3e092346 AD |
360 | print "<div class=\"row\">"; |
361 | print "<label id='updated'>Updated:</label>"; | |
362 | print "<input enabled='false' name='updated' disabled value='$updated_fmt'/>"; | |
363 | print "</div>"; | |
364 | ||
365 | print "</fieldset>"; | |
3bac78a0 AD |
366 | |
367 | $content = sanitize_rss($link, $line["content"]); | |
368 | $content = preg_replace("/href=/i", "target=\"_blank\" href=", $content); | |
369 | ||
706fe949 | 370 | print "<p>$content</p>"; |
6101b0e1 AD |
371 | |
372 | print "<fieldset>"; | |
373 | ||
374 | print "<div class=\"row\"> | |
375 | <label>Starred</label> | |
376 | <div class=\"toggle\" onclick=\"toggleMarked($id, this)\" toggled=\"$is_starred\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div> | |
377 | </div>"; | |
3e092346 | 378 | |
6101b0e1 AD |
379 | print "<div class=\"row\"> |
380 | <label>Published</label> | |
381 | <div class=\"toggle\" onclick=\"togglePublished($id, this)\" toggled=\"$is_published\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div> | |
382 | </div>"; | |
383 | ||
384 | print "</fieldset>"; | |
385 | ||
3e092346 | 386 | print "</div>"; |
f70f7e28 | 387 | |
3e092346 | 388 | } |
4a596be6 | 389 | |
4a596be6 | 390 | } |
0d3adafe | 391 | ?> |