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