]> git.wh0rd.org Git - tt-rss.git/blob - classes/dlg.php
10b6d580ed28cccd8a50787ef100cf84fca26639
[tt-rss.git] / classes / dlg.php
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/xml; charset=utf-8");
8                         $this->param = db_escape_string($_REQUEST["param"]);
9                         print "<dlg>";
10                         return true;
11                 }
12                 return false;
13         }
14
15         function after() {
16                 print "</dlg>";
17         }
18
19         function exportData() {
20
21                 print "<p style='text-align : center' id='export_status_message'>You need to prepare exported data first by clicking the button below.</p>";
22
23                 print "<div align='center'>";
24                 print "<button dojoType=\"dijit.form.Button\"
25                         onclick=\"dijit.byId('dataExportDlg').prepare()\">".
26                         __('Prepare data')."</button>";
27
28                 print "<button dojoType=\"dijit.form.Button\"
29                         onclick=\"dijit.byId('dataExportDlg').hide()\">".
30                         __('Close this window')."</button>";
31
32                 print "</div>";
33
34
35         }
36
37         function importOpml() {
38                 header("Content-Type: text/html"); # required for iframe
39
40                 print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
41
42                 print "<div class=\"prefFeedOPMLHolder\">";
43                 $owner_uid = $_SESSION["uid"];
44
45                 db_query($this->link, "BEGIN");
46
47                 print "<ul class='nomarks'>";
48
49                 $opml = new Opml($this->link, $_REQUEST);
50
51                 $opml->opml_import($_SESSION["uid"]);
52
53                 db_query($this->link, "COMMIT");
54
55                 print "</ul>";
56                 print "</div>";
57
58                 print "<div align='center'>";
59                 print "<button dojoType=\"dijit.form.Button\"
60                         onclick=\"dijit.byId('opmlImportDlg').execute()\">".
61                         __('Close this window')."</button>";
62                 print "</div>";
63
64                 print "</div>";
65
66                 //return;
67         }
68
69         function editPrefProfiles() {
70                 print "<div dojoType=\"dijit.Toolbar\">";
71
72                 print "<div dojoType=\"dijit.form.DropDownButton\">".
73                                 "<span>" . __('Select')."</span>";
74                 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
75                 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
76                         dojoType=\"dijit.MenuItem\">".__('All')."</div>";
77                 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
78                         dojoType=\"dijit.MenuItem\">".__('None')."</div>";
79                 print "</div></div>";
80
81                 print "<div style=\"float : right\">";
82
83                 print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
84                                 required=\"1\">
85                         <button dojoType=\"dijit.form.Button\"
86                         onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
87                                 __('Create profile')."</button></div>";
88
89                 print "</div>";
90
91                 $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
92                         WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
93
94                 print "<div class=\"prefFeedCatHolder\">";
95
96                 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
97
98                 print "<table width=\"100%\" class=\"prefFeedProfileList\"
99                         cellspacing=\"0\" id=\"prefFeedProfileList\">";
100
101                 print "<tr class=\"placeholder\" id=\"FCATR-0\">"; #odd
102
103                 print "<td width='5%' align='center'><input
104                         id='FCATC-0'
105                         onclick='toggleSelectRow2(this);'
106                         dojoType=\"dijit.form.CheckBox\"
107                         type=\"checkbox\"></td>";
108
109                 if (!$_SESSION["profile"]) {
110                         $is_active = __("(active)");
111                 } else {
112                         $is_active = "";
113                 }
114
115                 print "<td><span>" .
116                         __("Default profile") . " $is_active</span></td>";
117
118                 print "</tr>";
119
120                 $lnum = 1;
121
122                 while ($line = db_fetch_assoc($result)) {
123
124                         $class = ($lnum % 2) ? "even" : "odd";
125
126                         $profile_id = $line["id"];
127                         $this_row_id = "id=\"FCATR-$profile_id\"";
128
129                         print "<tr class=\"placeholder\" $this_row_id>";
130
131                         $edit_title = htmlspecialchars($line["title"]);
132
133                         print "<td width='5%' align='center'><input
134                                 onclick='toggleSelectRow2(this);'
135                                 id='FCATC-$profile_id'
136                                 dojoType=\"dijit.form.CheckBox\"
137                                 type=\"checkbox\"></td>";
138
139                         if ($_SESSION["profile"] == $line["id"]) {
140                                 $is_active = __("(active)");
141                         } else {
142                                 $is_active = "";
143                         }
144
145                         print "<td><span dojoType=\"dijit.InlineEditBox\"
146                                 width=\"300px\" autoSave=\"false\"
147                                 profile-id=\"$profile_id\">" . $edit_title .
148                                 "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
149                                         var elem = this;
150                                         dojo.xhrPost({
151                                                 url: 'backend.php',
152                                                 content: {op: 'rpc', method: 'saveprofile',
153                                                         value: this.value,
154                                                         id: this.srcNodeRef.getAttribute('profile-id')},
155                                                         load: function(response) {
156                                                                 elem.attr('value', response);
157                                                 }
158                                         });
159                                 </script>
160                         </span> $is_active</td>";
161
162                         print "</tr>";
163
164                         ++$lnum;
165                 }
166
167                 print "</table>";
168                 print "</form>";
169                 print "</div>";
170
171                 print "<div class='dlgButtons'>
172                         <div style='float : left'>
173                         <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">".
174                         __('Remove selected profiles')."</button>
175                         <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">".
176                         __('Activate profile')."</button>
177                         </div>";
178
179                 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">".
180                         __('Close this window')."</button>";
181                 print "</div>";
182
183         }
184
185         function pubOPMLUrl() {
186                 print "<title>".__('Public OPML URL')."</title>";
187                 print "<content><![CDATA[";
188
189                 $url_path = opml_publish_url($this->link);
190
191                 print __("Your Public OPML URL is:");
192
193                 print "<div class=\"tagCloudContainer\">";
194                 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
195                 print "</div>";
196
197                 print "<div align='center'>";
198
199                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
200                         __('Generate new URL')."</button> ";
201
202                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
203                         __('Close this window')."</button>";
204
205                 print "</div>";
206                 print "]]></content>";
207
208                 //return;
209         }
210
211         function explainError() {
212                 print "<title>".__('Notice')."</title>";
213                 print "<content><![CDATA[";
214
215                 print "<div class=\"errorExplained\">";
216
217                 if ($this->param == 1) {
218                         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.");
219
220                         $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
221
222                         print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
223
224                 }
225
226                 if ($this->param == 3) {
227                         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.");
228
229                         $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
230
231                         print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
232
233                 }
234
235                 print "</div>";
236
237                 print "<div align='center'>";
238
239                 print "<button onclick=\"return closeInfoBox()\">".
240                         __('Close this window')."</button>";
241
242                 print "</div>";
243                 print "]]></content>";
244
245                 //return;
246         }
247
248         function quickAddFeed() {
249                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
250                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
251
252                 print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
253                 print "<div class=\"dlgSecCont\">";
254
255                 print "<div style='float : right'>
256                         <img style='display : none'
257                                 id='feed_add_spinner' src='".
258                                 theme_image($this->link, 'images/indicator_white.gif')."'></div>";
259
260                 print "<input style=\"font-size : 16px; width : 20em;\"
261                         placeHolder=\"".__("Feed or site URL")."\"
262                         dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
263
264                 print "<hr/>";
265
266                 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
267                         print __('Place in category:') . " ";
268                         print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
269                 }
270
271                 print "</div>";
272
273                 print '<div id="feedDlg_feedsContainer" style="display : none">
274
275                                 <div class="dlgSec">' . __('Available feeds') . '</div>
276                                 <div class="dlgSecCont">'.
277                                 '<select id="feedDlg_feedContainerSelect"
278                                         dojoType="dijit.form.Select" size="3">
279                                         <script type="dojo/method" event="onChange" args="value">
280                                                 dijit.byId("feedDlg_feedUrl").attr("value", value);
281                                         </script>
282                                 </select>'.
283                                 '</div></div>';
284
285                 print "<div id='feedDlg_loginContainer' style='display : none'>
286
287                                 <div class=\"dlgSec\">".__("Authentication")."</div>
288                                 <div class=\"dlgSecCont\">".
289
290                                 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
291                                         placeHolder=\"".__("Login")."\"
292                                         style=\"width : 10em;\"> ".
293                                 " <input
294                                         placeHolder=\"".__("Password")."\"
295                                         dojoType=\"dijit.form.TextBox\" type='password'
296                                         style=\"width : 10em;\" name='pass'\">
297                         </div></div>";
298
299
300                 print "<div style=\"clear : both\">
301                         <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
302                                         onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
303                                 <label for=\"feedDlg_loginCheck\">".
304                                 __('This feed requires authentication.')."</div>";
305
306                 print "</form>";
307
308                 print "<div class=\"dlgButtons\">
309                         <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
310
311                 if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
312                         print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
313                 }
314
315                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
316                         </div>";
317
318                 //return;
319         }
320
321         function feedBrowser() {
322                 if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
323
324                 $browser_search = db_escape_string($_REQUEST["search"]);
325
326                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
327                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
328
329                 print "<div dojoType=\"dijit.Toolbar\">
330                         <div style='float : right'>
331                         <img style='display : none'
332                                 id='feed_browser_spinner' src='".
333                                 theme_image($this->link, 'images/indicator_white.gif')."'>
334                         <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
335                                 onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
336                         <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
337                 </div>";
338
339                 print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
340                         <option value='1'>" . __('Popular feeds') . "</option>
341                         <option value='2'>" . __('Feed archive') . "</option>
342                         </select> ";
343
344                 print __("limit:");
345
346                 print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
347
348                 foreach (array(25, 50, 100, 200) as $l) {
349                         $issel = ($l == $limit) ? "selected=\"1\"" : "";
350                         print "<option $issel value=\"$l\">$l</option>";
351                 }
352
353                 print "</select> ";
354
355                 print "</div>";
356
357                 $owner_uid = $_SESSION["uid"];
358
359                 print "<ul class='browseFeedList' id='browseFeedList'>";
360                 print make_feed_browser($this->link, $search, 25);
361                 print "</ul>";
362
363                 print "<div align='center'>
364                         <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
365                         <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
366                         <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
367
368         }
369
370         function search() {
371                 $this->params = explode(":", db_escape_string($_REQUEST["param"]), 2);
372
373                 $active_feed_id = sprintf("%d", $this->params[0]);
374                 $is_cat = $this->params[1] != "false";
375
376                 print "<div class=\"dlgSec\">".__('Look for')."</div>";
377
378                 print "<div class=\"dlgSecCont\">";
379
380                 print "<input dojoType=\"dijit.form.ValidationTextBox\"
381                         style=\"font-size : 16px; width : 20em;\"
382                         required=\"1\" name=\"query\" type=\"search\" value=''>";
383
384                 print "<hr/>".__('Limit search to:')." ";
385
386                 print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
387                         <option value=\"all_feeds\">".__('All feeds')."</option>";
388
389                 $feed_title = getFeedTitle($this->link, $active_feed_id);
390
391                 if (!$is_cat) {
392                         $feed_cat_title = getFeedCatTitle($this->link, $active_feed_id);
393                 } else {
394                         $feed_cat_title = getCategoryTitle($this->link, $active_feed_id);
395                 }
396
397                 if ($active_feed_id && !$is_cat) {
398                         print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
399                 } else {
400                         print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
401                 }
402
403                 if ($is_cat) {
404                         $cat_preselected = "selected=\"1\"";
405                 }
406
407                 if (get_pref($this->link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
408                         print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
409                 } else {
410                         //print "<option disabled>".__('This category')."</option>";
411                 }
412
413                 print "</select>";
414
415                 print "</div>";
416
417                 print "<div class=\"dlgButtons\">";
418
419                 if (!SPHINX_ENABLED) {
420                         print "<div style=\"float : left\">
421                                 <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">Search syntax</a>
422                                 </div>";
423                 }
424
425                 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
426                 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
427                 </div>";
428         }
429
430         function editArticleTags() {
431
432                 print __("Tags for this article (separated by commas):")."<br>";
433
434                 $tags = get_article_tags($this->link, $this->param);
435
436                 $tags_str = join(", ", $tags);
437
438                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">";
439                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
440                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
441
442                 print "<table width='100%'><tr><td>";
443
444                 print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
445                         style='font-size : 12px; width : 100%' id=\"tags_str\"
446                         name='tags_str'>$tags_str</textarea>
447                 <div class=\"autocomplete\" id=\"tags_choices\"
448                                 style=\"display:none\"></div>";
449
450                 print "</td></tr></table>";
451
452                 print "<div class='dlgButtons'>";
453
454                 print "<button dojoType=\"dijit.form.Button\"
455                         onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> ";
456                 print "<button dojoType=\"dijit.form.Button\"
457                         onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>";
458                 print "</div>";
459
460         }
461
462         function printTagCloud() {
463                 print "<title>".__('Tag Cloud')."</title>";
464                 print "<content><![CDATA[";
465
466                 print "<div class=\"tagCloudContainer\">";
467
468                 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
469
470                 $query = "SELECT tag_name, COUNT(post_int_id) AS count
471                         FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
472                         GROUP BY tag_name ORDER BY count DESC LIMIT 50";
473
474                 $result = db_query($this->link, $query);
475
476                 $tags = array();
477
478                 while ($line = db_fetch_assoc($result)) {
479                         $tags[$line["tag_name"]] = $line["count"];
480                 }
481
482         if( count($tags) == 0 ){ return; }
483
484                 ksort($tags);
485
486                 $max_size = 32; // max font size in pixels
487                 $min_size = 11; // min font size in pixels
488
489                 // largest and smallest array values
490                 $max_qty = max(array_values($tags));
491                 $min_qty = min(array_values($tags));
492
493                 // find the range of values
494                 $spread = $max_qty - $min_qty;
495                 if ($spread == 0) { // we don't want to divide by zero
496                                 $spread = 1;
497                 }
498
499                 // set the font-size increment
500                 $step = ($max_size - $min_size) / ($spread);
501
502                 // loop through the tag array
503                 foreach ($tags as $key => $value) {
504                         // calculate font-size
505                         // find the $value in excess of $min_qty
506                         // multiply by the font-size increment ($size)
507                         // and add the $min_size set above
508                         $size = round($min_size + (($value - $min_qty) * $step));
509
510                         $key_escaped = str_replace("'", "\\'", $key);
511
512                         echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " .
513                                 $size . "px\" title=\"$value articles tagged with " .
514                                 $key . '">' . $key . '</a> ';
515                 }
516
517
518
519                 print "</div>";
520
521                 print "<div align='center'>";
522                 print "<button dojoType=\"dijit.form.Button\"
523                         onclick=\"return closeInfoBox()\">".
524                         __('Close this window')."</button>";
525                 print "</div>";
526
527                 print "]]></content>";
528         }
529
530         function printTagSelect() {
531
532                 print "<title>" . __('Select item(s) by tags') . "</title>";
533                 print "<content><![CDATA[";
534
535                 print __("Match:"). "&nbsp;" .
536                         "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\" id=\"tag_mode_any\">";
537                 print "<label for=\"tag_mode_any\">".__("Any")."</label>";
538                 print "&nbsp;";
539                 print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\" id=\"tag_mode_all\">";
540                 print "<label for=\"tag_mode_all\">".__("All tags.")."</input>";
541
542                 print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
543                 $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
544                         AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
545
546                 while ($row = db_fetch_assoc($result)) {
547                         $tmp = htmlspecialchars($row["tag_name"]);
548                         print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
549                 }
550
551                 print "</select>";
552
553                 print "<div align='right'>";
554                 print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
555                         get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
556                 print "&nbsp;";
557                 print "<button dojoType=\"dijit.form.Button\"
558                 onclick=\"return closeInfoBox()\">" .
559                         __('Close this window') . "</button>";
560                 print "</div>";
561
562                 print "]]></content>";
563         }
564
565         function generatedFeed() {
566
567                 print "<title>".__('View as RSS')."</title>";
568                 print "<content><![CDATA[";
569
570                 $this->params = explode(":", $this->param, 3);
571                 $feed_id = db_escape_string($this->params[0]);
572                 $is_cat = (bool) $this->params[1];
573
574                 $key = get_feed_access_key($this->link, $feed_id, $is_cat);
575
576                 $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
577
578                 print "<div class=\"dialogNotice\">" .  __("You can view this feed as RSS using the following URL:") . "</div>";
579
580                 print "<div class=\"tagCloudContainer\">";
581                 print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
582                 print "</div>";
583
584                 print "<div align='center'>";
585
586                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
587                         __('Generate new URL')."</button> ";
588
589                 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
590                         __('Close this window')."</button>";
591
592                 print "</div>";
593                 print "]]></content>";
594
595                 //return;
596         }
597
598         function newVersion() {
599
600                 $version_data = check_for_update($this->link);
601                 $version = $version_data['version'];
602                 $id = $version_data['version_id'];
603
604                 print "<div class='tagCloudContainer'>";
605
606                 print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
607                         "<b>$version</b>");
608
609                 print "</div>";
610
611                 $details = "http://tt-rss.org/redmine/versions/$id";
612                 $download = "http://tt-rss.org/#Download";
613
614                 print "<p align='center'>".__("You can update using built-in updater in the Preferences or by using update.php")."</p>";
615
616                 print "<div style='text-align : center'>";
617                 print "<button dojoType=\"dijit.form.Button\"
618                         onclick=\"return window.open('$details')\">".__("Details")."</button>";
619                 print "<button dojoType=\"dijit.form.Button\"
620                         onclick=\"return window.open('$download')\">".__("Download")."</button>";
621                 print "<button dojoType=\"dijit.form.Button\"
622                         onclick=\"return dijit.byId('newVersionDlg').hide()\">".
623                         __('Close this window')."</button>";
624                 print "</div>";
625
626         }
627
628         function customizeCSS() {
629                 $value = get_pref($this->link, "USER_STYLESHEET");
630
631                 $value = str_replace("<br/>", "\n", $value);
632
633                 print "<div class=\"dialogNotice\">";
634                 print T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "tt-rss.css");
635                 print "</div>";
636
637                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
638                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
639                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
640
641                 print "<table width='100%'><tr><td>";
642                 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
643                         style='font-size : 12px; width : 100%; height: 200px;'
644                         placeHolder='body#ttrssMain { font-size : 14px; };'
645                         name='value'>$value</textarea>";
646                 print "</td></tr></table>";
647
648                 print "<div class='dlgButtons'>";
649                 print "<button dojoType=\"dijit.form.Button\"
650                         onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
651                 print "<button dojoType=\"dijit.form.Button\"
652                         onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
653                 print "</div>";
654
655         }
656
657         function addInstance() {
658                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"op\" value=\"pref-instances\">";
659                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"method\" value=\"add\">";
660
661                 print "<div class=\"dlgSec\">".__("Instance")."</div>";
662
663                 print "<div class=\"dlgSecCont\">";
664
665                 /* URL */
666
667                 print __("URL:") . " ";
668
669                 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
670                         placeHolder=\"".__("Instance URL")."\"
671                         regExp='^(http|https)://.*'
672                         style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
673
674                 print "<hr/>";
675
676                 $access_key = sha1(uniqid(rand(), true));
677
678                 /* Access key */
679
680                 print __("Access key:") . " ";
681
682                 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
683                         placeHolder=\"".__("Access key")."\" regExp='\w{40}'
684                         style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
685                         value=\"$access_key\">";
686
687                 print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
688
689                 print "</div>";
690
691                 print "<div class=\"dlgButtons\">
692                         <div style='float : left'>
693                                 <button dojoType=\"dijit.form.Button\"
694                                         onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
695                                         __('Generate new key')."</button>
696                         </div>
697                         <button dojoType=\"dijit.form.Button\"
698                                 onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
699                                 __('Create link')."</button>
700                         <button dojoType=\"dijit.form.Button\"
701                                 onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
702                                 __('Cancel')."</button></div>";
703
704                 return;
705         }
706
707         function dataImport() {
708                 header("Content-Type: text/html"); # required for iframe
709
710                 print "<div style='text-align : center'>";
711
712                 if (is_file($_FILES['export_file']['tmp_name'])) {
713
714                         perform_data_import($this->link, $_FILES['export_file']['tmp_name'], $_SESSION['uid']);
715
716                 } else {
717                         print "<p>" . T_sprintf("Could not upload file. You might need to adjust upload_max_filesize
718                                 in PHP.ini (current value = %s)", ini_get("upload_max_filesize")) . " or use CLI import tool.</p>";
719
720                 }
721
722                 print "<button dojoType=\"dijit.form.Button\"
723                         onclick=\"dijit.byId('dataImportDlg').hide()\">".
724                         __('Close this window')."</button>";
725
726                 print "</div>";
727
728         }
729
730         function batchSubscribe() {
731                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
732                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchaddfeeds\">";
733
734                 print "<table width='100%'><tr><td>
735                         ".__("Add one valid RSS feed per line (no feed detection is done)")."
736                 </td><td align='right'>";
737                 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
738                         print __('Place in category:') . " ";
739                         print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
740                 }
741                 print "</td></tr><tr><td colspan='2'>";
742                 print "<textarea
743                         style='font-size : 12px; width : 100%; height: 200px;'
744                         placeHolder=\"".__("Feeds to subscribe, One per line")."\"
745                         dojoType=\"dijit.form.SimpleTextarea\" required=\"1\" name=\"feeds\"></textarea>";
746
747                 print "</td></tr><tr><td colspan='2'>";
748
749                 print "<div id='feedDlg_loginContainer' style='display : none'>
750                                 " .
751                                 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
752                                         placeHolder=\"".__("Login")."\"
753                                         style=\"width : 10em;\"> ".
754                                 " <input
755                                         placeHolder=\"".__("Password")."\"
756                                         dojoType=\"dijit.form.TextBox\" type='password'
757                                         style=\"width : 10em;\" name='pass'\">".
758                                 "</div>";
759
760                 print "</td></tr><tr><td colspan='2'>";
761
762                 print "<div style=\"clear : both\">
763                         <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
764                                         onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
765                                 <label for=\"feedDlg_loginCheck\">".
766                                 __('Feeds require authentication.')."</div>";
767
768                 print "</form>";
769
770                 print "</td></tr></table>";
771
772                 print "<div class=\"dlgButtons\">
773                         <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').execute()\">".__('Subscribe')."</button>
774                         <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button>
775                         </div>";
776         }
777
778 }
779 ?>