]>
Commit | Line | Data |
---|---|---|
3f363052 | 1 | <?php |
9da07c8a | 2 | class Dlg extends Handler_Protected { |
3f363052 | 3 | private $param; |
46da73c2 | 4 | |
17f9d200 JK |
5 | function before($method) { |
6 | if (parent::before($method)) { | |
fb54e3b1 AD |
7 | header("Content-Type: text/html"); # required for iframe |
8 | ||
d9c85e0f | 9 | $this->param = $this->dbh->escape_string($_REQUEST["param"]); |
3f363052 AD |
10 | return true; |
11 | } | |
12 | return false; | |
13 | } | |
46da73c2 | 14 | |
3f363052 | 15 | function importOpml() { |
34aa9e20 AD |
16 | print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>"; |
17 | ||
3f363052 AD |
18 | print "<div class=\"prefFeedOPMLHolder\">"; |
19 | $owner_uid = $_SESSION["uid"]; | |
20 | ||
d9c85e0f | 21 | $this->dbh->query("BEGIN"); |
3f363052 | 22 | |
d75409bf | 23 | print "<ul class='nomarks'>"; |
3f363052 | 24 | |
a42c55f0 | 25 | $opml = new Opml($_REQUEST); |
3f363052 | 26 | |
d75409bf | 27 | $opml->opml_import($_SESSION["uid"]); |
3f363052 | 28 | |
d9c85e0f | 29 | $this->dbh->query("COMMIT"); |
b77d0c4a | 30 | |
c4c74732 | 31 | print "</ul>"; |
3f363052 AD |
32 | print "</div>"; |
33 | ||
34 | print "<div align='center'>"; | |
35 | print "<button dojoType=\"dijit.form.Button\" | |
34aa9e20 | 36 | onclick=\"dijit.byId('opmlImportDlg').execute()\">". |
3f363052 AD |
37 | __('Close this window')."</button>"; |
38 | print "</div>"; | |
39 | ||
40 | print "</div>"; | |
41 | ||
42 | //return; | |
43 | } | |
44 | ||
3f363052 | 45 | function pubOPMLUrl() { |
6322ac79 | 46 | $url_path = Opml::opml_publish_url(); |
3f363052 AD |
47 | |
48 | print __("Your Public OPML URL is:"); | |
49 | ||
50 | print "<div class=\"tagCloudContainer\">"; | |
51 | print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>"; | |
52 | print "</div>"; | |
53 | ||
54 | print "<div align='center'>"; | |
55 | ||
56 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">". | |
57 | __('Generate new URL')."</button> "; | |
58 | ||
59 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">". | |
60 | __('Close this window')."</button>"; | |
61 | ||
62 | print "</div>"; | |
3f363052 AD |
63 | |
64 | //return; | |
65 | } | |
66 | ||
67 | function explainError() { | |
3f363052 AD |
68 | print "<div class=\"errorExplained\">"; |
69 | ||
70 | if ($this->param == 1) { | |
71 | 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."); | |
72 | ||
73 | $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); | |
74 | ||
75 | print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); | |
76 | ||
77 | } | |
78 | ||
79 | if ($this->param == 3) { | |
80 | 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."); | |
81 | ||
82 | $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); | |
83 | ||
84 | print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); | |
85 | ||
86 | } | |
87 | ||
88 | print "</div>"; | |
89 | ||
90 | print "<div align='center'>"; | |
91 | ||
92 | print "<button onclick=\"return closeInfoBox()\">". | |
93 | __('Close this window')."</button>"; | |
94 | ||
95 | print "</div>"; | |
3f363052 AD |
96 | |
97 | //return; | |
98 | } | |
3f363052 AD |
99 | |
100 | function printTagCloud() { | |
3f363052 AD |
101 | print "<div class=\"tagCloudContainer\">"; |
102 | ||
79178062 AD |
103 | // from here: http://www.roscripts.com/Create_tag_cloud-71.html |
104 | ||
105 | $query = "SELECT tag_name, COUNT(post_int_id) AS count | |
106 | FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]." | |
107 | GROUP BY tag_name ORDER BY count DESC LIMIT 50"; | |
108 | ||
d9c85e0f | 109 | $result = $this->dbh->query($query); |
79178062 AD |
110 | |
111 | $tags = array(); | |
112 | ||
d9c85e0f | 113 | while ($line = $this->dbh->fetch_assoc($result)) { |
79178062 AD |
114 | $tags[$line["tag_name"]] = $line["count"]; |
115 | } | |
116 | ||
a42c55f0 | 117 | if(count($tags) == 0 ){ return; } |
79178062 AD |
118 | |
119 | ksort($tags); | |
120 | ||
121 | $max_size = 32; // max font size in pixels | |
122 | $min_size = 11; // min font size in pixels | |
123 | ||
124 | // largest and smallest array values | |
125 | $max_qty = max(array_values($tags)); | |
126 | $min_qty = min(array_values($tags)); | |
127 | ||
128 | // find the range of values | |
129 | $spread = $max_qty - $min_qty; | |
130 | if ($spread == 0) { // we don't want to divide by zero | |
131 | $spread = 1; | |
132 | } | |
133 | ||
134 | // set the font-size increment | |
135 | $step = ($max_size - $min_size) / ($spread); | |
136 | ||
137 | // loop through the tag array | |
138 | foreach ($tags as $key => $value) { | |
139 | // calculate font-size | |
140 | // find the $value in excess of $min_qty | |
141 | // multiply by the font-size increment ($size) | |
142 | // and add the $min_size set above | |
143 | $size = round($min_size + (($value - $min_qty) * $step)); | |
144 | ||
145 | $key_escaped = str_replace("'", "\\'", $key); | |
146 | ||
147 | echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " . | |
148 | $size . "px\" title=\"$value articles tagged with " . | |
149 | $key . '">' . $key . '</a> '; | |
150 | } | |
151 | ||
152 | ||
3f363052 AD |
153 | |
154 | print "</div>"; | |
155 | ||
156 | print "<div align='center'>"; | |
157 | print "<button dojoType=\"dijit.form.Button\" | |
158 | onclick=\"return closeInfoBox()\">". | |
159 | __('Close this window')."</button>"; | |
160 | print "</div>"; | |
161 | ||
3f363052 AD |
162 | } |
163 | ||
164 | function printTagSelect() { | |
46da73c2 | 165 | |
3f363052 | 166 | print __("Match:"). " " . |
7b28a986 AD |
167 | "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\" id=\"tag_mode_any\">"; |
168 | print "<label for=\"tag_mode_any\">".__("Any")."</label>"; | |
169 | print " "; | |
170 | print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\" id=\"tag_mode_all\">"; | |
171 | print "<label for=\"tag_mode_all\">".__("All tags.")."</input>"; | |
3f363052 AD |
172 | |
173 | print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">"; | |
d9c85e0f | 174 | $result = $this->dbh->query("SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']." |
3f363052 AD |
175 | AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC"); |
176 | ||
d9c85e0f | 177 | while ($row = $this->dbh->fetch_assoc($result)) { |
3f363052 AD |
178 | $tmp = htmlspecialchars($row["tag_name"]); |
179 | print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>"; | |
180 | } | |
181 | ||
182 | print "</select>"; | |
183 | ||
184 | print "<div align='right'>"; | |
185 | print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')), | |
186 | get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>"; | |
187 | print " "; | |
188 | print "<button dojoType=\"dijit.form.Button\" | |
189 | onclick=\"return closeInfoBox()\">" . | |
190 | __('Close this window') . "</button>"; | |
191 | print "</div>"; | |
192 | ||
3f363052 AD |
193 | } |
194 | ||
3f363052 | 195 | function generatedFeed() { |
46da73c2 | 196 | |
3f363052 | 197 | $this->params = explode(":", $this->param, 3); |
d9c85e0f | 198 | $feed_id = $this->dbh->escape_string($this->params[0]); |
3f363052 AD |
199 | $is_cat = (bool) $this->params[1]; |
200 | ||
a42c55f0 | 201 | $key = get_feed_access_key($feed_id, $is_cat); |
3f363052 AD |
202 | |
203 | $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key; | |
204 | ||
fcef9eea | 205 | print "<h2>".__("You can view this feed as RSS using the following URL:")."</h2>"; |
3f363052 AD |
206 | |
207 | print "<div class=\"tagCloudContainer\">"; | |
208 | print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>"; | |
209 | print "</div>"; | |
210 | ||
211 | print "<div align='center'>"; | |
212 | ||
213 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">". | |
214 | __('Generate new URL')."</button> "; | |
215 | ||
216 | print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">". | |
217 | __('Close this window')."</button>"; | |
218 | ||
219 | print "</div>"; | |
3f363052 AD |
220 | |
221 | //return; | |
222 | } | |
223 | ||
224 | function newVersion() { | |
46da73c2 | 225 | |
6322ac79 | 226 | $version_data = check_for_update(); |
3f363052 AD |
227 | $version = $version_data['version']; |
228 | $id = $version_data['version_id']; | |
229 | ||
ed47e3c4 AD |
230 | if ($version && $id) { |
231 | print "<div class='tagCloudContainer'>"; | |
3f363052 | 232 | |
ed47e3c4 AD |
233 | print T_sprintf("New version of Tiny Tiny RSS is available (%s).", |
234 | "<b>$version</b>"); | |
3f363052 | 235 | |
ed47e3c4 | 236 | print "</div>"; |
3f363052 | 237 | |
ed47e3c4 AD |
238 | $details = "http://tt-rss.org/redmine/versions/$id"; |
239 | $download = "http://tt-rss.org/#Download"; | |
3f363052 | 240 | |
ed47e3c4 | 241 | print "<p align='center'>".__("You can update using built-in updater in the Preferences or by using update.php")."</p>"; |
366f06f7 | 242 | |
ed47e3c4 AD |
243 | print "<div style='text-align : center'>"; |
244 | print "<button dojoType=\"dijit.form.Button\" | |
2e828a4a | 245 | onclick=\"return window.open('$details')\">".__("See the release notes")."</button>"; |
ed47e3c4 AD |
246 | print "<button dojoType=\"dijit.form.Button\" |
247 | onclick=\"return window.open('$download')\">".__("Download")."</button>"; | |
248 | print "<button dojoType=\"dijit.form.Button\" | |
249 | onclick=\"return dijit.byId('newVersionDlg').hide()\">". | |
250 | __('Close this window')."</button>"; | |
251 | ||
252 | } else { | |
253 | print "<div class='tagCloudContainer'>"; | |
254 | ||
255 | print "<p align='center'>".__("Error receiving version information or no new version available.")."</p>"; | |
256 | ||
257 | print "</div>"; | |
258 | ||
259 | print "<div style='text-align : center'>"; | |
260 | print "<button dojoType=\"dijit.form.Button\" | |
261 | onclick=\"return dijit.byId('newVersionDlg').hide()\">". | |
262 | __('Close this window')."</button>"; | |
263 | print "</div>"; | |
264 | ||
265 | } | |
3f363052 AD |
266 | print "</div>"; |
267 | ||
268 | } | |
269 | ||
3f363052 | 270 | |
3f363052 AD |
271 | } |
272 | ?> |