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