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