]> git.wh0rd.org - tt-rss.git/blob - modules/popup-dialog.php
createFilter: add label select dropbox
[tt-rss.git] / modules / popup-dialog.php
1 <?php
2 function module_popup_dialog($link) {
3 $id = $_GET["id"];
4 $param = db_escape_string($_GET["param"]);
5
6 if ($id == "explainError") {
7
8 print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
9 print "<div class=\"infoBoxContents\">";
10
11 if ($param == 1) {
12 print __("Update daemon is enabled in configuration, but daemon
13 process is not running, which prevents all feeds from updating. Please
14 start the daemon process or contact instance owner.");
15
16 $stamp = (int)read_stampfile("update_daemon.stamp");
17
18 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
19
20 }
21
22 if ($param == 2) {
23 $msg = check_for_update($link, false);
24
25 if (!$msg) {
26 print __("You are running the latest version of Tiny Tiny RSS. The
27 fact that you are seeing this dialog is probably a bug.");
28 } else {
29 print $msg;
30 }
31
32 }
33
34 if ($param == 3) {
35 print __("TT-RSS has detected that update daemon is taking too long to
36 perform a feed update. This could indicate a problem like crash
37 or a hang. Please check the daemon process or contact instance
38 owner.");
39
40 $stamp = (int)read_stampfile("update_daemon.stamp");
41
42 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
43
44 }
45
46 print "</div>";
47
48 print "<div align='center'>";
49
50 print "<input class=\"button\"
51 type=\"submit\" onclick=\"return closeInfoBox()\"
52 value=\"".__('Close this window')."\">";
53
54 print "</div>";
55
56 return;
57 }
58
59 if ($id == "quickAddFeed") {
60
61 print "<div id=\"infoBoxTitle\">".__('Subscribe to Feed')."</div>";
62 print "<div class=\"infoBoxContents\">";
63
64 print "<form id='feed_add_form' onsubmit='return false'>";
65
66 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
67 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
68 print "<input type=\"hidden\" name=\"from\" value=\"tt-rss\">";
69
70 print "<div class=\"dlgSec\">".__("Feed")."</div>";
71 print "<div class=\"dlgSecCont\">";
72
73 print __("URL:") . " ";
74
75 print "<input size=\"40\" onblur=\"javascript:enableHotkeys()\"
76 onkeypress=\"return filterCR(event, subscribeToFeed)\"
77 onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
78 onchange=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
79 onfocus=\"javascript:disableHotkeys()\" name=\"feed_url\"></td></tr>";
80
81 print "<br/>";
82
83 if (get_pref($link, 'ENABLE_FEED_CATS')) {
84 print __('Place in category:') . " ";
85 print_feed_cat_select($link, "cat_id");
86 }
87
88 print "</div>";
89
90
91 /* print "<tr><td colspan='2'><div class='insensitive'>";
92
93 print __("Some feeds require authentication. If you subscribe to such
94 feed, you will have to enter your login and password in Feed Editor");
95
96 print "</div></td></tr>"; */
97
98 /* print "<div id='fadd_login_prompt'><br/>
99 <a href='javascript:appearBlockElement(\"fadd_login_container\",
100 \"fadd_login_prompt\")'>".__('Click here if this feed requires authentication.')."</a></div>"; */
101
102 print "<div id='fadd_login_container' style='display:none'>
103
104 <div class=\"dlgSec\">".__("Authentication")."</div>
105 <div class=\"dlgSecCont\">".
106
107 __('Login:') . " <input name='auth_login' size=\"20\"
108 onfocus=\"javascript:disableHotkeys()\"
109 onfocus=\"javascript:disableHotkeys()\"
110 onkeypress=\"return filterCR(event, subscribeToFeed)\"> ".
111 __('Password:') . "<input type='password'
112 name='auth_pass' size=\"20\"
113 onfocus=\"javascript:disableHotkeys()\"
114 onfocus=\"javascript:disableHotkeys()\"
115 onkeypress=\"return filterCR(event, subscribeToFeed)\">
116 </div></div>";
117
118
119 print "<div style=\"clear : both\">
120 <input type=\"checkbox\" id=\"fadd_login_check\"
121 onclick='checkboxToggleElement(this, \"fadd_login_container\")'>
122 <label for=\"fadd_login_check\">".
123 __('This feed requires authentication.')."</div>";
124
125 print "</form>";
126
127 print "<div class=\"dlgButtons\">
128 <input class=\"button\"
129 id=\"fadd_submit_btn\" disabled=\"true\"
130 type=\"submit\" onclick=\"return subscribeToFeed()\" value=\"".__('Subscribe')."\">
131 <input class=\"button\"
132 type=\"submit\" onclick=\"return closeInfoBox()\"
133 value=\"".__('Cancel')."\"></div>";
134
135 return;
136 }
137
138 if ($id == "search") {
139
140 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
141 print "<div class=\"infoBoxContents\">";
142
143 print "<form id='search_form' onsubmit='return false'>";
144
145 #$active_feed_id = db_escape_string($_GET["param"]);
146
147 $params = split(":", db_escape_string($_GET["param"]));
148
149 $active_feed_id = sprintf("%d", $params[0]);
150 $is_cat = $params[1] == "true";
151
152 print "<div class=\"dlgSec\">".__('Search')."</div>";
153
154 print "<div class=\"dlgSecCont\">";
155
156 print "<input name=\"query\" size=\"30\" type=\"search\"
157 onkeypress=\"return filterCR(event, search)\"
158 onchange=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
159 onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
160 value=\"\">";
161
162 print " " . __('match on:')." ";
163
164 $search_fields = array(
165 "title" => __("Title"),
166 "content" => __("Content"),
167 "both" => __("Title or content"));
168
169 print_select_hash("match_on", 3, $search_fields);
170
171
172 print "<br/>".__('Limit search to:')." ";
173
174 print "<select name=\"search_mode\">
175 <option value=\"all_feeds\">".__('All feeds')."</option>";
176
177 $feed_title = getFeedTitle($link, $active_feed_id);
178
179 if (!$is_cat) {
180 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
181 } else {
182 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
183 }
184
185 if ($active_feed_id && !$is_cat) {
186 print "<option selected value=\"this_feed\">$feed_title</option>";
187 } else {
188 print "<option disabled>".__('This feed')."</option>";
189 }
190
191 if ($is_cat) {
192 $cat_preselected = "selected";
193 }
194
195 if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
196 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
197 } else {
198 //print "<option disabled>".__('This category')."</option>";
199 }
200
201 print "</select>";
202
203 print "</div>";
204
205 print "</form>";
206
207 print "<div class=\"dlgButtons\">
208 <input type=\"submit\"
209 class=\"button\" onclick=\"javascript:search()\"
210 id=\"search_submit_btn\" disabled=\"true\"
211 value=\"".__('Search')."\">
212 <input class=\"button\"
213 type=\"submit\" onclick=\"javascript:searchCancel()\"
214 value=\"".__('Cancel')."\"></div>";
215
216 print "</div>";
217
218 return;
219
220 }
221
222 /* if ($id == "quickAddLabel") {
223 print "<div id=\"infoBoxTitle\">".__('Create Label')."</div>";
224 print "<div class=\"infoBoxContents\">";
225
226 print "<form id=\"label_edit_form\" onsubmit='return false'>";
227
228 print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
229 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
230
231 print "<div class=\"dlgSec\">".__("Caption")."</div>";
232
233 print "<div class=\"dlgSecCont\">";
234
235 print "<input onkeypress=\"return filterCR(event, addLabel)\"
236 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
237 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
238 name=\"description\" size=\"30\" value=\"$description\">";
239 print "</div>";
240
241 print "<div class=\"dlgSec\">".__("Match SQL")."</div>";
242
243 print "<div class=\"dlgSecCont\">";
244
245 print "<textarea onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
246 rows=\"6\" name=\"sql_exp\" class=\"labelSQL\"
247 cols=\"50\">$sql_exp</textarea>";
248
249 print "<br/>";
250
251 print_label_dlg_common_examples();
252
253
254 print "</div>";
255
256 print "</form>";
257
258 print "<div style=\"display : none\" id=\"label_test_result\"></div>";
259
260 print "<div class=\"dlgButtons\">";
261
262 print "<div style='float : left'>";
263 print "<input type=\"submit\"
264 class=\"button\" onclick=\"return displayHelpInfobox(1)\"
265 value=\"".__('Help')."\"> ";
266 print "</div>";
267
268 print "<input type=\"submit\" onclick=\"labelTest()\" value=\"".__('Test')."\">
269 ";
270
271 print "<input type=\"submit\"
272 id=\"infobox_submit\"
273 disabled=\"true\"
274 class=\"button\" onclick=\"return addLabel()\"
275 value=\"".__('Create')."\"> ";
276
277 print "<input class=\"button\"
278 type=\"submit\" onclick=\"return labelEditCancel()\"
279 value=\"".__('Cancel')."\">";
280
281 return;
282 } */
283
284 if ($id == "quickAddFilter") {
285
286 $active_feed_id = db_escape_string($_GET["param"]);
287
288 print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
289 print "<div class=\"infoBoxContents\">";
290
291 print "<form id=\"filter_add_form\" onsubmit='return false'>";
292
293 print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
294 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
295 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
296
297 // print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>";
298
299 $result = db_query($link, "SELECT id,description
300 FROM ttrss_filter_types ORDER BY description");
301
302 $filter_types = array();
303
304 while ($line = db_fetch_assoc($result)) {
305 //array_push($filter_types, $line["description"]);
306 $filter_types[$line["id"]] = __($line["description"]);
307 }
308
309 /* print "<table width='100%'>";
310
311 print "<tr><td>".__('Match:')."</td>
312 <td><input onkeypress=\"return filterCR(event, createFilter)\"
313 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
314 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
315 name=\"reg_exp\" class=\"iedit\">";
316
317 print "</td></tr><tr><td>".__('On field:')."</td><td>";
318
319 print_select_hash("filter_type", 1, $filter_types, "class=\"_iedit\"");
320
321 print "</td></tr>";
322 print "<tr><td>".__('Feed:')."</td><td colspan='2'>";
323
324 print_feed_select($link, "feed_id", $active_feed_id);
325
326 print "</td></tr>";
327
328 print "<tr><td>".__('Action:')."</td>";
329
330 print "<td colspan='2'><select name=\"action_id\"
331 onchange=\"filterDlgCheckAction(this)\">";
332
333 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
334 ORDER BY name");
335
336 while ($line = db_fetch_assoc($result)) {
337 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
338 }
339
340 print "</select>";
341
342 print "</td></tr>";
343
344 print "<tr><td>".__('Params:')."</td>";
345
346 print "<td><input disabled class='iedit' name='action_param'></td></tr>";
347
348 print "<tr><td valign='top'>".__('Options:')."</td><td>";
349
350 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
351 <label for=\"inverse\">".__('Inverse match')."</label></td></tr>";
352
353 print "</table>";
354
355 print "</form>"; */
356
357 print "<div class=\"dlgSec\">".__("Match")."</div>";
358
359 print "<div class=\"dlgSecCont\">";
360
361 print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
362 print __("Date") . " ";
363
364 $filter_params = array(
365 "before" => __("before"),
366 "after" => __("after"));
367
368 print_select_hash("filter_date_modifier", "before", $filter_params);
369
370 print "&nbsp;</span>";
371
372 print "<input onkeypress=\"return filterCR(event, createFilter)\"
373 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
374 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
375 name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
376
377 print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
378 print "&nbsp;<input class=\"button\"
379 type=\"submit\" onclick=\"return filterDlgCheckDate()\"
380 value=\"".__('Check it')."\">";
381 print "</span>";
382
383 print "<br/> " . __("on field") . " ";
384 print_select_hash("filter_type", 1, $filter_types,
385 'onchange="filterDlgCheckType(this)"');
386
387 print "<br/>";
388
389 print __("in") . " ";
390 print_feed_select($link, "feed_id", $active_feed_id);
391
392 print "</div>";
393
394 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
395
396 print "<div class=\"dlgSecCont\">";
397
398 print "<select name=\"action_id\"
399 onchange=\"filterDlgCheckAction(this)\">";
400
401 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
402 ORDER BY name");
403
404 while ($line = db_fetch_assoc($result)) {
405 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
406 }
407
408 print "</select>";
409
410 print "<span id=\"filter_dlg_param_box\" style=\"display : none\">";
411 print " " . __("with parameters:") . " ";
412 print "<input size=\"20\"
413 onkeypress=\"return filterCR(event, createFilter)\"
414 name=\"action_param\">";
415
416 print_label_select($link, "action_param_label", $action_param);
417
418 print "</span>";
419
420 print "&nbsp;"; // tiny layout hack
421
422 print "</div>";
423
424 print "<div class=\"dlgSec\">".__("Options")."</div>";
425 print "<div class=\"dlgSecCont\">";
426
427 print "<div style=\"line-height : 100%\">";
428
429 print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
430 <label for=\"enabled\">".__('Enabled')."</label><br/>";
431
432 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
433 <label for=\"inverse\">".__('Inverse match')."</label>";
434
435 print "</div>";
436 print "</div>";
437
438 print "</form>";
439
440 print "<div class=\"dlgButtons\">";
441
442 print "<input type=\"submit\"
443 id=\"infobox_submit\"
444 class=\"button\" onclick=\"return createFilter()\"
445 disabled=\"true\" value=\"".__('Create')."\"> ";
446
447 print "<input class=\"button\"
448 type=\"submit\" onclick=\"return closeInfoBox()\"
449 value=\"".__('Cancel')."\">";
450
451 print "</div>";
452
453 // print "</td></tr></table>";
454
455 return;
456 }
457
458 if ($id == "feedUpdateErrors") {
459
460 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
461 print "<div class=\"infoBoxContents\">";
462
463 print __("These feeds have not been updated because of errors:");
464
465 $result = db_query($link, "SELECT id,title,feed_url,last_error
466 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
467
468 print "<ul class='feedErrorsList'>";
469
470 while ($line = db_fetch_assoc($result)) {
471 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " .
472 "<em>" . $line["last_error"] . "</em>";
473 }
474
475 print "</ul>";
476
477 print "<div align='center'>";
478
479 print "<input class=\"button\"
480 type=\"submit\" onclick=\"return closeInfoBox()\"
481 value=\"".__('Close')."\">";
482
483 print "</div>";
484
485 return;
486 }
487
488 if ($id == "editArticleTags") {
489
490 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
491 print "<div class=\"infoBoxContents\">";
492
493 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
494
495 print __("Tags for this article (separated by commas):")."<br>";
496
497 $tags = get_article_tags($link, $param);
498
499 $tags_str = join(", ", $tags);
500
501 print "<table width='100%'>";
502
503 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
504
505 print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str'
506 name='tags_str'>$tags_str</textarea>
507 <div class=\"autocomplete\" id=\"tags_choices\"
508 style=\"display:none\"></div>
509 </td></tr>";
510
511 /* print "<tr><td>".__('Add existing tag:')."</td>";
512
513 $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
514 WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name");
515
516 $found_tags = array();
517
518 array_push($found_tags, '');
519
520 while ($line = db_fetch_assoc($result)) {
521 array_push($found_tags, truncate_string($line["tag_name"], 20));
522 }
523
524 print "<td align='right'>";
525
526 print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
527
528 print "</td>";
529
530 print "</tr>"; */
531
532 print "</table>";
533
534 print "</form>";
535
536 print "<div align='right'>";
537
538 print "<input class=\"button\"
539 type=\"submit\" onclick=\"return editTagsSave()\"
540 value=\"".__('Save')."\"> ";
541
542 print "<input class=\"button\"
543 type=\"submit\" onclick=\"return closeInfoBox()\"
544 value=\"".__('Cancel')."\">";
545
546
547 print "</div>";
548
549 return;
550 }
551
552 if ($id == "printTagCloud") {
553 print "<div id=\"infoBoxTitle\">".__('Tag cloud')."</div>";
554 print "<div class=\"infoBoxContents\">";
555
556 print __("Showing most popular tags ")." (<a
557 href='javascript:toggleTags(true)'>".__('browse more')."</a>):<br/>";
558
559 print "<div class=\"tagCloudContainer\">";
560
561 printTagCloud($link);
562
563 print "</div>";
564
565 print "<div align='center'>";
566 print "<input class=\"button\"
567 type=\"submit\" onclick=\"return closeInfoBox()\"
568 value=\"".__('Close this window')."\">";
569 print "</div>";
570
571 print "</div>";
572
573 return;
574 }
575
576 print "<div id='infoBoxTitle'>Internal Error</div>
577 <div id='infoBoxContents'>
578 <p>Unknown dialog <b>$id</b></p>
579 </div></div>";
580
581 }
582 ?>