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