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