]> git.wh0rd.org - tt-rss.git/blame - modules/popup-dialog.php
code cleanup; remove unnecessary callbacks; rework subscribtion dialog
[tt-rss.git] / modules / popup-dialog.php
CommitLineData
ef8be8ea
AD
1<?php
2 function module_popup_dialog($link) {
b4e75b2a
AD
3 $id = $_REQUEST["id"];
4 $param = db_escape_string($_REQUEST["param"]);
ef8be8ea 5
cf9dc032
AD
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
ef16ae37
AD
33 if ($id == "explainError") {
34
cc17c205 35 print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
ef16ae37
AD
36 print "<div class=\"infoBoxContents\">";
37
73495fd1
AD
38 print "<div class=\"errorExplained\">";
39
ef16ae37 40 if ($param == 1) {
73495fd1 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.");
f6854e44
AD
42
43 $stamp = (int)read_stampfile("update_daemon.stamp");
44
45 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
46
ef16ae37
AD
47 }
48
d9fa39f1 49 if ($param == 2) {
73495fd1 50 $msg = check_for_update($link);
4d1d0a45
AD
51
52 if (!$msg) {
73495fd1 53 print __("You are running the latest version of Tiny Tiny RSS. The fact that you are seeing this dialog is probably a bug.");
4d1d0a45
AD
54 } else {
55 print $msg;
56 }
d9fa39f1
AD
57
58 }
59
8e00ae9b 60 if ($param == 3) {
73495fd1 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.");
f6854e44
AD
62
63 $stamp = (int)read_stampfile("update_daemon.stamp");
64
65 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
66
8e00ae9b
AD
67 }
68
ef16ae37 69 print "</div>";
73495fd1 70
ef16ae37
AD
71 print "<div align='center'>";
72
73495fd1
AD
73 print "<input class=\"button\"
74 type=\"submit\" onclick=\"return visitOfficialSite()\"
75 value=\"".__('Visit official site')."\"> ";
76
ef16ae37
AD
77 print "<input class=\"button\"
78 type=\"submit\" onclick=\"return closeInfoBox()\"
cc17c205 79 value=\"".__('Close this window')."\">";
ef16ae37 80
73495fd1 81 print "</div></div>";
ef16ae37 82
5e6f933a 83 return;
ef16ae37
AD
84 }
85
ef8be8ea
AD
86 if ($id == "quickAddFeed") {
87
ecace165 88 print "<div id=\"infoBoxTitle\">".__('Subscribe to Feed')."</div>";
ef8be8ea
AD
89 print "<div class=\"infoBoxContents\">";
90
e6312f6c 91 print "<form id='feed_add_form' onsubmit='return false'>";
ef8be8ea 92
a5819bb3
AD
93 print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
94 print "<input type=\"hidden\" name=\"subop\" value=\"addfeed\">";
95 //print "<input type=\"hidden\" name=\"from\" value=\"tt-rss\">";
ef8be8ea 96
ecace165
AD
97 print "<div class=\"dlgSec\">".__("Feed")."</div>";
98 print "<div class=\"dlgSecCont\">";
99
100 print __("URL:") . " ";
101
f88c7814 102 print "<input size=\"40\"
18ab3d7a 103 onkeypress=\"return filterCR(event, subscribeToFeed)\"
a5819bb3 104 name=\"feed\" id=\"feed_url\"></td></tr>";
ecace165
AD
105
106 print "<br/>";
107
ef8be8ea 108 if (get_pref($link, 'ENABLE_FEED_CATS')) {
ecace165 109 print __('Place in category:') . " ";
a5819bb3 110 print_feed_cat_select($link, "cat");
ef8be8ea
AD
111 }
112
ecace165
AD
113 print "</div>";
114
b9073cd9 115 print "<div id='fadd_login_container' style='display:none'>
ecace165
AD
116
117 <div class=\"dlgSec\">".__("Authentication")."</div>
118 <div class=\"dlgSecCont\">".
119
a5819bb3 120 __('Login:') . " <input name='login' size=\"20\"
ecace165
AD
121 onkeypress=\"return filterCR(event, subscribeToFeed)\"> ".
122 __('Password:') . "<input type='password'
a5819bb3 123 name='pass' size=\"20\"
ecace165
AD
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>";
f27de515 133
ef8be8ea
AD
134 print "</form>";
135
ecace165 136 print "<div class=\"dlgButtons\">
f88c7814
AD
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>";
ecace165 141
5e6f933a 142 return;
ef8be8ea
AD
143 }
144
145 if ($id == "search") {
146
cc17c205 147 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
ef8be8ea
AD
148 print "<div class=\"infoBoxContents\">";
149
e6312f6c 150 print "<form id='search_form' onsubmit='return false'>";
ef8be8ea 151
b4e75b2a 152 #$active_feed_id = db_escape_string($_REQUEST["param"]);
ef8be8ea 153
b4e75b2a 154 $params = split(":", db_escape_string($_REQUEST["param"]));
ef8be8ea
AD
155
156 $active_feed_id = sprintf("%d", $params[0]);
157 $is_cat = $params[1] == "true";
158
de85cac2 159 print "<div class=\"dlgSec\">".__('Look for')."</div>";
5bac8c29
AD
160
161 print "<div class=\"dlgSecCont\">";
162
ad491d75 163 print "<input name=\"query\" size=\"20\" type=\"search\" value=''>";
5bac8c29 164
b1710666 165 print " " . __('match on')." ";
5bac8c29
AD
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:')." ";
ef8be8ea
AD
176
177 print "<select name=\"search_mode\">
cc17c205 178 <option value=\"all_feeds\">".__('All feeds')."</option>";
ef8be8ea
AD
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) {
cc17c205 189 print "<option selected value=\"this_feed\">$feed_title</option>";
ef8be8ea 190 } else {
cc17c205 191 print "<option disabled>".__('This feed')."</option>";
ef8be8ea
AD
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)) {
cc17c205 199 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
ef8be8ea 200 } else {
c4b0f96c 201 //print "<option disabled>".__('This category')."</option>";
ef8be8ea
AD
202 }
203
5bac8c29 204 print "</select>";
ef8be8ea 205
5bac8c29 206 print "</div>";
ef8be8ea
AD
207
208 print "</form>";
209
5bac8c29 210 print "<div class=\"dlgButtons\">
d60009cd 211 <button onclick=\"javascript:search()\">".__('Search')."</button>
ad491d75
AD
212 <button onclick=\"javascript:searchCancel()\">".__('Cancel')."</button>
213 </div>";
ef8be8ea
AD
214
215 print "</div>";
216
5e6f933a
AD
217 return;
218
ef8be8ea
AD
219 }
220
ef8be8ea
AD
221 if ($id == "quickAddFilter") {
222
b4e75b2a 223 $active_feed_id = db_escape_string($_REQUEST["param"]);
ef8be8ea 224
ecace165 225 print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
ef8be8ea
AD
226 print "<div class=\"infoBoxContents\">";
227
e6312f6c 228 print "<form id=\"filter_add_form\" onsubmit='return false'>";
ef8be8ea
AD
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\">";
ef8be8ea
AD
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"]);
89cb787e 241 $filter_types[$line["id"]] = __($line["description"]);
ef8be8ea
AD
242 }
243
10fa6615
AD
244 print "<div class=\"dlgSec\">".__("Match")."</div>";
245
246 print "<div class=\"dlgSecCont\">";
247
d0da85c2 248 print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
6e278744 249 print __("Date") . " ";
44d0e774
AD
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>";
d0da85c2 258
8df90057 259 print "<input onkeypress=\"return filterCR(event, createFilter)\"
ad491d75 260 name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
10fa6615 261
6e278744 262 print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
d0da85c2
AD
263 print "&nbsp;<input class=\"button\"
264 type=\"submit\" onclick=\"return filterDlgCheckDate()\"
6e278744 265 value=\"".__('Check it')."\">";
d0da85c2
AD
266 print "</span>";
267
268 print "<br/> " . __("on field") . " ";
269 print_select_hash("filter_type", 1, $filter_types,
270 'onchange="filterDlgCheckType(this)"');
10fa6615
AD
271
272 print "<br/>";
273
274 print __("in") . " ";
275 print_feed_select($link, "feed_id", $active_feed_id);
276
277 print "</div>";
278
ecace165 279 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
10fa6615
AD
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
143a4973
AD
295 print "<span id=\"filter_dlg_param_box\" style=\"display : none\">";
296 print " " . __("with parameters:") . " ";
297 print "<input size=\"20\"
074bf20c 298 onkeypress=\"return filterCR(event, createFilter)\"
143a4973 299 name=\"action_param\">";
6427a306
AD
300
301 print_label_select($link, "action_param_label", $action_param);
302
143a4973 303 print "</span>";
10fa6615 304
143a4973 305 print "&nbsp;"; // tiny layout hack
10fa6615
AD
306
307 print "</div>";
308
309 print "<div class=\"dlgSec\">".__("Options")."</div>";
310 print "<div class=\"dlgSecCont\">";
311
ecace165
AD
312 print "<div style=\"line-height : 100%\">";
313
10fa6615
AD
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>";
ecace165 321 print "</div>";
10fa6615 322
ef8be8ea
AD
323 print "</form>";
324
10fa6615 325 print "<div class=\"dlgButtons\">";
ef8be8ea 326
ad491d75
AD
327 print "<button onclick=\"return createFilter()\">".
328 __('Create')."</button> ";
ef8be8ea 329
ad491d75
AD
330 print "<button onclick=\"return closeInfoBox()\">".__('Cancel').
331 "</button>";
ef8be8ea
AD
332
333 print "</div>";
334
335// print "</td></tr></table>";
336
5e6f933a 337 return;
ef8be8ea
AD
338 }
339
a3656a41
AD
340 if ($id == "feedUpdateErrors") {
341
cc17c205 342 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
a3656a41
AD
343 print "<div class=\"infoBoxContents\">";
344
cc17c205 345 print __("These feeds have not been updated because of errors:");
a3656a41
AD
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
e8dd519b 350 print "<ul class='feedErrorsList'>";
a3656a41
AD
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>";
a3656a41
AD
358
359 print "<div align='center'>";
360
361 print "<input class=\"button\"
362 type=\"submit\" onclick=\"return closeInfoBox()\"
cc17c205 363 value=\"".__('Close')."\">";
a3656a41
AD
364
365 print "</div>";
366
aa330b93 367 return;
a3656a41
AD
368 }
369
0b126ac2
AD
370 if ($id == "editArticleTags") {
371
cc17c205 372 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
0b126ac2
AD
373 print "<div class=\"infoBoxContents\">";
374
e6312f6c 375 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
0b126ac2 376
cc17c205 377 print __("Tags for this article (separated by commas):")."<br>";
0b126ac2
AD
378
379 $tags = get_article_tags($link, $param);
380
381 $tags_str = join(", ", $tags);
382
d62a3b63
AD
383 print "<table width='100%'>";
384
385 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
386
05fcdf52
AD
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>";
d62a3b63 392
d62a3b63 393 print "</table>";
0b126ac2
AD
394
395 print "</form>";
396
397 print "<div align='right'>";
398
2ae69126
AD
399 print "<button onclick=\"return editTagsSave()\">".__('Save')."</button> ";
400 print "<button onclick=\"return closeInfoBox()\">".__('Cancel')."</button>";
0b126ac2
AD
401
402 print "</div>";
403
5e6f933a 404 return;
0b126ac2
AD
405 }
406
0979b696 407 if ($id == "printTagCloud") {
d60009cd 408 print "<div id=\"infoBoxTitle\">".__('Tag Cloud')."</div>";
0979b696
AD
409 print "<div class=\"infoBoxContents\">";
410
dcac082b 411 print __("Showing most popular tags ")." (<a
326469fc 412 href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
0979b696
AD
413
414 print "<div class=\"tagCloudContainer\">";
415
416 printTagCloud($link);
417
418 print "</div>";
419
420 print "<div align='center'>";
d60009cd
AD
421 print "<button onclick=\"return closeInfoBox()\">".
422 __('Close this window')."</button>";
0979b696
AD
423 print "</div>";
424
425 print "</div>";
426
427 return;
428 }
429
51f6f917 430/* if ($id == "offlineDownload") {
87b16a0a
AD
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,
fe8f2f0c
AD
443 250 => 250,
444 500 => 500);
87b16a0a
AD
445
446 print_select_hash("amount", 50, $amount);
447
6a2034f9 448 print " " . __("latest articles for offline reading.");
87b16a0a 449
6a1cd591
AD
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
87b16a0a
AD
455 print "</div>";
456
457 print "</form>";
458
459 print "<div class=\"dlgButtons\">
6a2034f9
AD
460 <input class=\"button\"
461 type=\"submit\" onclick=\"return initiate_offline_download(0, this)\" value=\"".__('Download')."\">
87b16a0a
AD
462 <input class=\"button\"
463 type=\"submit\" onclick=\"return closeInfoBox()\"
464 value=\"".__('Cancel')."\"></div>";
465
466 print "</div>";
467
468 return;
51f6f917 469 } */
87b16a0a
AD
470
471
5e6f933a
AD
472 print "<div id='infoBoxTitle'>Internal Error</div>
473 <div id='infoBoxContents'>
474 <p>Unknown dialog <b>$id</b></p>
475 </div></div>";
476
ef8be8ea
AD
477 }
478?>