]>
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; | |
1037 | case 0: | |
1038 | print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); | |
1039 | break; | |
33d32a3c AD |
1040 | case 4: |
1041 | print_notice("Multiple feed URLs found."); | |
1042 | ||
1043 | $feed_urls = get_feeds_from_html($feed_url); | |
1044 | break; | |
08ac193a | 1045 | case 5: |
1046 | print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url)); | |
1047 | break; | |
a5819bb3 | 1048 | } |
e513a74a | 1049 | |
a5819bb3 | 1050 | if ($p_from != 'tt-rss') { |
e513a74a | 1051 | |
33d32a3c AD |
1052 | if ($feed_urls) { |
1053 | ||
1054 | print "<form action=\"backend.php\">"; | |
1055 | print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">"; | |
1056 | print "<input type=\"hidden\" name=\"quiet\" value=\"1\">"; | |
1057 | print "<input type=\"hidden\" name=\"subop\" value=\"add\">"; | |
8ffd2011 | 1058 | |
33d32a3c AD |
1059 | print "<select name=\"feed_url\">"; |
1060 | ||
1061 | foreach ($feed_urls as $url => $name) { | |
1062 | $url = htmlspecialchars($url); | |
1063 | $name = htmlspecialchars($name); | |
1064 | ||
1065 | print "<option value=\"$url\">$name</option>"; | |
1066 | } | |
1067 | ||
1068 | print "<input type=\"submit\" value=\"".__("Subscribe to selected feed"). | |
1069 | "\">"; | |
1070 | ||
1071 | print "</form>"; | |
1072 | } | |
e513a74a | 1073 | |
33d32a3c AD |
1074 | $tp_uri = get_self_url_prefix() . "/prefs.php"; |
1075 | $tt_uri = get_self_url_prefix(); | |
6906f145 | 1076 | |
08ac193a | 1077 | if ($rc <= 2){ |
1078 | $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE | |
1079 | feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); | |
aa2122d4 | 1080 | |
08ac193a | 1081 | $feed_id = db_fetch_result($result, 0, "id"); |
1082 | } else { | |
1083 | $feed_id = 0; | |
1084 | } | |
a5819bb3 AD |
1085 | print "<p>"; |
1086 | ||
1087 | if ($feed_id) { | |
8ffd2011 | 1088 | print "<form method=\"GET\" style='display: inline' |
a5819bb3 AD |
1089 | action=\"$tp_uri\"> |
1090 | <input type=\"hidden\" name=\"tab\" value=\"feedConfig\"> | |
1091 | <input type=\"hidden\" name=\"subop\" value=\"editFeed\"> | |
1092 | <input type=\"hidden\" name=\"subopparam\" value=\"$feed_id\"> | |
1093 | <input type=\"submit\" value=\"".__("Edit subscription options")."\"> | |
1094 | </form>"; | |
aa2122d4 | 1095 | } |
442d77f1 | 1096 | |
a5819bb3 AD |
1097 | print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\"> |
1098 | <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> | |
1099 | </form></p>"; | |
1100 | ||
1101 | print "</body></html>"; | |
1102 | return; | |
ef8be8ea AD |
1103 | } |
1104 | } | |
1105 | ||
ef8be8ea AD |
1106 | if ($subop == "categorize") { |
1107 | ||
ef8be8ea | 1108 | |
913f374b | 1109 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
ef8be8ea | 1110 | |
913f374b | 1111 | $cat_id = db_escape_string($_REQUEST["cat_id"]); |
ef8be8ea | 1112 | |
913f374b AD |
1113 | if ($cat_id == 0) { |
1114 | $cat_id_qpart = 'NULL'; | |
1115 | } else { | |
1116 | $cat_id_qpart = "'$cat_id'"; | |
1117 | } | |
ef8be8ea | 1118 | |
913f374b | 1119 | db_query($link, "BEGIN"); |
ef8be8ea | 1120 | |
913f374b | 1121 | foreach ($ids as $id) { |
8ffd2011 | 1122 | |
913f374b | 1123 | db_query($link, "UPDATE ttrss_feeds SET cat_id = $cat_id_qpart |
6e63a7c3 | 1124 | WHERE id = '$id' |
913f374b | 1125 | AND owner_uid = " . $_SESSION["uid"]); |
ef8be8ea | 1126 | |
ef8be8ea AD |
1127 | } |
1128 | ||
913f374b AD |
1129 | db_query($link, "COMMIT"); |
1130 | ||
ef8be8ea AD |
1131 | } |
1132 | ||
9c483746 AD |
1133 | if ($subop == "editCats") { |
1134 | ||
9c483746 AD |
1135 | $action = $_REQUEST["action"]; |
1136 | ||
1137 | if ($action == "save") { | |
1138 | ||
11f083e7 | 1139 | $cat_title = db_escape_string(trim($_REQUEST["value"])); |
b4e75b2a | 1140 | $cat_id = db_escape_string($_REQUEST["cid"]); |
11f083e7 | 1141 | |
8f708155 AD |
1142 | db_query($link, "BEGIN"); |
1143 | ||
1144 | $result = db_query($link, "SELECT title FROM ttrss_feed_categories | |
1145 | WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]); | |
1146 | ||
1147 | if (db_num_rows($result) == 1) { | |
1148 | ||
1149 | $old_title = db_fetch_result($result, 0, "title"); | |
8ffd2011 | 1150 | |
8f708155 AD |
1151 | if ($cat_title != "") { |
1152 | $result = db_query($link, "UPDATE ttrss_feed_categories SET | |
8ffd2011 | 1153 | title = '$cat_title' WHERE id = '$cat_id' AND |
8f708155 AD |
1154 | owner_uid = ".$_SESSION["uid"]); |
1155 | ||
1156 | print $cat_title; | |
1157 | } else { | |
1158 | print $old_title; | |
1159 | } | |
1160 | } else { | |
1161 | print $_REQUEST["value"]; | |
1162 | } | |
1163 | ||
1164 | db_query($link, "COMMIT"); | |
11f083e7 AD |
1165 | |
1166 | return; | |
1167 | ||
9c483746 AD |
1168 | } |
1169 | ||
1170 | if ($action == "add") { | |
1171 | ||
913f374b AD |
1172 | $feed_cat = db_escape_string(trim($_REQUEST["cat"])); |
1173 | ||
5c7c7da9 AD |
1174 | if (!add_feed_category($link, $feed_cat)) |
1175 | print_warning(T_sprintf("Category <b>$%s</b> already exists in the database.", $feed_cat)); | |
913f374b | 1176 | |
9c483746 AD |
1177 | } |
1178 | ||
1179 | if ($action == "remove") { | |
8ffd2011 | 1180 | |
b4e75b2a | 1181 | $ids = split(",", db_escape_string($_REQUEST["ids"])); |
8ffd2011 | 1182 | |
7e329f13 AD |
1183 | foreach ($ids as $id) { |
1184 | remove_feed_category($link, $id, $_SESSION["uid"]); | |
9c483746 AD |
1185 | } |
1186 | } | |
1187 | ||
a8328019 | 1188 | print "<div dojoType=\"dijit.Toolbar\"> |
da1f74c9 AD |
1189 | <input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\"> |
1190 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">". | |
1191 | __('Create category')."</button></div>"; | |
8ffd2011 | 1192 | |
9c483746 AD |
1193 | $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories |
1194 | WHERE owner_uid = ".$_SESSION["uid"]." | |
1195 | ORDER BY title"); | |
1196 | ||
a8328019 | 1197 | # print "<p>"; |
9c483746 AD |
1198 | |
1199 | if (db_num_rows($result) != 0) { | |
1200 | ||
9c483746 AD |
1201 | print "<div class=\"prefFeedCatHolder\">"; |
1202 | ||
da1f74c9 | 1203 | # print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">"; |
9c483746 | 1204 | |
8ffd2011 | 1205 | print "<table width=\"100%\" class=\"prefFeedCatList\" |
9c483746 | 1206 | cellspacing=\"0\" id=\"prefFeedCatList\">"; |
8ffd2011 | 1207 | |
9c483746 | 1208 | $lnum = 0; |
8ffd2011 | 1209 | |
9c483746 | 1210 | while ($line = db_fetch_assoc($result)) { |
8ffd2011 | 1211 | |
9c483746 | 1212 | $class = ($lnum % 2) ? "even" : "odd"; |
8ffd2011 | 1213 | |
9c483746 | 1214 | $cat_id = $line["id"]; |
11f083e7 | 1215 | $this_row_id = "id=\"FCATR-$cat_id\""; |
8ffd2011 | 1216 | |
a8328019 | 1217 | print "<tr class=\"\" $this_row_id>"; |
8ffd2011 | 1218 | |
47439031 | 1219 | $edit_title = htmlspecialchars($line["title"]); |
8ffd2011 AD |
1220 | |
1221 | print "<td width='5%' align='center'><input | |
1222 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
22988692 | 1223 | type=\"checkbox\"></td>"; |
8ffd2011 | 1224 | |
44e05f79 | 1225 | print "<td>"; |
44e05f79 | 1226 | |
8ffd2011 AD |
1227 | # print "<span id=\"FCATT-$cat_id\">" . |
1228 | # $edit_title . "</span>"; | |
1229 | ||
1230 | print "<span dojoType=\"dijit.InlineEditBox\" | |
44e05f79 | 1231 | width=\"300px\" autoSave=\"false\" |
8ffd2011 | 1232 | cat-id=\"$cat_id\">" . $edit_title . |
44e05f79 AD |
1233 | "<script type=\"dojo/method\" event=\"onChange\" args=\"item\"> |
1234 | var elem = this; | |
1235 | dojo.xhrPost({ | |
1236 | url: 'backend.php', | |
1237 | content: {op: 'pref-feeds', subop: 'editCats', | |
1238 | action: 'save', | |
1239 | value: this.value, | |
1240 | cid: this.srcNodeRef.getAttribute('cat-id')}, | |
1241 | load: function(response) { | |
1242 | elem.attr('value', response); | |
da1f74c9 | 1243 | updateFeedList(); |
44e05f79 | 1244 | } |
8ffd2011 | 1245 | }); |
44e05f79 AD |
1246 | </script> |
1247 | </span>"; | |
1248 | ||
1249 | print "</td></tr>"; | |
8ffd2011 | 1250 | |
9c483746 AD |
1251 | ++$lnum; |
1252 | } | |
8ffd2011 | 1253 | |
9c483746 AD |
1254 | print "</table>"; |
1255 | ||
da1f74c9 | 1256 | # print "</form>"; |
9c483746 AD |
1257 | |
1258 | print "</div>"; | |
1259 | ||
6f5b1e04 | 1260 | } else { |
31cc42f6 | 1261 | print "<p>".__('No feed categories defined.')."</p>"; |
6f5b1e04 | 1262 | } |
9c483746 | 1263 | |
d60009cd AD |
1264 | print "<div class='dlgButtons'> |
1265 | <div style='float : left'> | |
da1f74c9 AD |
1266 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">". |
1267 | __('Remove selected categories')."</button> | |
d60009cd | 1268 | </div>"; |
9c483746 | 1269 | |
da1f74c9 | 1270 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">". |
d60009cd | 1271 | __('Close this window')."</button></div>"; |
9c483746 AD |
1272 | |
1273 | return; | |
1274 | ||
1275 | } | |
1276 | ||
ef8be8ea AD |
1277 | if ($quiet) return; |
1278 | ||
8df7184c | 1279 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; |
29f11825 | 1280 | print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">"; |
8df7184c | 1281 | |
a3656a41 | 1282 | $result = db_query($link, "SELECT COUNT(id) AS num_errors |
ef8be8ea AD |
1283 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); |
1284 | ||
a3656a41 | 1285 | $num_errors = db_fetch_result($result, 0, "num_errors"); |
ef8be8ea | 1286 | |
a3656a41 | 1287 | if ($num_errors > 0) { |
ef8be8ea | 1288 | |
49c6c279 | 1289 | $error_button = "<button dojoType=\"dijit.form.Button\" |
8ffd2011 | 1290 | onclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . |
49c6c279 AD |
1291 | __("Feeds with errors") . "</button>"; |
1292 | ||
1293 | // print format_notice("<a href=\"javascript:showFeedsWithErrors()\">". | |
1294 | // __('Some feeds have update errors (click for details)')."</a>"); | |
ef8be8ea AD |
1295 | } |
1296 | ||
8ffd2011 AD |
1297 | if (DB_TYPE == "pgsql") { |
1298 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
1299 | } else { | |
1300 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
1301 | } | |
1302 | ||
1303 | $result = db_query($link, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE | |
1304 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
1305 | ttrss_entries.id = ref_id AND | |
1306 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND | |
1307 | ttrss_feeds.owner_uid = ".$_SESSION["uid"]); | |
1308 | ||
1309 | $num_inactive = db_fetch_result($result, 0, "num_inactive"); | |
1310 | ||
1311 | if ($num_inactive > 0) { | |
1312 | $inactive_button = "<button dojoType=\"dijit.form.Button\" | |
1313 | onclick=\"showInactiveFeeds()\">" . | |
1314 | __("Inactive feeds") . "</button>"; | |
1315 | } | |
1316 | ||
b4e75b2a | 1317 | $feed_search = db_escape_string($_REQUEST["search"]); |
ef8be8ea | 1318 | |
b4e75b2a | 1319 | if (array_key_exists("search", $_REQUEST)) { |
ef8be8ea AD |
1320 | $_SESSION["prefs_feed_search"] = $feed_search; |
1321 | } else { | |
1322 | $feed_search = $_SESSION["prefs_feed_search"]; | |
1323 | } | |
1324 | ||
8df7184c AD |
1325 | print "<div dojoType=\"dijit.Toolbar\">"; |
1326 | ||
16270276 AD |
1327 | print "<div style='float : right; padding-right : 4px;'> |
1328 | <input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\" | |
1329 | onchange=\"updateFeedList()\" value=\"$feed_search\"> | |
1330 | <button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">". | |
1331 | __('Search')."</button> | |
1332 | </div>"; | |
1333 | ||
1985a5e0 | 1334 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
d69fa6d6 | 1335 | "<span>" . __('Select')."</span>"; |
1985a5e0 | 1336 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
8ffd2011 | 1337 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\" |
1985a5e0 | 1338 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
8ffd2011 | 1339 | print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\" |
1985a5e0 | 1340 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; |
d69fa6d6 | 1341 | print "</div></div>"; |
1e5548db | 1342 | |
7b8a143f AD |
1343 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
1344 | "<span>" . __('Feeds')."</span>"; | |
1345 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
8ffd2011 | 1346 | print "<div onclick=\"quickAddFeed()\" |
7b8a143f | 1347 | dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>"; |
8ffd2011 | 1348 | print "<div onclick=\"editSelectedFeed()\" |
82aea978 | 1349 | dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>"; |
8ffd2011 | 1350 | print "<div onclick=\"resetFeedOrder()\" |
7b8a143f AD |
1351 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; |
1352 | print "</div></div>"; | |
1e5548db AD |
1353 | |
1354 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
7b8a143f AD |
1355 | print "<div dojoType=\"dijit.form.DropDownButton\">". |
1356 | "<span>" . __('Categories')."</span>"; | |
1357 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
8ffd2011 | 1358 | print "<div onclick=\"editFeedCats()\" |
7b8a143f | 1359 | dojoType=\"dijit.MenuItem\">".__('Edit categories')."</div>"; |
8ffd2011 | 1360 | print "<div onclick=\"resetCatOrder()\" |
7b8a143f AD |
1361 | dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>"; |
1362 | print "</div></div>"; | |
1e5548db | 1363 | |
1e5548db AD |
1364 | } |
1365 | ||
49c6c279 | 1366 | print $error_button; |
8ffd2011 | 1367 | print $inactive_button; |
49c6c279 | 1368 | |
1985a5e0 AD |
1369 | print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">" |
1370 | .__('Unsubscribe')."</button dojoType=\"dijit.form.Button\"> "; | |
1e5548db | 1371 | |
a522a767 | 1372 | if (defined('_ENABLE_FEED_DEBUGGING')) { |
ef8be8ea | 1373 | |
a522a767 AD |
1374 | print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\"> |
1375 | <option value=\"facDefault\" selected>".__('More actions...')."</option>"; | |
8ffd2011 | 1376 | |
a522a767 | 1377 | if (FORCE_ARTICLE_PURGE == 0) { |
8ffd2011 | 1378 | |
a522a767 AD |
1379 | "<option value=\"facPurge\">".__('Manual purge')."</option>"; |
1380 | } | |
8ffd2011 | 1381 | |
a522a767 AD |
1382 | print " |
1383 | <option value=\"facClear\">".__('Clear feed data')."</option> | |
1384 | <option value=\"facRescore\">".__('Rescore articles')."</option>"; | |
8ffd2011 | 1385 | |
a522a767 | 1386 | print "</select>"; |
0b9751cd | 1387 | |
a522a767 | 1388 | } |
0b9751cd | 1389 | |
8df7184c AD |
1390 | print "</div>"; # toolbar |
1391 | ||
1985a5e0 AD |
1392 | print "<div id=\"feedlistLoading\"> |
1393 | <img src='images/indicator_tiny.gif'>". | |
1394 | __("Loading, please wait...")."</div>"; | |
1395 | ||
8ffd2011 | 1396 | print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\" |
7b8a143f | 1397 | url=\"backend.php?op=pref-feeds&subop=getfeedtree\"> |
1985a5e0 AD |
1398 | </div> |
1399 | <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\" | |
1400 | query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\" | |
1401 | childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\"> | |
1402 | </div> | |
8ffd2011 AD |
1403 | <div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\" |
1404 | dndController=\"dijit.tree.dndSource\" | |
7b8a143f | 1405 | betweenThreshold=\"5\" |
1985a5e0 AD |
1406 | model=\"feedModel\" openOnClick=\"false\"> |
1407 | <script type=\"dojo/method\" event=\"onClick\" args=\"item\"> | |
1408 | var id = String(item.id); | |
1409 | var bare_id = id.substr(id.indexOf(':')+1); | |
1410 | ||
7b8a143f | 1411 | if (id.match('FEED:')) { |
8a097fa3 | 1412 | editFeed(bare_id); |
7b8a143f | 1413 | } else if (id.match('CAT:')) { |
8a097fa3 | 1414 | editCat(bare_id, item); |
8ffd2011 | 1415 | } |
1985a5e0 AD |
1416 | </script> |
1417 | <script type=\"dojo/method\" event=\"onLoad\" args=\"item\"> | |
1418 | Element.hide(\"feedlistLoading\"); | |
1419 | </script> | |
1985a5e0 AD |
1420 | </div>"; |
1421 | ||
a740f4b5 | 1422 | print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\"> |
57e24c82 | 1423 | ".__('<b>Hint:</b> you can drag feeds and categories around.')." |
a740f4b5 AD |
1424 | </div>"; |
1425 | ||
8df7184c | 1426 | print "</div>"; # feeds pane |
94a4ba88 | 1427 | |
8df7184c | 1428 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('OPML')."\">"; |
b6a6e262 | 1429 | |
00a35bb6 AD |
1430 | print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings."); |
1431 | ||
254ac705 | 1432 | print "<div class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</div>"; |
c107797c | 1433 | |
00a35bb6 AD |
1434 | print "</p>"; |
1435 | ||
8ffd2011 | 1436 | print "<iframe id=\"upload_iframe\" |
e1218480 | 1437 | name=\"upload_iframe\" onload=\"opmlImportComplete(this)\" |
b6a6e262 AD |
1438 | style=\"width: 400px; height: 100px; display: none;\"></iframe>"; |
1439 | ||
b6a6e262 | 1440 | print "<form style='display : block' target=\"upload_iframe\" |
8ffd2011 | 1441 | enctype=\"multipart/form-data\" method=\"POST\" |
b6a6e262 AD |
1442 | action=\"backend.php\"> |
1443 | <input id=\"opml_file\" name=\"opml_file\" type=\"file\"> | |
1444 | <input type=\"hidden\" name=\"op\" value=\"dlg\"> | |
1445 | <input type=\"hidden\" name=\"id\" value=\"importOpml\"> | |
d2d75353 | 1446 | <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" |
b6a6e262 | 1447 | type=\"submit\">".__('Import')."</button> |
d2d75353 | 1448 | <button dojoType=\"dijit.form.Button\" onclick=\"gotoExportOpml()\">".__('Export OPML')."</button> |
b6a6e262 | 1449 | </form>"; |
94a4ba88 | 1450 | |
c107797c AD |
1451 | print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.'); |
1452 | ||
1453 | 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 | 1454 | |
d2d75353 | 1455 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">". |
c107797c AD |
1456 | __('Display URL')."</button> "; |
1457 | ||
1458 | ||
8df7184c AD |
1459 | print "</div>"; # pane |
1460 | ||
68313e5d | 1461 | if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) { |
8df7184c AD |
1462 | |
1463 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Firefox integration')."\">"; | |
8ffd2011 | 1464 | |
c107797c | 1465 | print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>"; |
cf9dc032 | 1466 | |
68313e5d | 1467 | print "<p>"; |
cf9dc032 | 1468 | |
c107797c | 1469 | print "<button onclick='window.navigator.registerContentHandler(" . |
755a43ee AD |
1470 | "\"application/vnd.mozilla.maybe.feed\", " . |
1471 | "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . | |
8ffd2011 | 1472 | __('Click here to register this site as a feed reader.') . |
cf9dc032 | 1473 | "</button>"; |
755a43ee | 1474 | |
c107797c | 1475 | print "</p>"; |
755a43ee | 1476 | |
8df7184c AD |
1477 | print "</div>"; # pane |
1478 | } | |
46dc1538 | 1479 | |
8df7184c | 1480 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Subscribing using bookmarklet')."\">"; |
8ffd2011 | 1481 | |
46dc1538 AD |
1482 | 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>"; |
1483 | ||
1484 | $bm_subscribe_url = str_replace('%s', '', add_feed_url()); | |
1485 | ||
1486 | $confirm_str = __('Subscribe to %s in Tiny Tiny RSS?'); | |
1487 | ||
1488 | $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}"); | |
1489 | ||
d2d75353 | 1490 | print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Subscribe in Tiny Tiny RSS'). "</a>"; |
46dc1538 | 1491 | |
8df7184c AD |
1492 | print "</div>"; #pane |
1493 | ||
1494 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Published articles and generated feeds')."\">"; | |
e4f4b46f | 1495 | |
e635d56a | 1496 | 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 | 1497 | |
8ffd2011 | 1498 | $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . |
8801fb01 AD |
1499 | "/backend.php?op=rss&id=-2&view-mode=all_articles");; |
1500 | ||
d2d75353 | 1501 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('generatedFeed', '$rss_url')\">". |
cf9dc032 | 1502 | __('Display URL')."</button> "; |
8ffd2011 | 1503 | |
d2d75353 | 1504 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">". |
8d86f15f | 1505 | __('Clear all generated URLs')."</button> "; |
e4f4b46f | 1506 | |
8df7184c | 1507 | print "</div>"; #pane |
57e24c82 | 1508 | |
392b6d04 | 1509 | if (defined('CONSUMER_KEY') && CONSUMER_KEY != '') { |
57e24c82 | 1510 | |
392b6d04 | 1511 | print "<div id=\"pref-feeds-twitter\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Twitter')."\">"; |
8ffd2011 | 1512 | |
392b6d04 AD |
1513 | $result = db_query($link, "SELECT COUNT(*) AS cid FROM ttrss_users |
1514 | WHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND | |
1515 | id = " . $_SESSION['uid']); | |
8ffd2011 | 1516 | |
392b6d04 | 1517 | $is_registered = db_fetch_result($result, 0, "cid") != 0; |
8ffd2011 | 1518 | |
392b6d04 AD |
1519 | if (!$is_registered) { |
1520 | print_notice(__('Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.')); | |
1521 | } else { | |
1522 | print_notice(__('You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.')); | |
1523 | } | |
8ffd2011 | 1524 | |
392b6d04 AD |
1525 | print "<button dojoType=\"dijit.form.Button\" onclick=\"window.location.href = 'twitter.php?op=register'\">". |
1526 | __("Register with Twitter.com")."</button>"; | |
8ffd2011 | 1527 | |
392b6d04 | 1528 | print " "; |
8ffd2011 AD |
1529 | |
1530 | print "<button dojoType=\"dijit.form.Button\" | |
392b6d04 AD |
1531 | onclick=\"return clearTwitterCredentials()\">". |
1532 | __("Clear stored credentials")."</button>"; | |
8ffd2011 | 1533 | |
392b6d04 | 1534 | print "</div>"; # pane |
57e24c82 | 1535 | |
57e24c82 AD |
1536 | } |
1537 | ||
8df7184c AD |
1538 | print "</div>"; #container |
1539 | ||
ef8be8ea | 1540 | } |
b56465dd | 1541 | |
4a16bda3 | 1542 | function make_feed_browser($link, $search, $limit, $mode = 1) { |
b56465dd | 1543 | |
4a16bda3 AD |
1544 | $owner_uid = $_SESSION["uid"]; |
1545 | $rv = ''; | |
c2913898 AD |
1546 | |
1547 | if ($search) { | |
8ffd2011 | 1548 | $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR |
c2913898 AD |
1549 | UPPER(title) LIKE UPPER('%$search%'))"; |
1550 | } else { | |
1551 | $search_qpart = ""; | |
1552 | } | |
1553 | ||
082ae95b | 1554 | if ($mode == 1) { |
414d0d1f | 1555 | /* $result = db_query($link, "SELECT feed_url, subscribers FROM |
082ae95b AD |
1556 | ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf |
1557 | WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url | |
8ffd2011 | 1558 | AND owner_uid = '$owner_uid') $search_qpart |
414d0d1f AD |
1559 | ORDER BY subscribers DESC LIMIT $limit"); */ |
1560 | ||
1c36d3aa AD |
1561 | $result = db_query($link, "SELECT feed_url, site_url, title, SUM(subscribers) AS subscribers FROM |
1562 | (SELECT feed_url, site_url, title, subscribers FROM ttrss_feedbrowser_cache UNION ALL | |
1563 | SELECT feed_url, site_url, title, subscribers FROM ttrss_linked_feeds) AS qqq | |
414d0d1f AD |
1564 | WHERE |
1565 | (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf | |
1566 | WHERE tf.feed_url = qqq.feed_url | |
1567 | AND owner_uid = '$owner_uid') $search_qpart | |
1c36d3aa | 1568 | GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT $limit"); |
414d0d1f | 1569 | |
082ae95b | 1570 | } else if ($mode == 2) { |
ef88b1cc AD |
1571 | $result = db_query($link, "SELECT *, |
1572 | (SELECT COUNT(*) FROM ttrss_user_entries WHERE | |
1573 | orig_feed_id = ttrss_archived_feeds.id) AS articles_archived | |
1574 | FROM | |
1575 | ttrss_archived_feeds | |
8ffd2011 AD |
1576 | WHERE |
1577 | (SELECT COUNT(*) FROM ttrss_feeds | |
082ae95b | 1578 | WHERE ttrss_feeds.feed_url = ttrss_archived_feeds.feed_url AND |
8ffd2011 AD |
1579 | owner_uid = '$owner_uid') = 0 AND |
1580 | owner_uid = '$owner_uid' $search_qpart | |
082ae95b AD |
1581 | ORDER BY id DESC LIMIT $limit"); |
1582 | } | |
b56465dd AD |
1583 | |
1584 | $feedctr = 0; | |
8ffd2011 | 1585 | |
b56465dd | 1586 | while ($line = db_fetch_assoc($result)) { |
b56465dd | 1587 | |
082ae95b | 1588 | if ($mode == 1) { |
b56465dd | 1589 | |
1c36d3aa AD |
1590 | $feed_url = htmlspecialchars($line["feed_url"]); |
1591 | $site_url = htmlspecialchars($line["site_url"]); | |
082ae95b | 1592 | $subscribers = $line["subscribers"]; |
2211a391 | 1593 | |
8ffd2011 | 1594 | $check_box = "<input onclick='toggleSelectListRow2(this)' |
a8328019 | 1595 | dojoType=\"dijit.form.CheckBox\" |
11b9d0be | 1596 | type=\"checkbox\" \">"; |
8ffd2011 | 1597 | |
082ae95b | 1598 | $class = ($feedctr % 2) ? "even" : "odd"; |
8ffd2011 | 1599 | |
1c36d3aa AD |
1600 | $site_url = "<a target=\"_blank\" |
1601 | href=\"$site_url\"> | |
1602 | <span class=\"fb_feedTitle\">". | |
1603 | htmlspecialchars($line["title"])."</span></a>"; | |
2211a391 | 1604 | |
1c36d3aa AD |
1605 | $feed_url = "<a target=\"_blank\" class=\"fb_feedUrl\" |
1606 | href=\"$feed_url\"><img src='images/feed-icon-12x12.png' | |
1607 | style='vertical-align : middle'></a>"; | |
e15bb6f7 | 1608 | |
1c36d3aa AD |
1609 | $rv .= "<li>$check_box $feed_url $site_url". |
1610 | " <span class='subscribers'>($subscribers)</span></li>"; | |
8ffd2011 | 1611 | |
082ae95b | 1612 | } else if ($mode == 2) { |
ef88b1cc | 1613 | $feed_url = htmlspecialchars($line["feed_url"]); |
8ffd2011 | 1614 | $site_url = htmlspecialchars($line["site_url"]); |
ef88b1cc | 1615 | $title = htmlspecialchars($line["title"]); |
69877646 | 1616 | |
11b9d0be AD |
1617 | $check_box = "<input onclick='toggleSelectListRow2(this)' dojoType=\"dijit.form.CheckBox\" |
1618 | type=\"checkbox\">"; | |
8ffd2011 | 1619 | |
082ae95b | 1620 | $class = ($feedctr % 2) ? "even" : "odd"; |
ef88b1cc AD |
1621 | |
1622 | if ($line['articles_archived'] > 0) { | |
1623 | $archived = sprintf(__("%d archived articles"), $line['articles_archived']); | |
1624 | $archived = " <span class='subscribers'>($archived)</span>"; | |
1625 | } else { | |
1626 | $archived = ''; | |
1627 | } | |
1628 | ||
1c36d3aa AD |
1629 | $site_url = "<a target=\"_blank\" |
1630 | href=\"$site_url\"> | |
1631 | <span class=\"fb_feedTitle\">". | |
1632 | htmlspecialchars($line["title"])."</span></a>"; | |
e15bb6f7 | 1633 | |
1c36d3aa AD |
1634 | $feed_url = "<a target=\"_blank\" class=\"fb_feedUrl\" |
1635 | href=\"$feed_url\"><img src='images/feed-icon-12x12.png' | |
1636 | style='vertical-align : middle'></a>"; | |
b56465dd | 1637 | |
b56465dd | 1638 | |
1c36d3aa AD |
1639 | $rv .= "<li id=\"FBROW-".$line["id"]."\">". |
1640 | "$check_box $feed_url $site_url $archived</li>"; | |
2bab8824 AD |
1641 | } |
1642 | ||
082ae95b | 1643 | ++$feedctr; |
b56465dd AD |
1644 | } |
1645 | ||
1646 | if ($feedctr == 0) { | |
4a16bda3 | 1647 | $rv .= "<li style=\"text-align : center\"><p>".__('No feeds found.')."</p></li>"; |
b56465dd AD |
1648 | } |
1649 | ||
4a16bda3 | 1650 | return $rv; |
b56465dd AD |
1651 | |
1652 | } | |
a5819bb3 | 1653 | |
ef8be8ea | 1654 | ?> |