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