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