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