]> git.wh0rd.org - tt-rss.git/blame - modules/popup-dialog.php
tweak quickAddFeed dialog
[tt-rss.git] / modules / popup-dialog.php
CommitLineData
ef8be8ea
AD
1<?php
2 function module_popup_dialog($link) {
3 $id = $_GET["id"];
0b126ac2 4 $param = db_escape_string($_GET["param"]);
ef8be8ea 5
ef16ae37
AD
6 if ($id == "explainError") {
7
cc17c205 8 print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
ef16ae37
AD
9 print "<div class=\"infoBoxContents\">";
10
11 if ($param == 1) {
cc17c205 12 print __("Update daemon is enabled in configuration, but daemon
ef16ae37
AD
13 process is not running, which prevents all feeds from updating. Please
14 start the daemon process or contact instance owner.");
15 }
16
d9fa39f1 17 if ($param == 2) {
4d1d0a45
AD
18 $msg = check_for_update($link, false);
19
20 if (!$msg) {
cc17c205 21 print __("You are running the latest version of Tiny Tiny RSS. The
4d1d0a45
AD
22 fact that you are seeing this dialog is probably a bug.");
23 } else {
24 print $msg;
25 }
d9fa39f1
AD
26
27 }
28
8e00ae9b
AD
29 if ($param == 3) {
30 print __("TT-RSS has detected that update daemon is taking too long to
31 perform a feed update. This could indicate a problem like crash
32 or a hang. Please check the daemon process or contact instance
33 owner.");
34 }
35
ef16ae37
AD
36 print "</div>";
37
38 print "<div align='center'>";
39
40 print "<input class=\"button\"
41 type=\"submit\" onclick=\"return closeInfoBox()\"
cc17c205 42 value=\"".__('Close this window')."\">";
ef16ae37
AD
43
44 print "</div>";
45
5e6f933a 46 return;
ef16ae37
AD
47 }
48
ef8be8ea
AD
49 if ($id == "quickAddFeed") {
50
cc17c205 51 print "<div id=\"infoBoxTitle\">".__('Subscribe to feed')."</div>";
ef8be8ea
AD
52 print "<div class=\"infoBoxContents\">";
53
e6312f6c 54 print "<form id='feed_add_form' onsubmit='return false'>";
ef8be8ea
AD
55
56 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
365f95dc 57 /* print "<input type=\"hidden\" name=\"quiet\" value=\"1\">"; */
ef8be8ea 58 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
442d77f1 59 print "<input type=\"hidden\" name=\"from\" value=\"tt-rss\">";
ef8be8ea
AD
60
61 print "<table width='100%'>
89cb787e 62 <tr><td>".__('Feed URL:')."</td><td>
ef8be8ea 63 <input class=\"iedit\" onblur=\"javascript:enableHotkeys()\"
5e6f933a 64 onkeypress=\"return filterCR(event, qaddFeed)\"
ef8be8ea 65 onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
b5015f72 66 onchange=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
ef8be8ea
AD
67 onfocus=\"javascript:disableHotkeys()\" name=\"feed_url\"></td></tr>";
68
69 if (get_pref($link, 'ENABLE_FEED_CATS')) {
cc17c205 70 print "<tr><td>".__('Category:')."</td><td>";
ef8be8ea
AD
71 print_feed_cat_select($link, "cat_id");
72 print "</td></tr>";
73 }
74
21f4756a
AD
75/* print "<tr><td colspan='2'><div class='insensitive'>";
76
77 print __("Some feeds require authentication. If you subscribe to such
78 feed, you will have to enter your login and password in Feed Editor");
79
80 print "</div></td></tr>"; */
81
ef8be8ea 82 print "</table>";
f27de515 83
b9073cd9
AD
84/* print "<div id='fadd_login_prompt'><br/>
85 <a href='javascript:appearBlockElement(\"fadd_login_container\",
86 \"fadd_login_prompt\")'>".__('Click here if this feed requires authentication.')."</a></div>"; */
f27de515 87
b9073cd9 88 print "<div id='fadd_login_container' style='display:none'>
f27de515 89 <table width='100%'>
89cb787e
AD
90 <tr><td>".__('Login:')."</td><td><input name='auth_login' class='iedit'></td></tr>
91 <tr><td>".__('Password:')."</td><td><input type='password'
f27de515
AD
92 name='auth_pass' class='iedit'></td></tr>
93 </table>
94 </div>";
95
ef8be8ea
AD
96 print "</form>";
97
b9073cd9 98 print "<div style='float : right'>
ef8be8ea
AD
99 <input class=\"button\"
100 id=\"fadd_submit_btn\" disabled=\"true\"
5e6f933a 101 type=\"submit\" onclick=\"return qaddFeed()\" value=\"".__('Subscribe')."\">
ef8be8ea
AD
102 <input class=\"button\"
103 type=\"submit\" onclick=\"return closeInfoBox()\"
b9073cd9
AD
104 value=\"".__('Cancel')."\"></div>
105
106 <div>
107 <input type=\"checkbox\" id=\"fadd_login_check\"
108 onclick='checkboxToggleElement(this, \"fadd_login_container\")'>
109 <label for=\"fadd_login_check\">".
110 __('This feed requires authentication.')."</div>";
5e6f933a
AD
111
112 return;
ef8be8ea
AD
113 }
114
115 if ($id == "search") {
116
cc17c205 117 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
ef8be8ea
AD
118 print "<div class=\"infoBoxContents\">";
119
e6312f6c 120 print "<form id='search_form' onsubmit='return false'>";
ef8be8ea
AD
121
122 #$active_feed_id = db_escape_string($_GET["param"]);
123
124 $params = split(":", db_escape_string($_GET["param"]));
125
126 $active_feed_id = sprintf("%d", $params[0]);
127 $is_cat = $params[1] == "true";
128
cc17c205 129 print "<table width='100%'><tr><td>".__('Search:')."</td><td>";
ef8be8ea
AD
130
131 print "<input name=\"query\" class=\"iedit\"
132 onkeypress=\"return filterCR(event, search)\"
b5015f72 133 onchange=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
ef8be8ea
AD
134 onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
135 value=\"\">
136 </td></tr>";
137
cc17c205 138 print "<tr><td>".__('Where:')."</td><td>";
ef8be8ea
AD
139
140 print "<select name=\"search_mode\">
cc17c205 141 <option value=\"all_feeds\">".__('All feeds')."</option>";
ef8be8ea
AD
142
143 $feed_title = getFeedTitle($link, $active_feed_id);
144
145 if (!$is_cat) {
146 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
147 } else {
148 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
149 }
150
151 if ($active_feed_id && !$is_cat) {
cc17c205 152 print "<option selected value=\"this_feed\">$feed_title</option>";
ef8be8ea 153 } else {
cc17c205 154 print "<option disabled>".__('This feed')."</option>";
ef8be8ea
AD
155 }
156
157 if ($is_cat) {
158 $cat_preselected = "selected";
159 }
160
161 if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
cc17c205 162 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
ef8be8ea 163 } else {
c4b0f96c 164 //print "<option disabled>".__('This category')."</option>";
ef8be8ea
AD
165 }
166
167 print "</select></td></tr>";
168
cc17c205 169 print "<tr><td>".__('Match on:')."</td><td>";
ef8be8ea
AD
170
171 $search_fields = array(
cc17c205
AD
172 "title" => __("Title"),
173 "content" => __("Content"),
174 "both" => __("Title or content"));
ef8be8ea
AD
175
176 print_select_hash("match_on", 3, $search_fields);
177
178 print "</td></tr></table>";
179
180 print "</form>";
181
182 print "<div align=\"right\">
183 <input type=\"submit\"
184 class=\"button\" onclick=\"javascript:search()\"
185 id=\"search_submit_btn\" disabled=\"true\"
cc17c205 186 value=\"".__('Search')."\">
ef8be8ea
AD
187 <input class=\"button\"
188 type=\"submit\" onclick=\"javascript:searchCancel()\"
cc17c205 189 value=\"".__('Cancel')."\"></div>";
ef8be8ea
AD
190
191 print "</div>";
192
5e6f933a
AD
193 return;
194
ef8be8ea
AD
195 }
196
197 if ($id == "quickAddLabel") {
cc17c205 198 print "<div id=\"infoBoxTitle\">".__('Create label')."</div>";
ef8be8ea
AD
199 print "<div class=\"infoBoxContents\">";
200
e6312f6c 201 print "<form id=\"label_edit_form\" onsubmit='return false'>";
ef8be8ea
AD
202
203 print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
204 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
205
206 print "<table width='100%'>";
207
cc17c205 208 print "<tr><td>".__('Caption:')."</td>
ef8be8ea 209 <td><input onkeypress=\"return filterCR(event, addLabel)\"
b5015f72
AD
210 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
211 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
212 name=\"description\" class=\"iedit\">";
ef8be8ea
AD
213
214 print "</td></tr>";
215
216 print "<tr><td colspan=\"2\">
cc17c205 217 <p>".__('SQL Expression:')."</p>";
ef8be8ea
AD
218
219 print "<textarea onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
220 rows=\"4\" name=\"sql_exp\" class=\"iedit\"></textarea>";
221
222 print "</td></tr></table>";
223
224 print "</form>";
225
226 print "<div style=\"display : none\" id=\"label_test_result\"></div>";
227
228 print "<div align='right'>";
229
cc17c205 230 print "<input type=\"submit\" onclick=\"labelTest()\" value=\"".__('Test')."\">
ef8be8ea
AD
231 ";
232
233 print "<input type=\"submit\"
234 id=\"infobox_submit\"
235 disabled=\"true\"
236 class=\"button\" onclick=\"return addLabel()\"
cc17c205 237 value=\"".__('Create')."\"> ";
ef8be8ea
AD
238
239 print "<input class=\"button\"
240 type=\"submit\" onclick=\"return labelEditCancel()\"
cc17c205 241 value=\"".__('Cancel')."\">";
5e6f933a
AD
242
243 return;
ef8be8ea
AD
244 }
245
246 if ($id == "quickAddFilter") {
247
248 $active_feed_id = db_escape_string($_GET["param"]);
249
cc17c205 250 print "<div id=\"infoBoxTitle\">".__('Create filter')."</div>";
ef8be8ea
AD
251 print "<div class=\"infoBoxContents\">";
252
e6312f6c 253 print "<form id=\"filter_add_form\" onsubmit='return false'>";
ef8be8ea
AD
254
255 print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
256 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
257 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
258
259// print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>";
260
261 $result = db_query($link, "SELECT id,description
262 FROM ttrss_filter_types ORDER BY description");
263
264 $filter_types = array();
265
266 while ($line = db_fetch_assoc($result)) {
267 //array_push($filter_types, $line["description"]);
89cb787e 268 $filter_types[$line["id"]] = __($line["description"]);
ef8be8ea
AD
269 }
270
271 print "<table width='100%'>";
272
cc17c205 273 print "<tr><td>".__('Match:')."</td>
ef8be8ea 274 <td><input onkeypress=\"return filterCR(event, qaddFilter)\"
b5015f72
AD
275 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
276 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
8011ac36
AD
277 name=\"reg_exp\" class=\"iedit\">";
278
cc17c205 279 print "</td></tr><tr><td>".__('On field:')."</td><td>";
8011ac36
AD
280
281 print_select_hash("filter_type", 1, $filter_types, "class=\"_iedit\"");
ef8be8ea
AD
282
283 print "</td></tr>";
cc17c205 284 print "<tr><td>".__('Feed:')."</td><td colspan='2'>";
ef8be8ea
AD
285
286 print_feed_select($link, "feed_id", $active_feed_id);
287
288 print "</td></tr>";
289
cc17c205 290 print "<tr><td>".__('Action:')."</td>";
ef8be8ea 291
073ca0e6
AD
292 print "<td colspan='2'><select name=\"action_id\"
293 onchange=\"filterDlgCheckAction(this)\">";
ef8be8ea
AD
294
295 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
296 ORDER BY name");
297
298 while ($line = db_fetch_assoc($result)) {
89cb787e 299 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
ef8be8ea
AD
300 }
301
302 print "</select>";
303
073ca0e6
AD
304 print "</td></tr>";
305
cc17c205 306 print "<tr><td>".__('Params:')."</td>";
073ca0e6
AD
307
308 print "<td><input disabled class='iedit' name='action_param'></td></tr>";
309
cc17c205 310 print "<tr><td valign='top'>".__('Options:')."</td><td>";
3f2ff803
AD
311
312 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
cc17c205 313 <label for=\"inverse\">".__('Inverse match')."</label></td></tr>";
3f2ff803 314
073ca0e6 315 print "</table>";
ef8be8ea
AD
316
317 print "</form>";
318
319 print "<div align='right'>";
320
321 print "<input type=\"submit\"
322 id=\"infobox_submit\"
5e6f933a 323 class=\"button\" onclick=\"return addFilter()\"
cc17c205 324 disabled=\"true\" value=\"".__('Create')."\"> ";
ef8be8ea
AD
325
326 print "<input class=\"button\"
327 type=\"submit\" onclick=\"return closeInfoBox()\"
cc17c205 328 value=\"".__('Cancel')."\">";
ef8be8ea
AD
329
330 print "</div>";
331
332// print "</td></tr></table>";
333
5e6f933a 334 return;
ef8be8ea
AD
335 }
336
a3656a41
AD
337 if ($id == "feedUpdateErrors") {
338
cc17c205 339 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
a3656a41
AD
340 print "<div class=\"infoBoxContents\">";
341
cc17c205 342 print __("These feeds have not been updated because of errors:");
a3656a41
AD
343
344 $result = db_query($link, "SELECT id,title,feed_url,last_error
345 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
346
e8dd519b 347 print "<ul class='feedErrorsList'>";
a3656a41
AD
348
349 while ($line = db_fetch_assoc($result)) {
350 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " .
351 "<em>" . $line["last_error"] . "</em>";
352 }
353
354 print "</ul>";
355 print "</div>";
356
357 print "<div align='center'>";
358
359 print "<input class=\"button\"
360 type=\"submit\" onclick=\"return closeInfoBox()\"
cc17c205 361 value=\"".__('Close')."\">";
a3656a41
AD
362
363 print "</div>";
364
aa330b93 365 return;
a3656a41
AD
366 }
367
0b126ac2
AD
368 if ($id == "editArticleTags") {
369
cc17c205 370 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
0b126ac2
AD
371 print "<div class=\"infoBoxContents\">";
372
e6312f6c 373 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
0b126ac2 374
cc17c205 375 print __("Tags for this article (separated by commas):")."<br>";
0b126ac2
AD
376
377 $tags = get_article_tags($link, $param);
378
379 $tags_str = join(", ", $tags);
380
d62a3b63
AD
381 print "<table width='100%'>";
382
383 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
384
05fcdf52
AD
385 print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str'
386 name='tags_str'>$tags_str</textarea>
387 <div class=\"autocomplete\" id=\"tags_choices\"
388 style=\"display:none\"></div>
389 </td></tr>";
d62a3b63 390
05fcdf52 391/* print "<tr><td>".__('Add existing tag:')."</td>";
0b126ac2 392
d62a3b63
AD
393 $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
394 WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name");
395
396 $found_tags = array();
397
398 array_push($found_tags, '');
399
400 while ($line = db_fetch_assoc($result)) {
e4609ea9 401 array_push($found_tags, truncate_string($line["tag_name"], 20));
d62a3b63
AD
402 }
403
404 print "<td align='right'>";
405
406 print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
407
05fcdf52 408 print "</td>";
d62a3b63 409
05fcdf52 410 print "</tr>"; */
d62a3b63
AD
411
412 print "</table>";
0b126ac2
AD
413
414 print "</form>";
415
416 print "<div align='right'>";
417
418 print "<input class=\"button\"
419 type=\"submit\" onclick=\"return editTagsSave()\"
cc17c205 420 value=\"".__('Save')."\"> ";
0b126ac2
AD
421
422 print "<input class=\"button\"
423 type=\"submit\" onclick=\"return closeInfoBox()\"
cc17c205 424 value=\"".__('Cancel')."\">";
0b126ac2
AD
425
426
427 print "</div>";
428
5e6f933a 429 return;
0b126ac2
AD
430 }
431
0979b696 432 if ($id == "printTagCloud") {
27258a90 433 print "<div id=\"infoBoxTitle\">".__('Tag cloud')."</div>";
0979b696
AD
434 print "<div class=\"infoBoxContents\">";
435
dcac082b 436 print __("Showing most popular tags ")." (<a
ef1ac7c7 437 href='javascript:toggleTags(true)'>".__('browse more')."</a>):<br/>";
0979b696
AD
438
439 print "<div class=\"tagCloudContainer\">";
440
441 printTagCloud($link);
442
443 print "</div>";
444
445 print "<div align='center'>";
446 print "<input class=\"button\"
447 type=\"submit\" onclick=\"return closeInfoBox()\"
448 value=\"".__('Close')."\">";
449 print "</div>";
450
451 print "</div>";
452
453 return;
454 }
455
5e6f933a
AD
456 print "<div id='infoBoxTitle'>Internal Error</div>
457 <div id='infoBoxContents'>
458 <p>Unknown dialog <b>$id</b></p>
459 </div></div>";
460
ef8be8ea
AD
461 }
462?>