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