]> git.wh0rd.org Git - tt-rss.git/blob - classes/pref_filters.php
properly handle invalid regular expressions supplied when testing filters, add some...
[tt-rss.git] / classes / pref_filters.php
1 <?php
2 class Pref_Filters extends Protected_Handler {
3
4         function csrf_ignore($method) {
5                 $csrf_ignored = array("index", "getfiltertree", "edit");
6
7                 return array_search($method, $csrf_ignored) !== false;
8         }
9
10         function filter_test($filter_type, $reg_exp,
11                         $action_id, $action_param, $filter_param, $inverse, $feed_id, $cat_id,
12                         $cat_filter) {
13
14                 $result = db_query($this->link, "SELECT name FROM ttrss_filter_types WHERE
15                         id = " . $filter_type);
16                 $type_name = db_fetch_result($result, 0, "name");
17
18                 $result = db_query($this->link, "SELECT name FROM ttrss_filter_actions WHERE
19                         id = " . $action_id);
20                 $action_name = db_fetch_result($result, 0, "name");
21
22                 $filter["reg_exp"] = $reg_exp;
23                 $filter["action"] = $action_name;
24                 $filter["type"] = $type_name;
25                 $filter["action_param"] = $action_param;
26                 $filter["filter_param"] = $filter_param;
27                 $filter["inverse"] = $inverse;
28
29                 $filters[$type_name] = array($filter);
30
31                 if ($feed_id)
32                         $feed = $feed_id;
33                 else
34                         $feed = -4;
35
36                 $regexp_valid = preg_match('/' . $filter['reg_exp'] . '/',
37                         $filter['reg_exp']) !== FALSE;
38
39                 print __("Articles matching this filter:");
40
41                 print "<div class=\"inactiveFeedHolder\">";
42                 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
43
44                 if ($regexp_valid) {
45
46                         $feed_title = getFeedTitle($this->link, $feed);
47
48                         $qfh_ret = queryFeedHeadlines($this->link, $cat_filter ? $cat_id : $feed,
49                                 30, "", $cat_filter, false, false,
50                                 false, "date_entered DESC", 0, $_SESSION["uid"], $filter);
51
52                         $result = $qfh_ret[0];
53
54                         $articles = array();
55                         $found = 0;
56
57                         while ($line = db_fetch_assoc($result)) {
58
59                                 $entry_timestamp = strtotime($line["updated"]);
60                                 $entry_tags = get_article_tags($this->link, $line["id"], $_SESSION["uid"]);
61
62                                 $content_preview = truncate_string(
63                                         strip_tags($line["content_preview"]), 100, '...');
64
65                                 if ($line["feed_title"])
66                                         $feed_title = $line["feed_title"];
67
68                                 print "<tr>";
69
70                                 print "<td width='5%' align='center'><input
71                                         dojoType=\"dijit.form.CheckBox\" checked=\"1\"
72                                         disabled=\"1\" type=\"checkbox\"></td>";
73                                 print "<td>";
74
75                                 print $line["title"];
76                                 print "&nbsp;(";
77                                 print "<b>" . $feed_title . "</b>";
78                                 print "):&nbsp;";
79                                 print "<span class=\"insensitive\">" . $content_preview . "</span>";
80                                 print " " . mb_substr($line["date_entered"], 0, 16);
81
82                                 print "</td></tr>";
83
84                                 $found++;
85                         }
86
87                         if ($found == 0) {
88                                 print "<tr><td align='center'>" .
89                                         __("No articles matching this filter has been found.") . "</td></tr>";
90                         }
91                 } else {
92                         print "<tr><td align='center' class='error'>" .
93                                 __("Invalid regular expression.") . "</td></tr>";
94
95                 }
96
97                 print "</table>";
98                 print "</div>";
99
100         }
101
102         function getfiltertree() {
103                 $root = array();
104                 $root['id'] = 'root';
105                 $root['name'] = __('Filters');
106                 $root['items'] = array();
107
108                 $result = db_query($this->link, "SELECT
109                                 ttrss_filters.id AS id,reg_exp,
110                                 ttrss_filter_types.name AS filter_type_name,
111                                 ttrss_filter_types.description AS filter_type_descr,
112                                 enabled,
113                                 inverse,
114                                 cat_filter,
115                                 feed_id,
116                                 ttrss_filters.cat_id,
117                                 action_id,
118                                 filter_param,
119                                 filter_type,
120                                 ttrss_filter_actions.description AS action_description,
121                                 ttrss_feeds.title AS feed_title,
122                                 ttrss_feed_categories.title AS cat_title,
123                                 ttrss_filter_actions.name AS action_name,
124                                 ttrss_filters.action_param AS action_param
125                         FROM
126                                 ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN
127                                         ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id) LEFT JOIN
128                                         ttrss_feed_categories ON (ttrss_filters.cat_id = ttrss_feed_categories.id)
129                         WHERE
130                                 filter_type = ttrss_filter_types.id AND
131                                 ttrss_filter_actions.id = action_id AND
132                                 ttrss_filters.owner_uid = ".$_SESSION["uid"]."
133                         ORDER by action_description, reg_exp");
134
135                 $cat = false;
136                 $cur_action_description = "";
137
138                 if (db_num_rows($result) > 0) {
139
140                         while ($line = db_fetch_assoc($result)) {
141                                 if ($cur_action_description != $line['action_description']) {
142
143                                         if ($cat)
144                                                 array_push($root['items'], $cat);
145
146                                         $cat = array();
147                                         $cat['id'] = 'ACTION:' . $line['action_id'];
148                                         $cat['name'] = $line['action_description'];
149                                         $cat['items'] = array();
150
151                                         $cur_action_description = $line['action_description'];
152                                 }
153
154                                 if (array_search($line["action_name"],
155                                         array("score", "tag", "label")) === false) {
156
157                                                 $line["action_param"] = '';
158                                 } else {
159                                         if ($line['action_name'] == 'label') {
160
161                                                 $tmp_result = db_query($this->link, "SELECT fg_color, bg_color
162                                                         FROM ttrss_labels2 WHERE caption = '".
163                                                                 db_escape_string($line["action_param"])."' AND
164                                                                 owner_uid = " . $_SESSION["uid"]);
165
166                                                 if (db_num_rows($tmp_result) != 0) {
167                                                         $fg_color = db_fetch_result($tmp_result, 0, "fg_color");
168                                                         $bg_color = db_fetch_result($tmp_result, 0, "bg_color");
169
170                                                         $tmp = "<span class=\"labelColorIndicator\" style='color : $fg_color; background-color : $bg_color'>&alpha;</span> " . $line['action_param'];
171
172                                                         $line['action_param'] = $tmp;
173                                                 }
174                                         }
175                                 }
176
177                                 $filter = array();
178                                 $filter['id'] = 'FILTER:' . $line['id'];
179                                 $filter['bare_id'] = $line['id'];
180                                 $filter['name'] = $line['reg_exp'];
181                                 $filter['type'] = $line['filter_type'];
182                                 $filter['enabled'] = sql_bool_to_bool($line['enabled']);
183                                 $filter['param'] = $line['action_param'];
184                                 $filter['inverse'] = sql_bool_to_bool($line['inverse']);
185                                 $filter['checkbox'] = false;
186
187                                 if (sql_bool_to_bool($line['cat_filter']))
188                                         if ($line['cat_id'] != 0) {
189                                                 $filter['feed'] = $line['cat_title'];
190                                         } else {
191                                                 $filter['feed'] = __('Uncategorized');
192                                         }
193                                 else if ($line['feed_id'])
194                                         $filter['feed'] = $line['feed_title'];
195
196                                 array_push($cat['items'], $filter);
197                         }
198
199                         array_push($root['items'], $cat);
200                 }
201
202                 $fl = array();
203                 $fl['identifier'] = 'id';
204                 $fl['label'] = 'name';
205                 $fl['items'] = array($root);
206
207                 print json_encode($fl);
208                 return;
209         }
210
211         function edit() {
212
213                 $filter_id = db_escape_string($_REQUEST["id"]);
214
215                 $result = db_query($this->link,
216                         "SELECT * FROM ttrss_filters WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
217
218                 $reg_exp = htmlspecialchars(db_fetch_result($result, 0, "reg_exp"));
219                 $filter_type = db_fetch_result($result, 0, "filter_type");
220                 $feed_id = db_fetch_result($result, 0, "feed_id");
221                 $cat_id = db_fetch_result($result, 0, "cat_id");
222                 $action_id = db_fetch_result($result, 0, "action_id");
223                 $action_param = db_fetch_result($result, 0, "action_param");
224                 $filter_param = db_fetch_result($result, 0, "filter_param");
225
226                 $enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled"));
227                 $inverse = sql_bool_to_bool(db_fetch_result($result, 0, "inverse"));
228                 $cat_filter = sql_bool_to_bool(db_fetch_result($result, 0, "cat_filter"));
229
230                 print "<form id=\"filter_edit_form\" onsubmit='return false'>";
231
232                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
233                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$filter_id\">";
234                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
235                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
236
237                 $result = db_query($this->link, "SELECT id,description
238                         FROM ttrss_filter_types ORDER BY description");
239
240                 $filter_types = array();
241
242                 while ($line = db_fetch_assoc($result)) {
243                         //array_push($filter_types, $line["description"]);
244                         $filter_types[$line["id"]] = __($line["description"]);
245                 }
246
247                 print "<div class=\"dlgSec\">".__("Match")."</div>";
248
249                 print "<div class=\"dlgSecCont\">";
250
251                 if ($filter_type != 5) {
252                         $date_ops_invisible = 'style="display : none"';
253                 }
254
255                 print "<span id=\"filterDlg_dateModBox\" $date_ops_invisible>";
256                 print __("Date") . " ";
257
258                 $filter_params = array(
259                         "before" => __("before"),
260                         "after" => __("after"));
261
262                 print_select_hash("filter_date_modifier", $filter_param,
263                         $filter_params, 'dojoType="dijit.form.Select"');
264
265                 print "&nbsp;</span>";
266
267                 print "<input dojoType=\"dijit.form.ValidationTextBox\"
268                                  required=\"1\"
269                                  name=\"reg_exp\" style=\"font-size : 16px;\" value=\"$reg_exp\">";
270
271                 print "<span id=\"filterDlg_dateChkBox\" $date_ops_invisible>";
272                 print "&nbsp;<button dojoType=\"dijit.form.Button\" onclick=\"return filterDlgCheckDate()\">".
273                         __('Check it')."</button>";
274                 print "</span>";
275
276                 print "<hr/> " . __("on field") . " ";
277                 print_select_hash("filter_type", $filter_type, $filter_types,
278                         'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
279
280                 print "<hr/>";
281
282                 print __("in") . " ";
283
284                 $hidden = $cat_filter ? "style='display:none'" : "";
285
286                 print "<span id='filterDlg_feeds' $hidden>";
287                 print_feed_select($this->link, "feed_id", $feed_id,
288                         'dojoType="dijit.form.FilteringSelect"');
289                 print "</span>";
290
291                 $hidden = $cat_filter ? "" : "style='display:none'";
292
293                 print "<span id='filterDlg_cats' $hidden>";
294                 print_feed_cat_select($this->link, "cat_id", $cat_id,
295                         'dojoType="dijit.form.FilteringSelect"');
296                 print "</span>";
297
298
299                 print "</div>";
300
301                 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
302
303                 print "<div class=\"dlgSecCont\">";
304
305                 print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
306                         onchange=\"filterDlgCheckAction(this)\">";
307
308                 $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions
309                         ORDER BY name");
310
311                 while ($line = db_fetch_assoc($result)) {
312                         $is_sel = ($line["id"] == $action_id) ? "selected=\"1\"" : "";
313                         printf("<option value='%d' $is_sel>%s</option>", $line["id"], __($line["description"]));
314                 }
315
316                 print "</select>";
317
318                 $param_hidden = ($action_id == 4 || $action_id == 6 || $action_id == 7) ? "" : "display : none";
319
320                 print "<span id=\"filterDlg_paramBox\" style=\"$param_hidden\">";
321                 print " " . __("with parameters:") . " ";
322
323                 $param_int_hidden = ($action_id != 7) ? "" : "display : none";
324
325                 print "<input style=\"$param_int_hidden\"
326                                 dojoType=\"dijit.form.TextBox\" id=\"filterDlg_actionParam\"
327                                 name=\"action_param\" value=\"$action_param\">";
328
329                 $param_int_hidden = ($action_id == 7) ? "" : "display : none";
330
331                 print_label_select($this->link, "action_param_label", $action_param,
332                  "style=\"$param_int_hidden\"" .
333                  'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
334
335                 print "</span>";
336
337                 print "&nbsp;"; // tiny layout hack
338
339                 print "</div>";
340
341                 print "<div class=\"dlgSec\">".__("Options")."</div>";
342                 print "<div class=\"dlgSecCont\">";
343
344                 print "<div style=\"line-height : 100%\">";
345
346                 if ($enabled) {
347                         $checked = "checked=\"1\"";
348                 } else {
349                         $checked = "";
350                 }
351
352                 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked>
353                                 <label for=\"enabled\">".__('Enabled')."</label><hr/>";
354
355                 if ($inverse) {
356                         $checked = "checked=\"1\"";
357                 } else {
358                         $checked = "";
359                 }
360
361                 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
362                         <label for=\"inverse\">".__('Inverse match')."</label><hr/>";
363
364                 if ($cat_filter) {
365                         $checked = "checked=\"1\"";
366                 } else {
367                         $checked = "";
368                 }
369
370                 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\" $checked>
371                                 <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
372
373                 print "</div>";
374                 print "</div>";
375
376                 print "<div class=\"dlgButtons\">";
377
378                 print "<div style=\"float : left\">";
379                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').removeFilter()\">".
380                         __('Remove')."</button>";
381                 print "</div>";
382
383                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
384                         __('Test')."</button> ";
385
386                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
387                         __('Save')."</button> ";
388
389                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
390                         __('Cancel')."</button>";
391
392                 print "</div>";
393         }
394
395         function editSave() {
396
397                 global $memcache;
398
399                 if ($memcache) $memcache->flush();
400
401                 $savemode = db_escape_string($_REQUEST["savemode"]);
402                 $reg_exp = db_escape_string(trim($_REQUEST["reg_exp"]));
403                 $filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
404                 $filter_id = db_escape_string($_REQUEST["id"]);
405                 $feed_id = db_escape_string($_REQUEST["feed_id"]);
406                 $action_id = db_escape_string($_REQUEST["action_id"]);
407                 $action_param = db_escape_string($_REQUEST["action_param"]);
408                 $action_param_label = db_escape_string($_REQUEST["action_param_label"]);
409                 $enabled = checkbox_to_sql_bool(db_escape_string($_REQUEST["enabled"]));
410                 $inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
411                 $cat_filter = checkbox_to_sql_bool(db_escape_string($_REQUEST["cat_filter"]));
412                 $cat_id = db_escape_string($_REQUEST['cat_id']);
413
414                 # for the time being, no other filters use params anyway...
415                 $filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
416
417                 if (!$feed_id) {
418                         $feed_id = 'NULL';
419                 } else {
420                         $feed_id = sprintf("'%s'", db_escape_string($feed_id));
421                 }
422
423                 if (!$cat_id) {
424                         $cat_id = 'NULL';
425                 } else {
426                         $cat_id = sprintf("'%d'", db_escape_string($cat_id));
427                 }
428
429                 /* When processing 'assign label' filters, action_param_label dropbox
430                  * overrides action_param */
431
432                 if ($action_id == 7) {
433                         $action_param = $action_param_label;
434                 }
435
436                 if ($action_id == 6) {
437                         $action_param = (int) str_replace("+", "", $action_param);
438                 }
439
440                 if ($savemode != "test") {
441                         $result = db_query($this->link, "UPDATE ttrss_filters SET
442                                 reg_exp = '$reg_exp',
443                                 feed_id = $feed_id,
444                                 cat_id = $cat_id,
445                                 action_id = '$action_id',
446                                 filter_type = '$filter_type',
447                                 enabled = $enabled,
448                                 inverse = $inverse,
449                                 cat_filter = $cat_filter,
450                                 action_param = '$action_param',
451                                 filter_param = '$filter_param'
452                                 WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
453                 } else {
454
455                         $this->filter_test($filter_type, $reg_exp,
456                                 $action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
457                                 (int) $_REQUEST["feed_id"], (int) $_REQUEST['cat_id'],
458                                 sql_bool_to_bool($cat_filter));
459
460                         print "<div align='center'>";
461                         print "<button dojoType=\"dijit.form.Button\"
462                                 onclick=\"return dijit.byId('filterTestDlg').hide()\">".
463                                 __('Close this window')."</button>";
464                         print "</div>";
465
466                 }
467         }
468
469         function remove() {
470
471                 if ($memcache) $memcache->flush();
472
473                 $ids = split(",", db_escape_string($_REQUEST["ids"]));
474
475                 foreach ($ids as $id) {
476                         db_query($this->link, "DELETE FROM ttrss_filters WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
477                 }
478         }
479
480         function add() {
481
482                 if ($memcache) $memcache->flush();
483
484                 $savemode = db_escape_string($_REQUEST["savemode"]);
485                 $regexp = db_escape_string(trim($_REQUEST["reg_exp"]));
486                 $filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
487                 $feed_id = db_escape_string($_REQUEST["feed_id"]);
488                 $cat_id = db_escape_string($_REQUEST["cat_id"]);
489                 $action_id = db_escape_string($_REQUEST["action_id"]);
490                 $action_param = db_escape_string($_REQUEST["action_param"]);
491                 $action_param_label = db_escape_string($_REQUEST["action_param_label"]);
492                 $inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
493                 $cat_filter = checkbox_to_sql_bool(db_escape_string($_REQUEST["cat_filter"]));
494
495                 # for the time being, no other filters use params anyway...
496                 $filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
497
498                 if (!$regexp) return;
499
500                 if (!$feed_id) {
501                         $feed_id = 'NULL';
502                 } else {
503                         $feed_id = sprintf("'%s'", db_escape_string($feed_id));
504                 }
505
506                 if (!$cat_id) {
507                         $cat_id = 'NULL';
508                 } else {
509                         $cat_id = sprintf("'%d'", db_escape_string($cat_id));
510                 }
511
512                 /* When processing 'assign label' filters, action_param_label dropbox
513                  * overrides action_param */
514
515                 if ($action_id == 7) {
516                         $action_param = $action_param_label;
517                 }
518
519                 if ($action_id == 6) {
520                         $action_param = (int) str_replace("+", "", $action_param);
521                 }
522
523                 if ($savemode != "test") {
524                         $result = db_query($this->link,
525                                 "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,
526                                         action_id, action_param, inverse, filter_param, cat_id, cat_filter)
527                                 VALUES
528                                         ('$regexp', '$filter_type','".$_SESSION["uid"]."',
529                                         $feed_id, '$action_id', '$action_param', $inverse,
530                                         '$filter_param', $cat_id, '$cat_filter')");
531
532                         if (db_affected_rows($this->link, $result) != 0) {
533                                 print T_sprintf("Created filter <b>%s</b>", htmlspecialchars($regexp));
534                         }
535
536                 } else {
537
538                         $this->filter_test($filter_type, $regexp,
539                                 $action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
540                                 (int) $_REQUEST["feed_id"], (int) $_REQUEST['cat_id'],
541                                 sql_bool_to_bool($cat_filter));
542
543                         print "<div align='center'>";
544                         print "<button dojoType=\"dijit.form.Button\"
545                                 onclick=\"return dijit.byId('filterTestDlg').hide()\">".
546                                 __('Close this window')."</button>";
547                         print "</div>";
548
549                 }
550         }
551
552         function index() {
553
554                 $sort = db_escape_string($_REQUEST["sort"]);
555
556                 if (!$sort || $sort == "undefined") {
557                         $sort = "reg_exp";
558                 }
559
560                 $result = db_query($this->link, "SELECT id,description
561                         FROM ttrss_filter_types ORDER BY description");
562
563                 $filter_types = array();
564
565                 while ($line = db_fetch_assoc($result)) {
566                         //array_push($filter_types, $line["description"]);
567                         $filter_types[$line["id"]] = $line["description"];
568                 }
569
570
571                 $filter_search = db_escape_string($_REQUEST["search"]);
572
573                 if (array_key_exists("search", $_REQUEST)) {
574                         $_SESSION["prefs_filter_search"] = $filter_search;
575                 } else {
576                         $filter_search = $_SESSION["prefs_filter_search"];
577                 }
578
579                 print "<div id=\"pref-filter-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
580                 print "<div id=\"pref-filter-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
581                 print "<div id=\"pref-filter-toolbar\" dojoType=\"dijit.Toolbar\">";
582
583                 print "<div dojoType=\"dijit.form.DropDownButton\">".
584                                 "<span>" . __('Select')."</span>";
585                 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
586                 print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\"
587                         dojoType=\"dijit.MenuItem\">".__('All')."</div>";
588                 print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\"
589                         dojoType=\"dijit.MenuItem\">".__('None')."</div>";
590                 print "</div></div>";
591
592                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return quickAddFilter()\">".
593                         __('Create filter')."</button> ";
594
595                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return editSelectedFilter()\">".
596                         __('Edit')."</button> ";
597
598                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">".
599                         __('Remove')."</button> ";
600
601                 if (defined('_ENABLE_FEED_DEBUGGING')) {
602                         print "<button dojoType=\"dijit.form.Button\" onclick=\"rescore_all_feeds()\">".
603                                 __('Rescore articles')."</button> ";
604                 }
605
606                 print "</div>"; # toolbar
607                 print "</div>"; # toolbar-frame
608                 print "<div id=\"pref-filter-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
609
610                 print "<div id=\"filterlistLoading\">
611                 <img src='images/indicator_tiny.gif'>".
612                  __("Loading, please wait...")."</div>";
613
614                 print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"filterStore\"
615                         url=\"backend.php?op=pref-filters&method=getfiltertree\">
616                 </div>
617                 <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\"
618                 query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\"
619                         childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">
620                 </div>
621                 <div dojoType=\"fox.PrefFilterTree\" id=\"filterTree\"
622                         model=\"filterModel\" openOnClick=\"true\">
623                 <script type=\"dojo/method\" event=\"onLoad\" args=\"item\">
624                         Element.hide(\"filterlistLoading\");
625                 </script>
626                 <script type=\"dojo/method\" event=\"onClick\" args=\"item\">
627                         var id = String(item.id);
628                         var bare_id = id.substr(id.indexOf(':')+1);
629
630                         if (id.match('FILTER:')) {
631                                 editFilter(bare_id);
632                         }
633                 </script>
634
635                 </div>";
636
637                 print "</div>"; #pane
638                 print "</div>"; #container
639
640         }
641 }
642 ?>