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