]> git.wh0rd.org - tt-rss.git/blob - modules/popup-dialog.php
check update daemon timestamp
[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:showBlockElement(\"fadd_login_container\",
86 \"fadd_login_prompt\")'>Click here if this feed requires authentication.</a></div>";
87
88 print "<div id='fadd_login_container'>
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 align='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 return;
107 }
108
109 if ($id == "search") {
110
111 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
112 print "<div class=\"infoBoxContents\">";
113
114 print "<form id='search_form' onsubmit='return false'>";
115
116 #$active_feed_id = db_escape_string($_GET["param"]);
117
118 $params = split(":", db_escape_string($_GET["param"]));
119
120 $active_feed_id = sprintf("%d", $params[0]);
121 $is_cat = $params[1] == "true";
122
123 print "<table width='100%'><tr><td>".__('Search:')."</td><td>";
124
125 print "<input name=\"query\" class=\"iedit\"
126 onkeypress=\"return filterCR(event, search)\"
127 onchange=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
128 onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
129 value=\"\">
130 </td></tr>";
131
132 print "<tr><td>".__('Where:')."</td><td>";
133
134 print "<select name=\"search_mode\">
135 <option value=\"all_feeds\">".__('All feeds')."</option>";
136
137 $feed_title = getFeedTitle($link, $active_feed_id);
138
139 if (!$is_cat) {
140 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
141 } else {
142 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
143 }
144
145 if ($active_feed_id && !$is_cat) {
146 print "<option selected value=\"this_feed\">$feed_title</option>";
147 } else {
148 print "<option disabled>".__('This feed')."</option>";
149 }
150
151 if ($is_cat) {
152 $cat_preselected = "selected";
153 }
154
155 if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
156 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
157 } else {
158 //print "<option disabled>".__('This category')."</option>";
159 }
160
161 print "</select></td></tr>";
162
163 print "<tr><td>".__('Match on:')."</td><td>";
164
165 $search_fields = array(
166 "title" => __("Title"),
167 "content" => __("Content"),
168 "both" => __("Title or content"));
169
170 print_select_hash("match_on", 3, $search_fields);
171
172 print "</td></tr></table>";
173
174 print "</form>";
175
176 print "<div align=\"right\">
177 <input type=\"submit\"
178 class=\"button\" onclick=\"javascript:search()\"
179 id=\"search_submit_btn\" disabled=\"true\"
180 value=\"".__('Search')."\">
181 <input class=\"button\"
182 type=\"submit\" onclick=\"javascript:searchCancel()\"
183 value=\"".__('Cancel')."\"></div>";
184
185 print "</div>";
186
187 return;
188
189 }
190
191 if ($id == "quickAddLabel") {
192 print "<div id=\"infoBoxTitle\">".__('Create label')."</div>";
193 print "<div class=\"infoBoxContents\">";
194
195 print "<form id=\"label_edit_form\" onsubmit='return false'>";
196
197 print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
198 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
199
200 print "<table width='100%'>";
201
202 print "<tr><td>".__('Caption:')."</td>
203 <td><input onkeypress=\"return filterCR(event, addLabel)\"
204 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
205 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
206 name=\"description\" class=\"iedit\">";
207
208 print "</td></tr>";
209
210 print "<tr><td colspan=\"2\">
211 <p>".__('SQL Expression:')."</p>";
212
213 print "<textarea onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
214 rows=\"4\" name=\"sql_exp\" class=\"iedit\"></textarea>";
215
216 print "</td></tr></table>";
217
218 print "</form>";
219
220 print "<div style=\"display : none\" id=\"label_test_result\"></div>";
221
222 print "<div align='right'>";
223
224 print "<input type=\"submit\" onclick=\"labelTest()\" value=\"".__('Test')."\">
225 ";
226
227 print "<input type=\"submit\"
228 id=\"infobox_submit\"
229 disabled=\"true\"
230 class=\"button\" onclick=\"return addLabel()\"
231 value=\"".__('Create')."\"> ";
232
233 print "<input class=\"button\"
234 type=\"submit\" onclick=\"return labelEditCancel()\"
235 value=\"".__('Cancel')."\">";
236
237 return;
238 }
239
240 if ($id == "quickAddFilter") {
241
242 $active_feed_id = db_escape_string($_GET["param"]);
243
244 print "<div id=\"infoBoxTitle\">".__('Create filter')."</div>";
245 print "<div class=\"infoBoxContents\">";
246
247 print "<form id=\"filter_add_form\" onsubmit='return false'>";
248
249 print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
250 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
251 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
252
253 // print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>";
254
255 $result = db_query($link, "SELECT id,description
256 FROM ttrss_filter_types ORDER BY description");
257
258 $filter_types = array();
259
260 while ($line = db_fetch_assoc($result)) {
261 //array_push($filter_types, $line["description"]);
262 $filter_types[$line["id"]] = $line["description"];
263 }
264
265 print "<table width='100%'>";
266
267 print "<tr><td>".__('Match:')."</td>
268 <td><input onkeypress=\"return filterCR(event, qaddFilter)\"
269 onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
270 onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
271 name=\"reg_exp\" class=\"iedit\">";
272
273 print "</td></tr><tr><td>".__('On field:')."</td><td>";
274
275 print_select_hash("filter_type", 1, $filter_types, "class=\"_iedit\"");
276
277 print "</td></tr>";
278 print "<tr><td>".__('Feed:')."</td><td colspan='2'>";
279
280 print_feed_select($link, "feed_id", $active_feed_id);
281
282 print "</td></tr>";
283
284 print "<tr><td>".__('Action:')."</td>";
285
286 print "<td colspan='2'><select name=\"action_id\"
287 onchange=\"filterDlgCheckAction(this)\">";
288
289 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
290 ORDER BY name");
291
292 while ($line = db_fetch_assoc($result)) {
293 printf("<option value='%d'>%s</option>", $line["id"], $line["description"]);
294 }
295
296 print "</select>";
297
298 print "</td></tr>";
299
300 print "<tr><td>".__('Params:')."</td>";
301
302 print "<td><input disabled class='iedit' name='action_param'></td></tr>";
303
304 print "<tr><td valign='top'>".__('Options:')."</td><td>";
305
306 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
307 <label for=\"inverse\">".__('Inverse match')."</label></td></tr>";
308
309 print "</table>";
310
311 print "</form>";
312
313 print "<div align='right'>";
314
315 print "<input type=\"submit\"
316 id=\"infobox_submit\"
317 class=\"button\" onclick=\"return addFilter()\"
318 disabled=\"true\" value=\"".__('Create')."\"> ";
319
320 print "<input class=\"button\"
321 type=\"submit\" onclick=\"return closeInfoBox()\"
322 value=\"".__('Cancel')."\">";
323
324 print "</div>";
325
326 // print "</td></tr></table>";
327
328 return;
329 }
330
331 if ($id == "feedUpdateErrors") {
332
333 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
334 print "<div class=\"infoBoxContents\">";
335
336 print __("These feeds have not been updated because of errors:");
337
338 $result = db_query($link, "SELECT id,title,feed_url,last_error
339 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
340
341 print "<ul class='feedErrorsList'>";
342
343 while ($line = db_fetch_assoc($result)) {
344 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " .
345 "<em>" . $line["last_error"] . "</em>";
346 }
347
348 print "</ul>";
349 print "</div>";
350
351 print "<div align='center'>";
352
353 print "<input class=\"button\"
354 type=\"submit\" onclick=\"return closeInfoBox()\"
355 value=\"".__('Close')."\">";
356
357 print "</div>";
358
359 return;
360 }
361
362 if ($id == "editArticleTags") {
363
364 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
365 print "<div class=\"infoBoxContents\">";
366
367 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
368
369 print __("Tags for this article (separated by commas):")."<br>";
370
371 $tags = get_article_tags($link, $param);
372
373 $tags_str = join(", ", $tags);
374
375 print "<table width='100%'>";
376
377 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
378
379 print "<tr><td colspan='2'><textarea rows='4' class='iedit' name='tags_str'>$tags_str</textarea></td></tr>";
380
381 print "<tr><td>".__('Add existing tag:')."</td>";
382
383 $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags
384 WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY tag_name");
385
386 $found_tags = array();
387
388 array_push($found_tags, '');
389
390 while ($line = db_fetch_assoc($result)) {
391 array_push($found_tags, truncate_string($line["tag_name"], 20));
392 }
393
394 print "<td align='right'>";
395
396 print_select("found_tags", '', $found_tags, "onchange=\"javascript:editTagsInsert()\"");
397
398 print "</td>";
399
400 print "</tr>";
401
402 print "</table>";
403
404 print "</form>";
405
406 print "<div align='right'>";
407
408 print "<input class=\"button\"
409 type=\"submit\" onclick=\"return editTagsSave()\"
410 value=\"".__('Save')."\"> ";
411
412 print "<input class=\"button\"
413 type=\"submit\" onclick=\"return closeInfoBox()\"
414 value=\"".__('Cancel')."\">";
415
416
417 print "</div>";
418
419 return;
420 }
421
422 if ($id == "printTagCloud") {
423 print "<div id=\"infoBoxTitle\">".__('Tag cloud')."</div>";
424 print "<div class=\"infoBoxContents\">";
425
426 print __("Showing most popular tags ")." (<a
427 href='javascript:toggleTags(true)'>".__('browse all')."</a>):<br/>";
428
429 print "<div class=\"tagCloudContainer\">";
430
431 printTagCloud($link);
432
433 print "</div>";
434
435 print "<div align='center'>";
436 print "<input class=\"button\"
437 type=\"submit\" onclick=\"return closeInfoBox()\"
438 value=\"".__('Close')."\">";
439 print "</div>";
440
441 print "</div>";
442
443 return;
444 }
445
446 print "<div id='infoBoxTitle'>Internal Error</div>
447 <div id='infoBoxContents'>
448 <p>Unknown dialog <b>$id</b></p>
449 </div></div>";
450
451 }
452 ?>