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