]> git.wh0rd.org - tt-rss.git/blame - classes/dlg.php
Merge pull request #404 from RaphaelRochet/master
[tt-rss.git] / classes / dlg.php
CommitLineData
3f363052 1<?php
9da07c8a 2class 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 18 print "<div class=\"prefFeedOPMLHolder\">";
3f363052 19
d9c85e0f 20 $this->dbh->query("BEGIN");
3f363052 21
d75409bf 22 print "<ul class='nomarks'>";
3f363052 23
a42c55f0 24 $opml = new Opml($_REQUEST);
3f363052 25
d75409bf 26 $opml->opml_import($_SESSION["uid"]);
3f363052 27
d9c85e0f 28 $this->dbh->query("COMMIT");
b77d0c4a 29
c4c74732 30 print "</ul>";
3f363052
AD
31 print "</div>";
32
33 print "<div align='center'>";
34 print "<button dojoType=\"dijit.form.Button\"
34aa9e20 35 onclick=\"dijit.byId('opmlImportDlg').execute()\">".
3f363052
AD
36 __('Close this window')."</button>";
37 print "</div>";
38
39 print "</div>";
40
41 //return;
42 }
43
3f363052 44 function pubOPMLUrl() {
6322ac79 45 $url_path = Opml::opml_publish_url();
3f363052
AD
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>";
3f363052
AD
62
63 //return;
64 }
65
66 function explainError() {
3f363052
AD
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>";
3f363052
AD
95
96 //return;
97 }
3f363052
AD
98
99 function printTagCloud() {
3f363052
AD
100 print "<div class=\"tagCloudContainer\">";
101
79178062
AD
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
d9c85e0f 108 $result = $this->dbh->query($query);
79178062
AD
109
110 $tags = array();
111
d9c85e0f 112 while ($line = $this->dbh->fetch_assoc($result)) {
79178062
AD
113 $tags[$line["tag_name"]] = $line["count"];
114 }
115
a42c55f0 116 if(count($tags) == 0 ){ return; }
79178062
AD
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
3f363052
AD
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
3f363052
AD
161 }
162
163 function printTagSelect() {
46da73c2 164
3f363052 165 print __("Match:"). "&nbsp;" .
7b28a986
AD
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 "&nbsp;";
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>";
3f363052
AD
171
172 print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
d9c85e0f 173 $result = $this->dbh->query("SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
3f363052
AD
174 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
175
d9c85e0f 176 while ($row = $this->dbh->fetch_assoc($result)) {
3f363052 177 $tmp = htmlspecialchars($row["tag_name"]);
29f7ec0a 178 print "<option value=\"$tmp\">$tmp</option>";
3f363052
AD
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 "&nbsp;";
187 print "<button dojoType=\"dijit.form.Button\"
188 onclick=\"return closeInfoBox()\">" .
189 __('Close this window') . "</button>";
190 print "</div>";
191
3f363052
AD
192 }
193
3f363052 194 function generatedFeed() {
46da73c2 195
3f363052 196 $this->params = explode(":", $this->param, 3);
d9c85e0f 197 $feed_id = $this->dbh->escape_string($this->params[0]);
3f363052
AD
198 $is_cat = (bool) $this->params[1];
199
a42c55f0 200 $key = get_feed_access_key($feed_id, $is_cat);
3f363052
AD
201
202 $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
203
fcef9eea 204 print "<h2>".__("You can view this feed as RSS using the following URL:")."</h2>";
3f363052
AD
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>";
3f363052
AD
219
220 //return;
221 }
222
223 function newVersion() {
46da73c2 224
6322ac79 225 $version_data = check_for_update();
3f363052
AD
226 $version = $version_data['version'];
227 $id = $version_data['version_id'];
228
ed47e3c4
AD
229 if ($version && $id) {
230 print "<div class='tagCloudContainer'>";
3f363052 231
ed47e3c4
AD
232 print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
233 "<b>$version</b>");
3f363052 234
ed47e3c4 235 print "</div>";
3f363052 236
ed47e3c4
AD
237 $details = "http://tt-rss.org/redmine/versions/$id";
238 $download = "http://tt-rss.org/#Download";
3f363052 239
ed47e3c4 240 print "<p align='center'>".__("You can update using built-in updater in the Preferences or by using update.php")."</p>";
366f06f7 241
ed47e3c4
AD
242 print "<div style='text-align : center'>";
243 print "<button dojoType=\"dijit.form.Button\"
2e828a4a 244 onclick=\"return window.open('$details')\">".__("See the release notes")."</button>";
ed47e3c4
AD
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 }
3f363052
AD
265 print "</div>";
266
267 }
268
3f363052 269
3f363052
AD
270}
271?>