]>
Commit | Line | Data |
---|---|---|
3f363052 | 1 | <?php |
46da73c2 | 2 | class Dlg extends Protected_Handler { |
3f363052 | 3 | private $param; |
46da73c2 | 4 | |
3f363052 AD |
5 | function before() { |
6 | if (parent::before()) { | |
7 | header("Content-Type: text/xml; charset=utf-8"); | |
8 | $this->param = db_escape_string($_REQUEST["param"]); | |
9 | print "<dlg>"; | |
10 | return true; | |
11 | } | |
12 | return false; | |
13 | } | |
46da73c2 | 14 | |
3f363052 AD |
15 | function after() { |
16 | print "</dlg>"; | |
17 | } | |
18 | ||
566faa14 AD |
19 | function exportData() { |
20 | ||
21 | print "<p style='text-align : center' id='export_status_message'>You need to prepare exported data first by clicking the button below.</p>"; | |
22 | ||
23 | print "<div align='center'>"; | |
24 | print "<button dojoType=\"dijit.form.Button\" | |
25 | onclick=\"dijit.byId('dataExportDlg').prepare()\">". | |
26 | __('Prepare data')."</button>"; | |
27 | ||
28 | print "<button dojoType=\"dijit.form.Button\" | |
29 | onclick=\"dijit.byId('dataExportDlg').hide()\">". | |
30 | __('Close this window')."</button>"; | |
31 | ||
32 | print "</div>"; | |
33 | ||
34 | ||
35 | } | |
36 | ||
3f363052 AD |
37 | function importOpml() { |
38 | header("Content-Type: text/html"); # required for iframe | |
46da73c2 | 39 | |
34aa9e20 AD |
40 | print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>"; |
41 | ||
3f363052 AD |
42 | print "<div class=\"prefFeedOPMLHolder\">"; |
43 | $owner_uid = $_SESSION["uid"]; | |
44 | ||
45 | db_query($this->link, "BEGIN"); | |
46 | ||
47 | /* create Imported feeds category just in case */ | |
48 | ||
49 | $result = db_query($this->link, "SELECT id FROM | |
50 | ttrss_feed_categories WHERE title = 'Imported feeds' AND | |
51 | owner_uid = '$owner_uid' LIMIT 1"); | |
52 | ||
53 | if (db_num_rows($result) == 0) { | |
54 | db_query($this->link, "INSERT INTO ttrss_feed_categories | |
55 | (title,owner_uid) | |
56 | VALUES ('Imported feeds', '$owner_uid')"); | |
57 | } | |
58 | ||
59 | db_query($this->link, "COMMIT"); | |
60 | ||
61 | /* Handle OPML import by DOMXML/DOMDocument */ | |
62 | ||
c4c74732 | 63 | print "<ul class='nomarks'>"; |
c4c74732 AD |
64 | require_once "opml.php"; |
65 | opml_import_domdoc($this->link, $owner_uid); | |
66 | print "</ul>"; | |
3f363052 AD |
67 | print "</div>"; |
68 | ||
69 | print "<div align='center'>"; | |
70 | print "<button dojoType=\"dijit.form.Button\" | |
34aa9e20 | 71 | onclick=\"dijit.byId('opmlImportDlg').execute()\">". |
3f363052 AD |
72 | __('Close this window')."</button>"; |
73 | print "</div>"; | |
74 | ||
75 | print "</div>"; | |
76 | ||
77 | //return; | |
78 | } | |
79 | ||
80 | function editPrefProfiles() { | |
81 | print "<div dojoType=\"dijit.Toolbar\">"; | |
82 | ||
83 | print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\" | |
84 | required=\"1\"> | |
85 | <button dojoType=\"dijit.form.Button\" | |
86 | onclick=\"dijit.byId('profileEditDlg').addProfile()\">". | |
87 | __('Create profile')."</button></div>"; | |
88 | ||
89 | $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles | |
90 | WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title"); | |
91 | ||
92 | print "<div class=\"prefFeedCatHolder\">"; | |
93 | ||
94 | print "<form id=\"profile_edit_form\" onsubmit=\"return false\">"; | |
95 | ||
96 | print "<table width=\"100%\" class=\"prefFeedProfileList\" | |
97 | cellspacing=\"0\" id=\"prefFeedProfileList\">"; | |
98 | ||
99 | print "<tr class=\"\" id=\"FCATR-0\">"; #odd | |
100 | ||
101 | print "<td width='5%' align='center'><input | |
102 | onclick='toggleSelectRow2(this);' | |
103 | dojoType=\"dijit.form.CheckBox\" | |
104 | type=\"checkbox\"></td>"; | |
105 | ||
106 | if (!$_SESSION["profile"]) { | |
107 | $is_active = __("(active)"); | |
108 | } else { | |
109 | $is_active = ""; | |
110 | } | |
111 | ||
112 | print "<td><span>" . | |
113 | __("Default profile") . " $is_active</span></td>"; | |
114 | ||
115 | print "</tr>"; | |
116 | ||
117 | $lnum = 1; | |
118 | ||
119 | while ($line = db_fetch_assoc($result)) { | |
120 | ||
121 | $class = ($lnum % 2) ? "even" : "odd"; | |
122 | ||
123 | $profile_id = $line["id"]; | |
124 | $this_row_id = "id=\"FCATR-$profile_id\""; | |
125 | ||
126 | print "<tr class=\"\" $this_row_id>"; | |
127 | ||
128 | $edit_title = htmlspecialchars($line["title"]); | |
129 | ||
130 | print "<td width='5%' align='center'><input | |
131 | onclick='toggleSelectRow2(this);' | |
132 | dojoType=\"dijit.form.CheckBox\" | |
133 | type=\"checkbox\"></td>"; | |
134 | ||
135 | if ($_SESSION["profile"] == $line["id"]) { | |
136 | $is_active = __("(active)"); | |
137 | } else { | |
138 | $is_active = ""; | |
139 | } | |
140 | ||
141 | print "<td><span dojoType=\"dijit.InlineEditBox\" | |
142 | width=\"300px\" autoSave=\"false\" | |
143 | profile-id=\"$profile_id\">" . $edit_title . | |
144 | "<script type=\"dojo/method\" event=\"onChange\" args=\"item\"> | |
145 | var elem = this; | |
146 | dojo.xhrPost({ | |
147 | url: 'backend.php', | |
148 | content: {op: 'rpc', method: 'saveprofile', | |
149 | value: this.value, | |
150 | id: this.srcNodeRef.getAttribute('profile-id')}, | |
151 | load: function(response) { | |
152 | elem.attr('value', response); | |
153 | } | |
154 | }); | |
155 | </script> | |
156 | </span> $is_active</td>"; | |
157 | ||
158 | print "</tr>"; | |
159 | ||
160 | ++$lnum; | |
161 | } | |
162 | ||
163 | print "</table>"; | |
164 | print "</form>"; | |
165 | print "</div>"; | |
166 | ||
167 | print "<div class='dlgButtons'> | |
168 | <div style='float : left'> | |
169 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">". | |
170 | __('Remove selected profiles')."</button> | |
171 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">". | |
172 | __('Activate profile')."</button> | |
173 | </div>"; | |
174 | ||
175 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">". | |
176 | __('Close this window')."</button>"; | |
177 | print "</div>"; | |
178 | ||
179 | } | |
180 | ||
181 | function pubOPMLUrl() { | |
182 | print "<title>".__('Public OPML URL')."</title>"; | |
183 | print "<content><![CDATA["; | |
184 | ||
185 | $url_path = opml_publish_url($this->link); | |
186 | ||
187 | print __("Your Public OPML URL is:"); | |
188 | ||
189 | print "<div class=\"tagCloudContainer\">"; | |
190 | print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>"; | |
191 | print "</div>"; | |
192 | ||
193 | print "<div align='center'>"; | |
194 | ||
195 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">". | |
196 | __('Generate new URL')."</button> "; | |
197 | ||
198 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">". | |
199 | __('Close this window')."</button>"; | |
200 | ||
201 | print "</div>"; | |
202 | print "]]></content>"; | |
203 | ||
204 | //return; | |
205 | } | |
206 | ||
207 | function explainError() { | |
208 | print "<title>".__('Notice')."</title>"; | |
209 | print "<content><![CDATA["; | |
210 | ||
211 | print "<div class=\"errorExplained\">"; | |
212 | ||
213 | if ($this->param == 1) { | |
214 | print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner."); | |
215 | ||
216 | $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); | |
217 | ||
218 | print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); | |
219 | ||
220 | } | |
221 | ||
222 | if ($this->param == 3) { | |
223 | print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner."); | |
224 | ||
225 | $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); | |
226 | ||
227 | print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); | |
228 | ||
229 | } | |
230 | ||
231 | print "</div>"; | |
232 | ||
233 | print "<div align='center'>"; | |
234 | ||
235 | print "<button onclick=\"return closeInfoBox()\">". | |
236 | __('Close this window')."</button>"; | |
237 | ||
238 | print "</div>"; | |
239 | print "]]></content>"; | |
240 | ||
241 | //return; | |
242 | } | |
243 | ||
244 | function quickAddFeed() { | |
245 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">"; | |
246 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">"; | |
247 | ||
248 | print "<div class=\"dlgSec\">".__("Feed")."</div>"; | |
249 | print "<div class=\"dlgSecCont\">"; | |
250 | ||
251 | print "<input style=\"font-size : 16px; width : 20em;\" | |
252 | placeHolder=\"".__("Feed URL")."\" | |
253 | dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">"; | |
254 | ||
255 | print "<hr/>"; | |
256 | ||
257 | if (get_pref($this->link, 'ENABLE_FEED_CATS')) { | |
258 | print __('Place in category:') . " "; | |
259 | print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"'); | |
260 | } | |
261 | ||
262 | print "</div>"; | |
263 | ||
264 | print '<div id="feedDlg_feedsContainer" style="display : none"> | |
265 | ||
266 | <div class="dlgSec">' . __('Available feeds') . '</div> | |
267 | <div class="dlgSecCont">'. | |
268 | '<select id="feedDlg_feedContainerSelect" | |
269 | dojoType="dijit.form.Select" size="3"> | |
270 | <script type="dojo/method" event="onChange" args="value"> | |
271 | dijit.byId("feedDlg_feedUrl").attr("value", value); | |
272 | </script> | |
273 | </select>'. | |
274 | '</div></div>'; | |
275 | ||
276 | print "<div id='feedDlg_loginContainer' style='display : none'> | |
277 | ||
278 | <div class=\"dlgSec\">".__("Authentication")."</div> | |
279 | <div class=\"dlgSecCont\">". | |
280 | ||
281 | " <input dojoType=\"dijit.form.TextBox\" name='login'\" | |
282 | placeHolder=\"".__("Login")."\" | |
283 | style=\"width : 10em;\"> ". | |
284 | " <input | |
285 | placeHolder=\"".__("Password")."\" | |
286 | dojoType=\"dijit.form.TextBox\" type='password' | |
287 | style=\"width : 10em;\" name='pass'\"> | |
288 | </div></div>"; | |
289 | ||
290 | ||
291 | print "<div style=\"clear : both\"> | |
292 | <input type=\"checkbox\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\" | |
293 | onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'> | |
294 | <label for=\"feedDlg_loginCheck\">". | |
295 | __('This feed requires authentication.')."</div>"; | |
296 | ||
297 | print "</form>"; | |
298 | ||
299 | print "<div class=\"dlgButtons\"> | |
300 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button> | |
301 | <button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button> | |
302 | <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button> | |
303 | </div>"; | |
304 | ||
305 | //return; | |
306 | } | |
307 | ||
308 | function feedBrowser() { | |
309 | $browser_search = db_escape_string($_REQUEST["search"]); | |
310 | ||
311 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">"; | |
312 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">"; | |
313 | ||
314 | print "<div dojoType=\"dijit.Toolbar\"> | |
315 | <div style='float : right'> | |
316 | <img style='display : none' | |
317 | id='feed_browser_spinner' src='". | |
318 | theme_image($this->link, 'images/indicator_white.gif')."'> | |
319 | <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\" | |
320 | onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\"> | |
321 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button> | |
322 | </div>"; | |
323 | ||
324 | print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\"> | |
325 | <option value='1'>" . __('Popular feeds') . "</option> | |
326 | <option value='2'>" . __('Feed archive') . "</option> | |
327 | </select> "; | |
328 | ||
329 | print __("limit:"); | |
330 | ||
331 | print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">"; | |
332 | ||
333 | foreach (array(25, 50, 100, 200) as $l) { | |
334 | $issel = ($l == $limit) ? "selected=\"1\"" : ""; | |
335 | print "<option $issel value=\"$l\">$l</option>"; | |
336 | } | |
337 | ||
338 | print "</select> "; | |
339 | ||
340 | print "</div>"; | |
341 | ||
342 | $owner_uid = $_SESSION["uid"]; | |
343 | ||
344 | print "<ul class='browseFeedList' id='browseFeedList'>"; | |
345 | print make_feed_browser($this->link, $search, 25); | |
346 | print "</ul>"; | |
347 | ||
348 | print "<div align='center'> | |
349 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button> | |
350 | <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button> | |
351 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>"; | |
352 | ||
353 | } | |
354 | ||
355 | function search() { | |
356 | $this->params = explode(":", db_escape_string($_REQUEST["param"]), 2); | |
357 | ||
358 | $active_feed_id = sprintf("%d", $this->params[0]); | |
359 | $is_cat = $this->params[1] != "false"; | |
360 | ||
361 | print "<div class=\"dlgSec\">".__('Look for')."</div>"; | |
362 | ||
363 | print "<div class=\"dlgSecCont\">"; | |
364 | ||
365 | if (!SPHINX_ENABLED) { | |
366 | ||
367 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
368 | style=\"font-size : 16px; width : 12em;\" | |
369 | required=\"1\" name=\"query\" type=\"search\" value=''>"; | |
370 | ||
371 | print " " . __('match on')." "; | |
372 | ||
373 | $search_fields = array( | |
374 | "title" => __("Title"), | |
375 | "content" => __("Content"), | |
376 | "both" => __("Title or content")); | |
377 | ||
378 | print_select_hash("match_on", 3, $search_fields, | |
379 | 'dojoType="dijit.form.Select"'); | |
380 | } else { | |
381 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
382 | style=\"font-size : 16px; width : 20em;\" | |
383 | required=\"1\" name=\"query\" type=\"search\" value=''>"; | |
384 | } | |
385 | ||
386 | ||
387 | print "<hr/>".__('Limit search to:')." "; | |
388 | ||
389 | print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\"> | |
390 | <option value=\"all_feeds\">".__('All feeds')."</option>"; | |
391 | ||
392 | $feed_title = getFeedTitle($this->link, $active_feed_id); | |
393 | ||
394 | if (!$is_cat) { | |
395 | $feed_cat_title = getFeedCatTitle($this->link, $active_feed_id); | |
396 | } else { | |
397 | $feed_cat_title = getCategoryTitle($this->link, $active_feed_id); | |
398 | } | |
399 | ||
400 | if ($active_feed_id && !$is_cat) { | |
401 | print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>"; | |
402 | } else { | |
403 | print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>"; | |
404 | } | |
405 | ||
406 | if ($is_cat) { | |
407 | $cat_preselected = "selected=\"1\""; | |
408 | } | |
409 | ||
410 | if (get_pref($this->link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) { | |
411 | print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>"; | |
412 | } else { | |
413 | //print "<option disabled>".__('This category')."</option>"; | |
414 | } | |
415 | ||
416 | print "</select>"; | |
417 | ||
418 | print "</div>"; | |
419 | ||
420 | print "<div class=\"dlgButtons\">"; | |
421 | ||
422 | if (!SPHINX_ENABLED) { | |
423 | print "<div style=\"float : left\"> | |
424 | <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/redmine/wiki/tt-rss/SearchSyntax\">Search syntax</a> | |
425 | </div>"; | |
426 | } | |
427 | ||
428 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button> | |
429 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button> | |
430 | </div>"; | |
431 | } | |
432 | ||
433 | function quickAddFilter() { | |
434 | $active_feed_id = db_escape_string($_REQUEST["param"]); | |
435 | ||
436 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">"; | |
437 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">"; | |
438 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">"; | |
b69a09ea | 439 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">"; |
3f363052 AD |
440 | |
441 | $result = db_query($this->link, "SELECT id,description | |
442 | FROM ttrss_filter_types ORDER BY description"); | |
443 | ||
444 | $filter_types = array(); | |
445 | ||
446 | while ($line = db_fetch_assoc($result)) { | |
447 | //array_push($filter_types, $line["description"]); | |
448 | $filter_types[$line["id"]] = __($line["description"]); | |
449 | } | |
450 | ||
451 | print "<div class=\"dlgSec\">".__("Match")."</div>"; | |
452 | ||
453 | print "<div class=\"dlgSecCont\">"; | |
454 | ||
455 | print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">"; | |
456 | ||
457 | $filter_params = array( | |
458 | "before" => __("before"), | |
459 | "after" => __("after")); | |
460 | ||
461 | print_select_hash("filter_date_modifier", "before", | |
462 | $filter_params, 'dojoType="dijit.form.Select"'); | |
463 | ||
464 | print " </span>"; | |
465 | ||
466 | print "<input dojoType=\"dijit.form.ValidationTextBox\" | |
467 | required=\"true\" id=\"filterDlg_regExp\" | |
468 | style=\"font-size : 16px\" | |
469 | name=\"reg_exp\" value=\"$reg_exp\"/>"; | |
470 | ||
471 | print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">"; | |
472 | print " <button dojoType=\"dijit.form.Button\" | |
473 | onclick=\"return filterDlgCheckDate()\">". | |
474 | __('Check it')."</button>"; | |
475 | print "</span>"; | |
476 | ||
477 | print "<hr/>" . __("on field") . " "; | |
478 | print_select_hash("filter_type", 1, $filter_types, | |
479 | 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"'); | |
480 | ||
481 | print "<hr/>"; | |
482 | ||
483 | print __("in") . " "; | |
ba975b2e AD |
484 | |
485 | print "<span id='filterDlg_feeds'>"; | |
3f363052 AD |
486 | print_feed_select($this->link, "feed_id", $active_feed_id, |
487 | 'dojoType="dijit.form.FilteringSelect"'); | |
ba975b2e AD |
488 | print "</span>"; |
489 | ||
490 | print "<span id='filterDlg_cats' style='display : none'>"; | |
491 | print_feed_cat_select($this->link, "cat_id", $active_cat_id, | |
492 | 'dojoType="dijit.form.FilteringSelect"'); | |
493 | print "</span>"; | |
3f363052 AD |
494 | |
495 | print "</div>"; | |
496 | ||
497 | print "<div class=\"dlgSec\">".__("Perform Action")."</div>"; | |
498 | ||
499 | print "<div class=\"dlgSecCont\">"; | |
500 | ||
501 | print "<select name=\"action_id\" dojoType=\"dijit.form.Select\" | |
502 | onchange=\"filterDlgCheckAction(this)\">"; | |
503 | ||
504 | $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions | |
505 | ORDER BY name"); | |
506 | ||
507 | while ($line = db_fetch_assoc($result)) { | |
508 | printf("<option value='%d'>%s</option>", $line["id"], __($line["description"])); | |
509 | } | |
510 | ||
511 | print "</select>"; | |
512 | ||
513 | print "<span id=\"filterDlg_paramBox\" style=\"display : none\">"; | |
514 | print " " . __("with parameters:") . " "; | |
515 | print "<input dojoType=\"dijit.form.TextBox\" | |
516 | id=\"filterDlg_actionParam\" | |
517 | name=\"action_param\">"; | |
518 | ||
519 | print_label_select($this->link, "action_param_label", $action_param, | |
520 | 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"'); | |
521 | ||
522 | print "</span>"; | |
523 | ||
524 | print " "; // tiny layout hack | |
525 | ||
526 | print "</div>"; | |
527 | ||
528 | print "<div class=\"dlgSec\">".__("Options")."</div>"; | |
529 | print "<div class=\"dlgSecCont\">"; | |
530 | ||
531 | print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\"> | |
532 | <label for=\"enabled\">".__('Enabled')."</label><hr/>"; | |
533 | ||
534 | print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\"> | |
ba975b2e AD |
535 | <label for=\"inverse\">".__('Inverse match')."</label><hr/>"; |
536 | ||
537 | print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\"> | |
538 | <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>"; | |
539 | ||
3f363052 AD |
540 | |
541 | print "</div>"; | |
542 | ||
543 | print "<div class=\"dlgButtons\">"; | |
544 | ||
545 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">". | |
546 | __('Test')."</button> "; | |
547 | ||
548 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">". | |
549 | __('Create')."</button> "; | |
550 | ||
551 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">". | |
552 | __('Cancel')."</button>"; | |
553 | ||
554 | print "</div>"; | |
555 | } | |
556 | ||
557 | function inactiveFeeds() { | |
46da73c2 | 558 | |
3f363052 AD |
559 | if (DB_TYPE == "pgsql") { |
560 | $interval_qpart = "NOW() - INTERVAL '3 months'"; | |
561 | } else { | |
562 | $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)"; | |
563 | } | |
564 | ||
565 | $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url, | |
566 | ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article | |
567 | FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE | |
568 | (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE | |
569 | ttrss_entries.id = ref_id AND | |
570 | ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart | |
571 | AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND | |
572 | ttrss_user_entries.feed_id = ttrss_feeds.id AND | |
573 | ttrss_entries.id = ref_id | |
574 | GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url | |
575 | ORDER BY last_article"); | |
576 | ||
577 | print __("These feeds have not been updated with new content for 3 months (oldest first):"); | |
578 | ||
579 | print "<div class=\"inactiveFeedHolder\">"; | |
580 | ||
581 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">"; | |
582 | ||
583 | $lnum = 1; | |
584 | ||
585 | while ($line = db_fetch_assoc($result)) { | |
586 | ||
587 | $class = ($lnum % 2) ? "even" : "odd"; | |
588 | $feed_id = $line["id"]; | |
589 | $this_row_id = "id=\"FUPDD-$feed_id\""; | |
590 | ||
591 | print "<tr class=\"\" $this_row_id>"; | |
592 | ||
593 | $edit_title = htmlspecialchars($line["title"]); | |
594 | ||
595 | print "<td width='5%' align='center'><input | |
596 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
597 | type=\"checkbox\"></td>"; | |
598 | print "<td>"; | |
599 | ||
600 | print "<a class=\"visibleLink\" href=\"#\" ". | |
601 | "title=\"".__("Click to edit feed")."\" ". | |
602 | "onclick=\"editFeed(".$line["id"].")\">". | |
603 | htmlspecialchars($line["title"])."</a>"; | |
604 | ||
605 | print "</td><td class=\"insensitive\" align='right'>"; | |
606 | print make_local_datetime($this->link, $line['last_article'], false); | |
607 | print "</td>"; | |
608 | print "</tr>"; | |
609 | ||
610 | ++$lnum; | |
611 | } | |
612 | ||
613 | print "</table>"; | |
614 | print "</div>"; | |
615 | ||
616 | print "<div class='dlgButtons'>"; | |
617 | print "<div style='float : left'>"; | |
618 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">" | |
619 | .__('Unsubscribe from selected feeds')."</button> "; | |
620 | print "</div>"; | |
621 | ||
622 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">". | |
623 | __('Close this window')."</button>"; | |
624 | ||
625 | print "</div>"; | |
626 | ||
627 | } | |
628 | ||
629 | function feedsWithErrors() { | |
630 | print __("These feeds have not been updated because of errors:"); | |
631 | ||
632 | $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url | |
633 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]); | |
634 | ||
635 | print "<div class=\"inactiveFeedHolder\">"; | |
636 | ||
637 | print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">"; | |
638 | ||
639 | $lnum = 1; | |
640 | ||
641 | while ($line = db_fetch_assoc($result)) { | |
642 | ||
643 | $class = ($lnum % 2) ? "even" : "odd"; | |
644 | $feed_id = $line["id"]; | |
645 | $this_row_id = "id=\"FUPDD-$feed_id\""; | |
646 | ||
647 | print "<tr class=\"\" $this_row_id>"; | |
648 | ||
649 | $edit_title = htmlspecialchars($line["title"]); | |
650 | ||
651 | print "<td width='5%' align='center'><input | |
652 | onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" | |
653 | type=\"checkbox\"></td>"; | |
654 | print "<td>"; | |
655 | ||
656 | print "<a class=\"visibleLink\" href=\"#\" ". | |
657 | "title=\"".__("Click to edit feed")."\" ". | |
658 | "onclick=\"editFeed(".$line["id"].")\">". | |
659 | htmlspecialchars($line["title"])."</a>: "; | |
660 | ||
661 | print "<span class=\"insensitive\">"; | |
662 | print htmlspecialchars($line["last_error"]); | |
663 | print "</span>"; | |
664 | ||
665 | print "</td>"; | |
666 | print "</tr>"; | |
667 | ||
668 | ++$lnum; | |
669 | } | |
670 | ||
671 | print "</table>"; | |
672 | print "</div>"; | |
673 | ||
674 | print "<div class='dlgButtons'>"; | |
675 | print "<div style='float : left'>"; | |
676 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">" | |
677 | .__('Unsubscribe from selected feeds')."</button> "; | |
678 | print "</div>"; | |
679 | ||
680 | print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">". | |
681 | __('Close this window')."</button>"; | |
682 | ||
683 | print "</div>"; | |
684 | } | |
685 | ||
686 | function editArticleTags() { | |
687 | ||
688 | print __("Tags for this article (separated by commas):")."<br>"; | |
689 | ||
690 | $tags = get_article_tags($this->link, $this->param); | |
691 | ||
692 | $tags_str = join(", ", $tags); | |
693 | ||
694 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">"; | |
695 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">"; | |
696 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">"; | |
697 | ||
698 | print "<table width='100%'><tr><td>"; | |
699 | ||
700 | print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4' | |
701 | style='font-size : 12px; width : 100%' id=\"tags_str\" | |
702 | name='tags_str'>$tags_str</textarea> | |
703 | <div class=\"autocomplete\" id=\"tags_choices\" | |
704 | style=\"display:none\"></div>"; | |
705 | ||
706 | print "</td></tr></table>"; | |
707 | ||
708 | print "<div class='dlgButtons'>"; | |
709 | ||
710 | print "<button dojoType=\"dijit.form.Button\" | |
711 | onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> "; | |
712 | print "<button dojoType=\"dijit.form.Button\" | |
713 | onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>"; | |
714 | print "</div>"; | |
715 | ||
716 | } | |
717 | ||
718 | function printTagCloud() { | |
719 | print "<title>".__('Tag Cloud')."</title>"; | |
720 | print "<content><![CDATA["; | |
721 | ||
722 | print "<div class=\"tagCloudContainer\">"; | |
723 | ||
79178062 AD |
724 | // from here: http://www.roscripts.com/Create_tag_cloud-71.html |
725 | ||
726 | $query = "SELECT tag_name, COUNT(post_int_id) AS count | |
727 | FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]." | |
728 | GROUP BY tag_name ORDER BY count DESC LIMIT 50"; | |
729 | ||
730 | $result = db_query($this->link, $query); | |
731 | ||
732 | $tags = array(); | |
733 | ||
734 | while ($line = db_fetch_assoc($result)) { | |
735 | $tags[$line["tag_name"]] = $line["count"]; | |
736 | } | |
737 | ||
738 | if( count($tags) == 0 ){ return; } | |
739 | ||
740 | ksort($tags); | |
741 | ||
742 | $max_size = 32; // max font size in pixels | |
743 | $min_size = 11; // min font size in pixels | |
744 | ||
745 | // largest and smallest array values | |
746 | $max_qty = max(array_values($tags)); | |
747 | $min_qty = min(array_values($tags)); | |
748 | ||
749 | // find the range of values | |
750 | $spread = $max_qty - $min_qty; | |
751 | if ($spread == 0) { // we don't want to divide by zero | |
752 | $spread = 1; | |
753 | } | |
754 | ||
755 | // set the font-size increment | |
756 | $step = ($max_size - $min_size) / ($spread); | |
757 | ||
758 | // loop through the tag array | |
759 | foreach ($tags as $key => $value) { | |
760 | // calculate font-size | |
761 | // find the $value in excess of $min_qty | |
762 | // multiply by the font-size increment ($size) | |
763 | // and add the $min_size set above | |
764 | $size = round($min_size + (($value - $min_qty) * $step)); | |
765 | ||
766 | $key_escaped = str_replace("'", "\\'", $key); | |
767 | ||
768 | echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " . | |
769 | $size . "px\" title=\"$value articles tagged with " . | |
770 | $key . '">' . $key . '</a> '; | |
771 | } | |
772 | ||
773 | ||
3f363052 AD |
774 | |
775 | print "</div>"; | |
776 | ||
777 | print "<div align='center'>"; | |
778 | print "<button dojoType=\"dijit.form.Button\" | |
779 | onclick=\"return closeInfoBox()\">". | |
780 | __('Close this window')."</button>"; | |
781 | print "</div>"; | |
782 | ||
783 | print "]]></content>"; | |
784 | } | |
785 | ||
786 | function printTagSelect() { | |
46da73c2 | 787 | |
3f363052 AD |
788 | print "<title>" . __('Select item(s) by tags') . "</title>"; |
789 | print "<content><![CDATA["; | |
790 | ||
791 | print __("Match:"). " " . | |
792 | "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\"> Any "; | |
793 | print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\"> All "; | |
794 | print " tags."; | |
795 | ||
796 | print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">"; | |
797 | $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']." | |
798 | AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC"); | |
799 | ||
800 | while ($row = db_fetch_assoc($result)) { | |
801 | $tmp = htmlspecialchars($row["tag_name"]); | |
802 | print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>"; | |
803 | } | |
804 | ||
805 | print "</select>"; | |
806 | ||
807 | print "<div align='right'>"; | |
808 | print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')), | |
809 | get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>"; | |
810 | print " "; | |
811 | print "<button dojoType=\"dijit.form.Button\" | |
812 | onclick=\"return closeInfoBox()\">" . | |
813 | __('Close this window') . "</button>"; | |
814 | print "</div>"; | |
815 | ||
816 | print "]]></content>"; | |
817 | } | |
818 | ||
3f363052 | 819 | function generatedFeed() { |
46da73c2 | 820 | |
3f363052 AD |
821 | print "<title>".__('View as RSS')."</title>"; |
822 | print "<content><![CDATA["; | |
823 | ||
824 | $this->params = explode(":", $this->param, 3); | |
825 | $feed_id = db_escape_string($this->params[0]); | |
826 | $is_cat = (bool) $this->params[1]; | |
827 | ||
828 | $key = get_feed_access_key($this->link, $feed_id, $is_cat); | |
829 | ||
830 | $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key; | |
831 | ||
832 | print __("You can view this feed as RSS using the following URL:"); | |
833 | ||
834 | print "<div class=\"tagCloudContainer\">"; | |
835 | print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>"; | |
836 | print "</div>"; | |
837 | ||
838 | print "<div align='center'>"; | |
839 | ||
840 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">". | |
841 | __('Generate new URL')."</button> "; | |
842 | ||
843 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">". | |
844 | __('Close this window')."</button>"; | |
845 | ||
846 | print "</div>"; | |
847 | print "]]></content>"; | |
848 | ||
849 | //return; | |
850 | } | |
851 | ||
852 | function newVersion() { | |
46da73c2 | 853 | |
3f363052 AD |
854 | $version_data = check_for_update($this->link); |
855 | $version = $version_data['version']; | |
856 | $id = $version_data['version_id']; | |
857 | ||
858 | print "<div class='tagCloudContainer'>"; | |
859 | ||
860 | print T_sprintf("New version of Tiny Tiny RSS is available (%s).", | |
861 | "<b>$version</b>"); | |
862 | ||
863 | print "</div>"; | |
864 | ||
865 | $details = "http://tt-rss.org/redmine/versions/show/$id"; | |
866 | $download = "http://tt-rss.org/#Download"; | |
867 | ||
868 | print "<div style='text-align : center'>"; | |
869 | print "<button dojoType=\"dijit.form.Button\" | |
870 | onclick=\"return window.open('$details')\">".__("Details")."</button>"; | |
871 | print "<button dojoType=\"dijit.form.Button\" | |
872 | onclick=\"return window.open('$download')\">".__("Download")."</button>"; | |
873 | print "<button dojoType=\"dijit.form.Button\" | |
874 | onclick=\"return dijit.byId('newVersionDlg').hide()\">". | |
875 | __('Close this window')."</button>"; | |
876 | print "</div>"; | |
877 | ||
878 | } | |
879 | ||
880 | function customizeCSS() { | |
881 | $value = get_pref($this->link, "USER_STYLESHEET"); | |
882 | ||
883 | $value = str_replace("<br/>", "\n", $value); | |
884 | ||
885 | print T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "tt-rss.css"); | |
886 | ||
887 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">"; | |
888 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">"; | |
889 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">"; | |
890 | ||
891 | print "<table width='100%'><tr><td>"; | |
892 | print "<textarea dojoType=\"dijit.form.SimpleTextarea\" | |
893 | style='font-size : 12px; width : 100%; height: 200px;' | |
894 | placeHolder='body#ttrssMain { font-size : 14px; };' | |
895 | name='value'>$value</textarea>"; | |
896 | print "</td></tr></table>"; | |
897 | ||
898 | print "<div class='dlgButtons'>"; | |
899 | print "<button dojoType=\"dijit.form.Button\" | |
900 | onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> "; | |
901 | print "<button dojoType=\"dijit.form.Button\" | |
902 | onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>"; | |
903 | print "</div>"; | |
904 | ||
905 | } | |
906 | ||
3f363052 AD |
907 | function addInstance() { |
908 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">"; | |
909 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">"; | |
910 | ||
911 | print "<div class=\"dlgSec\">".__("Instance")."</div>"; | |
912 | ||
913 | print "<div class=\"dlgSecCont\">"; | |
914 | ||
915 | /* URL */ | |
916 | ||
917 | print __("URL:") . " "; | |
918 | ||
919 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" | |
920 | placeHolder=\"".__("Instance URL")."\" | |
921 | regExp='^(http|https)://.*' | |
922 | style=\"font-size : 16px; width: 20em\" name=\"access_url\">"; | |
923 | ||
924 | print "<hr/>"; | |
925 | ||
926 | $access_key = sha1(uniqid(rand(), true)); | |
927 | ||
928 | /* Access key */ | |
929 | ||
930 | print __("Access key:") . " "; | |
931 | ||
932 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" | |
933 | placeHolder=\"".__("Access key")."\" regExp='\w{40}' | |
934 | style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\" | |
935 | value=\"$access_key\">"; | |
936 | ||
937 | print "<p class='insensitive'>" . __("Use one access key for both linked instances."); | |
938 | ||
939 | print "</div>"; | |
940 | ||
941 | print "<div class=\"dlgButtons\"> | |
942 | <div style='float : left'> | |
943 | <button dojoType=\"dijit.form.Button\" | |
944 | onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">". | |
945 | __('Generate new key')."</button> | |
946 | </div> | |
947 | <button dojoType=\"dijit.form.Button\" | |
948 | onclick=\"return dijit.byId('instanceAddDlg').execute()\">". | |
949 | __('Create link')."</button> | |
950 | <button dojoType=\"dijit.form.Button\" | |
951 | onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">". | |
952 | __('Cancel')."</button></div>"; | |
953 | ||
954 | return; | |
955 | } | |
956 | ||
55f34b81 AD |
957 | function dataImport() { |
958 | header("Content-Type: text/html"); # required for iframe | |
959 | ||
960 | print "<div style='text-align : center'>"; | |
961 | ||
962 | if (is_file($_FILES['export_file']['tmp_name'])) { | |
963 | ||
964 | perform_data_import($this->link, $_FILES['export_file']['tmp_name'], $_SESSION['uid']); | |
965 | ||
966 | } else { | |
967 | print "<p>" . T_sprintf("Could not upload file. You might need to adjust upload_max_filesize | |
968 | in PHP.ini (current value = %s)", ini_get("upload_max_filesize")) . " or use CLI import tool.</p>"; | |
969 | ||
970 | } | |
971 | ||
972 | print "<button dojoType=\"dijit.form.Button\" | |
973 | onclick=\"dijit.byId('dataImportDlg').hide()\">". | |
974 | __('Close this window')."</button>"; | |
975 | ||
976 | print "</div>"; | |
977 | ||
978 | } | |
979 | ||
3f363052 AD |
980 | } |
981 | ?> |