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