]> git.wh0rd.org - tt-rss.git/blob - modules/popup-dialog.php
rework feed dialog layouts
[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 "<table width='100%'><tr><td>".__('Search:')."</td><td>";
153
154 print "<input name=\"query\" class=\"iedit\" type=\"search\"
155 onkeypress=\"return filterCR(event, search)\"
156 onchange=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
157 onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
158 value=\"\">
159 </td></tr>";
160
161 print "<tr><td>".__('Where:')."</td><td>";
162
163 print "<select name=\"search_mode\">
164 <option value=\"all_feeds\">".__('All feeds')."</option>";
165
166 $feed_title = getFeedTitle($link, $active_feed_id);
167
168 if (!$is_cat) {
169 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
170 } else {
171 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
172 }
173
174 if ($active_feed_id && !$is_cat) {
175 print "<option selected value=\"this_feed\">$feed_title</option>";
176 } else {
177 print "<option disabled>".__('This feed')."</option>";
178 }
179
180 if ($is_cat) {
181 $cat_preselected = "selected";
182 }
183
184 if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
185 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
186 } else {
187 //print "<option disabled>".__('This category')."</option>";
188 }
189
190 print "</select></td></tr>";
191
192 print "<tr><td>".__('Match on:')."</td><td>";
193
194 $search_fields = array(
195 "title" => __("Title"),
196 "content" => __("Content"),
197 "both" => __("Title or content"));
198
199 print_select_hash("match_on", 3, $search_fields);
200
201 print "</td></tr></table>";
202
203 print "</form>";
204
205 print "<div align=\"right\">
206 <input type=\"submit\"
207 class=\"button\" onclick=\"javascript:search()\"
208 id=\"search_submit_btn\" disabled=\"true\"
209 value=\"".__('Search')."\">
210 <input class=\"button\"
211 type=\"submit\" onclick=\"javascript:searchCancel()\"
212 value=\"".__('Cancel')."\"></div>";
213
214 print "</div>";
215
216 return;
217
218 }
219
220 if ($id == "quickAddLabel") {
221 print "<div id=\"infoBoxTitle\">".__('Create Label')."</div>";
222 print "<div class=\"infoBoxContents\">";
223
224 print "<form id=\"label_edit_form\" onsubmit='return false'>";
225
226 print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
227 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
228
229 print "<div class=\"dlgSec\">".__("Caption")."</div>";
230
231 print "<div class=\"dlgSecCont\">";
232
233 print "<input onkeypress=\"return filterCR(event, labelEditSave)\"
234 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
235 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
236 name=\"description\" size=\"30\" value=\"$description\">";
237 print "</div>";
238
239 print "<div class=\"dlgSec\">".__("Match SQL")."</div>";
240
241 print "<div class=\"dlgSecCont\">";
242
243 print "<textarea onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
244 rows=\"6\" name=\"sql_exp\" class=\"labelSQL\" cols=\"50\">$sql_exp</textarea>";
245
246 print "</div>";
247
248 print "</form>";
249
250 print "<div style=\"display : none\" id=\"label_test_result\"></div>";
251
252 print "<div class=\"dlgButtons\">";
253
254 print "<div style='float : left'>";
255 print "<input type=\"submit\"
256 class=\"button\" onclick=\"return displayHelpInfobox(1)\"
257 value=\"".__('Help')."\"> ";
258 print "</div>";
259
260 print "<input type=\"submit\" onclick=\"labelTest()\" value=\"".__('Test')."\">
261 ";
262
263 print "<input type=\"submit\"
264 id=\"infobox_submit\"
265 disabled=\"true\"
266 class=\"button\" onclick=\"return addLabel()\"
267 value=\"".__('Create')."\"> ";
268
269 print "<input class=\"button\"
270 type=\"submit\" onclick=\"return labelEditCancel()\"
271 value=\"".__('Cancel')."\">";
272
273 return;
274 }
275
276 if ($id == "quickAddFilter") {
277
278 $active_feed_id = db_escape_string($_GET["param"]);
279
280 print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
281 print "<div class=\"infoBoxContents\">";
282
283 print "<form id=\"filter_add_form\" onsubmit='return false'>";
284
285 print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
286 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
287 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
288
289 // print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>";
290
291 $result = db_query($link, "SELECT id,description
292 FROM ttrss_filter_types ORDER BY description");
293
294 $filter_types = array();
295
296 while ($line = db_fetch_assoc($result)) {
297 //array_push($filter_types, $line["description"]);
298 $filter_types[$line["id"]] = __($line["description"]);
299 }
300
301 /* print "<table width='100%'>";
302
303 print "<tr><td>".__('Match:')."</td>
304 <td><input onkeypress=\"return filterCR(event, createFilter)\"
305 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
306 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
307 name=\"reg_exp\" class=\"iedit\">";
308
309 print "</td></tr><tr><td>".__('On field:')."</td><td>";
310
311 print_select_hash("filter_type", 1, $filter_types, "class=\"_iedit\"");
312
313 print "</td></tr>";
314 print "<tr><td>".__('Feed:')."</td><td colspan='2'>";
315
316 print_feed_select($link, "feed_id", $active_feed_id);
317
318 print "</td></tr>";
319
320 print "<tr><td>".__('Action:')."</td>";
321
322 print "<td colspan='2'><select name=\"action_id\"
323 onchange=\"filterDlgCheckAction(this)\">";
324
325 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
326 ORDER BY name");
327
328 while ($line = db_fetch_assoc($result)) {
329 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
330 }
331
332 print "</select>";
333
334 print "</td></tr>";
335
336 print "<tr><td>".__('Params:')."</td>";
337
338 print "<td><input disabled class='iedit' name='action_param'></td></tr>";
339
340 print "<tr><td valign='top'>".__('Options:')."</td><td>";
341
342 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
343 <label for=\"inverse\">".__('Inverse match')."</label></td></tr>";
344
345 print "</table>";
346
347 print "</form>"; */
348
349 print "<div class=\"dlgSec\">".__("Match")."</div>";
350
351 print "<div class=\"dlgSecCont\">";
352
353 print "<input onkeypress=\"return filterCR(event, filterEditSave)\"
354 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
355 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
356 name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
357
358 print " " . __("on field") . " ";
359 print_select_hash("filter_type", 1, $filter_types);
360
361 print "<br/>";
362
363 print __("in") . " ";
364 print_feed_select($link, "feed_id", $active_feed_id);
365
366 print "</div>";
367
368 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
369
370 print "<div class=\"dlgSecCont\">";
371
372 print "<select name=\"action_id\"
373 onchange=\"filterDlgCheckAction(this)\">";
374
375 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
376 ORDER BY name");
377
378 while ($line = db_fetch_assoc($result)) {
379 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
380 }
381
382 print "</select>";
383
384 print " " . __("with params") . " ";
385
386 print "<input disabled size=\"20\"
387 name=\"action_param\">";
388
389 print "</div>";
390
391 print "<div class=\"dlgSec\">".__("Options")."</div>";
392 print "<div class=\"dlgSecCont\">";
393
394 print "<div style=\"line-height : 100%\">";
395
396 print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
397 <label for=\"enabled\">".__('Enabled')."</label><br/>";
398
399 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
400 <label for=\"inverse\">".__('Inverse match')."</label>";
401
402 print "</div>";
403 print "</div>";
404
405 print "</form>";
406
407 print "<div class=\"dlgButtons\">";
408
409 print "<input type=\"submit\"
410 id=\"infobox_submit\"
411 class=\"button\" onclick=\"return createFilter()\"
412 disabled=\"true\" value=\"".__('Create')."\"> ";
413
414 print "<input class=\"button\"
415 type=\"submit\" onclick=\"return closeInfoBox()\"
416 value=\"".__('Cancel')."\">";
417
418 print "</div>";
419
420 // print "</td></tr></table>";
421
422 return;
423 }
424
425 if ($id == "feedUpdateErrors") {
426
427 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
428 print "<div class=\"infoBoxContents\">";
429
430 print __("These feeds have not been updated because of errors:");
431
432 $result = db_query($link, "SELECT id,title,feed_url,last_error
433 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
434
435 print "<ul class='feedErrorsList'>";
436
437 while ($line = db_fetch_assoc($result)) {
438 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " .
439 "<em>" . $line["last_error"] . "</em>";
440 }
441
442 print "</ul>";
443 print "</div>";
444
445 print "<div align='center'>";
446
447 print "<input class=\"button\"
448 type=\"submit\" onclick=\"return closeInfoBox()\"
449 value=\"".__('Close')."\">";
450
451 print "</div>";
452
453 return;
454 }
455
456 if ($id == "editArticleTags") {
457
458 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
459 print "<div class=\"infoBoxContents\">";
460
461 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
462
463 print __("Tags for this article (separated by commas):")."<br>";
464
465 $tags = get_article_tags($link, $param);
466
467 $tags_str = join(", ", $tags);
468
469 print "<table width='100%'>";
470
471 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
472
473 print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str'
474 name='tags_str'>$tags_str</textarea>
475 <div class=\"autocomplete\" id=\"tags_choices\"
476 style=\"display:none\"></div>
477 </td></tr>";
478
479 /* print "<tr><td>".__('Add existing tag:')."</td>";
480
481 $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
482 WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name");
483
484 $found_tags = array();
485
486 array_push($found_tags, '');
487
488 while ($line = db_fetch_assoc($result)) {
489 array_push($found_tags, truncate_string($line["tag_name"], 20));
490 }
491
492 print "<td align='right'>";
493
494 print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
495
496 print "</td>";
497
498 print "</tr>"; */
499
500 print "</table>";
501
502 print "</form>";
503
504 print "<div align='right'>";
505
506 print "<input class=\"button\"
507 type=\"submit\" onclick=\"return editTagsSave()\"
508 value=\"".__('Save')."\"> ";
509
510 print "<input class=\"button\"
511 type=\"submit\" onclick=\"return closeInfoBox()\"
512 value=\"".__('Cancel')."\">";
513
514
515 print "</div>";
516
517 return;
518 }
519
520 if ($id == "printTagCloud") {
521 print "<div id=\"infoBoxTitle\">".__('Tag cloud')."</div>";
522 print "<div class=\"infoBoxContents\">";
523
524 print __("Showing most popular tags ")." (<a
525 href='javascript:toggleTags(true)'>".__('browse more')."</a>):<br/>";
526
527 print "<div class=\"tagCloudContainer\">";
528
529 printTagCloud($link);
530
531 print "</div>";
532
533 print "<div align='center'>";
534 print "<input class=\"button\"
535 type=\"submit\" onclick=\"return closeInfoBox()\"
536 value=\"".__('Close this window')."\">";
537 print "</div>";
538
539 print "</div>";
540
541 return;
542 }
543
544 print "<div id='infoBoxTitle'>Internal Error</div>
545 <div id='infoBoxContents'>
546 <p>Unknown dialog <b>$id</b></p>
547 </div></div>";
548
549 }
550 ?>