2 class Dlg extends Protected_Handler {
6 if (parent::before()) {
7 header("Content-Type: text/xml; charset=utf-8");
8 $this->param = db_escape_string($_REQUEST["param"]);
19 function exportData() {
21 print "<p style='text-align : center' id='export_status_message'>You need to prepare exported data first by clicking the button below.</p>";
23 print "<div align='center'>";
24 print "<button dojoType=\"dijit.form.Button\"
25 onclick=\"dijit.byId('dataExportDlg').prepare()\">".
26 __('Prepare data')."</button>";
28 print "<button dojoType=\"dijit.form.Button\"
29 onclick=\"dijit.byId('dataExportDlg').hide()\">".
30 __('Close this window')."</button>";
37 function importOpml() {
38 header("Content-Type: text/html"); # required for iframe
40 print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
42 print "<div class=\"prefFeedOPMLHolder\">";
43 $owner_uid = $_SESSION["uid"];
45 db_query($this->link, "BEGIN");
47 /* create Imported feeds category just in case */
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");
53 if (db_num_rows($result) == 0) {
54 db_query($this->link, "INSERT INTO ttrss_feed_categories
56 VALUES ('Imported feeds', '$owner_uid')");
59 db_query($this->link, "COMMIT");
61 /* Handle OPML import by DOMXML/DOMDocument */
63 print "<ul class='nomarks'>";
64 require_once "opml.php";
65 opml_import_domdoc($this->link, $owner_uid);
69 print "<div align='center'>";
70 print "<button dojoType=\"dijit.form.Button\"
71 onclick=\"dijit.byId('opmlImportDlg').execute()\">".
72 __('Close this window')."</button>";
80 function editPrefProfiles() {
81 print "<div dojoType=\"dijit.Toolbar\">";
83 print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
85 <button dojoType=\"dijit.form.Button\"
86 onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
87 __('Create profile')."</button></div>";
89 $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
90 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
92 print "<div class=\"prefFeedCatHolder\">";
94 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
96 print "<table width=\"100%\" class=\"prefFeedProfileList\"
97 cellspacing=\"0\" id=\"prefFeedProfileList\">";
99 print "<tr class=\"\" id=\"FCATR-0\">"; #odd
101 print "<td width='5%' align='center'><input
102 onclick='toggleSelectRow2(this);'
103 dojoType=\"dijit.form.CheckBox\"
104 type=\"checkbox\"></td>";
106 if (!$_SESSION["profile"]) {
107 $is_active = __("(active)");
113 __("Default profile") . " $is_active</span></td>";
119 while ($line = db_fetch_assoc($result)) {
121 $class = ($lnum % 2) ? "even" : "odd";
123 $profile_id = $line["id"];
124 $this_row_id = "id=\"FCATR-$profile_id\"";
126 print "<tr class=\"\" $this_row_id>";
128 $edit_title = htmlspecialchars($line["title"]);
130 print "<td width='5%' align='center'><input
131 onclick='toggleSelectRow2(this);'
132 dojoType=\"dijit.form.CheckBox\"
133 type=\"checkbox\"></td>";
135 if ($_SESSION["profile"] == $line["id"]) {
136 $is_active = __("(active)");
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\">
148 content: {op: 'rpc', method: 'saveprofile',
150 id: this.srcNodeRef.getAttribute('profile-id')},
151 load: function(response) {
152 elem.attr('value', response);
156 </span> $is_active</td>";
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>
175 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">".
176 __('Close this window')."</button>";
181 function pubOPMLUrl() {
182 print "<title>".__('Public OPML URL')."</title>";
183 print "<content><![CDATA[";
185 $url_path = opml_publish_url($this->link);
187 print __("Your Public OPML URL is:");
189 print "<div class=\"tagCloudContainer\">";
190 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
193 print "<div align='center'>";
195 print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
196 __('Generate new URL')."</button> ";
198 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
199 __('Close this window')."</button>";
202 print "]]></content>";
207 function explainError() {
208 print "<title>".__('Notice')."</title>";
209 print "<content><![CDATA[";
211 print "<div class=\"errorExplained\">";
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.");
216 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
218 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
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.");
225 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
227 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
233 print "<div align='center'>";
235 print "<button onclick=\"return closeInfoBox()\">".
236 __('Close this window')."</button>";
239 print "]]></content>";
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\">";
248 print "<div class=\"dlgSec\">".__("Feed")."</div>";
249 print "<div class=\"dlgSecCont\">";
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\">";
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"');
264 print '<div id="feedDlg_feedsContainer" style="display : none">
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);
276 print "<div id='feedDlg_loginContainer' style='display : none'>
278 <div class=\"dlgSec\">".__("Authentication")."</div>
279 <div class=\"dlgSecCont\">".
281 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
282 placeHolder=\"".__("Login")."\"
283 style=\"width : 10em;\"> ".
285 placeHolder=\"".__("Password")."\"
286 dojoType=\"dijit.form.TextBox\" type='password'
287 style=\"width : 10em;\" name='pass'\">".
288 " <p class='insensitive'>".__("OAuth will be used automatically for Twitter feeds.")."</p>
292 print "<div style=\"clear : both\">
293 <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
294 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
295 <label for=\"feedDlg_loginCheck\">".
296 __('This feed requires authentication.')."</div>";
300 print "<div class=\"dlgButtons\">
301 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>
302 <button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>
303 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
309 function feedBrowser() {
310 $browser_search = db_escape_string($_REQUEST["search"]);
312 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
313 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
315 print "<div dojoType=\"dijit.Toolbar\">
316 <div style='float : right'>
317 <img style='display : none'
318 id='feed_browser_spinner' src='".
319 theme_image($this->link, 'images/indicator_white.gif')."'>
320 <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
321 onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
322 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
325 print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
326 <option value='1'>" . __('Popular feeds') . "</option>
327 <option value='2'>" . __('Feed archive') . "</option>
332 print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
334 foreach (array(25, 50, 100, 200) as $l) {
335 $issel = ($l == $limit) ? "selected=\"1\"" : "";
336 print "<option $issel value=\"$l\">$l</option>";
343 $owner_uid = $_SESSION["uid"];
345 print "<ul class='browseFeedList' id='browseFeedList'>";
346 print make_feed_browser($this->link, $search, 25);
349 print "<div align='center'>
350 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
351 <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
352 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
357 $this->params = explode(":", db_escape_string($_REQUEST["param"]), 2);
359 $active_feed_id = sprintf("%d", $this->params[0]);
360 $is_cat = $this->params[1] != "false";
362 print "<div class=\"dlgSec\">".__('Look for')."</div>";
364 print "<div class=\"dlgSecCont\">";
366 if (!SPHINX_ENABLED) {
368 print "<input dojoType=\"dijit.form.ValidationTextBox\"
369 style=\"font-size : 16px; width : 12em;\"
370 required=\"1\" name=\"query\" type=\"search\" value=''>";
372 print " " . __('match on')." ";
374 $search_fields = array(
375 "title" => __("Title"),
376 "content" => __("Content"),
377 "both" => __("Title or content"));
379 print_select_hash("match_on", 3, $search_fields,
380 'dojoType="dijit.form.Select"');
382 print "<input dojoType=\"dijit.form.ValidationTextBox\"
383 style=\"font-size : 16px; width : 20em;\"
384 required=\"1\" name=\"query\" type=\"search\" value=''>";
388 print "<hr/>".__('Limit search to:')." ";
390 print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
391 <option value=\"all_feeds\">".__('All feeds')."</option>";
393 $feed_title = getFeedTitle($this->link, $active_feed_id);
396 $feed_cat_title = getFeedCatTitle($this->link, $active_feed_id);
398 $feed_cat_title = getCategoryTitle($this->link, $active_feed_id);
401 if ($active_feed_id && !$is_cat) {
402 print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
404 print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
408 $cat_preselected = "selected=\"1\"";
411 if (get_pref($this->link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
412 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
414 //print "<option disabled>".__('This category')."</option>";
421 print "<div class=\"dlgButtons\">";
423 if (!SPHINX_ENABLED) {
424 print "<div style=\"float : left\">
425 <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/redmine/wiki/tt-rss/SearchSyntax\">Search syntax</a>
429 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
430 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
434 function quickAddFilter() {
435 $active_feed_id = db_escape_string($_REQUEST["param"]);
437 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
438 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">";
439 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
440 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
442 $result = db_query($this->link, "SELECT id,description
443 FROM ttrss_filter_types ORDER BY description");
445 $filter_types = array();
447 while ($line = db_fetch_assoc($result)) {
448 //array_push($filter_types, $line["description"]);
449 $filter_types[$line["id"]] = __($line["description"]);
452 print "<div class=\"dlgSec\">".__("Match")."</div>";
454 print "<div class=\"dlgSecCont\">";
456 print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">";
458 $filter_params = array(
459 "before" => __("before"),
460 "after" => __("after"));
462 print_select_hash("filter_date_modifier", "before",
463 $filter_params, 'dojoType="dijit.form.Select"');
465 print " </span>";
467 print "<input dojoType=\"dijit.form.ValidationTextBox\"
468 required=\"true\" id=\"filterDlg_regExp\"
469 style=\"font-size : 16px\"
470 name=\"reg_exp\" value=\"$reg_exp\"/>";
472 print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">";
473 print " <button dojoType=\"dijit.form.Button\"
474 onclick=\"return filterDlgCheckDate()\">".
475 __('Check it')."</button>";
478 print "<hr/>" . __("on field") . " ";
479 print_select_hash("filter_type", 1, $filter_types,
480 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
484 print __("in") . " ";
486 print "<span id='filterDlg_feeds'>";
487 print_feed_select($this->link, "feed_id", $active_feed_id,
488 'dojoType="dijit.form.FilteringSelect"');
491 print "<span id='filterDlg_cats' style='display : none'>";
492 print_feed_cat_select($this->link, "cat_id", $active_cat_id,
493 'dojoType="dijit.form.FilteringSelect"');
498 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
500 print "<div class=\"dlgSecCont\">";
502 print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
503 onchange=\"filterDlgCheckAction(this)\">";
505 $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions
508 while ($line = db_fetch_assoc($result)) {
509 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
514 print "<span id=\"filterDlg_paramBox\" style=\"display : none\">";
515 print " " . __("with parameters:") . " ";
516 print "<input dojoType=\"dijit.form.TextBox\"
517 id=\"filterDlg_actionParam\"
518 name=\"action_param\">";
520 print_label_select($this->link, "action_param_label", $action_param,
521 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
525 print " "; // tiny layout hack
529 print "<div class=\"dlgSec\">".__("Options")."</div>";
530 print "<div class=\"dlgSecCont\">";
532 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
533 <label for=\"enabled\">".__('Enabled')."</label><hr/>";
535 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
536 <label for=\"inverse\">".__('Inverse match')."</label><hr/>";
538 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\">
539 <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
544 print "<div class=\"dlgButtons\">";
546 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
547 __('Test')."</button> ";
549 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
550 __('Create')."</button> ";
552 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
553 __('Cancel')."</button>";
558 function inactiveFeeds() {
560 if (DB_TYPE == "pgsql") {
561 $interval_qpart = "NOW() - INTERVAL '3 months'";
563 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
566 $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
567 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
568 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
569 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
570 ttrss_entries.id = ref_id AND
571 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
572 AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND
573 ttrss_user_entries.feed_id = ttrss_feeds.id AND
574 ttrss_entries.id = ref_id
575 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
576 ORDER BY last_article");
578 print __("These feeds have not been updated with new content for 3 months (oldest first):");
580 print "<div class=\"inactiveFeedHolder\">";
582 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
586 while ($line = db_fetch_assoc($result)) {
588 $class = ($lnum % 2) ? "even" : "odd";
589 $feed_id = $line["id"];
590 $this_row_id = "id=\"FUPDD-$feed_id\"";
592 print "<tr class=\"\" $this_row_id>";
594 $edit_title = htmlspecialchars($line["title"]);
596 print "<td width='5%' align='center'><input
597 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
598 type=\"checkbox\"></td>";
601 print "<a class=\"visibleLink\" href=\"#\" ".
602 "title=\"".__("Click to edit feed")."\" ".
603 "onclick=\"editFeed(".$line["id"].")\">".
604 htmlspecialchars($line["title"])."</a>";
606 print "</td><td class=\"insensitive\" align='right'>";
607 print make_local_datetime($this->link, $line['last_article'], false);
617 print "<div class='dlgButtons'>";
618 print "<div style='float : left'>";
619 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
620 .__('Unsubscribe from selected feeds')."</button> ";
623 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">".
624 __('Close this window')."</button>";
630 function feedsWithErrors() {
631 print __("These feeds have not been updated because of errors:");
633 $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
634 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
636 print "<div class=\"inactiveFeedHolder\">";
638 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
642 while ($line = db_fetch_assoc($result)) {
644 $class = ($lnum % 2) ? "even" : "odd";
645 $feed_id = $line["id"];
646 $this_row_id = "id=\"FUPDD-$feed_id\"";
648 print "<tr class=\"\" $this_row_id>";
650 $edit_title = htmlspecialchars($line["title"]);
652 print "<td width='5%' align='center'><input
653 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
654 type=\"checkbox\"></td>";
657 print "<a class=\"visibleLink\" href=\"#\" ".
658 "title=\"".__("Click to edit feed")."\" ".
659 "onclick=\"editFeed(".$line["id"].")\">".
660 htmlspecialchars($line["title"])."</a>: ";
662 print "<span class=\"insensitive\">";
663 print htmlspecialchars($line["last_error"]);
675 print "<div class='dlgButtons'>";
676 print "<div style='float : left'>";
677 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
678 .__('Unsubscribe from selected feeds')."</button> ";
681 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
682 __('Close this window')."</button>";
687 function editArticleTags() {
689 print __("Tags for this article (separated by commas):")."<br>";
691 $tags = get_article_tags($this->link, $this->param);
693 $tags_str = join(", ", $tags);
695 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">";
696 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
697 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
699 print "<table width='100%'><tr><td>";
701 print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
702 style='font-size : 12px; width : 100%' id=\"tags_str\"
703 name='tags_str'>$tags_str</textarea>
704 <div class=\"autocomplete\" id=\"tags_choices\"
705 style=\"display:none\"></div>";
707 print "</td></tr></table>";
709 print "<div class='dlgButtons'>";
711 print "<button dojoType=\"dijit.form.Button\"
712 onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> ";
713 print "<button dojoType=\"dijit.form.Button\"
714 onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>";
719 function printTagCloud() {
720 print "<title>".__('Tag Cloud')."</title>";
721 print "<content><![CDATA[";
723 print "<div class=\"tagCloudContainer\">";
725 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
727 $query = "SELECT tag_name, COUNT(post_int_id) AS count
728 FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
729 GROUP BY tag_name ORDER BY count DESC LIMIT 50";
731 $result = db_query($this->link, $query);
735 while ($line = db_fetch_assoc($result)) {
736 $tags[$line["tag_name"]] = $line["count"];
739 if( count($tags) == 0 ){ return; }
743 $max_size = 32; // max font size in pixels
744 $min_size = 11; // min font size in pixels
746 // largest and smallest array values
747 $max_qty = max(array_values($tags));
748 $min_qty = min(array_values($tags));
750 // find the range of values
751 $spread = $max_qty - $min_qty;
752 if ($spread == 0) { // we don't want to divide by zero
756 // set the font-size increment
757 $step = ($max_size - $min_size) / ($spread);
759 // loop through the tag array
760 foreach ($tags as $key => $value) {
761 // calculate font-size
762 // find the $value in excess of $min_qty
763 // multiply by the font-size increment ($size)
764 // and add the $min_size set above
765 $size = round($min_size + (($value - $min_qty) * $step));
767 $key_escaped = str_replace("'", "\\'", $key);
769 echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " .
770 $size . "px\" title=\"$value articles tagged with " .
771 $key . '">' . $key . '</a> ';
778 print "<div align='center'>";
779 print "<button dojoType=\"dijit.form.Button\"
780 onclick=\"return closeInfoBox()\">".
781 __('Close this window')."</button>";
784 print "]]></content>";
787 function printTagSelect() {
789 print "<title>" . __('Select item(s) by tags') . "</title>";
790 print "<content><![CDATA[";
792 print __("Match:"). " " .
793 "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\"> Any ";
794 print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\"> All ";
797 print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
798 $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
799 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
801 while ($row = db_fetch_assoc($result)) {
802 $tmp = htmlspecialchars($row["tag_name"]);
803 print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
808 print "<div align='right'>";
809 print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
810 get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
812 print "<button dojoType=\"dijit.form.Button\"
813 onclick=\"return closeInfoBox()\">" .
814 __('Close this window') . "</button>";
817 print "]]></content>";
820 function generatedFeed() {
822 print "<title>".__('View as RSS')."</title>";
823 print "<content><![CDATA[";
825 $this->params = explode(":", $this->param, 3);
826 $feed_id = db_escape_string($this->params[0]);
827 $is_cat = (bool) $this->params[1];
829 $key = get_feed_access_key($this->link, $feed_id, $is_cat);
831 $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
833 print __("You can view this feed as RSS using the following URL:");
835 print "<div class=\"tagCloudContainer\">";
836 print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
839 print "<div align='center'>";
841 print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
842 __('Generate new URL')."</button> ";
844 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
845 __('Close this window')."</button>";
848 print "]]></content>";
853 function newVersion() {
855 $version_data = check_for_update($this->link);
856 $version = $version_data['version'];
857 $id = $version_data['version_id'];
859 print "<div class='tagCloudContainer'>";
861 print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
866 $details = "http://tt-rss.org/redmine/versions/show/$id";
867 $download = "http://tt-rss.org/#Download";
869 print "<div style='text-align : center'>";
870 print "<button dojoType=\"dijit.form.Button\"
871 onclick=\"return window.open('$details')\">".__("Details")."</button>";
872 print "<button dojoType=\"dijit.form.Button\"
873 onclick=\"return window.open('$download')\">".__("Download")."</button>";
874 print "<button dojoType=\"dijit.form.Button\"
875 onclick=\"return dijit.byId('newVersionDlg').hide()\">".
876 __('Close this window')."</button>";
881 function customizeCSS() {
882 $value = get_pref($this->link, "USER_STYLESHEET");
884 $value = str_replace("<br/>", "\n", $value);
886 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");
888 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
889 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
890 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
892 print "<table width='100%'><tr><td>";
893 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
894 style='font-size : 12px; width : 100%; height: 200px;'
895 placeHolder='body#ttrssMain { font-size : 14px; };'
896 name='value'>$value</textarea>";
897 print "</td></tr></table>";
899 print "<div class='dlgButtons'>";
900 print "<button dojoType=\"dijit.form.Button\"
901 onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
902 print "<button dojoType=\"dijit.form.Button\"
903 onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
908 function addInstance() {
909 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
910 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
912 print "<div class=\"dlgSec\">".__("Instance")."</div>";
914 print "<div class=\"dlgSecCont\">";
918 print __("URL:") . " ";
920 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
921 placeHolder=\"".__("Instance URL")."\"
922 regExp='^(http|https)://.*'
923 style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
927 $access_key = sha1(uniqid(rand(), true));
931 print __("Access key:") . " ";
933 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
934 placeHolder=\"".__("Access key")."\" regExp='\w{40}'
935 style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
936 value=\"$access_key\">";
938 print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
942 print "<div class=\"dlgButtons\">
943 <div style='float : left'>
944 <button dojoType=\"dijit.form.Button\"
945 onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
946 __('Generate new key')."</button>
948 <button dojoType=\"dijit.form.Button\"
949 onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
950 __('Create link')."</button>
951 <button dojoType=\"dijit.form.Button\"
952 onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
953 __('Cancel')."</button></div>";
958 function dataImport() {
959 header("Content-Type: text/html"); # required for iframe
961 print "<div style='text-align : center'>";
963 if (is_file($_FILES['export_file']['tmp_name'])) {
965 perform_data_import($this->link, $_FILES['export_file']['tmp_name'], $_SESSION['uid']);
968 print "<p>" . T_sprintf("Could not upload file. You might need to adjust upload_max_filesize
969 in PHP.ini (current value = %s)", ini_get("upload_max_filesize")) . " or use CLI import tool.</p>";
973 print "<button dojoType=\"dijit.form.Button\"
974 onclick=\"dijit.byId('dataImportDlg').hide()\">".
975 __('Close this window')."</button>";