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