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