codysnider /
tt-rss
| 1 | <?php |
||
| 2 | class Dlg extends Handler_Protected { |
||
| 3 | private $param; |
||
| 4 | private $params; |
||
| 5 | |||
| 6 | function before($method) { |
||
| 7 | if (parent::before($method)) { |
||
| 8 | header("Content-Type: text/html"); # required for iframe |
||
| 9 | |||
| 10 | $this->param = $_REQUEST["param"]; |
||
| 11 | return true; |
||
| 12 | } |
||
| 13 | return false; |
||
| 14 | } |
||
| 15 | |||
| 16 | public function importOpml() { |
||
| 17 | print_notice("If you have imported labels and/or filters, you might need to reload preferences to see your new data."); |
||
| 18 | |||
| 19 | print "<div class='panel panel-scrollable'>"; |
||
| 20 | |||
| 21 | $opml = new Opml($_REQUEST); |
||
| 22 | |||
| 23 | $opml->opml_import($_SESSION["uid"]); |
||
| 24 | |||
| 25 | print "</div>"; |
||
| 26 | |||
| 27 | print "<footer class='text-center'>"; |
||
| 28 | print "<button dojoType='dijit.form.Button' |
||
| 29 | onclick=\"dijit.byId('opmlImportDlg').execute()\">". |
||
| 30 | __('Close this window')."</button>"; |
||
| 31 | print "</footer>"; |
||
| 32 | |||
| 33 | print "</div>"; |
||
| 34 | |||
| 35 | //return; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function pubOPMLUrl() { |
||
| 39 | $url_path = Opml::opml_publish_url(); |
||
| 40 | |||
| 41 | print "<header>".__("Your Public OPML URL is:")."</header>"; |
||
| 42 | |||
| 43 | print "<section>"; |
||
| 44 | |||
| 45 | print "<div class='panel text-center'>"; |
||
| 46 | print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>"; |
||
| 47 | print "</div>"; |
||
| 48 | |||
| 49 | print "</section>"; |
||
| 50 | |||
| 51 | print "<footer class='text-center'>"; |
||
| 52 | |||
| 53 | print "<button dojoType='dijit.form.Button' onclick=\"return Helpers.OPML.changeKey()\">". |
||
| 54 | __('Generate new URL')."</button> "; |
||
| 55 | |||
| 56 | print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">". |
||
| 57 | __('Close this window')."</button>"; |
||
| 58 | |||
| 59 | print "</footer>"; |
||
| 60 | |||
| 61 | //return; |
||
| 62 | } |
||
| 63 | |||
| 64 | public function explainError() { |
||
| 65 | print "<div class=\"errorExplained\">"; |
||
| 66 | |||
| 67 | if ($this->param == 1) { |
||
| 68 | 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."); |
||
| 69 | |||
| 70 | $stamp = (int) file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp"); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 71 | |||
| 72 | print "<p>".__("Last update:")." ".date("Y.m.d, G:i", $stamp); |
||
| 73 | |||
| 74 | } |
||
| 75 | |||
| 76 | if ($this->param == 3) { |
||
| 77 | 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."); |
||
| 78 | |||
| 79 | $stamp = (int) file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp"); |
||
| 80 | |||
| 81 | print "<p>".__("Last update:")." ".date("Y.m.d, G:i", $stamp); |
||
| 82 | |||
| 83 | } |
||
| 84 | |||
| 85 | print "</div>"; |
||
| 86 | |||
| 87 | print "<footer class='text-center'>"; |
||
| 88 | print "<button onclick=\"return CommonDialogs.closeInfoBox()\">". |
||
| 89 | __('Close this window')."</button>"; |
||
| 90 | print "</footer>"; |
||
| 91 | |||
| 92 | //return; |
||
| 93 | } |
||
| 94 | |||
| 95 | public function printTagCloud() { |
||
| 96 | print "<div class='panel text-center'>"; |
||
| 97 | |||
| 98 | // from here: http://www.roscripts.com/Create_tag_cloud-71.html |
||
| 99 | |||
| 100 | $sth = $this->pdo->prepare("SELECT tag_name, COUNT(post_int_id) AS count |
||
| 101 | FROM ttrss_tags WHERE owner_uid = ? |
||
| 102 | GROUP BY tag_name ORDER BY count DESC LIMIT 50"); |
||
| 103 | $sth->execute([$_SESSION['uid']]); |
||
| 104 | |||
| 105 | $tags = array(); |
||
| 106 | |||
| 107 | while ($line = $sth->fetch()) { |
||
| 108 | $tags[$line["tag_name"]] = $line["count"]; |
||
| 109 | } |
||
| 110 | |||
| 111 | if (count($tags) == 0) { return; } |
||
| 112 | |||
| 113 | ksort($tags); |
||
| 114 | |||
| 115 | $max_size = 32; // max font size in pixels |
||
| 116 | $min_size = 11; // min font size in pixels |
||
| 117 | |||
| 118 | // largest and smallest array values |
||
| 119 | $max_qty = max(array_values($tags)); |
||
| 120 | $min_qty = min(array_values($tags)); |
||
| 121 | |||
| 122 | // find the range of values |
||
| 123 | $spread = $max_qty - $min_qty; |
||
| 124 | if ($spread == 0) { // we don't want to divide by zero |
||
| 125 | $spread = 1; |
||
| 126 | } |
||
| 127 | |||
| 128 | // set the font-size increment |
||
| 129 | $step = ($max_size - $min_size) / ($spread); |
||
| 130 | |||
| 131 | // loop through the tag array |
||
| 132 | foreach ($tags as $key => $value) { |
||
| 133 | // calculate font-size |
||
| 134 | // find the $value in excess of $min_qty |
||
| 135 | // multiply by the font-size increment ($size) |
||
| 136 | // and add the $min_size set above |
||
| 137 | $size = round($min_size + (($value - $min_qty) * $step)); |
||
| 138 | |||
| 139 | $key_escaped = str_replace("'", "\\'", $key); |
||
| 140 | |||
| 141 | echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: ". |
||
| 142 | $size."px\" title=\"$value articles tagged with ". |
||
| 143 | $key.'">'.$key.'</a> '; |
||
| 144 | } |
||
| 145 | |||
| 146 | |||
| 147 | |||
| 148 | print "</div>"; |
||
| 149 | |||
| 150 | print "<footer class='text-center'>"; |
||
| 151 | print "<button dojoType='dijit.form.Button' |
||
| 152 | onclick=\"return CommonDialogs.closeInfoBox()\">". |
||
| 153 | __('Close this window')."</button>"; |
||
| 154 | print "</footer>"; |
||
| 155 | |||
| 156 | } |
||
| 157 | |||
| 158 | public function generatedFeed() { |
||
| 159 | |||
| 160 | $this->params = explode(":", $this->param, 3); |
||
| 161 | $feed_id = $this->params[0]; |
||
| 162 | $is_cat = (bool) $this->params[1]; |
||
| 163 | |||
| 164 | $key = Feeds::get_feed_access_key($feed_id, $is_cat); |
||
| 165 | |||
| 166 | $url_path = htmlspecialchars($this->params[2])."&key=".$key; |
||
| 167 | |||
| 168 | $feed_title = Feeds::getFeedTitle($feed_id, $is_cat); |
||
| 169 | |||
| 170 | print "<header>".T_sprintf("%s can be accessed via the following secret URL:", $feed_title)."</header>"; |
||
| 171 | |||
| 172 | print "<section>"; |
||
| 173 | print "<div class='panel text-center'>"; |
||
| 174 | print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>"; |
||
| 175 | print "</div>"; |
||
| 176 | print "</section>"; |
||
| 177 | |||
| 178 | print "<footer>"; |
||
| 179 | |||
| 180 | print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/GeneratedFeeds\")'> |
||
| 181 | <i class='material-icons'>help</i> ".__("More info...")."</button>"; |
||
| 182 | |||
| 183 | print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">". |
||
| 184 | __('Generate new URL')."</button> "; |
||
| 185 | |||
| 186 | print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">". |
||
| 187 | __('Close this window')."</button>"; |
||
| 188 | |||
| 189 | print "</footer>"; |
||
| 190 | |||
| 191 | //return; |
||
| 192 | } |
||
| 193 | |||
| 194 | public function defaultPasswordWarning() { |
||
| 195 | |||
| 196 | print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
||
| 197 | |||
| 198 | print "<footer class='text-center'>"; |
||
| 199 | print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">". |
||
| 200 | __('Open Preferences')."</button> "; |
||
| 201 | print "<button dojoType='dijit.form.Button' |
||
| 202 | onclick=\"return CommonDialogs.closeInfoBox()\">". |
||
| 203 | __('Close this window')."</button>"; |
||
| 204 | print "</footeer>"; |
||
| 205 | } |
||
| 206 | } |
||
| 207 |