]> git.wh0rd.org - tt-rss.git/blob - modules/popup-dialog.php
Add callback to Popups, focus subscribe URL input.
[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 == "pubUrl") {
7
8 print "<div id=\"infoBoxTitle\">".__('Published Articles')."</div>";
9 print "<div class=\"infoBoxContents\">";
10
11 $url_path = article_publish_url($link);
12
13 print __("Your Published articles feed URL is:");
14
15 print "<div class=\"tagCloudContainer\">";
16 print "<a id='pub_feed_url' href='$url_path' target='_blank'>$url_path</a>";
17 print "</div>";
18
19 print "<div align='center'>";
20
21 print "<button onclick=\"return pubRegenKey()\">".
22 __('Generate new URL')."</button> ";
23
24 print "<input class=\"button\"
25 type=\"submit\" onclick=\"return closeInfoBox()\"
26 value=\"".__('Close this window')."\">";
27
28 print "</div></div>";
29
30 return;
31 }
32
33 if ($id == "explainError") {
34
35 print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
36 print "<div class=\"infoBoxContents\">";
37
38 print "<div class=\"errorExplained\">";
39
40 if ($param == 1) {
41 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.");
42
43 $stamp = (int)read_stampfile("update_daemon.stamp");
44
45 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
46
47 }
48
49 if ($param == 2) {
50 $msg = check_for_update($link);
51
52 if (!$msg) {
53 print __("You are running the latest version of Tiny Tiny RSS. The fact that you are seeing this dialog is probably a bug.");
54 } else {
55 print $msg;
56 }
57
58 }
59
60 if ($param == 3) {
61 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.");
62
63 $stamp = (int)read_stampfile("update_daemon.stamp");
64
65 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
66
67 }
68
69 print "</div>";
70
71 print "<div align='center'>";
72
73 print "<input class=\"button\"
74 type=\"submit\" onclick=\"return visitOfficialSite()\"
75 value=\"".__('Visit official site')."\"> ";
76
77 print "<input class=\"button\"
78 type=\"submit\" onclick=\"return closeInfoBox()\"
79 value=\"".__('Close this window')."\">";
80
81 print "</div></div>";
82
83 return;
84 }
85
86 if ($id == "quickAddFeed") {
87
88 print "<div id=\"infoBoxTitle\">".__('Subscribe to Feed')."</div>";
89 print "<div class=\"infoBoxContents\">";
90
91 print "<form id='feed_add_form' onsubmit='return false'>";
92
93 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
94 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
95 print "<input type=\"hidden\" name=\"from\" value=\"tt-rss\">";
96
97 print "<div class=\"dlgSec\">".__("Feed")."</div>";
98 print "<div class=\"dlgSecCont\">";
99
100 print __("URL:") . " ";
101
102 print "<input size=\"40\"
103 onkeypress=\"return filterCR(event, subscribeToFeed)\"
104 name=\"feed_url\" id=\"feed_url\"></td></tr>";
105
106 print "<br/>";
107
108 if (get_pref($link, 'ENABLE_FEED_CATS')) {
109 print __('Place in category:') . " ";
110 print_feed_cat_select($link, "cat_id");
111 }
112
113 print "</div>";
114
115 print "<div id='fadd_login_container' style='display:none'>
116
117 <div class=\"dlgSec\">".__("Authentication")."</div>
118 <div class=\"dlgSecCont\">".
119
120 __('Login:') . " <input name='auth_login' size=\"20\"
121 onkeypress=\"return filterCR(event, subscribeToFeed)\"> ".
122 __('Password:') . "<input type='password'
123 name='auth_pass' size=\"20\"
124 onkeypress=\"return filterCR(event, subscribeToFeed)\">
125 </div></div>";
126
127
128 print "<div style=\"clear : both\">
129 <input type=\"checkbox\" id=\"fadd_login_check\"
130 onclick='checkboxToggleElement(this, \"fadd_login_container\")'>
131 <label for=\"fadd_login_check\">".
132 __('This feed requires authentication.')."</div>";
133
134 print "</form>";
135
136 print "<div class=\"dlgButtons\">
137 <button class=\"button\" id=\"fadd_submit_btn\"
138 onclick=\"return subscribeToFeed()\">".__('Subscribe')."</button>
139 <button onclick=\"return browseFeeds()\">".__('More feeds')."</button>
140 <button onclick=\"return closeInfoBox()\">".__('Cancel')."</button></div>";
141
142 return;
143 }
144
145 if ($id == "search") {
146
147 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
148 print "<div class=\"infoBoxContents\">";
149
150 print "<form id='search_form' onsubmit='return false'>";
151
152 #$active_feed_id = db_escape_string($_REQUEST["param"]);
153
154 $params = split(":", db_escape_string($_REQUEST["param"]));
155
156 $active_feed_id = sprintf("%d", $params[0]);
157 $is_cat = $params[1] == "true";
158
159 print "<div class=\"dlgSec\">".__('Look for')."</div>";
160
161 print "<div class=\"dlgSecCont\">";
162
163 print "<input name=\"query\" size=\"20\" type=\"search\" 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 <button onclick=\"javascript:search()\">".__('Search')."</button>
212 <button onclick=\"javascript:searchCancel()\">".__('Cancel')."</button>
213 </div>";
214
215 print "</div>";
216
217 return;
218
219 }
220
221 if ($id == "quickAddFilter") {
222
223 $active_feed_id = db_escape_string($_REQUEST["param"]);
224
225 print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
226 print "<div class=\"infoBoxContents\">";
227
228 print "<form id=\"filter_add_form\" onsubmit='return false'>";
229
230 print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
231 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
232 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
233
234 $result = db_query($link, "SELECT id,description
235 FROM ttrss_filter_types ORDER BY description");
236
237 $filter_types = array();
238
239 while ($line = db_fetch_assoc($result)) {
240 //array_push($filter_types, $line["description"]);
241 $filter_types[$line["id"]] = __($line["description"]);
242 }
243
244 print "<div class=\"dlgSec\">".__("Match")."</div>";
245
246 print "<div class=\"dlgSecCont\">";
247
248 print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
249 print __("Date") . " ";
250
251 $filter_params = array(
252 "before" => __("before"),
253 "after" => __("after"));
254
255 print_select_hash("filter_date_modifier", "before", $filter_params);
256
257 print "&nbsp;</span>";
258
259 print "<input onkeypress=\"return filterCR(event, createFilter)\"
260 name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
261
262 print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
263 print "&nbsp;<input class=\"button\"
264 type=\"submit\" onclick=\"return filterDlgCheckDate()\"
265 value=\"".__('Check it')."\">";
266 print "</span>";
267
268 print "<br/> " . __("on field") . " ";
269 print_select_hash("filter_type", 1, $filter_types,
270 'onchange="filterDlgCheckType(this)"');
271
272 print "<br/>";
273
274 print __("in") . " ";
275 print_feed_select($link, "feed_id", $active_feed_id);
276
277 print "</div>";
278
279 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
280
281 print "<div class=\"dlgSecCont\">";
282
283 print "<select name=\"action_id\"
284 onchange=\"filterDlgCheckAction(this)\">";
285
286 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
287 ORDER BY name");
288
289 while ($line = db_fetch_assoc($result)) {
290 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
291 }
292
293 print "</select>";
294
295 print "<span id=\"filter_dlg_param_box\" style=\"display : none\">";
296 print " " . __("with parameters:") . " ";
297 print "<input size=\"20\"
298 onkeypress=\"return filterCR(event, createFilter)\"
299 name=\"action_param\">";
300
301 print_label_select($link, "action_param_label", $action_param);
302
303 print "</span>";
304
305 print "&nbsp;"; // tiny layout hack
306
307 print "</div>";
308
309 print "<div class=\"dlgSec\">".__("Options")."</div>";
310 print "<div class=\"dlgSecCont\">";
311
312 print "<div style=\"line-height : 100%\">";
313
314 print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
315 <label for=\"enabled\">".__('Enabled')."</label><br/>";
316
317 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
318 <label for=\"inverse\">".__('Inverse match')."</label>";
319
320 print "</div>";
321 print "</div>";
322
323 print "</form>";
324
325 print "<div class=\"dlgButtons\">";
326
327 print "<button onclick=\"return createFilter()\">".
328 __('Create')."</button> ";
329
330 print "<button onclick=\"return closeInfoBox()\">".__('Cancel').
331 "</button>";
332
333 print "</div>";
334
335 // print "</td></tr></table>";
336
337 return;
338 }
339
340 if ($id == "feedUpdateErrors") {
341
342 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
343 print "<div class=\"infoBoxContents\">";
344
345 print __("These feeds have not been updated because of errors:");
346
347 $result = db_query($link, "SELECT id,title,feed_url,last_error
348 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
349
350 print "<ul class='feedErrorsList'>";
351
352 while ($line = db_fetch_assoc($result)) {
353 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " .
354 "<em>" . $line["last_error"] . "</em>";
355 }
356
357 print "</ul>";
358
359 print "<div align='center'>";
360
361 print "<input class=\"button\"
362 type=\"submit\" onclick=\"return closeInfoBox()\"
363 value=\"".__('Close')."\">";
364
365 print "</div>";
366
367 return;
368 }
369
370 if ($id == "editArticleTags") {
371
372 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
373 print "<div class=\"infoBoxContents\">";
374
375 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
376
377 print __("Tags for this article (separated by commas):")."<br>";
378
379 $tags = get_article_tags($link, $param);
380
381 $tags_str = join(", ", $tags);
382
383 print "<table width='100%'>";
384
385 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
386
387 print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str'
388 name='tags_str'>$tags_str</textarea>
389 <div class=\"autocomplete\" id=\"tags_choices\"
390 style=\"display:none\"></div>
391 </td></tr>";
392
393 print "</table>";
394
395 print "</form>";
396
397 print "<div align='right'>";
398
399 print "<button onclick=\"return editTagsSave()\">".__('Save')."</button> ";
400 print "<button onclick=\"return closeInfoBox()\">".__('Cancel')."</button>";
401
402 print "</div>";
403
404 return;
405 }
406
407 if ($id == "printTagCloud") {
408 print "<div id=\"infoBoxTitle\">".__('Tag Cloud')."</div>";
409 print "<div class=\"infoBoxContents\">";
410
411 print __("Showing most popular tags ")." (<a
412 href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
413
414 print "<div class=\"tagCloudContainer\">";
415
416 printTagCloud($link);
417
418 print "</div>";
419
420 print "<div align='center'>";
421 print "<button onclick=\"return closeInfoBox()\">".
422 __('Close this window')."</button>";
423 print "</div>";
424
425 print "</div>";
426
427 return;
428 }
429
430 /* if ($id == "offlineDownload") {
431 print "<div id=\"infoBoxTitle\">".__('Download articles')."</div>";
432 print "<div class=\"infoBoxContents\">";
433
434 print "<form name='download_ops_form' id='download_ops_form'>";
435
436 print "<div class=\"dlgSec\">".__("Download")."</div>";
437
438 print "<div class=\"dlgSecCont\">";
439
440 $amount = array(
441 50 => 50,
442 100 => 100,
443 250 => 250,
444 500 => 500);
445
446 print_select_hash("amount", 50, $amount);
447
448 print " " . __("latest articles for offline reading.");
449
450 print "<br/>";
451
452 print "<input checked='yes' type='checkbox' name='unread_only' id='unread_only'>";
453 print "<label for='unread_only'>".__('Only include unread articles')."</label>";
454
455 print "</div>";
456
457 print "</form>";
458
459 print "<div class=\"dlgButtons\">
460 <input class=\"button\"
461 type=\"submit\" onclick=\"return initiate_offline_download(0, this)\" value=\"".__('Download')."\">
462 <input class=\"button\"
463 type=\"submit\" onclick=\"return closeInfoBox()\"
464 value=\"".__('Cancel')."\"></div>";
465
466 print "</div>";
467
468 return;
469 } */
470
471
472 print "<div id='infoBoxTitle'>Internal Error</div>
473 <div id='infoBoxContents'>
474 <p>Unknown dialog <b>$id</b></p>
475 </div></div>";
476
477 }
478 ?>