]>
Commit | Line | Data |
---|---|---|
ef8be8ea | 1 | <?php |
d20f3544 | 2 | |
758e1c4a | 3 | function batch_edit_cbox($elem, $label = false) { |
cd935c42 | 4 | print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\" |
758e1c4a AD |
5 | onchange=\"batchFeedsToggleField(this, '$elem', '$label')\">"; |
6 | } | |
7 | ||
ef8be8ea AD |
8 | function module_pref_feeds($link) { |
9 | ||
d20f3544 AD |
10 | global $update_intervals; |
11 | global $purge_intervals; | |
16211ddb | 12 | global $update_methods; |
d20f3544 | 13 | |
ef8be8ea AD |
14 | $subop = $_REQUEST["subop"]; |
15 | $quiet = $_REQUEST["quiet"]; | |
082ae95b | 16 | $mode = $_REQUEST["mode"]; |
ef8be8ea | 17 | |
7b8a143f AD |
18 | if ($subop == "renamecat") { |
19 | $title = db_escape_string($_REQUEST['title']); | |
20 | $id = db_escape_string($_REQUEST['id']); | |
21 | ||
22 | if ($title) { | |
23 | db_query($link, "UPDATE ttrss_feed_categories SET | |
24 | title = '$title' WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]); | |
25 | } | |
26 | return; | |
27 | } | |
28 | ||
29 | if ($subop == "getfeedtree") { | |
30 | ||
31 | $root = array(); | |
32 | $root['id'] = 'root'; | |
33 | $root['name'] = __('Feeds'); | |
34 | $root['items'] = array(); | |
e8c20f92 | 35 | $root['type'] = 'category'; |
7b8a143f AD |
36 | |
37 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
38 | ||
39 | $result = db_query($link, "SELECT id, title FROM ttrss_feed_categories | |
40 | WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY order_id, title"); | |
41 | ||
42 | while ($line = db_fetch_assoc($result)) { | |
43 | $cat = array(); | |
44 | $cat['id'] = 'CAT:' . $line['id']; | |
45 | $cat['bare_id'] = $feed_id; | |
46 | $cat['name'] = $line['title']; | |
47 | $cat['items'] = array(); | |
e8c20f92 | 48 | $cat['type'] = 'category'; |
7b8a143f | 49 | |
82aea978 AD |
50 | $feed_result = db_query($link, "SELECT id, title, last_error |
51 | FROM ttrss_feeds | |
7b8a143f AD |
52 | WHERE cat_id = '".$line['id']."' AND owner_uid = ".$_SESSION["uid"]. |
53 | " ORDER BY order_id, title"); | |
54 | ||
55 | while ($feed_line = db_fetch_assoc($feed_result)) { | |
56 | $feed = array(); | |
57 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
58 | $feed['bare_id'] = $feed_line['id']; | |
59 | $feed['name'] = $feed_line['title']; | |
60 | $feed['checkbox'] = false; | |
82aea978 AD |
61 | $feed['error'] = $feed_line['last_error']; |
62 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
63 | ||
7b8a143f AD |
64 | array_push($cat['items'], $feed); |
65 | } | |
66 | ||
67 | array_push($root['items'], $cat); | |
68 | } | |
69 | ||
70 | /* Uncategorized is a special case */ | |
71 | ||
72 | $cat = array(); | |
73 | $cat['id'] = 'CAT:0'; | |
74 | $cat['bare_id'] = 0; | |
75 | $cat['name'] = __("Uncategorized"); | |
76 | $cat['items'] = array(); | |
77 | ||
82aea978 AD |
78 | $feed_result = db_query($link, "SELECT id, title,last_error |
79 | FROM ttrss_feeds | |
7b8a143f AD |
80 | WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"]. |
81 | " ORDER BY order_id, title"); | |
82 | ||
83 | while ($feed_line = db_fetch_assoc($feed_result)) { | |
84 | $feed = array(); | |
85 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
86 | $feed['bare_id'] = $feed_line['id']; | |
87 | $feed['name'] = $feed_line['title']; | |
88 | $feed['checkbox'] = false; | |
82aea978 AD |
89 | $feed['error'] = $feed_line['last_error']; |
90 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
91 | ||
7b8a143f AD |
92 | array_push($cat['items'], $feed); |
93 | } | |
94 | ||
95 | array_push($root['items'], $cat); | |
96 | } else { | |
82aea978 AD |
97 | $feed_result = db_query($link, "SELECT id, title, last_error |
98 | FROM ttrss_feeds | |
7b8a143f AD |
99 | WHERE owner_uid = ".$_SESSION["uid"]. |
100 | " ORDER BY order_id, title"); | |
101 | ||
102 | while ($feed_line = db_fetch_assoc($feed_result)) { | |
103 | $feed = array(); | |
104 | $feed['id'] = 'FEED:' . $feed_line['id']; | |
105 | $feed['bare_id'] = $feed_line['id']; | |
106 | $feed['name'] = $feed_line['title']; | |
107 | $feed['checkbox'] = false; | |
82aea978 AD |
108 | $feed['error'] = $feed_line['last_error']; |
109 | $feed['icon'] = getFeedIcon($feed_line['id']); | |
110 | ||
7b8a143f AD |
111 | array_push($root['items'], $feed); |
112 | } | |
113 | } | |
114 | ||
115 | $fl = array(); | |
116 | $fl['identifier'] = 'id'; | |
117 | $fl['label'] = 'name'; | |
118 | $fl['items'] = array($root); | |
119 | ||
120 | print json_encode($fl); | |
121 | return; | |
122 | } | |
123 | ||
124 | if ($subop == "catsortreset") { | |
125 | db_query($link, "UPDATE ttrss_feed_categories | |
126 | SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); | |
127 | return; | |
128 | } | |
129 | ||
130 | if ($subop == "feedsortreset") { | |
131 | db_query($link, "UPDATE ttrss_feeds | |
132 | SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); | |
133 | return; | |
134 | } | |
135 | ||
136 | if ($subop == "savefeedorder") { | |
e8c20f92 AD |
137 | # if ($_POST['payload']) { |
138 | # file_put_contents("/tmp/blahblah.txt", $_POST['payload']); | |
139 | # $data = json_decode($_POST['payload'], true); | |
140 | # } else { | |
141 | # $data = json_decode(file_get_contents("/tmp/blahblah.txt"), true); | |
142 | # } | |
7b8a143f | 143 | |
e8c20f92 | 144 | $data = json_decode($_POST['payload'], true); |
7b8a143f AD |
145 | |
146 | if (is_array($data) && is_array($data['items'])) { | |
147 | $cat_order_id = 0; | |
148 | ||
149 | $data_map = array(); | |
150 | ||
151 | foreach ($data['items'] as $item) { | |
e8c20f92 AD |
152 | |
153 | if ($item['id'] != 'root') { | |
154 | if (is_array($item['items'])) { | |
155 | if (isset($item['items']['_reference'])) { | |
156 | $data_map[$item['id']] = array($item['items']); | |
157 | } else { | |
158 | $data_map[$item['id']] =& $item['items']; | |
159 | } | |
160 | } | |
161 | } | |
7b8a143f AD |
162 | } |
163 | ||
164 | foreach ($data['items'][0]['items'] as $item) { | |
165 | $id = $item['_reference']; | |
166 | $bare_id = substr($id, strpos($id, ':')+1); | |
167 | ||
168 | ++$cat_order_id; | |
169 | ||
170 | if ($bare_id > 0) { | |
171 | db_query($link, "UPDATE ttrss_feed_categories | |
172 | SET order_id = '$cat_order_id' WHERE id = '$bare_id' AND | |
173 | owner_uid = " . $_SESSION["uid"]); | |
174 | } | |
175 | ||
176 | $feed_order_id = 0; | |
177 | ||
178 | if (is_array($data_map[$id])) { | |
179 | foreach ($data_map[$id] as $feed) { | |
180 | $id = $feed['_reference']; | |
e8c20f92 AD |
181 | $feed_id = substr($id, strpos($id, ':')+1); |
182 | ||
183 | if ($bare_id != 0) | |
184 | $cat_query = "cat_id = '$bare_id'"; | |
185 | else | |
186 | $cat_query = "cat_id = NULL"; | |
187 | ||
7b8a143f | 188 | db_query($link, "UPDATE ttrss_feeds |
e8c20f92 AD |
189 | SET order_id = '$feed_order_id', |
190 | $cat_query | |
191 | WHERE id = '$feed_id' AND | |
192 | owner_uid = " . $_SESSION["uid"]); | |
7b8a143f AD |
193 | |
194 | ++$feed_order_id; | |
195 | } | |
196 | } | |
197 | } | |
198 | } | |
199 | ||
200 | return; | |
201 | } | |
202 | ||
7abf159d AD |
203 | if ($subop == "removeicon") { |
204 | $feed_id = db_escape_string($_REQUEST["feed_id"]); | |
205 | ||
206 | $result = db_query($link, "SELECT id FROM ttrss_feeds | |
207 | WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]); | |
208 | ||
209 | if (db_num_rows($result) != 0) { | |
210 | unlink(ICONS_DIR . "/$feed_id.ico"); | |
211 | } | |
212 | ||
213 | return; | |
214 | } | |
215 | ||
c3b7b797 | 216 | if ($subop == "uploadicon") { |
7abf159d AD |
217 | $icon_file = $_FILES['icon_file']['tmp_name']; |
218 | $feed_id = db_escape_string($_REQUEST["feed_id"]); | |
219 | ||
220 | if (is_file($icon_file) && $feed_id) { | |
e258bceb | 221 | if (filesize($icon_file) < 20000) { |
7abf159d AD |
222 | |
223 | $result = db_query($link, "SELECT id FROM ttrss_feeds | |
224 | WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]); | |
225 | ||
226 | if (db_num_rows($result) != 0) { | |
227 | unlink(ICONS_DIR . "/$feed_id.ico"); | |
228 | move_uploaded_file($icon_file, ICONS_DIR . "/$feed_id.ico"); | |
229 | $rc = 0; | |
230 | } else { | |
231 | $rc = 2; | |
232 | } | |
233 | } else { | |
234 | $rc = 1; | |
235 | } | |
236 | } else { | |
237 | $rc = 2; | |
238 | } | |
239 | ||
c3b7b797 | 240 | print "<script type=\"text/javascript\">"; |
7abf159d | 241 | print "parent.uploadIconHandler($rc);"; |
c3b7b797 AD |
242 | print "</script>"; |
243 | return; | |
244 | } | |
245 | ||
951906dc AD |
246 | if ($subop == "editfeed") { |
247 | header("Content-Type: text/xml"); | |
ef8be8ea | 248 | |
951906dc AD |
249 | print "<dlg id=\"$subop\">"; |
250 | print "<title>".__('Feed Editor')."</title>"; | |
251 | print "<content><![CDATA["; | |
ef8be8ea | 252 | |
ef8be8ea AD |
253 | $feed_id = db_escape_string($_REQUEST["id"]); |
254 | ||
255 | $result = db_query($link, | |
256 | "SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND | |
257 | owner_uid = " . $_SESSION["uid"]); | |
258 | ||
47439031 AD |
259 | $title = htmlspecialchars(db_fetch_result($result, |
260 | 0, "title")); | |
ef8be8ea AD |
261 | |
262 | $icon_file = ICONS_DIR . "/$feed_id.ico"; | |
263 | ||
264 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
265 | $feed_icon = "<img width=\"16\" height=\"16\" | |
266 | src=\"" . ICONS_URL . "/$feed_id.ico\">"; | |
267 | } else { | |
268 | $feed_icon = ""; | |
269 | } | |
270 | ||
e6312f6c | 271 | print "<form id=\"edit_feed_form\" onsubmit=\"return false\">"; |
ef8be8ea AD |
272 | |
273 | print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">"; | |
274 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
275 | print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; | |
276 | ||
ecace165 AD |
277 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; |
278 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 279 | |
ecace165 AD |
280 | /* Title */ |
281 | ||
282 | print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
283 | name=\"title\" value=\"$title\">"; | |
284 | ||
285 | /* Feed URL */ | |
ef8be8ea AD |
286 | |
287 | $feed_url = db_fetch_result($result, 0, "feed_url"); | |
47439031 AD |
288 | $feed_url = htmlspecialchars(db_fetch_result($result, |
289 | 0, "feed_url")); | |
ecace165 AD |
290 | |
291 | print "<br/>"; | |
292 | ||
293 | print __('URL:') . " "; | |
294 | print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
295 | name=\"feed_url\" value=\"$feed_url\">"; | |
296 | ||
297 | /* Category */ | |
ef8be8ea AD |
298 | |
299 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
300 | ||
301 | $cat_id = db_fetch_result($result, 0, "cat_id"); | |
302 | ||
ecace165 AD |
303 | print "<br/>"; |
304 | ||
305 | print __('Place in category:') . " "; | |
ef8be8ea | 306 | |
ecace165 | 307 | print_feed_cat_select($link, "cat_id", $cat_id, $disabled); |
ef8be8ea AD |
308 | } |
309 | ||
ecace165 | 310 | print "</div>"; |
ef8be8ea | 311 | |
e6bf0f4b | 312 | print "<div class=\"dlgSec\">".__("Update")."</div>"; |
ecace165 | 313 | print "<div class=\"dlgSecCont\">"; |
ef8be8ea | 314 | |
ecace165 | 315 | /* Update Interval */ |
ef8be8ea | 316 | |
ecace165 AD |
317 | $update_interval = db_fetch_result($result, 0, "update_interval"); |
318 | ||
319 | print_select_hash("update_interval", $update_interval, $update_intervals); | |
16211ddb | 320 | |
ecace165 AD |
321 | /* Update method */ |
322 | ||
34f29d78 | 323 | $update_method = db_fetch_result($result, 0, "update_method"); |
ecace165 | 324 | |
34f29d78 AD |
325 | print " " . __('using') . " "; |
326 | print_select_hash("update_method", $update_method, $update_methods); | |
16211ddb | 327 | |
22c1bc60 AD |
328 | $purge_interval = db_fetch_result($result, 0, "purge_interval"); |
329 | ||
3907ef71 | 330 | if (FORCE_ARTICLE_PURGE == 0) { |
ecace165 | 331 | |
3907ef71 AD |
332 | /* Purge intl */ |
333 | ||
334 | print "<br/>"; | |
335 | ||
3907ef71 | 336 | print __('Article purging:') . " "; |
ecace165 | 337 | |
3907ef71 | 338 | print_select_hash("purge_interval", $purge_interval, $purge_intervals); |
ecace165 | 339 | |
22c1bc60 AD |
340 | } else { |
341 | print "<input type='hidden' name='purge_interval' value='$purge_interval'>"; | |
342 | ||
3907ef71 | 343 | } |
ecace165 AD |
344 | |
345 | print "</div>"; | |
346 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
347 | print "<div class=\"dlgSecCont\">"; | |
348 | ||
47439031 | 349 | $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login")); |
ef8be8ea | 350 | |
d616904c AD |
351 | print "<table>"; |
352 | ||
353 | print "<tr><td>" . __('Login:') . "</td><td>"; | |
354 | ||
ecace165 AD |
355 | print "<input size=\"20\" onkeypress=\"return filterCR(event, feedEditSave)\" |
356 | name=\"auth_login\" value=\"$auth_login\">"; | |
357 | ||
d616904c | 358 | print "</tr><tr><td>" . __("Password:") . "</td><td>"; |
ef8be8ea | 359 | |
47439031 | 360 | $auth_pass = htmlspecialchars(db_fetch_result($result, 0, "auth_pass")); |
ef8be8ea | 361 | |
ecace165 | 362 | print "<input size=\"20\" type=\"password\" name=\"auth_pass\" |
ef8be8ea | 363 | onkeypress=\"return filterCR(event, feedEditSave)\" |
ecace165 | 364 | value=\"$auth_pass\">"; |
ef8be8ea | 365 | |
d616904c AD |
366 | print "</td></tr></table>"; |
367 | ||
ecace165 AD |
368 | print "</div>"; |
369 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
370 | print "<div class=\"dlgSecCont\">"; | |
ef8be8ea | 371 | |
ecace165 | 372 | print "<div style=\"line-height : 100%\">"; |
ef8be8ea | 373 | |
886d4bce AD |
374 | $private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); |
375 | ||
376 | if ($private) { | |
377 | $checked = "checked"; | |
378 | } else { | |
379 | $checked = ""; | |
380 | } | |
381 | ||
ecace165 | 382 | print "<input type=\"checkbox\" name=\"private\" id=\"private\" |
117335bf | 383 | $checked> <label for=\"private\">".__('Hide from Popular feeds')."</label>"; |
ef8be8ea AD |
384 | |
385 | $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); | |
386 | ||
387 | if ($rtl_content) { | |
388 | $checked = "checked"; | |
389 | } else { | |
390 | $checked = ""; | |
391 | } | |
392 | ||
ecace165 AD |
393 | print "<br/><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" |
394 | $checked> <label for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
ef8be8ea | 395 | |
ef8be8ea AD |
396 | $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest")); |
397 | ||
398 | if ($include_in_digest) { | |
399 | $checked = "checked"; | |
400 | } else { | |
401 | $checked = ""; | |
402 | } | |
403 | ||
ecace165 | 404 | print "<br/><input type=\"checkbox\" id=\"include_in_digest\" |
ef8be8ea | 405 | name=\"include_in_digest\" |
ecace165 | 406 | $checked> <label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; |
ef8be8ea | 407 | |
54e61a68 AD |
408 | |
409 | $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures")); | |
410 | ||
411 | if ($always_display_enclosures) { | |
412 | $checked = "checked"; | |
413 | } else { | |
414 | $checked = ""; | |
415 | } | |
416 | ||
417 | print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\" | |
418 | name=\"always_display_enclosures\" | |
419 | $checked> <label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
420 | ||
421 | ||
bc0f0785 AD |
422 | $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); |
423 | ||
424 | if ($cache_images) { | |
425 | $checked = "checked"; | |
426 | } else { | |
427 | $checked = ""; | |
428 | } | |
429 | ||
78a5c296 | 430 | if (SIMPLEPIE_CACHE_IMAGES) { |
bc0f0785 AD |
431 | $disabled = ""; |
432 | $label_class = ""; | |
433 | } else { | |
434 | $disabled = "disabled"; | |
435 | $label_class = "class='insensitive'"; | |
436 | } | |
437 | ||
ecace165 | 438 | print "<br/><input type=\"checkbox\" id=\"cache_images\" |
bc0f0785 | 439 | name=\"cache_images\" $disabled |
ecace165 | 440 | $checked> <label $label_class for=\"cache_images\">". |
bc0f0785 AD |
441 | __('Cache images locally')."</label>"; |
442 | ||
ef8be8ea | 443 | |
ecace165 AD |
444 | print "</div>"; |
445 | print "</div>"; | |
ef8be8ea AD |
446 | |
447 | print "</form>"; | |
448 | ||
c3b7b797 AD |
449 | /* Icon */ |
450 | ||
451 | print "<br/>"; | |
452 | ||
7abf159d | 453 | print "<div class=\"dlgSec\">".__("Icon")."</div>"; |
c3b7b797 AD |
454 | print "<div class=\"dlgSecCont\">"; |
455 | ||
456 | print "<iframe name=\"icon_upload_iframe\" | |
457 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; | |
458 | ||
459 | print "<form style='display : block' target=\"icon_upload_iframe\" | |
460 | enctype=\"multipart/form-data\" method=\"POST\" | |
461 | action=\"backend.php\"> | |
7abf159d | 462 | <input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\"> |
c3b7b797 | 463 | <input type=\"hidden\" name=\"op\" value=\"pref-feeds\"> |
7abf159d | 464 | <input type=\"hidden\" name=\"feed_id\" value=\"$feed_id\"> |
c3b7b797 AD |
465 | <input type=\"hidden\" name=\"subop\" value=\"uploadicon\"> |
466 | <button onclick=\"return uploadFeedIcon();\" | |
467 | type=\"submit\">".__('Replace')."</button> | |
7abf159d AD |
468 | <button onclick=\"return removeFeedIcon($feed_id);\" |
469 | type=\"submit\">".__('Remove')."</button> | |
c3b7b797 AD |
470 | </form>"; |
471 | ||
7abf159d | 472 | print "</div>"; |
c3b7b797 | 473 | |
ddb61e79 AD |
474 | $title = htmlspecialchars($title, ENT_QUOTES); |
475 | ||
ecace165 | 476 | print "<div class='dlgButtons'> |
143a4973 | 477 | <div style=\"float : left\"> |
ad491d75 AD |
478 | <button onclick='return unsubscribeFeed($feed_id, \"$title\")'>". |
479 | __('Unsubscribe')."</button> | |
143a4973 | 480 | </div> |
ad491d75 AD |
481 | <button onclick=\"return feedEditSave()\">".__('Save')."</button> |
482 | <button onclick=\"return feedEditCancel()\">".__('Cancel')."</button> | |
c8d5dcfe | 483 | </div>"; |
ef8be8ea | 484 | |
951906dc AD |
485 | print "]]></content></dlg>"; |
486 | ||
ef8be8ea AD |
487 | return; |
488 | } | |
489 | ||
758e1c4a AD |
490 | if ($subop == "editfeeds") { |
491 | ||
492 | $feed_ids = db_escape_string($_REQUEST["ids"]); | |
951906dc AD |
493 | |
494 | header("Content-Type: text/xml"); | |
495 | print "<dlg id=\"$subop\">"; | |
496 | print "<title>".__('Multiple Feed Editor')."</title>"; | |
497 | print "<content><![CDATA["; | |
758e1c4a | 498 | |
758e1c4a AD |
499 | print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">"; |
500 | ||
501 | print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">"; | |
502 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
503 | print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">"; | |
504 | ||
505 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
506 | print "<div class=\"dlgSecCont\">"; | |
507 | ||
508 | /* Title */ | |
509 | ||
510 | print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
511 | name=\"title\" value=\"$title\">"; | |
512 | ||
513 | batch_edit_cbox("title"); | |
514 | ||
515 | /* Feed URL */ | |
516 | ||
517 | print "<br/>"; | |
518 | ||
519 | print __('URL:') . " "; | |
520 | print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
521 | name=\"feed_url\" value=\"$feed_url\">"; | |
522 | ||
523 | batch_edit_cbox("feed_url"); | |
524 | ||
525 | /* Category */ | |
526 | ||
527 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
528 | ||
529 | print "<br/>"; | |
530 | ||
531 | print __('Place in category:') . " "; | |
532 | ||
533 | print_feed_cat_select($link, "cat_id", $cat_id, "disabled"); | |
534 | ||
535 | batch_edit_cbox("cat_id"); | |
536 | ||
537 | } | |
538 | ||
539 | print "</div>"; | |
540 | ||
541 | print "<div class=\"dlgSec\">".__("Update")."</div>"; | |
542 | print "<div class=\"dlgSecCont\">"; | |
543 | ||
544 | /* Update Interval */ | |
545 | ||
546 | print_select_hash("update_interval", $update_interval, $update_intervals, | |
547 | "disabled"); | |
548 | ||
549 | batch_edit_cbox("update_interval"); | |
550 | ||
551 | /* Update method */ | |
552 | ||
34f29d78 AD |
553 | print " " . __('using') . " "; |
554 | print_select_hash("update_method", $update_method, $update_methods, | |
555 | "disabled"); | |
556 | batch_edit_cbox("update_method"); | |
758e1c4a AD |
557 | |
558 | /* Purge intl */ | |
559 | ||
3907ef71 | 560 | if (FORCE_ARTICLE_PURGE != 0) { |
758e1c4a | 561 | |
3907ef71 | 562 | print "<br/>"; |
758e1c4a | 563 | |
3907ef71 | 564 | print __('Article purging:') . " "; |
758e1c4a | 565 | |
3907ef71 AD |
566 | print_select_hash("purge_interval", $purge_interval, $purge_intervals, |
567 | "disabled"); | |
568 | ||
569 | batch_edit_cbox("purge_interval"); | |
570 | } | |
758e1c4a AD |
571 | |
572 | print "</div>"; | |
573 | print "<div class=\"dlgSec\">".__("Authentication")."</div>"; | |
574 | print "<div class=\"dlgSecCont\">"; | |
575 | ||
576 | print __('Login:') . " "; | |
577 | print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\" | |
578 | name=\"auth_login\" value=\"$auth_login\">"; | |
579 | ||
580 | batch_edit_cbox("auth_login"); | |
581 | ||
582 | print " " . __("Password:") . " "; | |
583 | ||
584 | print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\" | |
585 | onkeypress=\"return filterCR(event, feedEditSave)\" | |
586 | value=\"$auth_pass\">"; | |
587 | ||
588 | batch_edit_cbox("auth_pass"); | |
589 | ||
590 | print "</div>"; | |
591 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
592 | print "<div class=\"dlgSecCont\">"; | |
593 | ||
594 | print "<div style=\"line-height : 100%\">"; | |
595 | ||
596 | print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\" | |
43f0968e | 597 | $checked> <label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>"; |
758e1c4a AD |
598 | |
599 | print " "; batch_edit_cbox("private", "private_l"); | |
600 | ||
601 | print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\" | |
602 | $checked> <label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>"; | |
603 | ||
604 | print " "; batch_edit_cbox("rtl_content", "rtl_content_l"); | |
605 | ||
758e1c4a AD |
606 | print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\" |
607 | name=\"include_in_digest\" | |
608 | $checked> <label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>"; | |
609 | ||
610 | print " "; batch_edit_cbox("include_in_digest", "include_in_digest_l"); | |
611 | ||
c9f185bd AD |
612 | print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\" |
613 | name=\"always_display_enclosures\" | |
614 | $checked> <label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>"; | |
615 | ||
616 | print " "; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l"); | |
617 | ||
758e1c4a AD |
618 | print "<br/><input disabled type=\"checkbox\" id=\"cache_images\" |
619 | name=\"cache_images\" | |
620 | $checked> <label class='insensitive' id=\"cache_images_l\" | |
621 | for=\"cache_images\">". | |
622 | __('Cache images locally')."</label>"; | |
623 | ||
624 | ||
78a5c296 | 625 | if (SIMPLEPIE_CACHE_IMAGES) { |
758e1c4a AD |
626 | print " "; batch_edit_cbox("cache_images", "cache_images_l"); |
627 | } | |
628 | ||
629 | print "</div>"; | |
630 | print "</div>"; | |
631 | ||
632 | print "</form>"; | |
633 | ||
634 | print "<div class='dlgButtons'> | |
635 | <input type=\"submit\" class=\"button\" | |
636 | onclick=\"return feedsEditSave()\" value=\"".__('Save')."\"> | |
637 | <input type='submit' class='button' | |
638 | onclick=\"return feedEditCancel()\" value=\"".__('Cancel')."\"> | |
639 | </div>"; | |
640 | ||
951906dc AD |
641 | print "]]></content></dlg>"; |
642 | ||
758e1c4a AD |
643 | return; |
644 | } | |
645 | ||
b0f015a2 | 646 | if ($subop == "editSave" || $subop == "batchEditSave") { |
ef8be8ea AD |
647 | |
648 | $feed_title = db_escape_string(trim($_POST["title"])); | |
649 | $feed_link = db_escape_string(trim($_POST["feed_url"])); | |
650 | $upd_intl = db_escape_string($_POST["update_interval"]); | |
651 | $purge_intl = db_escape_string($_POST["purge_interval"]); | |
b0f015a2 AD |
652 | $feed_id = db_escape_string($_POST["id"]); /* editSave */ |
653 | $feed_ids = db_escape_string($_POST["ids"]); /* batchEditSave */ | |
ef8be8ea AD |
654 | $cat_id = db_escape_string($_POST["cat_id"]); |
655 | $auth_login = db_escape_string(trim($_POST["auth_login"])); | |
656 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
ef8be8ea AD |
657 | $private = checkbox_to_sql_bool(db_escape_string($_POST["private"])); |
658 | $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"])); | |
ef8be8ea AD |
659 | $include_in_digest = checkbox_to_sql_bool( |
660 | db_escape_string($_POST["include_in_digest"])); | |
bc0f0785 AD |
661 | $cache_images = checkbox_to_sql_bool( |
662 | db_escape_string($_POST["cache_images"])); | |
16211ddb | 663 | $update_method = (int) db_escape_string($_POST["update_method"]); |
ef8be8ea | 664 | |
54e61a68 AD |
665 | $always_display_enclosures = checkbox_to_sql_bool( |
666 | db_escape_string($_POST["always_display_enclosures"])); | |
667 | ||
ef8be8ea AD |
668 | if (get_pref($link, 'ENABLE_FEED_CATS')) { |
669 | if ($cat_id && $cat_id != 0) { | |
670 | $category_qpart = "cat_id = '$cat_id',"; | |
671 | $category_qpart_nocomma = "cat_id = '$cat_id'"; | |
672 | } else { | |
673 | $category_qpart = 'cat_id = NULL,'; | |
674 | $category_qpart_nocomma = 'cat_id = NULL'; | |
675 | } | |
676 | } else { | |
677 | $category_qpart = ""; | |
678 | $category_qpart_nocomma = ""; | |
679 | } | |
680 | ||
78a5c296 | 681 | if (SIMPLEPIE_CACHE_IMAGES) { |
bc0f0785 AD |
682 | $cache_images_qpart = "cache_images = $cache_images,"; |
683 | } else { | |
684 | $cache_images_qpart = ""; | |
685 | } | |
686 | ||
b0f015a2 AD |
687 | if ($subop == "editSave") { |
688 | ||
689 | $result = db_query($link, "UPDATE ttrss_feeds SET | |
6e63a7c3 | 690 | $category_qpart |
b0f015a2 AD |
691 | title = '$feed_title', feed_url = '$feed_link', |
692 | update_interval = '$upd_intl', | |
693 | purge_interval = '$purge_intl', | |
694 | auth_login = '$auth_login', | |
695 | auth_pass = '$auth_pass', | |
696 | private = $private, | |
697 | rtl_content = $rtl_content, | |
b0f015a2 AD |
698 | $cache_images_qpart |
699 | include_in_digest = $include_in_digest, | |
54e61a68 | 700 | always_display_enclosures = $always_display_enclosures, |
b0f015a2 | 701 | update_method = '$update_method' |
5ffd798d | 702 | WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); |
b0f015a2 | 703 | |
b0f015a2 AD |
704 | } else if ($subop == "batchEditSave") { |
705 | $feed_data = array(); | |
ef8be8ea | 706 | |
b0f015a2 AD |
707 | foreach (array_keys($_POST) as $k) { |
708 | if ($k != "op" && $k != "subop" && $k != "ids") { | |
709 | $feed_data[$k] = $_POST[$k]; | |
710 | } | |
711 | } | |
712 | ||
713 | db_query($link, "BEGIN"); | |
714 | ||
715 | foreach (array_keys($feed_data) as $k) { | |
716 | ||
717 | $qpart = ""; | |
718 | ||
719 | switch ($k) { | |
720 | case "title": | |
721 | $qpart = "title = '$feed_title'"; | |
722 | break; | |
723 | ||
724 | case "feed_url": | |
725 | $qpart = "feed_url = '$feed_link'"; | |
726 | break; | |
727 | ||
728 | case "update_interval": | |
729 | $qpart = "update_interval = '$upd_intl'"; | |
730 | break; | |
731 | ||
732 | case "purge_interval": | |
733 | $qpart = "purge_interval = '$purge_intl'"; | |
734 | break; | |
735 | ||
736 | case "auth_login": | |
737 | $qpart = "auth_login = '$auth_login'"; | |
738 | break; | |
739 | ||
740 | case "auth_pass": | |
741 | $qpart = "auth_pass = '$auth_pass'"; | |
742 | break; | |
743 | ||
744 | case "private": | |
745 | $qpart = "private = '$private'"; | |
746 | break; | |
747 | ||
b0f015a2 AD |
748 | case "include_in_digest": |
749 | $qpart = "include_in_digest = '$include_in_digest'"; | |
750 | break; | |
751 | ||
c9f185bd AD |
752 | case "always_display_enclosures": |
753 | $qpart = "always_display_enclosures = '$always_display_enclosures'"; | |
754 | break; | |
755 | ||
5d538f4f AD |
756 | case "cache_images": |
757 | $qpart = "cache_images = '$cache_images'"; | |
758 | break; | |
759 | ||
760 | case "rtl_content": | |
761 | $qpart = "rtl_content = '$rtl_content'"; | |
762 | break; | |
763 | ||
b0f015a2 AD |
764 | case "update_method": |
765 | $qpart = "update_method = '$update_method'"; | |
766 | break; | |
767 | ||
768 | case "cat_id": | |
769 | $qpart = $category_qpart_nocomma; | |
770 | break; | |
771 | ||
772 | } | |
773 | ||
774 | if ($qpart) { | |
cff7a3a2 | 775 | db_query($link, |
b0f015a2 | 776 | "UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids) |
cd935c42 AD |
777 | AND owner_uid = " . $_SESSION["uid"]); |
778 | print "<br/>"; | |
b0f015a2 AD |
779 | } |
780 | } | |
781 | ||
782 | db_query($link, "COMMIT"); | |
ef8be8ea | 783 | } |
b0f015a2 | 784 | |
ef8be8ea AD |
785 | } |
786 | ||
ef8be8ea AD |
787 | if ($subop == "remove") { |
788 | ||
b4e75b2a | 789 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea | 790 | |
810b1561 | 791 | foreach ($ids as $id) { |
7e329f13 | 792 | remove_feed($link, $id, $_SESSION["uid"]); |
ef8be8ea | 793 | } |
b6a6e262 AD |
794 | |
795 | return; | |
ef8be8ea AD |
796 | } |
797 | ||
d1f0c584 | 798 | if ($subop == "clear") { |
b4e75b2a | 799 | $id = db_escape_string($_REQUEST["id"]); |
d1f0c584 AD |
800 | clear_feed_articles($link, $id); |
801 | } | |
802 | ||
fee840fb | 803 | if ($subop == "rescore") { |
b4e75b2a | 804 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
fee840fb AD |
805 | |
806 | foreach ($ids as $id) { | |
807 | ||
808 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
809 | ||
38edb151 AD |
810 | $result = db_query($link, "SELECT |
811 | title, content, link, ref_id, author,". | |
812 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
813 | FROM | |
fee840fb AD |
814 | ttrss_user_entries, ttrss_entries |
815 | WHERE ref_id = id AND feed_id = '$id' AND | |
816 | owner_uid = " .$_SESSION['uid']." | |
ef1b0366 | 817 | "); |
fee840fb AD |
818 | |
819 | $scores = array(); | |
820 | ||
821 | while ($line = db_fetch_assoc($result)) { | |
822 | ||
38edb151 AD |
823 | $tags = get_article_tags($link, $line["ref_id"]); |
824 | ||
fee840fb | 825 | $article_filters = get_article_filters($filters, $line['title'], |
38edb151 AD |
826 | $line['content'], $line['link'], strtotime($line['updated']), |
827 | $line['author'], $tags); | |
fee840fb AD |
828 | |
829 | $new_score = calculate_article_score($article_filters); | |
830 | ||
831 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
832 | ||
833 | array_push($scores[$new_score], $line['ref_id']); | |
834 | } | |
835 | ||
836 | foreach (array_keys($scores) as $s) { | |
837 | if ($s > 1000) { | |
838 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
839 | marked = true WHERE | |
95a948a5 | 840 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
1618a849 AD |
841 | } else if ($s < -500) { |
842 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
843 | unread = false WHERE | |
844 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
95a948a5 AD |
845 | } else { |
846 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
847 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
848 | } | |
849 | } | |
850 | } | |
851 | ||
852 | print __("All done."); | |
853 | ||
854 | } | |
855 | ||
856 | if ($subop == "rescoreAll") { | |
857 | ||
858 | $result = db_query($link, | |
859 | "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']); | |
860 | ||
861 | while ($feed_line = db_fetch_assoc($result)) { | |
862 | ||
863 | $id = $feed_line["id"]; | |
864 | ||
865 | $filters = load_filters($link, $id, $_SESSION["uid"], 6); | |
866 | ||
38edb151 AD |
867 | $tmp_result = db_query($link, "SELECT |
868 | title, content, link, ref_id, author,". | |
869 | SUBSTRING_FOR_DATE."(updated, 1, 19) AS updated | |
870 | FROM | |
95a948a5 AD |
871 | ttrss_user_entries, ttrss_entries |
872 | WHERE ref_id = id AND feed_id = '$id' AND | |
873 | owner_uid = " .$_SESSION['uid']." | |
874 | "); | |
875 | ||
876 | $scores = array(); | |
877 | ||
878 | while ($line = db_fetch_assoc($tmp_result)) { | |
879 | ||
38edb151 AD |
880 | $tags = get_article_tags($link, $line["ref_id"]); |
881 | ||
95a948a5 | 882 | $article_filters = get_article_filters($filters, $line['title'], |
38edb151 AD |
883 | $line['content'], $line['link'], strtotime($line['updated']), |
884 | $line['author'], $tags); | |
885 | ||
95a948a5 AD |
886 | $new_score = calculate_article_score($article_filters); |
887 | ||
888 | if (!$scores[$new_score]) $scores[$new_score] = array(); | |
889 | ||
890 | array_push($scores[$new_score], $line['ref_id']); | |
891 | } | |
892 | ||
893 | foreach (array_keys($scores) as $s) { | |
894 | if ($s > 1000) { | |
895 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s', | |
896 | marked = true WHERE | |
fee840fb AD |
897 | ref_id IN (" . join(',', $scores[$s]) . ")"); |
898 | } else { | |
899 | db_query($link, "UPDATE ttrss_user_entries SET score = '$s' WHERE | |
900 | ref_id IN (" . join(',', $scores[$s]) . ")"); | |
901 | } | |
902 | } | |
903 | } | |
904 | ||
905 | print __("All done."); | |
906 | ||
907 | } | |
908 | ||
ef8be8ea | 909 | if ($subop == "add") { |
ef8be8ea | 910 | |
a5819bb3 AD |
911 | $feed_url = db_escape_string(trim($_REQUEST["feed_url"])); |
912 | $cat_id = db_escape_string($_REQUEST["cat_id"]); | |
913 | $p_from = db_escape_string($_REQUEST["from"]); | |
ef8be8ea | 914 | |
a5819bb3 | 915 | /* only read authentication information from POST */ |
aa2122d4 | 916 | |
a5819bb3 AD |
917 | $auth_login = db_escape_string(trim($_POST["auth_login"])); |
918 | $auth_pass = db_escape_string(trim($_POST["auth_pass"])); | |
aa2122d4 | 919 | |
a5819bb3 AD |
920 | if ($p_from != 'tt-rss') { |
921 | print "<html> | |
922 | <head> | |
923 | <title>Tiny Tiny RSS</title> | |
924 | <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\"> | |
925 | </head> | |
926 | <body> | |
927 | <img class=\"floatingLogo\" src=\"images/ttrss_logo.png\" | |
928 | alt=\"Tiny Tiny RSS\"/> | |
929 | <h1>Subscribe to feed...</h1>"; | |
930 | } | |
d70c5ae4 | 931 | |
a5819bb3 AD |
932 | $rc = subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass); |
933 | ||
934 | switch ($rc) { | |
935 | case 1: | |
936 | print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); | |
937 | break; | |
938 | case 2: | |
939 | print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url)); | |
940 | break; | |
941 | case 0: | |
942 | print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); | |
943 | break; | |
944 | } | |
e513a74a | 945 | |
a5819bb3 AD |
946 | if ($p_from != 'tt-rss') { |
947 | $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]); | |
e513a74a | 948 | |
e513a74a | 949 | |
a5819bb3 | 950 | $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]); |
6906f145 | 951 | |
a5819bb3 AD |
952 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE |
953 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
e513a74a | 954 | |
a5819bb3 | 955 | $feed_id = db_fetch_result($result, 0, "id"); |
aa2122d4 | 956 | |
a5819bb3 AD |
957 | print "<p>"; |
958 | ||
959 | if ($feed_id) { | |
960 | print "<form method=\"GET\" style='display: inline' | |
961 | action=\"$tp_uri\"> | |
962 | <input type=\"hidden\" name=\"tab\" value=\"feedConfig\"> | |
963 | <input type=\"hidden\" name=\"subop\" value=\"editFeed\"> | |
964 | <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\"> | |
965 | <input type=\"submit\" value=\"".__("Edit subscription options")."\"> | |
966 | </form>"; | |
aa2122d4 | 967 | } |
442d77f1 | 968 | |
a5819bb3 AD |
969 | print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\"> |
970 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
971 | </form></p>"; | |
972 | ||
973 | print "</body></html>"; | |
974 | return; | |
ef8be8ea AD |
975 | } |
976 | } | |
977 | ||
ef8be8ea AD |
978 | if ($subop == "categorize") { |
979 | ||
ef8be8ea | 980 | |
913f374b | 981 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea | 982 | |
913f374b | 983 | $cat_id = db_escape_string($_REQUEST["cat_id"]); |
ef8be8ea | 984 | |
913f374b AD |
985 | if ($cat_id == 0) { |
986 | $cat_id_qpart = 'NULL'; | |
987 | } else { | |
988 | $cat_id_qpart = "'$cat_id'"; | |
989 | } | |
ef8be8ea | 990 | |
913f374b | 991 | db_query($link, "BEGIN"); |
ef8be8ea | 992 | |
913f374b AD |
993 | foreach ($ids as $id) { |
994 | ||
995 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart | |
6e63a7c3 | 996 | WHERE id = '$id' |
913f374b | 997 | AND owner_uid = " . $_SESSION["uid"]); |
ef8be8ea | 998 | |
ef8be8ea AD |
999 | } |
1000 | ||
913f374b AD |
1001 | db_query($link, "COMMIT"); |
1002 | ||
ef8be8ea AD |
1003 | } |
1004 | ||
9c483746 AD |
1005 | if ($subop == "editCats") { |
1006 | ||
9c483746 AD |
1007 | $action = $_REQUEST["action"]; |
1008 | ||
1009 | if ($action == "save") { | |
1010 | ||
11f083e7 | 1011 | $cat_title = db_escape_string(trim($_REQUEST["value"])); |
b4e75b2a | 1012 | $cat_id = db_escape_string($_REQUEST["cid"]); |
11f083e7 | 1013 | |
8f708155 AD |
1014 | db_query($link, "BEGIN"); |
1015 | ||
1016 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
1017 | WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
1018 | ||
1019 | if (db_num_rows($result) == 1) { | |
1020 | ||
1021 | $old_title = db_fetch_result($result, 0, "title"); | |
1022 | ||
1023 | if ($cat_title != "") { | |
1024 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
1025 | title = '$cat_title' WHERE id = '$cat_id' AND | |
1026 | owner_uid = ".$_SESSION["uid"]); | |
1027 | ||
1028 | print $cat_title; | |
1029 | } else { | |
1030 | print $old_title; | |
1031 | } | |
1032 | } else { | |
1033 | print $_REQUEST["value"]; | |
1034 | } | |
1035 | ||
1036 | db_query($link, "COMMIT"); | |
11f083e7 AD |
1037 | |
1038 | return; | |
1039 | ||
9c483746 AD |
1040 | } |
1041 | ||
951906dc AD |
1042 | header("Content-Type: text/xml"); |
1043 | print "<dlg id=\"$subop\">"; | |
1044 | print "<title>".__('Category editor')."</title>"; | |
1045 | print "<content><![CDATA["; | |
11f083e7 | 1046 | |
9c483746 AD |
1047 | if ($action == "add") { |
1048 | ||
913f374b AD |
1049 | $feed_cat = db_escape_string(trim($_REQUEST["cat"])); |
1050 | ||
5c7c7da9 AD |
1051 | if (!add_feed_category($link, $feed_cat)) |
1052 | print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", $feed_cat)); | |
913f374b | 1053 | |
9c483746 AD |
1054 | } |
1055 | ||
1056 | if ($action == "remove") { | |
1057 | ||
b4e75b2a | 1058 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
9c483746 | 1059 | |
7e329f13 AD |
1060 | foreach ($ids as $id) { |
1061 | remove_feed_category($link, $id, $_SESSION["uid"]); | |
9c483746 AD |
1062 | } |
1063 | } | |
1064 | ||
a8328019 | 1065 | print "<div dojoType=\"dijit.Toolbar\"> |
9c483746 | 1066 | <input id=\"fadd_cat\" |
1043a8c3 | 1067 | onkeypress=\"return filterCR(event, addFeedCat)\" |
d60009cd | 1068 | size=\"40\"> |
a998dbef | 1069 | <button onclick=\"addFeedCat()\">". |
d60009cd | 1070 | __('Create category')."</button></div>"; |
9c483746 AD |
1071 | |
1072 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories | |
1073 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1074 | ORDER BY title"); | |
1075 | ||
a8328019 | 1076 | # print "<p>"; |
9c483746 AD |
1077 | |
1078 | if (db_num_rows($result) != 0) { | |
1079 | ||
a8328019 AD |
1080 | # print __('Select:')." |
1081 | # <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'all')\">".__('All')."</a>, | |
1082 | # <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'none')\">".__('None')."</a>"; | |
1083 | # | |
9c483746 AD |
1084 | print "<div class=\"prefFeedCatHolder\">"; |
1085 | ||
e6312f6c | 1086 | print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">"; |
9c483746 AD |
1087 | |
1088 | print "<table width=\"100%\" class=\"prefFeedCatList\" | |
1089 | cellspacing=\"0\" id=\"prefFeedCatList\">"; | |
9c483746 AD |
1090 | |
1091 | $lnum = 0; | |
1092 | ||
1093 | while ($line = db_fetch_assoc($result)) { | |
1094 | ||
1095 | $class = ($lnum % 2) ? "even" : "odd"; | |
1096 | ||
1097 | $cat_id = $line["id"]; | |
11f083e7 | 1098 | $this_row_id = "id=\"FCATR-$cat_id\""; |
9c483746 | 1099 | |
a8328019 | 1100 | print "<tr class=\"\" $this_row_id>"; |
9c483746 | 1101 | |
47439031 | 1102 | $edit_title = htmlspecialchars($line["title"]); |
9c483746 | 1103 | |
11f083e7 | 1104 | print "<td width='5%' align='center'><input |
a8328019 | 1105 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" |
11f083e7 AD |
1106 | type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>"; |
1107 | ||
44e05f79 | 1108 | print "<td>"; |
9c483746 | 1109 | |
44e05f79 AD |
1110 | # print "<span id=\"FCATT-$cat_id\">" . |
1111 | # $edit_title . "</span>"; | |
1112 | ||
1113 | print "<span dojoType=\"dijit.InlineEditBox\" | |
1114 | width=\"300px\" autoSave=\"false\" | |
1115 | cat-id=\"$cat_id\">" . $edit_title . | |
1116 | "<script type=\"dojo/method\" event=\"onChange\" args=\"item\"> | |
1117 | var elem = this; | |
1118 | dojo.xhrPost({ | |
1119 | url: 'backend.php', | |
1120 | content: {op: 'pref-feeds', subop: 'editCats', | |
1121 | action: 'save', | |
1122 | value: this.value, | |
1123 | cid: this.srcNodeRef.getAttribute('cat-id')}, | |
1124 | load: function(response) { | |
1125 | elem.attr('value', response); | |
1126 | } | |
1127 | }); | |
1128 | </script> | |
1129 | </span>"; | |
1130 | ||
1131 | print "</td></tr>"; | |
9c483746 AD |
1132 | |
1133 | ++$lnum; | |
1134 | } | |
1135 | ||
1136 | print "</table>"; | |
1137 | ||
1138 | print "</form>"; | |
1139 | ||
1140 | print "</div>"; | |
1141 | ||
6f5b1e04 | 1142 | } else { |
31cc42f6 | 1143 | print "<p>".__('No feed categories defined.')."</p>"; |
6f5b1e04 | 1144 | } |
9c483746 | 1145 | |
d60009cd AD |
1146 | print "<div class='dlgButtons'> |
1147 | <div style='float : left'> | |
1148 | <button onclick=\"return removeSelectedFeedCats()\">". | |
1149 | __('Remove')."</button> | |
1150 | </div>"; | |
9c483746 | 1151 | |
d60009cd AD |
1152 | print "<button onclick=\"selectTab('feedConfig')\">". |
1153 | __('Close this window')."</button></div>"; | |
9c483746 | 1154 | |
951906dc | 1155 | print "]]></content></dlg>"; |
6f5b1e04 | 1156 | |
9c483746 AD |
1157 | return; |
1158 | ||
1159 | } | |
1160 | ||
ef8be8ea AD |
1161 | if ($quiet) return; |
1162 | ||
8df7184c AD |
1163 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; |
1164 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">"; | |
1165 | ||
442d77f1 AD |
1166 | set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig"); |
1167 | ||
a3656a41 | 1168 | $result = db_query($link, "SELECT COUNT(id) AS num_errors |
ef8be8ea AD |
1169 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); |
1170 | ||
a3656a41 | 1171 | $num_errors = db_fetch_result($result, 0, "num_errors"); |
ef8be8ea | 1172 | |
a3656a41 | 1173 | if ($num_errors > 0) { |
ef8be8ea | 1174 | |
49c6c279 AD |
1175 | $error_button = "<button dojoType=\"dijit.form.Button\" |
1176 | onclick=\"showFeedsWithErrors\" id=\"errorButton\">" . | |
1177 | __("Feeds with errors") . "</button>"; | |
1178 | ||
1179 | // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">". | |
1180 | // __('Some feeds have update errors (click for details)')."</a>"); | |
ef8be8ea AD |
1181 | } |
1182 | ||
b4e75b2a | 1183 | $feed_search = db_escape_string($_REQUEST["search"]); |
ef8be8ea | 1184 | |
b4e75b2a | 1185 | if (array_key_exists("search", $_REQUEST)) { |
ef8be8ea AD |
1186 | $_SESSION["prefs_feed_search"] = $feed_search; |
1187 | } else { | |
1188 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1189 | } | |
1190 | ||
8df7184c AD |
1191 | print "<div dojoType=\"dijit.Toolbar\">"; |
1192 | ||
1985a5e0 | 1193 | /* |
577399e8 | 1194 | print "<div style='float : right'> |
3dc8ee84 | 1195 | <input id=\"feed_search\" size=\"20\" type=\"search\" |
a998dbef AD |
1196 | onfocus=\"disableHotkeys();\" |
1197 | onblur=\"enableHotkeys();\" | |
1198 | onchange=\"updateFeedList()\" value=\"$feed_search\"> | |
1199 | <button onclick=\"updateFeedList()\">". | |
577399e8 | 1200 | __('Search')."</button> |
1985a5e0 AD |
1201 | </div>"; */ |
1202 | ||
1203 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
d69fa6d6 | 1204 | "<span>" . __('Select')."</span>"; |
1985a5e0 AD |
1205 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
1206 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\" | |
1207 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
1208 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\" | |
1209 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
d69fa6d6 | 1210 | print "</div></div>"; |
1e5548db | 1211 | |
7b8a143f AD |
1212 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
1213 | "<span>" . __('Feeds')."</span>"; | |
1214 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1215 | print "<div onclick=\"quickAddFeed()\" | |
1216 | dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>"; | |
1217 | print "<div onclick=\"editSelectedFeed()\" | |
82aea978 | 1218 | dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>"; |
7b8a143f AD |
1219 | print "<div onclick=\"resetFeedOrder()\" |
1220 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
1221 | print "</div></div>"; | |
1e5548db AD |
1222 | |
1223 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
7b8a143f AD |
1224 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
1225 | "<span>" . __('Categories')."</span>"; | |
1226 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
1227 | print "<div onclick=\"editFeedCats()\" | |
1228 | dojoType=\"dijit.MenuItem\">".__('Edit categories')."</div>"; | |
1229 | print "<div onclick=\"resetCatOrder()\" | |
1230 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; | |
1231 | print "</div></div>"; | |
1e5548db | 1232 | |
1e5548db AD |
1233 | } |
1234 | ||
49c6c279 AD |
1235 | print $error_button; |
1236 | ||
1985a5e0 AD |
1237 | print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">" |
1238 | .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> "; | |
1e5548db | 1239 | |
a522a767 | 1240 | if (defined('_ENABLE_FEED_DEBUGGING')) { |
ef8be8ea | 1241 | |
a522a767 AD |
1242 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> |
1243 | <option value=\"facDefault\" selected>".__('More actions...')."</option>"; | |
1244 | ||
1245 | if (FORCE_ARTICLE_PURGE == 0) { | |
1246 | ||
1247 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; | |
1248 | } | |
1249 | ||
1250 | print " | |
1251 | <option value=\"facClear\">".__('Clear feed data')."</option> | |
1252 | <option value=\"facRescore\">".__('Rescore articles')."</option>"; | |
1253 | ||
1254 | print "</select>"; | |
0b9751cd | 1255 | |
a522a767 | 1256 | } |
0b9751cd | 1257 | |
8df7184c AD |
1258 | print "</div>"; # toolbar |
1259 | ||
1985a5e0 AD |
1260 | print "<div id=\"feedlistLoading\"> |
1261 | <img src='images/indicator_tiny.gif'>". | |
1262 | __("Loading, please wait...")."</div>"; | |
1263 | ||
7b8a143f AD |
1264 | print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\" |
1265 | url=\"backend.php?op=pref-feeds&subop=getfeedtree\"> | |
1985a5e0 AD |
1266 | </div> |
1267 | <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\" | |
1268 | query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\" | |
1269 | childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\"> | |
1270 | </div> | |
2148e0d5 AD |
1271 | <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\" |
1272 | dndController=\"dijit.tree.dndSource\" | |
7b8a143f | 1273 | betweenThreshold=\"5\" |
1985a5e0 AD |
1274 | model=\"feedModel\" openOnClick=\"false\"> |
1275 | <script type=\"dojo/method\" event=\"onClick\" args=\"item\"> | |
1276 | var id = String(item.id); | |
1277 | var bare_id = id.substr(id.indexOf(':')+1); | |
1278 | ||
7b8a143f | 1279 | if (id.match('FEED:')) { |
1985a5e0 | 1280 | editFeed(bare_id, event); |
7b8a143f AD |
1281 | } else if (id.match('CAT:')) { |
1282 | editCat(bare_id, item, event); | |
1283 | } | |
1985a5e0 AD |
1284 | </script> |
1285 | <script type=\"dojo/method\" event=\"onLoad\" args=\"item\"> | |
1286 | Element.hide(\"feedlistLoading\"); | |
1287 | </script> | |
1985a5e0 AD |
1288 | </div>"; |
1289 | ||
a740f4b5 AD |
1290 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\"> |
1291 | <b>Hint:</b> you can drag feeds and categories around. | |
1292 | </div>"; | |
1293 | ||
8df7184c | 1294 | print "</div>"; # feeds pane |
94a4ba88 | 1295 | |
8df7184c | 1296 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">"; |
b6a6e262 | 1297 | |
00a35bb6 AD |
1298 | print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings."); |
1299 | ||
254ac705 | 1300 | print "<div class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</div>"; |
c107797c | 1301 | |
00a35bb6 AD |
1302 | print "</p>"; |
1303 | ||
c3b7b797 | 1304 | print "<iframe name=\"upload_iframe\" |
b6a6e262 AD |
1305 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; |
1306 | ||
1307 | print "<div style='float : left'>"; | |
1308 | print "<form style='display : block' target=\"upload_iframe\" | |
1309 | enctype=\"multipart/form-data\" method=\"POST\" | |
1310 | action=\"backend.php\"> | |
1311 | <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
1312 | <input type=\"hidden\" name=\"op\" value=\"dlg\"> | |
1313 | <input type=\"hidden\" name=\"id\" value=\"importOpml\"> | |
1314 | <button onclick=\"return opmlImport();\" | |
1315 | type=\"submit\">".__('Import')."</button> | |
1316 | </form>"; | |
1317 | print "</div> "; | |
94a4ba88 | 1318 | |
8df7184c | 1319 | print "<button onclick=\"gotoExportOpml()\">".__('Export OPML')."</button>"; |
94a4ba88 | 1320 | |
c107797c AD |
1321 | print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.'); |
1322 | ||
1323 | print "<div class=\"insensitive\">" . __("Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</div>" . "</p>"; | |
e4f4b46f | 1324 | |
c107797c AD |
1325 | print "<button onclick=\"return displayDlg('pubOPMLUrl')\">". |
1326 | __('Display URL')."</button> "; | |
1327 | ||
1328 | ||
8df7184c AD |
1329 | print "</div>"; # pane |
1330 | ||
68313e5d | 1331 | if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) { |
8df7184c AD |
1332 | |
1333 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">"; | |
755a43ee | 1334 | |
c107797c | 1335 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>"; |
cf9dc032 | 1336 | |
68313e5d | 1337 | print "<p>"; |
cf9dc032 | 1338 | |
c107797c | 1339 | print "<button onclick='window.navigator.registerContentHandler(" . |
755a43ee AD |
1340 | "\"application/vnd.mozilla.maybe.feed\", " . |
1341 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
cf9dc032 AD |
1342 | __('Click here to register this site as a feed reader.') . |
1343 | "</button>"; | |
755a43ee | 1344 | |
c107797c | 1345 | print "</p>"; |
755a43ee | 1346 | |
8df7184c AD |
1347 | print "</div>"; # pane |
1348 | } | |
46dc1538 | 1349 | |
8df7184c AD |
1350 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Subscribing using bookmarklet')."\">"; |
1351 | ||
46dc1538 AD |
1352 | print "<p>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</p>"; |
1353 | ||
1354 | $bm_subscribe_url = str_replace('%s', '', add_feed_url()); | |
1355 | ||
1356 | $confirm_str = __('Subscribe to %s in Tiny Tiny RSS?'); | |
1357 | ||
1358 | $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}"); | |
1359 | ||
1360 | print "<a href=\"$bm_url\" class='visibleLink'>" . __('Subscribe in Tiny Tiny RSS'). "</a>"; | |
1361 | ||
8df7184c AD |
1362 | print "</div>"; #pane |
1363 | ||
1364 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published articles and generated feeds')."\">"; | |
e4f4b46f | 1365 | |
e635d56a | 1366 | print "<p>".__('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.')."</p>"; |
e4f4b46f | 1367 | |
8801fb01 AD |
1368 | $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . |
1369 | "/backend.php?op=rss&id=-2&view-mode=all_articles");; | |
1370 | ||
1371 | print "<button onclick=\"return displayDlg('generatedFeed', '$rss_url')\">". | |
cf9dc032 | 1372 | __('Display URL')."</button> "; |
c107797c | 1373 | |
8d86f15f AD |
1374 | print "<button onclick=\"return clearFeedAccessKeys()\">". |
1375 | __('Clear all generated URLs')."</button> "; | |
e4f4b46f | 1376 | |
8df7184c AD |
1377 | print "</div>"; #pane |
1378 | print "</div>"; #container | |
1379 | ||
ef8be8ea | 1380 | } |
b56465dd | 1381 | |
082ae95b | 1382 | function print_feed_browser($link, $search, $limit, $mode = 1) { |
b56465dd | 1383 | |
c2913898 AD |
1384 | $owner_uid = $_SESSION["uid"]; |
1385 | ||
1386 | if ($search) { | |
1387 | $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR | |
1388 | UPPER(title) LIKE UPPER('%$search%'))"; | |
1389 | } else { | |
1390 | $search_qpart = ""; | |
1391 | } | |
1392 | ||
082ae95b AD |
1393 | if ($mode == 1) { |
1394 | $result = db_query($link, "SELECT feed_url, subscribers FROM | |
1395 | ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
1396 | WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url | |
1397 | AND owner_uid = '$owner_uid') $search_qpart | |
1398 | ORDER BY subscribers DESC LIMIT $limit"); | |
1399 | } else if ($mode == 2) { | |
ef88b1cc AD |
1400 | $result = db_query($link, "SELECT *, |
1401 | (SELECT COUNT(*) FROM ttrss_user_entries WHERE | |
1402 | orig_feed_id = ttrss_archived_feeds.id) AS articles_archived | |
1403 | FROM | |
1404 | ttrss_archived_feeds | |
1405 | WHERE | |
082ae95b AD |
1406 | (SELECT COUNT(*) FROM ttrss_feeds |
1407 | WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND | |
1408 | owner_uid = '$owner_uid') = 0 AND | |
1409 | owner_uid = '$owner_uid' $search_qpart | |
1410 | ORDER BY id DESC LIMIT $limit"); | |
1411 | } | |
b56465dd AD |
1412 | |
1413 | $feedctr = 0; | |
1414 | ||
1415 | while ($line = db_fetch_assoc($result)) { | |
b56465dd | 1416 | |
082ae95b | 1417 | if ($mode == 1) { |
b56465dd | 1418 | |
2211a391 | 1419 | $feed_url = $line["feed_url"]; |
082ae95b | 1420 | $subscribers = $line["subscribers"]; |
2211a391 | 1421 | |
082ae95b AD |
1422 | $det_result = db_query($link, "SELECT site_url,title,id |
1423 | FROM ttrss_feeds WHERE feed_url = '$feed_url' LIMIT 1"); | |
1424 | ||
1425 | $details = db_fetch_assoc($det_result); | |
1426 | ||
1427 | $icon_file = ICONS_DIR . "/" . $details["id"] . ".ico"; | |
1428 | ||
1429 | if (file_exists($icon_file) && filesize($icon_file) > 0) { | |
a8328019 | 1430 | $feed_icon = "<img style=\"vertical-align : middle\" class=\"tinyFeedIcon\" src=\"" . ICONS_URL . |
082ae95b AD |
1431 | "/".$details["id"].".ico\">"; |
1432 | } else { | |
1433 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1434 | } | |
1435 | ||
a8328019 AD |
1436 | $check_box = "<input onclick='toggleSelectListRow2(this)' |
1437 | dojoType=\"dijit.form.CheckBox\" | |
082ae95b AD |
1438 | type=\"checkbox\" id=\"FBCHK-" . $details["id"] . "\">"; |
1439 | ||
1440 | $class = ($feedctr % 2) ? "even" : "odd"; | |
1441 | ||
2211a391 AD |
1442 | $feed_url = htmlspecialchars($line["feed_url"]); |
1443 | ||
082ae95b | 1444 | if ($details["site_url"]) { |
ef88b1cc AD |
1445 | $site_url = "<a target=\"_blank\" href=\"". |
1446 | htmlspecialchars($details["site_url"])."\"> | |
082ae95b AD |
1447 | <img style='border-width : 0px' src='images/www.png' alt='www'></a>"; |
1448 | } else { | |
1449 | $site_url = ""; | |
1450 | } | |
e15bb6f7 AD |
1451 | |
1452 | $feed_url = "<a target=\"_blank\" href=\"$feed_url\"><img | |
1453 | style='border-width : 0px; vertical-align : middle' | |
1454 | src='images/feed-icon-12x12.png'></a>"; | |
1455 | ||
ef88b1cc | 1456 | print "<li title=\"".htmlspecialchars($details["site_url"])."\" |
a8328019 | 1457 | id=\"FBROW-".$details["id"]."\">$check_box". |
e15bb6f7 | 1458 | "$feed_icon $feed_url " . htmlspecialchars($details["title"]) . |
082ae95b | 1459 | " <span class='subscribers'>($subscribers)</span> |
ef88b1cc | 1460 | $site_url</li>"; |
082ae95b AD |
1461 | |
1462 | } else if ($mode == 2) { | |
ef88b1cc AD |
1463 | $feed_url = htmlspecialchars($line["feed_url"]); |
1464 | $site_url = htmlspecialchars($line["site_url"]); | |
1465 | $title = htmlspecialchars($line["title"]); | |
69877646 AD |
1466 | |
1467 | $icon_file = ICONS_DIR . "/" . $line["id"] . ".ico"; | |
082ae95b | 1468 | |
69877646 AD |
1469 | if (file_exists($icon_file) && filesize($icon_file) > 0) { |
1470 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . | |
1471 | "/".$line["id"].".ico\">"; | |
1472 | } else { | |
1473 | $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">"; | |
1474 | } | |
1475 | ||
082ae95b AD |
1476 | $check_box = "<input onclick='toggleSelectListRow(this)' class='feedBrowseCB' |
1477 | type=\"checkbox\" id=\"FBCHK-" . $line["id"] . "\">"; | |
1478 | ||
1479 | $class = ($feedctr % 2) ? "even" : "odd"; | |
ef88b1cc AD |
1480 | |
1481 | if ($line['articles_archived'] > 0) { | |
1482 | $archived = sprintf(__("%d archived articles"), $line['articles_archived']); | |
1483 | $archived = " <span class='subscribers'>($archived)</span>"; | |
1484 | } else { | |
1485 | $archived = ''; | |
1486 | } | |
1487 | ||
082ae95b | 1488 | if ($line["site_url"]) { |
ef88b1cc | 1489 | $site_url = "<a target=\"_blank\" href=\"$site_url\"> |
082ae95b AD |
1490 | <img style='border-width : 0px' src='images/www.png' alt='www'></a>"; |
1491 | } else { | |
1492 | $site_url = ""; | |
1493 | } | |
e15bb6f7 AD |
1494 | |
1495 | $feed_url = "<a target=\"_blank\" href=\"$feed_url\"><img | |
1496 | style='border-width : 0px; vertical-align : middle' | |
1497 | src='images/feed-icon-12x12.png'></a>"; | |
1498 | ||
ef88b1cc AD |
1499 | print "<li title='".$line['site_url']."' class='$class' |
1500 | id=\"FBROW-".$line["id"]."\">". | |
e15bb6f7 AD |
1501 | $check_box . "$feed_icon $feed_url " . $title . |
1502 | $archived . $site_url . "</li>"; | |
b56465dd | 1503 | |
b56465dd | 1504 | |
2bab8824 AD |
1505 | } |
1506 | ||
082ae95b | 1507 | ++$feedctr; |
b56465dd AD |
1508 | } |
1509 | ||
1510 | if ($feedctr == 0) { | |
1511 | print "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>"; | |
1512 | } | |
1513 | ||
1514 | return $feedctr; | |
1515 | ||
1516 | } | |
a5819bb3 | 1517 | |
ef8be8ea | 1518 | ?> |