]> git.wh0rd.org - tt-rss.git/blame - classes/dlg.php
move customizeCSS to pref-prefs
[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
3972bf59 9 $this->param = db_escape_string($this->link, $_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
21 db_query($this->link, "BEGIN");
22
d75409bf 23 print "<ul class='nomarks'>";
3f363052 24
d75409bf 25 $opml = new Opml($this->link, $_REQUEST);
3f363052 26
d75409bf 27 $opml->opml_import($_SESSION["uid"]);
3f363052 28
b77d0c4a
AD
29 db_query($this->link, "COMMIT");
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
45 function editPrefProfiles() {
46 print "<div dojoType=\"dijit.Toolbar\">";
47
ddb575c7
AD
48 print "<div dojoType=\"dijit.form.DropDownButton\">".
49 "<span>" . __('Select')."</span>";
50 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
51 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
52 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
53 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
54 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
55 print "</div></div>";
56
57 print "<div style=\"float : right\">";
58
3f363052
AD
59 print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
60 required=\"1\">
61 <button dojoType=\"dijit.form.Button\"
62 onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
63 __('Create profile')."</button></div>";
64
ddb575c7
AD
65 print "</div>";
66
3f363052
AD
67 $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
68 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
69
a7edcc55 70 print "<div class=\"prefProfileHolder\">";
3f363052
AD
71
72 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
73
74 print "<table width=\"100%\" class=\"prefFeedProfileList\"
75 cellspacing=\"0\" id=\"prefFeedProfileList\">";
76
ddb575c7 77 print "<tr class=\"placeholder\" id=\"FCATR-0\">"; #odd
3f363052
AD
78
79 print "<td width='5%' align='center'><input
ddb575c7 80 id='FCATC-0'
3f363052
AD
81 onclick='toggleSelectRow2(this);'
82 dojoType=\"dijit.form.CheckBox\"
83 type=\"checkbox\"></td>";
84
85 if (!$_SESSION["profile"]) {
86 $is_active = __("(active)");
87 } else {
88 $is_active = "";
89 }
90
91 print "<td><span>" .
92 __("Default profile") . " $is_active</span></td>";
93
94 print "</tr>";
95
96 $lnum = 1;
97
98 while ($line = db_fetch_assoc($result)) {
99
100 $class = ($lnum % 2) ? "even" : "odd";
101
102 $profile_id = $line["id"];
103 $this_row_id = "id=\"FCATR-$profile_id\"";
104
ddb575c7 105 print "<tr class=\"placeholder\" $this_row_id>";
3f363052
AD
106
107 $edit_title = htmlspecialchars($line["title"]);
108
109 print "<td width='5%' align='center'><input
110 onclick='toggleSelectRow2(this);'
ddb575c7 111 id='FCATC-$profile_id'
3f363052
AD
112 dojoType=\"dijit.form.CheckBox\"
113 type=\"checkbox\"></td>";
114
115 if ($_SESSION["profile"] == $line["id"]) {
116 $is_active = __("(active)");
117 } else {
118 $is_active = "";
119 }
120
121 print "<td><span dojoType=\"dijit.InlineEditBox\"
122 width=\"300px\" autoSave=\"false\"
123 profile-id=\"$profile_id\">" . $edit_title .
124 "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
125 var elem = this;
126 dojo.xhrPost({
127 url: 'backend.php',
128 content: {op: 'rpc', method: 'saveprofile',
129 value: this.value,
130 id: this.srcNodeRef.getAttribute('profile-id')},
131 load: function(response) {
132 elem.attr('value', response);
133 }
134 });
135 </script>
136 </span> $is_active</td>";
137
138 print "</tr>";
139
140 ++$lnum;
141 }
142
143 print "</table>";
144 print "</form>";
145 print "</div>";
146
147 print "<div class='dlgButtons'>
148 <div style='float : left'>
149 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">".
150 __('Remove selected profiles')."</button>
151 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">".
152 __('Activate profile')."</button>
153 </div>";
154
155 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">".
156 __('Close this window')."</button>";
157 print "</div>";
158
159 }
160
161 function pubOPMLUrl() {
50832719 162 $url_path = Opml::opml_publish_url($this->link);
3f363052
AD
163
164 print __("Your Public OPML URL is:");
165
166 print "<div class=\"tagCloudContainer\">";
167 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
168 print "</div>";
169
170 print "<div align='center'>";
171
172 print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
173 __('Generate new URL')."</button> ";
174
175 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
176 __('Close this window')."</button>";
177
178 print "</div>";
3f363052
AD
179
180 //return;
181 }
182
183 function explainError() {
3f363052
AD
184 print "<div class=\"errorExplained\">";
185
186 if ($this->param == 1) {
187 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.");
188
189 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
190
191 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
192
193 }
194
195 if ($this->param == 3) {
196 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.");
197
198 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
199
200 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
201
202 }
203
204 print "</div>";
205
206 print "<div align='center'>";
207
208 print "<button onclick=\"return closeInfoBox()\">".
209 __('Close this window')."</button>";
210
211 print "</div>";
3f363052
AD
212
213 //return;
214 }
3f363052
AD
215
216 function printTagCloud() {
3f363052
AD
217 print "<div class=\"tagCloudContainer\">";
218
79178062
AD
219 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
220
221 $query = "SELECT tag_name, COUNT(post_int_id) AS count
222 FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
223 GROUP BY tag_name ORDER BY count DESC LIMIT 50";
224
225 $result = db_query($this->link, $query);
226
227 $tags = array();
228
229 while ($line = db_fetch_assoc($result)) {
230 $tags[$line["tag_name"]] = $line["count"];
231 }
232
233 if( count($tags) == 0 ){ return; }
234
235 ksort($tags);
236
237 $max_size = 32; // max font size in pixels
238 $min_size = 11; // min font size in pixels
239
240 // largest and smallest array values
241 $max_qty = max(array_values($tags));
242 $min_qty = min(array_values($tags));
243
244 // find the range of values
245 $spread = $max_qty - $min_qty;
246 if ($spread == 0) { // we don't want to divide by zero
247 $spread = 1;
248 }
249
250 // set the font-size increment
251 $step = ($max_size - $min_size) / ($spread);
252
253 // loop through the tag array
254 foreach ($tags as $key => $value) {
255 // calculate font-size
256 // find the $value in excess of $min_qty
257 // multiply by the font-size increment ($size)
258 // and add the $min_size set above
259 $size = round($min_size + (($value - $min_qty) * $step));
260
261 $key_escaped = str_replace("'", "\\'", $key);
262
263 echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " .
264 $size . "px\" title=\"$value articles tagged with " .
265 $key . '">' . $key . '</a> ';
266 }
267
268
3f363052
AD
269
270 print "</div>";
271
272 print "<div align='center'>";
273 print "<button dojoType=\"dijit.form.Button\"
274 onclick=\"return closeInfoBox()\">".
275 __('Close this window')."</button>";
276 print "</div>";
277
3f363052
AD
278 }
279
280 function printTagSelect() {
46da73c2 281
3f363052 282 print __("Match:"). "&nbsp;" .
7b28a986
AD
283 "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\" id=\"tag_mode_any\">";
284 print "<label for=\"tag_mode_any\">".__("Any")."</label>";
285 print "&nbsp;";
286 print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\" id=\"tag_mode_all\">";
287 print "<label for=\"tag_mode_all\">".__("All tags.")."</input>";
3f363052
AD
288
289 print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
290 $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
291 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
292
293 while ($row = db_fetch_assoc($result)) {
294 $tmp = htmlspecialchars($row["tag_name"]);
295 print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
296 }
297
298 print "</select>";
299
300 print "<div align='right'>";
301 print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
302 get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
303 print "&nbsp;";
304 print "<button dojoType=\"dijit.form.Button\"
305 onclick=\"return closeInfoBox()\">" .
306 __('Close this window') . "</button>";
307 print "</div>";
308
3f363052
AD
309 }
310
3f363052 311 function generatedFeed() {
46da73c2 312
3f363052 313 $this->params = explode(":", $this->param, 3);
3972bf59 314 $feed_id = db_escape_string($this->link, $this->params[0]);
3f363052
AD
315 $is_cat = (bool) $this->params[1];
316
317 $key = get_feed_access_key($this->link, $feed_id, $is_cat);
318
319 $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
320
fcef9eea 321 print "<h2>".__("You can view this feed as RSS using the following URL:")."</h2>";
3f363052
AD
322
323 print "<div class=\"tagCloudContainer\">";
324 print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
325 print "</div>";
326
327 print "<div align='center'>";
328
329 print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
330 __('Generate new URL')."</button> ";
331
332 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
333 __('Close this window')."</button>";
334
335 print "</div>";
3f363052
AD
336
337 //return;
338 }
339
340 function newVersion() {
46da73c2 341
3f363052
AD
342 $version_data = check_for_update($this->link);
343 $version = $version_data['version'];
344 $id = $version_data['version_id'];
345
ed47e3c4
AD
346 if ($version && $id) {
347 print "<div class='tagCloudContainer'>";
3f363052 348
ed47e3c4
AD
349 print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
350 "<b>$version</b>");
3f363052 351
ed47e3c4 352 print "</div>";
3f363052 353
ed47e3c4
AD
354 $details = "http://tt-rss.org/redmine/versions/$id";
355 $download = "http://tt-rss.org/#Download";
3f363052 356
ed47e3c4 357 print "<p align='center'>".__("You can update using built-in updater in the Preferences or by using update.php")."</p>";
366f06f7 358
ed47e3c4
AD
359 print "<div style='text-align : center'>";
360 print "<button dojoType=\"dijit.form.Button\"
2e828a4a 361 onclick=\"return window.open('$details')\">".__("See the release notes")."</button>";
ed47e3c4
AD
362 print "<button dojoType=\"dijit.form.Button\"
363 onclick=\"return window.open('$download')\">".__("Download")."</button>";
364 print "<button dojoType=\"dijit.form.Button\"
365 onclick=\"return dijit.byId('newVersionDlg').hide()\">".
366 __('Close this window')."</button>";
367
368 } else {
369 print "<div class='tagCloudContainer'>";
370
371 print "<p align='center'>".__("Error receiving version information or no new version available.")."</p>";
372
373 print "</div>";
374
375 print "<div style='text-align : center'>";
376 print "<button dojoType=\"dijit.form.Button\"
377 onclick=\"return dijit.byId('newVersionDlg').hide()\">".
378 __('Close this window')."</button>";
379 print "</div>";
380
381 }
3f363052
AD
382 print "</div>";
383
384 }
385
3f363052
AD
386 function addInstance() {
387 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
388 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
389
390 print "<div class=\"dlgSec\">".__("Instance")."</div>";
391
392 print "<div class=\"dlgSecCont\">";
393
394 /* URL */
395
396 print __("URL:") . " ";
397
398 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
399 placeHolder=\"".__("Instance URL")."\"
400 regExp='^(http|https)://.*'
401 style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
402
403 print "<hr/>";
404
405 $access_key = sha1(uniqid(rand(), true));
406
407 /* Access key */
408
409 print __("Access key:") . " ";
410
411 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
412 placeHolder=\"".__("Access key")."\" regExp='\w{40}'
413 style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
414 value=\"$access_key\">";
415
416 print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
417
418 print "</div>";
419
420 print "<div class=\"dlgButtons\">
421 <div style='float : left'>
422 <button dojoType=\"dijit.form.Button\"
423 onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
424 __('Generate new key')."</button>
425 </div>
426 <button dojoType=\"dijit.form.Button\"
427 onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
428 __('Create link')."</button>
429 <button dojoType=\"dijit.form.Button\"
430 onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
431 __('Cancel')."</button></div>";
432
433 return;
434 }
435
33f0fdd0
AD
436 function batchSubscribe() {
437 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
438 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchaddfeeds\">";
439
440 print "<table width='100%'><tr><td>
441 ".__("Add one valid RSS feed per line (no feed detection is done)")."
442 </td><td align='right'>";
443 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
444 print __('Place in category:') . " ";
445 print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
446 }
447 print "</td></tr><tr><td colspan='2'>";
448 print "<textarea
449 style='font-size : 12px; width : 100%; height: 200px;'
450 placeHolder=\"".__("Feeds to subscribe, One per line")."\"
451 dojoType=\"dijit.form.SimpleTextarea\" required=\"1\" name=\"feeds\"></textarea>";
452
453 print "</td></tr><tr><td colspan='2'>";
454
455 print "<div id='feedDlg_loginContainer' style='display : none'>
456 " .
457 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
458 placeHolder=\"".__("Login")."\"
459 style=\"width : 10em;\"> ".
460 " <input
461 placeHolder=\"".__("Password")."\"
462 dojoType=\"dijit.form.TextBox\" type='password'
463 style=\"width : 10em;\" name='pass'\">".
7ac3f735 464 "</div>";
33f0fdd0
AD
465
466 print "</td></tr><tr><td colspan='2'>";
467
468 print "<div style=\"clear : both\">
469 <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
470 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
471 <label for=\"feedDlg_loginCheck\">".
472 __('Feeds require authentication.')."</div>";
473
474 print "</form>";
475
476 print "</td></tr></table>";
477
478 print "<div class=\"dlgButtons\">
479 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').execute()\">".__('Subscribe')."</button>
480 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button>
481 </div>";
482 }
483
3f363052
AD
484}
485?>