]>
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 | ||
70 | print "<ul id='cat--1' title='$title' myBackLabel='Feeds' | |
71 | myBackHref='index.php' myBackTarget='_self'>"; | |
72 | ||
73 | foreach (array(-4, -1,-2,-3) as $id) { | |
74 | $title = getFeedTitle($link, $id); | |
75 | $unread = getFeedUnread($link, $id, false); | |
76 | ||
77 | if ($unread > 0) { | |
78 | $title = $title . " ($unread)"; | |
79 | $class = ''; | |
80 | } else { | |
81 | $class = 'oldItem'; | |
eead4d26 | 82 | } |
8e3f7217 | 83 | |
e2b7a855 AD |
84 | print "<li class='$class'> |
85 | <a href='feed.php?id=$id&cat_id=-1'>$title</a></li>"; | |
86 | } | |
8e3f7217 | 87 | |
e2b7a855 AD |
88 | print "</ul>"; |
89 | } | |
0d3adafe AD |
90 | } |
91 | ||
3518718b AD |
92 | function render_categories_list($link) { |
93 | $owner_uid = $_SESSION["uid"]; | |
2f468537 | 94 | |
2f468537 | 95 | |
3518718b | 96 | print '<ul id="home" title="Feeds" selected="true">'; |
eead4d26 | 97 | |
3518718b AD |
98 | foreach (array(-1, -2) as $id) { |
99 | $title = getCategoryTitle($link, $id); | |
100 | $unread = getFeedUnread($link, $id, true); | |
101 | if ($unread > 0) { | |
102 | $title = $title . " ($unread)"; | |
103 | $class = ''; | |
eead4d26 | 104 | } else { |
3518718b | 105 | $class = 'oldItem'; |
c878bc01 | 106 | } |
2f468537 | 107 | |
3518718b | 108 | print "<li class='$class'><a href='cat.php?id=$id'>$title</a></li>"; |
2f468537 AD |
109 | } |
110 | ||
3518718b AD |
111 | $result = db_query($link, "SELECT |
112 | ttrss_feed_categories.id, | |
113 | ttrss_feed_categories.title, | |
114 | COUNT(ttrss_feeds.id) AS num_feeds | |
115 | FROM ttrss_feed_categories, ttrss_feeds | |
116 | WHERE ttrss_feed_categories.owner_uid = $owner_uid | |
117 | AND ttrss_feed_categories.id = cat_id | |
118 | AND hidden = false | |
119 | GROUP BY ttrss_feed_categories.id, | |
120 | ttrss_feed_categories.title | |
121 | ORDER BY ttrss_feed_categories.title"); | |
2f468537 | 122 | |
3518718b | 123 | $cat_ids = array(); |
2f468537 | 124 | |
3518718b | 125 | while ($line = db_fetch_assoc($result)) { |
fc46ab83 | 126 | |
3518718b | 127 | if ($line["num_feeds"] > 0) { |
2f468537 | 128 | |
3518718b | 129 | $unread = getFeedUnread($link, $line["id"], true); |
2f468537 | 130 | $id = $line["id"]; |
510ac75f | 131 | |
3518718b AD |
132 | if ($unread > 0) { |
133 | $line["title"] = $line["title"] . " ($unread)"; | |
134 | $class = ''; | |
510ac75f | 135 | } else { |
3518718b | 136 | $class = 'oldItem'; |
510ac75f | 137 | } |
2f468537 | 138 | |
2f468537 | 139 | |
3518718b AD |
140 | print "<li class='$class'><a href='cat.php?id=$id'>" . |
141 | $line["title"] . "</a></li>"; | |
ab1486d5 | 142 | |
3518718b | 143 | array_push($cat_ids, $id); |
2f468537 | 144 | |
2f468537 | 145 | } |
2f468537 AD |
146 | } |
147 | ||
2f468537 | 148 | |
3518718b AD |
149 | $result = db_query($link, "SELECT COUNT(*) AS nf FROM ttrss_feeds WHERE |
150 | cat_id IS NULL and owner_uid = '$owner_uid'"); | |
42096f52 | 151 | |
3518718b | 152 | $num_feeds = db_fetch_result($result, 0, "nf"); |
42096f52 | 153 | |
3518718b AD |
154 | if ($num_feeds > 0) { |
155 | $unread = getFeedUnread($link, 0, true); | |
156 | $title = "Uncategorized"; | |
42096f52 | 157 | |
3518718b AD |
158 | if ($unread > 0) { |
159 | $title = "$title ($unread)"; | |
160 | $class = ''; | |
42096f52 | 161 | } else { |
3518718b | 162 | $class = 'oldItem'; |
42096f52 AD |
163 | } |
164 | ||
3518718b | 165 | array_push($cat_ids, 0); |
eead4d26 | 166 | |
3518718b AD |
167 | print "<li class='$class'><a href='cat.php?id=0'>$title</a></li>"; |
168 | } | |
42096f52 | 169 | |
3518718b AD |
170 | print "</ul>"; |
171 | } | |
24ac6776 | 172 | |
3e092346 | 173 | function render_headlines_list($link, $feed_id, $cat_id) { |
24ac6776 | 174 | |
3518718b AD |
175 | $feed_id = $feed_id; |
176 | $limit = 30; | |
177 | $filter = ''; | |
3e092346 | 178 | $is_cat = false; |
3518718b | 179 | $view_mode = 'adaptive'; |
d9aad400 | 180 | |
3518718b | 181 | /* do not rely on params below */ |
d9aad400 | 182 | |
3518718b AD |
183 | $search = ''; |
184 | $search_mode = ''; | |
185 | $match_on = ''; | |
186 | ||
187 | $qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, | |
188 | $view_mode, $is_cat, $search, $search_mode, $match_on); | |
541890fb | 189 | |
3518718b AD |
190 | $result = $qfh_ret[0]; |
191 | $feed_title = $qfh_ret[1]; | |
42096f52 | 192 | |
3e092346 AD |
193 | $cat_title = getCategoryTitle($link, $cat_id); |
194 | ||
195 | print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\" | |
196 | myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>"; | |
24ac6776 | 197 | |
3518718b AD |
198 | while ($line = db_fetch_assoc($result)) { |
199 | $id = $line["id"]; | |
f70f7e28 | 200 | |
3518718b AD |
201 | if (sql_bool_to_bool($line["unread"])) { |
202 | $class = ''; | |
f70f7e28 | 203 | } else { |
3518718b | 204 | $class = 'oldItem'; |
f70f7e28 AD |
205 | } |
206 | ||
3e092346 AD |
207 | print "<li class='$class'> |
208 | <a href='article.php?id=$id&feed=$feed_id&cat=$cat_id'>"; | |
3518718b AD |
209 | print $line["title"]; |
210 | print "</a></li>"; | |
4a596be6 | 211 | |
42096f52 AD |
212 | } |
213 | ||
3518718b AD |
214 | print "</ul>"; |
215 | ||
42096f52 AD |
216 | } |
217 | ||
3e092346 | 218 | function render_article($link, $id, $feed_id, $cat_id) { |
0809065e | 219 | |
3518718b AD |
220 | $query = "SELECT title,link,content,feed_id,comments,int_id, |
221 | marked,unread,published, | |
222 | ".SUBSTRING_FOR_DATE."(updated,1,16) as updated, | |
223 | author | |
224 | FROM ttrss_entries,ttrss_user_entries | |
225 | WHERE id = '$id' AND ref_id = id AND owner_uid = " . | |
226 | $_SESSION["uid"] ; | |
0809065e | 227 | |
3518718b | 228 | $result = db_query($link, $query); |
0809065e | 229 | |
3e092346 | 230 | if (db_num_rows($result) != 0) { |
0809065e | 231 | |
3e092346 | 232 | $line = db_fetch_assoc($result); |
0809065e | 233 | |
3e092346 AD |
234 | $tmp_result = db_query($link, "UPDATE ttrss_user_entries |
235 | SET unread = false,last_read = NOW() | |
236 | WHERE ref_id = '$id' | |
237 | AND owner_uid = " . $_SESSION["uid"]); | |
0809065e | 238 | |
3e092346 AD |
239 | if (get_pref($link, 'HEADLINES_SMART_DATE')) { |
240 | $updated_fmt = smart_date_time(strtotime($line["updated"])); | |
241 | } else { | |
242 | $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); | |
243 | $updated_fmt = date($short_date, strtotime($line["updated"])); | |
244 | } | |
245 | ||
246 | $title = $line["title"]; | |
247 | $article_link = $line["link"]; | |
248 | ||
249 | $feed_title = getFeedTitle($link, $feed_id, false); | |
250 | ||
251 | print "<div class=\"panel\" id=\"article-$id\" title=\"$title\" | |
252 | selected=\"true\" | |
253 | myBackLabel='$feed_title' myBackHref='feed.php?id=$feed_id&cat=$cat_id'>"; | |
254 | ||
255 | // print "<h2><a target='_blank' href='$link'>$title</a></h2>"; | |
256 | ||
257 | print "<fieldset>"; | |
258 | ||
259 | print "<div class=\"row\">"; | |
260 | print "<label id='title'><a target='_blank' href='$article_link'>$title</a></label>"; | |
261 | print "</div>"; | |
262 | ||
263 | $is_starred = (sql_bool_to_bool($line["marked"])) ? "true" : "false"; | |
264 | $is_published = (sql_bool_to_bool($line["published"])) ? "true" : "false"; | |
265 | ||
266 | print "<div class=\"row\"> | |
267 | <label>Starred</label> | |
268 | <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> | |
269 | </div>"; | |
270 | ||
271 | print "<div class=\"row\"> | |
272 | <label>Published</label> | |
273 | <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> | |
274 | </div>"; | |
275 | ||
276 | ||
277 | print "<div class=\"row\">"; | |
278 | print "<label id='updated'>Updated:</label>"; | |
279 | print "<input enabled='false' name='updated' disabled value='$updated_fmt'/>"; | |
280 | print "</div>"; | |
281 | ||
282 | print "</fieldset>"; | |
283 | ||
284 | print "<p>"; | |
285 | print $line["content"]; | |
286 | print "</p>"; | |
287 | ||
288 | print "</div>"; | |
f70f7e28 | 289 | |
3e092346 | 290 | } |
4a596be6 | 291 | |
4a596be6 | 292 | } |
0d3adafe | 293 | ?> |