]> git.wh0rd.org - tt-rss.git/blob - modules/popup-dialog.php
tweak quickAddFeed dialog
[tt-rss.git] / modules / popup-dialog.php
1 <?php
2 function module_popup_dialog($link) {
3 $id = $_GET["id"];
4 $param = db_escape_string($_GET["param"]);
5
6 if ($id == "explainError") {
7
8 print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
9 print "<div class=\"infoBoxContents\">";
10
11 if ($param == 1) {
12 print __("Update daemon is enabled in configuration, but daemon
13 process is not running, which prevents all feeds from updating. Please
14 start the daemon process or contact instance owner.");
15 }
16
17 if ($param == 2) {
18 $msg = check_for_update($link, false);
19
20 if (!$msg) {
21 print __("You are running the latest version of Tiny Tiny RSS. The
22 fact that you are seeing this dialog is probably a bug.");
23 } else {
24 print $msg;
25 }
26
27 }
28
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
36 print "</div>";
37
38 print "<div align='center'>";
39
40 print "<input class=\"button\"
41 type=\"submit\" onclick=\"return closeInfoBox()\"
42 value=\"".__('Close this window')."\">";
43
44 print "</div>";
45
46 return;
47 }
48
49 if ($id == "quickAddFeed") {
50
51 print "<div id=\"infoBoxTitle\">".__('Subscribe to feed')."</div>";
52 print "<div class=\"infoBoxContents\">";
53
54 print "<form id='feed_add_form' onsubmit='return false'>";
55
56 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
57 /* print "<input type=\"hidden\" name=\"quiet\" value=\"1\">"; */
58 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
59 print "<input type=\"hidden\" name=\"from\" value=\"tt-rss\">";
60
61 print "<table width='100%'>
62 <tr><td>".__('Feed URL:')."</td><td>
63 <input class=\"iedit\" onblur=\"javascript:enableHotkeys()\"
64 onkeypress=\"return filterCR(event, qaddFeed)\"
65 onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
66 onchange=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
67 onfocus=\"javascript:disableHotkeys()\" name=\"feed_url\"></td></tr>";
68
69 if (get_pref($link, 'ENABLE_FEED_CATS')) {
70 print "<tr><td>".__('Category:')."</td><td>";
71 print_feed_cat_select($link, "cat_id");
72 print "</td></tr>";
73 }
74
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
82 print "</table>";
83
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>"; */
87
88 print "<div id='fadd_login_container' style='display:none'>
89 <table width='100%'>
90 <tr><td>".__('Login:')."</td><td><input name='auth_login' class='iedit'></td></tr>
91 <tr><td>".__('Password:')."</td><td><input type='password'
92 name='auth_pass' class='iedit'></td></tr>
93 </table>
94 </div>";
95
96 print "</form>";
97
98 print "<div style='float : right'>
99 <input class=\"button\"
100 id=\"fadd_submit_btn\" disabled=\"true\"
101 type=\"submit\" onclick=\"return qaddFeed()\" value=\"".__('Subscribe')."\">
102 <input class=\"button\"
103 type=\"submit\" onclick=\"return closeInfoBox()\"
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>";
111
112 return;
113 }
114
115 if ($id == "search") {
116
117 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
118 print "<div class=\"infoBoxContents\">";
119
120 print "<form id='search_form' onsubmit='return false'>";
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
129 print "<table width='100%'><tr><td>".__('Search:')."</td><td>";
130
131 print "<input name=\"query\" class=\"iedit\"
132 onkeypress=\"return filterCR(event, search)\"
133 onchange=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
134 onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
135 value=\"\">
136 </td></tr>";
137
138 print "<tr><td>".__('Where:')."</td><td>";
139
140 print "<select name=\"search_mode\">
141 <option value=\"all_feeds\">".__('All feeds')."</option>";
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) {
152 print "<option selected value=\"this_feed\">$feed_title</option>";
153 } else {
154 print "<option disabled>".__('This feed')."</option>";
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)) {
162 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
163 } else {
164 //print "<option disabled>".__('This category')."</option>";
165 }
166
167 print "</select></td></tr>";
168
169 print "<tr><td>".__('Match on:')."</td><td>";
170
171 $search_fields = array(
172 "title" => __("Title"),
173 "content" => __("Content"),
174 "both" => __("Title or content"));
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\"
186 value=\"".__('Search')."\">
187 <input class=\"button\"
188 type=\"submit\" onclick=\"javascript:searchCancel()\"
189 value=\"".__('Cancel')."\"></div>";
190
191 print "</div>";
192
193 return;
194
195 }
196
197 if ($id == "quickAddLabel") {
198 print "<div id=\"infoBoxTitle\">".__('Create label')."</div>";
199 print "<div class=\"infoBoxContents\">";
200
201 print "<form id=\"label_edit_form\" onsubmit='return false'>";
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
208 print "<tr><td>".__('Caption:')."</td>
209 <td><input onkeypress=\"return filterCR(event, addLabel)\"
210 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
211 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
212 name=\"description\" class=\"iedit\">";
213
214 print "</td></tr>";
215
216 print "<tr><td colspan=\"2\">
217 <p>".__('SQL Expression:')."</p>";
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
230 print "<input type=\"submit\" onclick=\"labelTest()\" value=\"".__('Test')."\">
231 ";
232
233 print "<input type=\"submit\"
234 id=\"infobox_submit\"
235 disabled=\"true\"
236 class=\"button\" onclick=\"return addLabel()\"
237 value=\"".__('Create')."\"> ";
238
239 print "<input class=\"button\"
240 type=\"submit\" onclick=\"return labelEditCancel()\"
241 value=\"".__('Cancel')."\">";
242
243 return;
244 }
245
246 if ($id == "quickAddFilter") {
247
248 $active_feed_id = db_escape_string($_GET["param"]);
249
250 print "<div id=\"infoBoxTitle\">".__('Create filter')."</div>";
251 print "<div class=\"infoBoxContents\">";
252
253 print "<form id=\"filter_add_form\" onsubmit='return false'>";
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"]);
268 $filter_types[$line["id"]] = __($line["description"]);
269 }
270
271 print "<table width='100%'>";
272
273 print "<tr><td>".__('Match:')."</td>
274 <td><input onkeypress=\"return filterCR(event, qaddFilter)\"
275 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
276 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
277 name=\"reg_exp\" class=\"iedit\">";
278
279 print "</td></tr><tr><td>".__('On field:')."</td><td>";
280
281 print_select_hash("filter_type", 1, $filter_types, "class=\"_iedit\"");
282
283 print "</td></tr>";
284 print "<tr><td>".__('Feed:')."</td><td colspan='2'>";
285
286 print_feed_select($link, "feed_id", $active_feed_id);
287
288 print "</td></tr>";
289
290 print "<tr><td>".__('Action:')."</td>";
291
292 print "<td colspan='2'><select name=\"action_id\"
293 onchange=\"filterDlgCheckAction(this)\">";
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)) {
299 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
300 }
301
302 print "</select>";
303
304 print "</td></tr>";
305
306 print "<tr><td>".__('Params:')."</td>";
307
308 print "<td><input disabled class='iedit' name='action_param'></td></tr>";
309
310 print "<tr><td valign='top'>".__('Options:')."</td><td>";
311
312 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
313 <label for=\"inverse\">".__('Inverse match')."</label></td></tr>";
314
315 print "</table>";
316
317 print "</form>";
318
319 print "<div align='right'>";
320
321 print "<input type=\"submit\"
322 id=\"infobox_submit\"
323 class=\"button\" onclick=\"return addFilter()\"
324 disabled=\"true\" value=\"".__('Create')."\"> ";
325
326 print "<input class=\"button\"
327 type=\"submit\" onclick=\"return closeInfoBox()\"
328 value=\"".__('Cancel')."\">";
329
330 print "</div>";
331
332 // print "</td></tr></table>";
333
334 return;
335 }
336
337 if ($id == "feedUpdateErrors") {
338
339 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
340 print "<div class=\"infoBoxContents\">";
341
342 print __("These feeds have not been updated because of errors:");
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
347 print "<ul class='feedErrorsList'>";
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()\"
361 value=\"".__('Close')."\">";
362
363 print "</div>";
364
365 return;
366 }
367
368 if ($id == "editArticleTags") {
369
370 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
371 print "<div class=\"infoBoxContents\">";
372
373 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
374
375 print __("Tags for this article (separated by commas):")."<br>";
376
377 $tags = get_article_tags($link, $param);
378
379 $tags_str = join(", ", $tags);
380
381 print "<table width='100%'>";
382
383 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
384
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>";
390
391 /* print "<tr><td>".__('Add existing tag:')."</td>";
392
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)) {
401 array_push($found_tags, truncate_string($line["tag_name"], 20));
402 }
403
404 print "<td align='right'>";
405
406 print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
407
408 print "</td>";
409
410 print "</tr>"; */
411
412 print "</table>";
413
414 print "</form>";
415
416 print "<div align='right'>";
417
418 print "<input class=\"button\"
419 type=\"submit\" onclick=\"return editTagsSave()\"
420 value=\"".__('Save')."\"> ";
421
422 print "<input class=\"button\"
423 type=\"submit\" onclick=\"return closeInfoBox()\"
424 value=\"".__('Cancel')."\">";
425
426
427 print "</div>";
428
429 return;
430 }
431
432 if ($id == "printTagCloud") {
433 print "<div id=\"infoBoxTitle\">".__('Tag cloud')."</div>";
434 print "<div class=\"infoBoxContents\">";
435
436 print __("Showing most popular tags ")." (<a
437 href='javascript:toggleTags(true)'>".__('browse more')."</a>):<br/>";
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
456 print "<div id='infoBoxTitle'>Internal Error</div>
457 <div id='infoBoxContents'>
458 <p>Unknown dialog <b>$id</b></p>
459 </div></div>";
460
461 }
462 ?>