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