]> git.wh0rd.org Git - tt-rss.git/blob - modules/popup-dialog.php
code cleanup; initial button usage
[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\"
76                                         onkeypress=\"return filterCR(event, subscribeToFeed)\"
77                                         name=\"feed_url\"></td></tr>";
78
79                         print "<br/>";
80
81                         if (get_pref($link, 'ENABLE_FEED_CATS')) {
82                                 print __('Place in category:') . " ";
83                                 print_feed_cat_select($link, "cat_id");                 
84                         }
85
86                         print "</div>";
87
88                         print "<div id='fadd_login_container' style='display:none'>
89         
90                                         <div class=\"dlgSec\">".__("Authentication")."</div>
91                                         <div class=\"dlgSecCont\">".
92
93                                         __('Login:') . " <input name='auth_login' size=\"20\" 
94                                                         onkeypress=\"return filterCR(event, subscribeToFeed)\"> ".
95                                         __('Password:') . "<input type='password'
96                                                         name='auth_pass' size=\"20\" 
97                                                         onkeypress=\"return filterCR(event, subscribeToFeed)\">
98                                 </div></div>";
99
100
101                         print "<div style=\"clear : both\">                             
102                                 <input type=\"checkbox\" id=\"fadd_login_check\" 
103                                                 onclick='checkboxToggleElement(this, \"fadd_login_container\")'>
104                                         <label for=\"fadd_login_check\">".
105                                         __('This feed requires authentication.')."</div>";
106
107                         print "</form>";
108
109                         print "<div class=\"dlgButtons\">
110                                 <button class=\"button\" id=\"fadd_submit_btn\"
111                                         onclick=\"return subscribeToFeed()\">".__('Subscribe')."</button>
112                                 <button onclick=\"return browseFeeds()\">".__('More feeds')."</button>
113                                 <button onclick=\"return closeInfoBox()\">".__('Cancel')."</button></div>";
114                         
115                         return;
116                 }
117
118                 if ($id == "search") {
119
120                         print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
121                         print "<div class=\"infoBoxContents\">";
122
123                         print "<form id='search_form'  onsubmit='return false'>";
124
125                         #$active_feed_id = db_escape_string($_REQUEST["param"]);
126
127                         $params = split(":", db_escape_string($_REQUEST["param"]));
128
129                         $active_feed_id = sprintf("%d", $params[0]);
130                         $is_cat = $params[1] == "true";
131
132                         print "<div class=\"dlgSec\">".__('Look for')."</div>";
133
134                         print "<div class=\"dlgSecCont\">";
135
136                         print "<input name=\"query\" size=\"20\" type=\"search\"
137                                 onkeypress=\"return filterCR(event, search)\"
138                                 onchange=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
139                                 onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
140                                 value=\"\">";
141
142                         print " " . __('match on')." ";
143
144                         $search_fields = array(
145                                 "title" => __("Title"),
146                                 "content" => __("Content"),
147                                 "both" => __("Title or content"));
148
149                         print_select_hash("match_on", 3, $search_fields); 
150
151
152                         print "<br/>".__('Limit search to:')." ";
153                         
154                         print "<select name=\"search_mode\">
155                                 <option value=\"all_feeds\">".__('All feeds')."</option>";
156                         
157                         $feed_title = getFeedTitle($link, $active_feed_id);
158
159                         if (!$is_cat) {
160                                 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
161                         } else {
162                                 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
163                         }
164                         
165                         if ($active_feed_id && !$is_cat) {                              
166                                 print "<option selected value=\"this_feed\">$feed_title</option>";
167                         } else {
168                                 print "<option disabled>".__('This feed')."</option>";
169                         }
170
171                         if ($is_cat) {
172                                 $cat_preselected = "selected";
173                         }
174
175                         if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
176                                 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
177                         } else {
178                                 //print "<option disabled>".__('This category')."</option>";
179                         }
180
181                         print "</select>"; 
182
183                         print "</div>";
184
185                         print "</form>";
186
187                         print "<div class=\"dlgButtons\">
188                         <input type=\"submit\" 
189                                 class=\"button\" onclick=\"javascript:search()\" 
190                                 id=\"search_submit_btn\" disabled=\"true\"
191                                 value=\"".__('Search')."\">
192                         <input class=\"button\"
193                                 type=\"submit\" onclick=\"javascript:searchCancel()\" 
194                                 value=\"".__('Cancel')."\"></div>";
195
196                         print "</div>";
197
198                         return;
199
200                 }
201
202                 if ($id == "quickAddFilter") {
203
204                         $active_feed_id = db_escape_string($_REQUEST["param"]);
205
206                         print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
207                         print "<div class=\"infoBoxContents\">";
208
209                         print "<form id=\"filter_add_form\" onsubmit='return false'>";
210
211                         print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
212                         print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
213                         print "<input type=\"hidden\" name=\"subop\" value=\"add\">"; 
214                 
215                         $result = db_query($link, "SELECT id,description 
216                                 FROM ttrss_filter_types ORDER BY description");
217         
218                         $filter_types = array();
219         
220                         while ($line = db_fetch_assoc($result)) {
221                                 //array_push($filter_types, $line["description"]);
222                                 $filter_types[$line["id"]] = __($line["description"]);
223                         }
224
225                         print "<div class=\"dlgSec\">".__("Match")."</div>";
226
227                         print "<div class=\"dlgSecCont\">";
228
229                         print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
230                         print __("Date") . " ";
231
232                         $filter_params = array(
233                                 "before" => __("before"),
234                                 "after" => __("after"));
235
236                         print_select_hash("filter_date_modifier", "before", $filter_params);
237
238                         print "&nbsp;</span>";
239
240                         print "<input onkeypress=\"return filterCR(event, createFilter)\"
241                                          onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
242                                          onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
243                                          name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
244
245                         print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
246                         print "&nbsp;<input class=\"button\"
247                                 type=\"submit\" onclick=\"return filterDlgCheckDate()\" 
248                                 value=\"".__('Check it')."\">";
249                         print "</span>";
250
251                         print "<br/> " . __("on field") . " ";
252                         print_select_hash("filter_type", 1, $filter_types,
253                                 'onchange="filterDlgCheckType(this)"');
254
255                         print "<br/>";
256
257                         print __("in") . " ";
258                         print_feed_select($link, "feed_id", $active_feed_id);
259
260                         print "</div>";
261
262                         print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
263
264                         print "<div class=\"dlgSecCont\">";
265
266                         print "<select name=\"action_id\"
267                                 onchange=\"filterDlgCheckAction(this)\">";
268         
269                         $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions 
270                                 ORDER BY name");
271
272                         while ($line = db_fetch_assoc($result)) {
273                                 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
274                         }
275         
276                         print "</select>";
277
278                         print "<span id=\"filter_dlg_param_box\" style=\"display : none\">";
279                         print " " . __("with parameters:") . " ";
280                         print "<input size=\"20\"
281                                         onkeypress=\"return filterCR(event, createFilter)\"
282                                         name=\"action_param\">";
283
284                         print_label_select($link, "action_param_label", $action_param);
285
286                         print "</span>";
287
288                         print "&nbsp;"; // tiny layout hack
289
290                         print "</div>";
291
292                         print "<div class=\"dlgSec\">".__("Options")."</div>";
293                         print "<div class=\"dlgSecCont\">";
294
295                         print "<div style=\"line-height : 100%\">";
296
297                         print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
298                                         <label for=\"enabled\">".__('Enabled')."</label><br/>";
299
300                         print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
301                                 <label for=\"inverse\">".__('Inverse match')."</label>";
302
303                         print "</div>";
304                         print "</div>";
305
306                         print "</form>";
307
308                         print "<div class=\"dlgButtons\">";
309
310                         print "<input type=\"submit\" 
311                                 id=\"infobox_submit\"
312                                 class=\"button\" onclick=\"return createFilter()\" 
313                                 disabled=\"true\" value=\"".__('Create')."\"> ";
314
315                         print "<input class=\"button\"
316                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
317                                 value=\"".__('Cancel')."\">";
318
319                         print "</div>";
320
321 //                      print "</td></tr></table>"; 
322
323                         return;
324                 }
325
326                 if ($id == "feedUpdateErrors") {
327
328                         print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
329                         print "<div class=\"infoBoxContents\">";
330
331                         print __("These feeds have not been updated because of errors:");
332
333                         $result = db_query($link, "SELECT id,title,feed_url,last_error
334                         FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
335
336                         print "<ul class='feedErrorsList'>";
337
338                         while ($line = db_fetch_assoc($result)) {
339                                 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " . 
340                                         "<em>" . $line["last_error"] . "</em>";
341                         }
342
343                         print "</ul>";
344
345                         print "<div align='center'>";
346
347                         print "<input class=\"button\"
348                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
349                                 value=\"".__('Close')."\">";
350
351                         print "</div>";
352
353                         return;
354                 }
355
356                 if ($id == "editArticleTags") {
357
358                         print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
359                         print "<div class=\"infoBoxContents\">";
360
361                         print "<form id=\"tag_edit_form\" onsubmit='return false'>";
362
363                         print __("Tags for this article (separated by commas):")."<br>";
364
365                         $tags = get_article_tags($link, $param);
366
367                         $tags_str = join(", ", $tags);
368
369                         print "<table width='100%'>";
370
371                         print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
372
373                         print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str' 
374                                 name='tags_str'>$tags_str</textarea>
375                         <div class=\"autocomplete\" id=\"tags_choices\" 
376                                         style=\"display:none\"></div>   
377                         </td></tr>";
378
379 /*                      print "<tr><td>".__('Add existing tag:')."</td>";
380
381                         $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags 
382                                 WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name");
383
384                         $found_tags = array();
385
386                         array_push($found_tags, '');
387
388                         while ($line = db_fetch_assoc($result)) {
389                                 array_push($found_tags, truncate_string($line["tag_name"], 20));
390                         }
391
392                         print "<td align='right'>";
393
394                         print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
395
396                         print "</td>"; 
397
398                         print "</tr>"; */
399
400                         print "</table>";
401
402                         print "</form>";
403
404                         print "<div align='right'>";
405
406                         print "<input class=\"button\"
407                                 type=\"submit\" onclick=\"return editTagsSave()\" 
408                                 value=\"".__('Save')."\"> ";
409
410                         print "<input class=\"button\"
411                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
412                                 value=\"".__('Cancel')."\">";
413
414
415                         print "</div>";
416
417                         return;
418                 }
419
420                 if ($id == "printTagCloud") {
421                         print "<div id=\"infoBoxTitle\">".__('Tag cloud')."</div>";
422                         print "<div class=\"infoBoxContents\">";
423
424                         print __("Showing most popular tags ")." (<a 
425                         href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>"; 
426
427                         print "<div class=\"tagCloudContainer\">";
428
429                         printTagCloud($link);
430
431                         print "</div>";
432
433                         print "<div align='center'>";
434                         print "<input class=\"button\"
435                                 type=\"submit\" onclick=\"return closeInfoBox()\" 
436                                 value=\"".__('Close this window')."\">";
437                         print "</div>";
438
439                         print "</div>";
440
441                         return;
442                 }
443
444 /*              if ($id == "offlineDownload") {
445                         print "<div id=\"infoBoxTitle\">".__('Download articles')."</div>";
446                         print "<div class=\"infoBoxContents\">";
447
448                         print "<form name='download_ops_form' id='download_ops_form'>";
449
450                         print "<div class=\"dlgSec\">".__("Download")."</div>";
451
452                         print "<div class=\"dlgSecCont\">";
453
454                         $amount = array(
455                                 50  => 50,
456                                 100 => 100,
457                                 250 => 250,
458                                 500 => 500);
459
460                         print_select_hash("amount", 50, $amount);
461
462                         print " " . __("latest articles for offline reading.");
463
464                         print "<br/>";
465
466                         print "<input checked='yes' type='checkbox' name='unread_only' id='unread_only'>";
467                         print "<label for='unread_only'>".__('Only include unread articles')."</label>";
468
469                         print "</div>";
470
471                         print "</form>";
472
473                         print "<div class=\"dlgButtons\">
474                                 <input class=\"button\"
475                                         type=\"submit\" onclick=\"return initiate_offline_download(0, this)\" value=\"".__('Download')."\">
476                                 <input class=\"button\"
477                                         type=\"submit\" onclick=\"return closeInfoBox()\" 
478                                         value=\"".__('Cancel')."\"></div>";
479
480                         print "</div>";
481
482                         return;
483                 } */
484
485
486                 print "<div id='infoBoxTitle'>Internal Error</div>
487                         <div id='infoBoxContents'>
488                         <p>Unknown dialog <b>$id</b></p>
489                         </div></div>";
490         
491         }
492 ?>