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