]> git.wh0rd.org - tt-rss.git/blob - modules/popup-dialog.php
Revert "theme_image: do not display themed image if noone is logged in"
[tt-rss.git] / modules / popup-dialog.php
1 <?php
2 function module_popup_dialog($link) {
3 $id = $_REQUEST["id"];
4 $param = db_escape_string($_REQUEST["param"]);
5
6 if ($id == "importOpml") {
7 print "<div id=\"infoBoxTitle\">".__('OPML Import')."</div>";
8 print "<div class=\"infoBoxContents\">";
9
10 print "<div class=\"prefFeedCatHolder\">";
11
12 $owner_uid = $_SESSION["uid"];
13
14 db_query($link, "BEGIN");
15
16 /* create Imported feeds category just in case */
17
18 $result = db_query($link, "SELECT id FROM
19 ttrss_feed_categories WHERE title = 'Imported feeds' AND
20 owner_uid = '$owner_uid' LIMIT 1");
21
22 if (db_num_rows($result) == 0) {
23 db_query($link, "INSERT INTO ttrss_feed_categories
24 (title,owner_uid)
25 VALUES ('Imported feeds', '$owner_uid')");
26 }
27
28 db_query($link, "COMMIT");
29
30 /* Handle OPML import by DOMXML/DOMDocument */
31
32 if (function_exists('domxml_open_file')) {
33 print "<ul class='nomarks'>";
34 print "<li>".__("Importing using DOMXML.")."</li>";
35 require_once "modules/opml_domxml.php";
36 opml_import_domxml($link, $owner_uid);
37 print "</ul>";
38 } else if (PHP_VERSION >= 5) {
39 print "<ul class='nomarks'>";
40 print "<li>".__("Importing using DOMDocument.")."</li>";
41 require_once "modules/opml_domdoc.php";
42 opml_import_domdoc($link, $owner_uid);
43 print "</ul>";
44 } else {
45 print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
46 }
47
48 print "</div>";
49
50 print "<div align='center'>";
51
52 print "<button onclick=\"return opmlImportDone()\">".
53 __('Close this window')."</button>";
54
55 print "</div>";
56
57 print "<script type=\"text/javascript\">";
58 print "parent.opmlImportHandler(this)";
59 print "</script>";
60
61 print "</div></div>";
62
63 return;
64 }
65
66 if ($id == "editPrefProfiles") {
67
68 print "<div id=\"infoBoxTitle\">".__('Settings Profiles')."</div>";
69 print "<div class=\"infoBoxContents\">";
70
71 print "<div><input id=\"fadd_profile\"
72 onkeypress=\"return filterCR(event, addPrefProfile)\"
73 size=\"40\">
74 <button onclick=\"javascript:addPrefProfile()\">".
75 __('Create profile')."</button></div>";
76
77 print "<p>";
78
79 $result = db_query($link, "SELECT title,id FROM ttrss_settings_profiles
80 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
81
82 print __('Select:')."
83 <a href=\"javascript:selectPrefRows('fcat', true)\">".__('All')."</a>,
84 <a href=\"javascript:selectPrefRows('fcat', false)\">".__('None')."</a>";
85
86 print "<div class=\"prefFeedCatHolder\">";
87
88 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
89
90 print "<table width=\"100%\" class=\"prefFeedCatList\"
91 cellspacing=\"0\" id=\"prefFeedCatList\">";
92
93 print "<tr class=\"odd\" id=\"FCATR-0\">";
94
95 print "<td width='5%' align='center'><input
96 onclick='toggleSelectPrefRow(this, \"fcat\");'
97 type=\"checkbox\" id=\"FCCHK-0\"></td>";
98
99 if (!$_SESSION["profile"]) {
100 $is_active = __("(active)");
101 } else {
102 $is_active = "";
103 }
104
105 print "<td><span id=\"FCATT-0\">" .
106 __("Default profile") . " $is_active</span></td>";
107
108 print "</tr>";
109
110 $lnum = 1;
111
112 while ($line = db_fetch_assoc($result)) {
113
114 $class = ($lnum % 2) ? "even" : "odd";
115
116 $cat_id = $line["id"];
117 $this_row_id = "id=\"FCATR-$cat_id\"";
118
119 print "<tr class=\"$class\" $this_row_id>";
120
121 $edit_title = htmlspecialchars($line["title"]);
122
123 print "<td width='5%' align='center'><input
124 onclick='toggleSelectPrefRow(this, \"fcat\");'
125 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
126
127 if ($_SESSION["profile"] == $line["id"]) {
128 $is_active = __("(active)");
129 } else {
130 $is_active = "";
131 }
132
133 print "<td><span id=\"FCATT-$cat_id\">" .
134 $edit_title . "</span> $is_active</td>";
135
136 print "</tr>";
137
138 ++$lnum;
139 }
140
141 print "</table>";
142 print "</form>";
143 print "</div>";
144
145 print "<div class='dlgButtons'>
146 <div style='float : left'>
147 <button onclick=\"return removeSelectedPrefProfiles()\">".
148 __('Remove')."</button>
149 <button onclick=\"return activatePrefProfile()\">".
150 __('Activate')."</button>
151 </div>";
152
153 print "<button onclick=\"return closeInfoBox()\">".
154 __('Close this window')."</button>";
155
156 print "</div></div>";
157
158 return;
159 }
160
161 if ($id == "pubUrl") {
162
163 print "<div id=\"infoBoxTitle\">".__('Published Articles')."</div>";
164 print "<div class=\"infoBoxContents\">";
165
166 $url_path = article_publish_url($link);
167
168 print __("Your Published articles feed URL is:");
169
170 print "<div class=\"tagCloudContainer\">";
171 print "<a id='pub_feed_url' href='$url_path' target='_blank'>$url_path</a>";
172 print "</div>";
173
174 print "<div align='center'>";
175
176 print "<button onclick=\"return pubRegenKey()\">".
177 __('Generate new URL')."</button> ";
178
179 print "<input class=\"button\"
180 type=\"submit\" onclick=\"return closeInfoBox()\"
181 value=\"".__('Close this window')."\">";
182
183 print "</div></div>";
184
185 return;
186 }
187
188 if ($id == "explainError") {
189
190 print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
191 print "<div class=\"infoBoxContents\">";
192
193 print "<div class=\"errorExplained\">";
194
195 if ($param == 1) {
196 print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner.");
197
198 $stamp = (int)read_stampfile("update_daemon.stamp");
199
200 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
201
202 }
203
204 if ($param == 2) {
205 $msg = check_for_update($link);
206
207 if (!$msg) {
208 print __("You are running the latest version of Tiny Tiny RSS. The fact that you are seeing this dialog is probably a bug.");
209 } else {
210 print $msg;
211 }
212
213 }
214
215 if ($param == 3) {
216 print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner.");
217
218 $stamp = (int)read_stampfile("update_daemon.stamp");
219
220 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
221
222 }
223
224 print "</div>";
225
226 print "<div align='center'>";
227
228 print "<input class=\"button\"
229 type=\"submit\" onclick=\"return visitOfficialSite()\"
230 value=\"".__('Visit official site')."\"> ";
231
232 print "<input class=\"button\"
233 type=\"submit\" onclick=\"return closeInfoBox()\"
234 value=\"".__('Close this window')."\">";
235
236 print "</div></div>";
237
238 return;
239 }
240
241 if ($id == "quickAddFeed") {
242
243 print "<div id=\"infoBoxTitle\">".__('Subscribe to Feed')."</div>";
244 print "<div class=\"infoBoxContents\">";
245
246 print "<form id='feed_add_form' onsubmit='return false'>";
247
248 print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
249 print "<input type=\"hidden\" name=\"subop\" value=\"addfeed\">";
250 //print "<input type=\"hidden\" name=\"from\" value=\"tt-rss\">";
251
252 print "<div class=\"dlgSec\">".__("Feed")."</div>";
253 print "<div class=\"dlgSecCont\">";
254
255 print __("URL:") . " ";
256
257 print "<input size=\"40\"
258 onkeypress=\"return filterCR(event, subscribeToFeed)\"
259 name=\"feed\" id=\"feed_url\"></td></tr>";
260
261 print "<br/>";
262
263 if (get_pref($link, 'ENABLE_FEED_CATS')) {
264 print __('Place in category:') . " ";
265 print_feed_cat_select($link, "cat");
266 }
267
268 print "</div>";
269
270 print "<div id='fadd_login_container' style='display:none'>
271
272 <div class=\"dlgSec\">".__("Authentication")."</div>
273 <div class=\"dlgSecCont\">".
274
275 __('Login:') . " <input name='login' size=\"20\"
276 onkeypress=\"return filterCR(event, subscribeToFeed)\"> ".
277 __('Password:') . "<input type='password'
278 name='pass' size=\"20\"
279 onkeypress=\"return filterCR(event, subscribeToFeed)\">
280 </div></div>";
281
282
283 print "<div style=\"clear : both\">
284 <input type=\"checkbox\" id=\"fadd_login_check\"
285 onclick='checkboxToggleElement(this, \"fadd_login_container\")'>
286 <label for=\"fadd_login_check\">".
287 __('This feed requires authentication.')."</div>";
288
289 print "</form>";
290
291 print "<div class=\"dlgButtons\">
292 <button class=\"button\" id=\"fadd_submit_btn\"
293 onclick=\"return subscribeToFeed()\">".__('Subscribe')."</button>
294 <button onclick=\"return browseFeeds()\">".__('More feeds')."</button>
295 <button onclick=\"return closeInfoBox()\">".__('Cancel')."</button></div>";
296
297 return;
298 }
299
300 if ($id == "feedBrowser") {
301
302 print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
303
304 print "<div class=\"infoBoxContents\">";
305
306 $browser_search = db_escape_string($_REQUEST["search"]);
307
308 print "<form onsubmit='return false;' display='inline'
309 name='feed_browser' id='feed_browser'>";
310
311 print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
312 print "<input type=\"hidden\" name=\"subop\" value=\"updateFeedBrowser\">";
313
314 print "
315 <div style='float : right'>
316 <img style='display : none'
317 id='feed_browser_spinner' src='".
318 theme_image($link, 'images/indicator_white.gif')."'>
319 <input name=\"search\" size=\"20\" type=\"search\"
320 onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
321 <button onclick=\"javascript:updateFeedBrowser()\">".__('Search')."</button>
322 </div>";
323
324 print " <select name=\"mode\" onchange=\"updateFeedBrowser()\">
325 <option value='1'>" . __('Popular feeds') . "</option>
326 <option value='2'>" . __('Feed archive') . "</option>
327 </select> ";
328
329 print __("limit:");
330
331 print " <select name=\"limit\" onchange='updateFeedBrowser()'>";
332
333 foreach (array(25, 50, 100, 200) as $l) {
334 $issel = ($l == $limit) ? "selected" : "";
335 print "<option $issel>$l</option>";
336 }
337
338 print "</select> ";
339
340 print "<p>";
341
342 $owner_uid = $_SESSION["uid"];
343
344 /* print __('Select:')."
345 <a href=\"javascript:selectPrefRows('fbrowse', true)\">".__('All')."</a>,
346 <a href=\"javascript:selectPrefRows('fbrowse', false)\">".__('None')."</a>"; */
347
348 print "<ul class='browseFeedList' id='browseFeedList'>";
349 print_feed_browser($link, $search, 25);
350 print "</ul>";
351
352 print "<div align='center'>
353 <button onclick=\"feedBrowserSubscribe()\">".__('Subscribe')."</button>
354 <button style='display : none' id='feed_archive_remove' onclick=\"feedArchiveRemove()\">".__('Remove')."</button>
355 <button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
356
357 print "</div>";
358 return;
359 }
360
361 if ($id == "search") {
362
363 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
364 print "<div class=\"infoBoxContents\">";
365
366 print "<form id='search_form' onsubmit='return false'>";
367
368 #$active_feed_id = db_escape_string($_REQUEST["param"]);
369
370 $params = split(":", db_escape_string($_REQUEST["param"]));
371
372 $active_feed_id = sprintf("%d", $params[0]);
373 $is_cat = $params[1] == "true";
374
375 print "<div class=\"dlgSec\">".__('Look for')."</div>";
376
377 print "<div class=\"dlgSecCont\">";
378
379 print "<input onkeypress=\"return filterCR(event, search)\"
380 name=\"query\" size=\"20\" type=\"search\" value=''>";
381
382 print " " . __('match on')." ";
383
384 $search_fields = array(
385 "title" => __("Title"),
386 "content" => __("Content"),
387 "both" => __("Title or content"));
388
389 print_select_hash("match_on", 3, $search_fields);
390
391
392 print "<br/>".__('Limit search to:')." ";
393
394 print "<select name=\"search_mode\">
395 <option value=\"all_feeds\">".__('All feeds')."</option>";
396
397 $feed_title = getFeedTitle($link, $active_feed_id);
398
399 if (!$is_cat) {
400 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
401 } else {
402 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
403 }
404
405 if ($active_feed_id && !$is_cat) {
406 print "<option selected value=\"this_feed\">$feed_title</option>";
407 } else {
408 print "<option disabled>".__('This feed')."</option>";
409 }
410
411 if ($is_cat) {
412 $cat_preselected = "selected";
413 }
414
415 if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
416 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
417 } else {
418 //print "<option disabled>".__('This category')."</option>";
419 }
420
421 print "</select>";
422
423 print "</div>";
424
425 print "</form>";
426
427 print "<div class=\"dlgButtons\">
428 <button onclick=\"javascript:search()\">".__('Search')."</button>
429 <button onclick=\"javascript:searchCancel()\">".__('Cancel')."</button>
430 </div>";
431
432 print "</div>";
433
434 return;
435
436 }
437
438 if ($id == "quickAddFilter") {
439
440 $active_feed_id = db_escape_string($_REQUEST["param"]);
441
442 print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
443 print "<div class=\"infoBoxContents\">";
444
445 print "<form id=\"filter_add_form\" onsubmit='return false'>";
446
447 print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
448 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
449 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
450
451 $result = db_query($link, "SELECT id,description
452 FROM ttrss_filter_types ORDER BY description");
453
454 $filter_types = array();
455
456 while ($line = db_fetch_assoc($result)) {
457 //array_push($filter_types, $line["description"]);
458 $filter_types[$line["id"]] = __($line["description"]);
459 }
460
461 print "<div class=\"dlgSec\">".__("Match")."</div>";
462
463 print "<div class=\"dlgSecCont\">";
464
465 print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
466 print __("Date") . " ";
467
468 $filter_params = array(
469 "before" => __("before"),
470 "after" => __("after"));
471
472 print_select_hash("filter_date_modifier", "before", $filter_params);
473
474 print "&nbsp;</span>";
475
476 print "<input onkeypress=\"return filterCR(event, createFilter)\"
477 name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
478
479 print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
480 print "&nbsp;<input class=\"button\"
481 type=\"submit\" onclick=\"return filterDlgCheckDate()\"
482 value=\"".__('Check it')."\">";
483 print "</span>";
484
485 print "<br/> " . __("on field") . " ";
486 print_select_hash("filter_type", 1, $filter_types,
487 'onchange="filterDlgCheckType(this)"');
488
489 print "<br/>";
490
491 print __("in") . " ";
492 print_feed_select($link, "feed_id", $active_feed_id);
493
494 print "</div>";
495
496 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
497
498 print "<div class=\"dlgSecCont\">";
499
500 print "<select name=\"action_id\"
501 onchange=\"filterDlgCheckAction(this)\">";
502
503 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
504 ORDER BY name");
505
506 while ($line = db_fetch_assoc($result)) {
507 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
508 }
509
510 print "</select>";
511
512 print "<span id=\"filter_dlg_param_box\" style=\"display : none\">";
513 print " " . __("with parameters:") . " ";
514 print "<input size=\"20\"
515 onkeypress=\"return filterCR(event, createFilter)\"
516 name=\"action_param\">";
517
518 print_label_select($link, "action_param_label", $action_param);
519
520 print "</span>";
521
522 print "&nbsp;"; // tiny layout hack
523
524 print "</div>";
525
526 print "<div class=\"dlgSec\">".__("Options")."</div>";
527 print "<div class=\"dlgSecCont\">";
528
529 print "<div style=\"line-height : 100%\">";
530
531 print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
532 <label for=\"enabled\">".__('Enabled')."</label><br/>";
533
534 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
535 <label for=\"inverse\">".__('Inverse match')."</label>";
536
537 print "</div>";
538 print "</div>";
539
540 print "</form>";
541
542 print "<div class=\"dlgButtons\">";
543
544 print "<button onclick=\"return createFilter()\">".
545 __('Create')."</button> ";
546
547 print "<button onclick=\"return closeInfoBox()\">".__('Cancel').
548 "</button>";
549
550 print "</div>";
551
552 // print "</td></tr></table>";
553
554 return;
555 }
556
557 if ($id == "feedUpdateErrors") {
558
559 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
560 print "<div class=\"infoBoxContents\">";
561
562 print __("These feeds have not been updated because of errors:");
563
564 $result = db_query($link, "SELECT id,title,feed_url,last_error
565 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
566
567 print "<ul class='feedErrorsList'>";
568
569 while ($line = db_fetch_assoc($result)) {
570 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " .
571 "<em>" . $line["last_error"] . "</em>";
572 }
573
574 print "</ul>";
575
576 print "<div align='center'>";
577
578 print "<button onclick=\"return closeInfoBox()\">".
579 __('Close this window')."</button>";
580
581 print "</div>";
582
583 return;
584 }
585
586 if ($id == "editArticleTags") {
587
588 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
589 print "<div class=\"infoBoxContents\">";
590
591 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
592
593 print __("Tags for this article (separated by commas):")."<br>";
594
595 $tags = get_article_tags($link, $param);
596
597 $tags_str = join(", ", $tags);
598
599 print "<table width='100%'>";
600
601 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
602
603 print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str'
604 name='tags_str'>$tags_str</textarea>
605 <div class=\"autocomplete\" id=\"tags_choices\"
606 style=\"display:none\"></div>
607 </td></tr>";
608
609 print "</table>";
610
611 print "</form>";
612
613 print "<div align='right'>";
614
615 print "<button onclick=\"return editTagsSave()\">".__('Save')."</button> ";
616 print "<button onclick=\"return closeInfoBox()\">".__('Cancel')."</button>";
617
618 print "</div>";
619
620 return;
621 }
622
623 if ($id == "printTagCloud") {
624 print "<div id=\"infoBoxTitle\">".__('Tag Cloud')."</div>";
625 print "<div class=\"infoBoxContents\">";
626
627 print __("Showing most popular tags ")." (<a
628 href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
629
630 print "<div class=\"tagCloudContainer\">";
631
632 printTagCloud($link);
633
634 print "</div>";
635
636 print "<div align='center'>";
637 print "<button onclick=\"return closeInfoBox()\">".
638 __('Close this window')."</button>";
639 print "</div>";
640
641 print "</div>";
642
643 return;
644 }
645
646 /* if ($id == "offlineDownload") {
647 print "<div id=\"infoBoxTitle\">".__('Download articles')."</div>";
648 print "<div class=\"infoBoxContents\">";
649
650 print "<form name='download_ops_form' id='download_ops_form'>";
651
652 print "<div class=\"dlgSec\">".__("Download")."</div>";
653
654 print "<div class=\"dlgSecCont\">";
655
656 $amount = array(
657 50 => 50,
658 100 => 100,
659 250 => 250,
660 500 => 500);
661
662 print_select_hash("amount", 50, $amount);
663
664 print " " . __("latest articles for offline reading.");
665
666 print "<br/>";
667
668 print "<input checked='yes' type='checkbox' name='unread_only' id='unread_only'>";
669 print "<label for='unread_only'>".__('Only include unread articles')."</label>";
670
671 print "</div>";
672
673 print "</form>";
674
675 print "<div class=\"dlgButtons\">
676 <input class=\"button\"
677 type=\"submit\" onclick=\"return initiate_offline_download(0, this)\" value=\"".__('Download')."\">
678 <input class=\"button\"
679 type=\"submit\" onclick=\"return closeInfoBox()\"
680 value=\"".__('Cancel')."\"></div>";
681
682 print "</div>";
683
684 return;
685 } */
686
687
688 print "<div id='infoBoxTitle'>Internal Error</div>
689 <div id='infoBoxContents'>
690 <p>Unknown dialog <b>$id</b></p>
691 </div></div>";
692
693 }
694 ?>