]> git.wh0rd.org Git - tt-rss.git/blob - modules/popup-dialog.php
00efdcb74f9b1577fa3397d742c243526bed672f
[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 == "explainError") {
7
8                         print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
9                         print "<div class=\"infoBoxContents\">";
10
11                         print "<div class=\"errorExplained\">";
12
13                         if ($param == 1) {
14                                 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.");
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);
24
25                                 if (!$msg) {
26                                         print __("You are running the latest version of Tiny Tiny RSS. The fact that you are seeing this dialog is probably a bug.");
27                                 } else {
28                                         print $msg;
29                                 }
30
31                         }
32
33                         if ($param == 3) {
34                                 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.");
35
36                                 $stamp = (int)read_stampfile("update_daemon.stamp");
37
38                                 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); 
39
40                         }
41
42                         print "</div>";
43                         
44                         print "<div align='center'>";
45
46                         print "<input class=\"button\"
47                                 type=\"submit\" onclick=\"return visitOfficialSite()\" 
48                                 value=\"".__('Visit official site')."\"> ";
49
50                         print "<input class=\"button\"
51                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
52                                 value=\"".__('Close this window')."\">";
53
54                         print "</div></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 browseFeeds()\" value=\"".__('More feeds')."\">
133
134                                 <input class=\"button\"
135                                         type=\"submit\" onclick=\"return closeInfoBox()\" 
136                                         value=\"".__('Cancel')."\"></div>";
137                         
138                         return;
139                 }
140
141                 if ($id == "search") {
142
143                         print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
144                         print "<div class=\"infoBoxContents\">";
145
146                         print "<form id='search_form'  onsubmit='return false'>";
147
148                         #$active_feed_id = db_escape_string($_REQUEST["param"]);
149
150                         $params = split(":", db_escape_string($_REQUEST["param"]));
151
152                         $active_feed_id = sprintf("%d", $params[0]);
153                         $is_cat = $params[1] == "true";
154
155                         print "<div class=\"dlgSec\">".__('Look for')."</div>";
156
157                         print "<div class=\"dlgSecCont\">";
158
159                         print "<input name=\"query\" size=\"20\" type=\"search\"
160                                 onkeypress=\"return filterCR(event, search)\"
161                                 onchange=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
162                                 onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
163                                 value=\"\">";
164
165                         print " " . __('match on')." ";
166
167                         $search_fields = array(
168                                 "title" => __("Title"),
169                                 "content" => __("Content"),
170                                 "both" => __("Title or content"));
171
172                         print_select_hash("match_on", 3, $search_fields); 
173
174
175                         print "<br/>".__('Limit search to:')." ";
176                         
177                         print "<select name=\"search_mode\">
178                                 <option value=\"all_feeds\">".__('All feeds')."</option>";
179                         
180                         $feed_title = getFeedTitle($link, $active_feed_id);
181
182                         if (!$is_cat) {
183                                 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
184                         } else {
185                                 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
186                         }
187                         
188                         if ($active_feed_id && !$is_cat) {                              
189                                 print "<option selected value=\"this_feed\">$feed_title</option>";
190                         } else {
191                                 print "<option disabled>".__('This feed')."</option>";
192                         }
193
194                         if ($is_cat) {
195                                 $cat_preselected = "selected";
196                         }
197
198                         if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
199                                 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
200                         } else {
201                                 //print "<option disabled>".__('This category')."</option>";
202                         }
203
204                         print "</select>"; 
205
206                         print "</div>";
207
208                         print "</form>";
209
210                         print "<div class=\"dlgButtons\">
211                         <input type=\"submit\" 
212                                 class=\"button\" onclick=\"javascript:search()\" 
213                                 id=\"search_submit_btn\" disabled=\"true\"
214                                 value=\"".__('Search')."\">
215                         <input class=\"button\"
216                                 type=\"submit\" onclick=\"javascript:searchCancel()\" 
217                                 value=\"".__('Cancel')."\"></div>";
218
219                         print "</div>";
220
221                         return;
222
223                 }
224
225                 if ($id == "quickAddFilter") {
226
227                         $active_feed_id = db_escape_string($_REQUEST["param"]);
228
229                         print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
230                         print "<div class=\"infoBoxContents\">";
231
232                         print "<form id=\"filter_add_form\" onsubmit='return false'>";
233
234                         print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
235                         print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
236                         print "<input type=\"hidden\" name=\"subop\" value=\"add\">"; 
237                 
238                         $result = db_query($link, "SELECT id,description 
239                                 FROM ttrss_filter_types ORDER BY description");
240         
241                         $filter_types = array();
242         
243                         while ($line = db_fetch_assoc($result)) {
244                                 //array_push($filter_types, $line["description"]);
245                                 $filter_types[$line["id"]] = __($line["description"]);
246                         }
247
248                         print "<div class=\"dlgSec\">".__("Match")."</div>";
249
250                         print "<div class=\"dlgSecCont\">";
251
252                         print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
253                         print __("Date") . " ";
254
255                         $filter_params = array(
256                                 "before" => __("before"),
257                                 "after" => __("after"));
258
259                         print_select_hash("filter_date_modifier", "before", $filter_params);
260
261                         print "&nbsp;</span>";
262
263                         print "<input onkeypress=\"return filterCR(event, createFilter)\"
264                                          onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
265                                          onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
266                                          name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
267
268                         print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
269                         print "&nbsp;<input class=\"button\"
270                                 type=\"submit\" onclick=\"return filterDlgCheckDate()\" 
271                                 value=\"".__('Check it')."\">";
272                         print "</span>";
273
274                         print "<br/> " . __("on field") . " ";
275                         print_select_hash("filter_type", 1, $filter_types,
276                                 'onchange="filterDlgCheckType(this)"');
277
278                         print "<br/>";
279
280                         print __("in") . " ";
281                         print_feed_select($link, "feed_id", $active_feed_id);
282
283                         print "</div>";
284
285                         print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
286
287                         print "<div class=\"dlgSecCont\">";
288
289                         print "<select name=\"action_id\"
290                                 onchange=\"filterDlgCheckAction(this)\">";
291         
292                         $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions 
293                                 ORDER BY name");
294
295                         while ($line = db_fetch_assoc($result)) {
296                                 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
297                         }
298         
299                         print "</select>";
300
301                         print "<span id=\"filter_dlg_param_box\" style=\"display : none\">";
302                         print " " . __("with parameters:") . " ";
303                         print "<input size=\"20\"
304                                         onkeypress=\"return filterCR(event, createFilter)\"
305                                         name=\"action_param\">";
306
307                         print_label_select($link, "action_param_label", $action_param);
308
309                         print "</span>";
310
311                         print "&nbsp;"; // tiny layout hack
312
313                         print "</div>";
314
315                         print "<div class=\"dlgSec\">".__("Options")."</div>";
316                         print "<div class=\"dlgSecCont\">";
317
318                         print "<div style=\"line-height : 100%\">";
319
320                         print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
321                                         <label for=\"enabled\">".__('Enabled')."</label><br/>";
322
323                         print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
324                                 <label for=\"inverse\">".__('Inverse match')."</label>";
325
326                         print "</div>";
327                         print "</div>";
328
329                         print "</form>";
330
331                         print "<div class=\"dlgButtons\">";
332
333                         print "<input type=\"submit\" 
334                                 id=\"infobox_submit\"
335                                 class=\"button\" onclick=\"return createFilter()\" 
336                                 disabled=\"true\" value=\"".__('Create')."\"> ";
337
338                         print "<input class=\"button\"
339                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
340                                 value=\"".__('Cancel')."\">";
341
342                         print "</div>";
343
344 //                      print "</td></tr></table>"; 
345
346                         return;
347                 }
348
349                 if ($id == "feedUpdateErrors") {
350
351                         print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
352                         print "<div class=\"infoBoxContents\">";
353
354                         print __("These feeds have not been updated because of errors:");
355
356                         $result = db_query($link, "SELECT id,title,feed_url,last_error
357                         FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
358
359                         print "<ul class='feedErrorsList'>";
360
361                         while ($line = db_fetch_assoc($result)) {
362                                 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " . 
363                                         "<em>" . $line["last_error"] . "</em>";
364                         }
365
366                         print "</ul>";
367
368                         print "<div align='center'>";
369
370                         print "<input class=\"button\"
371                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
372                                 value=\"".__('Close')."\">";
373
374                         print "</div>";
375
376                         return;
377                 }
378
379                 if ($id == "editArticleTags") {
380
381                         print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
382                         print "<div class=\"infoBoxContents\">";
383
384                         print "<form id=\"tag_edit_form\" onsubmit='return false'>";
385
386                         print __("Tags for this article (separated by commas):")."<br>";
387
388                         $tags = get_article_tags($link, $param);
389
390                         $tags_str = join(", ", $tags);
391
392                         print "<table width='100%'>";
393
394                         print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
395
396                         print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str' 
397                                 name='tags_str'>$tags_str</textarea>
398                         <div class=\"autocomplete\" id=\"tags_choices\" 
399                                         style=\"display:none\"></div>   
400                         </td></tr>";
401
402 /*                      print "<tr><td>".__('Add existing tag:')."</td>";
403
404                         $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags 
405                                 WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name");
406
407                         $found_tags = array();
408
409                         array_push($found_tags, '');
410
411                         while ($line = db_fetch_assoc($result)) {
412                                 array_push($found_tags, truncate_string($line["tag_name"], 20));
413                         }
414
415                         print "<td align='right'>";
416
417                         print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
418
419                         print "</td>"; 
420
421                         print "</tr>"; */
422
423                         print "</table>";
424
425                         print "</form>";
426
427                         print "<div align='right'>";
428
429                         print "<input class=\"button\"
430                                 type=\"submit\" onclick=\"return editTagsSave()\" 
431                                 value=\"".__('Save')."\"> ";
432
433                         print "<input class=\"button\"
434                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
435                                 value=\"".__('Cancel')."\">";
436
437
438                         print "</div>";
439
440                         return;
441                 }
442
443                 if ($id == "printTagCloud") {
444                         print "<div id=\"infoBoxTitle\">".__('Tag cloud')."</div>";
445                         print "<div class=\"infoBoxContents\">";
446
447                         print __("Showing most popular tags ")." (<a 
448                         href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>"; 
449
450                         print "<div class=\"tagCloudContainer\">";
451
452                         printTagCloud($link);
453
454                         print "</div>";
455
456                         print "<div align='center'>";
457                         print "<input class=\"button\"
458                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
459                                 value=\"".__('Close this window')."\">";
460                         print "</div>";
461
462                         print "</div>";
463
464                         return;
465                 }
466
467 /*              if ($id == "offlineDownload") {
468                         print "<div id=\"infoBoxTitle\">".__('Download articles')."</div>";
469                         print "<div class=\"infoBoxContents\">";
470
471                         print "<form name='download_ops_form' id='download_ops_form'>";
472
473                         print "<div class=\"dlgSec\">".__("Download")."</div>";
474
475                         print "<div class=\"dlgSecCont\">";
476
477                         $amount = array(
478                                 50  => 50,
479                                 100 => 100,
480                                 250 => 250,
481                                 500 => 500);
482
483                         print_select_hash("amount", 50, $amount);
484
485                         print " " . __("latest articles for offline reading.");
486
487                         print "<br/>";
488
489                         print "<input checked='yes' type='checkbox' name='unread_only' id='unread_only'>";
490                         print "<label for='unread_only'>".__('Only include unread articles')."</label>";
491
492                         print "</div>";
493
494                         print "</form>";
495
496                         print "<div class=\"dlgButtons\">
497                                 <input class=\"button\"
498                                         type=\"submit\" onclick=\"return initiate_offline_download(0, this)\" value=\"".__('Download')."\">
499                                 <input class=\"button\"
500                                         type=\"submit\" onclick=\"return closeInfoBox()\" 
501                                         value=\"".__('Cancel')."\"></div>";
502
503                         print "</div>";
504
505                         return;
506                 } */
507
508
509                 print "<div id='infoBoxTitle'>Internal Error</div>
510                         <div id='infoBoxContents'>
511                         <p>Unknown dialog <b>$id</b></p>
512                         </div></div>";
513         
514         }
515 ?>