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