]> git.wh0rd.org - tt-rss.git/blame - classes/dlg.php
api: disable deprecated HTTP parameter support by default
[tt-rss.git] / classes / dlg.php
CommitLineData
3f363052 1<?php
46da73c2 2class Dlg extends Protected_Handler {
3f363052 3 private $param;
46da73c2 4
17f9d200
JK
5 function before($method) {
6 if (parent::before($method)) {
3f363052
AD
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 }
46da73c2 14
3f363052
AD
15 function after() {
16 print "</dlg>";
17 }
18
566faa14
AD
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
3f363052
AD
37 function importOpml() {
38 header("Content-Type: text/html"); # required for iframe
46da73c2 39
34aa9e20
AD
40 print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
41
3f363052
AD
42 print "<div class=\"prefFeedOPMLHolder\">";
43 $owner_uid = $_SESSION["uid"];
44
45 db_query($this->link, "BEGIN");
46
d75409bf 47 print "<ul class='nomarks'>";
3f363052 48
d75409bf 49 $opml = new Opml($this->link, $_REQUEST);
3f363052 50
d75409bf 51 $opml->opml_import($_SESSION["uid"]);
3f363052 52
c4c74732 53 print "</ul>";
3f363052
AD
54 print "</div>";
55
56 print "<div align='center'>";
57 print "<button dojoType=\"dijit.form.Button\"
34aa9e20 58 onclick=\"dijit.byId('opmlImportDlg').execute()\">".
3f363052
AD
59 __('Close this window')."</button>";
60 print "</div>";
61
62 print "</div>";
63
64 //return;
65 }
66
67 function editPrefProfiles() {
68 print "<div dojoType=\"dijit.Toolbar\">";
69
ddb575c7
AD
70 print "<div dojoType=\"dijit.form.DropDownButton\">".
71 "<span>" . __('Select')."</span>";
72 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
73 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
74 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
75 print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
76 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
77 print "</div></div>";
78
79 print "<div style=\"float : right\">";
80
3f363052
AD
81 print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
82 required=\"1\">
83 <button dojoType=\"dijit.form.Button\"
84 onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
85 __('Create profile')."</button></div>";
86
ddb575c7
AD
87 print "</div>";
88
3f363052
AD
89 $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
90 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
91
92 print "<div class=\"prefFeedCatHolder\">";
93
94 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
95
96 print "<table width=\"100%\" class=\"prefFeedProfileList\"
97 cellspacing=\"0\" id=\"prefFeedProfileList\">";
98
ddb575c7 99 print "<tr class=\"placeholder\" id=\"FCATR-0\">"; #odd
3f363052
AD
100
101 print "<td width='5%' align='center'><input
ddb575c7 102 id='FCATC-0'
3f363052
AD
103 onclick='toggleSelectRow2(this);'
104 dojoType=\"dijit.form.CheckBox\"
105 type=\"checkbox\"></td>";
106
107 if (!$_SESSION["profile"]) {
108 $is_active = __("(active)");
109 } else {
110 $is_active = "";
111 }
112
113 print "<td><span>" .
114 __("Default profile") . " $is_active</span></td>";
115
116 print "</tr>";
117
118 $lnum = 1;
119
120 while ($line = db_fetch_assoc($result)) {
121
122 $class = ($lnum % 2) ? "even" : "odd";
123
124 $profile_id = $line["id"];
125 $this_row_id = "id=\"FCATR-$profile_id\"";
126
ddb575c7 127 print "<tr class=\"placeholder\" $this_row_id>";
3f363052
AD
128
129 $edit_title = htmlspecialchars($line["title"]);
130
131 print "<td width='5%' align='center'><input
132 onclick='toggleSelectRow2(this);'
ddb575c7 133 id='FCATC-$profile_id'
3f363052
AD
134 dojoType=\"dijit.form.CheckBox\"
135 type=\"checkbox\"></td>";
136
137 if ($_SESSION["profile"] == $line["id"]) {
138 $is_active = __("(active)");
139 } else {
140 $is_active = "";
141 }
142
143 print "<td><span dojoType=\"dijit.InlineEditBox\"
144 width=\"300px\" autoSave=\"false\"
145 profile-id=\"$profile_id\">" . $edit_title .
146 "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
147 var elem = this;
148 dojo.xhrPost({
149 url: 'backend.php',
150 content: {op: 'rpc', method: 'saveprofile',
151 value: this.value,
152 id: this.srcNodeRef.getAttribute('profile-id')},
153 load: function(response) {
154 elem.attr('value', response);
155 }
156 });
157 </script>
158 </span> $is_active</td>";
159
160 print "</tr>";
161
162 ++$lnum;
163 }
164
165 print "</table>";
166 print "</form>";
167 print "</div>";
168
169 print "<div class='dlgButtons'>
170 <div style='float : left'>
171 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">".
172 __('Remove selected profiles')."</button>
173 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">".
174 __('Activate profile')."</button>
175 </div>";
176
177 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">".
178 __('Close this window')."</button>";
179 print "</div>";
180
181 }
182
183 function pubOPMLUrl() {
184 print "<title>".__('Public OPML URL')."</title>";
185 print "<content><![CDATA[";
186
187 $url_path = opml_publish_url($this->link);
188
189 print __("Your Public OPML URL is:");
190
191 print "<div class=\"tagCloudContainer\">";
192 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
193 print "</div>";
194
195 print "<div align='center'>";
196
197 print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
198 __('Generate new URL')."</button> ";
199
200 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
201 __('Close this window')."</button>";
202
203 print "</div>";
204 print "]]></content>";
205
206 //return;
207 }
208
209 function explainError() {
210 print "<title>".__('Notice')."</title>";
211 print "<content><![CDATA[";
212
213 print "<div class=\"errorExplained\">";
214
215 if ($this->param == 1) {
216 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.");
217
218 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
219
220 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
221
222 }
223
224 if ($this->param == 3) {
225 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.");
226
227 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
228
229 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
230
231 }
232
233 print "</div>";
234
235 print "<div align='center'>";
236
237 print "<button onclick=\"return closeInfoBox()\">".
238 __('Close this window')."</button>";
239
240 print "</div>";
241 print "]]></content>";
242
243 //return;
244 }
245
246 function quickAddFeed() {
247 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
248 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
249
250 print "<div class=\"dlgSec\">".__("Feed")."</div>";
251 print "<div class=\"dlgSecCont\">";
252
253 print "<input style=\"font-size : 16px; width : 20em;\"
254 placeHolder=\"".__("Feed URL")."\"
255 dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
256
257 print "<hr/>";
258
259 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
260 print __('Place in category:') . " ";
261 print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
262 }
263
264 print "</div>";
265
266 print '<div id="feedDlg_feedsContainer" style="display : none">
267
268 <div class="dlgSec">' . __('Available feeds') . '</div>
269 <div class="dlgSecCont">'.
270 '<select id="feedDlg_feedContainerSelect"
271 dojoType="dijit.form.Select" size="3">
272 <script type="dojo/method" event="onChange" args="value">
273 dijit.byId("feedDlg_feedUrl").attr("value", value);
274 </script>
275 </select>'.
276 '</div></div>';
277
278 print "<div id='feedDlg_loginContainer' style='display : none'>
279
280 <div class=\"dlgSec\">".__("Authentication")."</div>
281 <div class=\"dlgSecCont\">".
282
283 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
284 placeHolder=\"".__("Login")."\"
285 style=\"width : 10em;\"> ".
286 " <input
287 placeHolder=\"".__("Password")."\"
288 dojoType=\"dijit.form.TextBox\" type='password'
aa60999b
AD
289 style=\"width : 10em;\" name='pass'\">".
290 " <p class='insensitive'>".__("OAuth will be used automatically for Twitter feeds.")."</p>
3f363052
AD
291 </div></div>";
292
293
294 print "<div style=\"clear : both\">
aa60999b 295 <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
3f363052
AD
296 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
297 <label for=\"feedDlg_loginCheck\">".
298 __('This feed requires authentication.')."</div>";
299
300 print "</form>";
301
302 print "<div class=\"dlgButtons\">
303 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>
304 <button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>
305 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
306 </div>";
307
308 //return;
309 }
310
311 function feedBrowser() {
312 $browser_search = db_escape_string($_REQUEST["search"]);
313
314 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
315 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
316
317 print "<div dojoType=\"dijit.Toolbar\">
318 <div style='float : right'>
319 <img style='display : none'
320 id='feed_browser_spinner' src='".
321 theme_image($this->link, 'images/indicator_white.gif')."'>
322 <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
323 onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
324 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
325 </div>";
326
327 print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
328 <option value='1'>" . __('Popular feeds') . "</option>
329 <option value='2'>" . __('Feed archive') . "</option>
330 </select> ";
331
332 print __("limit:");
333
334 print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
335
336 foreach (array(25, 50, 100, 200) as $l) {
337 $issel = ($l == $limit) ? "selected=\"1\"" : "";
338 print "<option $issel value=\"$l\">$l</option>";
339 }
340
341 print "</select> ";
342
343 print "</div>";
344
345 $owner_uid = $_SESSION["uid"];
346
347 print "<ul class='browseFeedList' id='browseFeedList'>";
348 print make_feed_browser($this->link, $search, 25);
349 print "</ul>";
350
351 print "<div align='center'>
352 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
353 <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
354 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
355
356 }
357
358 function search() {
359 $this->params = explode(":", db_escape_string($_REQUEST["param"]), 2);
360
361 $active_feed_id = sprintf("%d", $this->params[0]);
362 $is_cat = $this->params[1] != "false";
363
364 print "<div class=\"dlgSec\">".__('Look for')."</div>";
365
366 print "<div class=\"dlgSecCont\">";
367
368 if (!SPHINX_ENABLED) {
369
370 print "<input dojoType=\"dijit.form.ValidationTextBox\"
371 style=\"font-size : 16px; width : 12em;\"
372 required=\"1\" name=\"query\" type=\"search\" value=''>";
373
374 print " " . __('match on')." ";
375
376 $search_fields = array(
377 "title" => __("Title"),
378 "content" => __("Content"),
379 "both" => __("Title or content"));
380
381 print_select_hash("match_on", 3, $search_fields,
382 'dojoType="dijit.form.Select"');
383 } else {
384 print "<input dojoType=\"dijit.form.ValidationTextBox\"
385 style=\"font-size : 16px; width : 20em;\"
386 required=\"1\" name=\"query\" type=\"search\" value=''>";
387 }
388
389
390 print "<hr/>".__('Limit search to:')." ";
391
392 print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
393 <option value=\"all_feeds\">".__('All feeds')."</option>";
394
395 $feed_title = getFeedTitle($this->link, $active_feed_id);
396
397 if (!$is_cat) {
398 $feed_cat_title = getFeedCatTitle($this->link, $active_feed_id);
399 } else {
400 $feed_cat_title = getCategoryTitle($this->link, $active_feed_id);
401 }
402
403 if ($active_feed_id && !$is_cat) {
404 print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
405 } else {
406 print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
407 }
408
409 if ($is_cat) {
410 $cat_preselected = "selected=\"1\"";
411 }
412
413 if (get_pref($this->link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
414 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
415 } else {
416 //print "<option disabled>".__('This category')."</option>";
417 }
418
419 print "</select>";
420
421 print "</div>";
422
423 print "<div class=\"dlgButtons\">";
424
425 if (!SPHINX_ENABLED) {
426 print "<div style=\"float : left\">
427 <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/redmine/wiki/tt-rss/SearchSyntax\">Search syntax</a>
428 </div>";
429 }
430
431 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
432 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
433 </div>";
434 }
435
436 function quickAddFilter() {
437 $active_feed_id = db_escape_string($_REQUEST["param"]);
438
439 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
440 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">";
441 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
b69a09ea 442 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
3f363052
AD
443
444 $result = db_query($this->link, "SELECT id,description
445 FROM ttrss_filter_types ORDER BY description");
446
447 $filter_types = array();
448
449 while ($line = db_fetch_assoc($result)) {
450 //array_push($filter_types, $line["description"]);
451 $filter_types[$line["id"]] = __($line["description"]);
452 }
453
454 print "<div class=\"dlgSec\">".__("Match")."</div>";
455
456 print "<div class=\"dlgSecCont\">";
457
458 print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">";
459
460 $filter_params = array(
461 "before" => __("before"),
462 "after" => __("after"));
463
464 print_select_hash("filter_date_modifier", "before",
465 $filter_params, 'dojoType="dijit.form.Select"');
466
467 print "&nbsp;</span>";
468
469 print "<input dojoType=\"dijit.form.ValidationTextBox\"
470 required=\"true\" id=\"filterDlg_regExp\"
471 style=\"font-size : 16px\"
472 name=\"reg_exp\" value=\"$reg_exp\"/>";
473
474 print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">";
475 print "&nbsp;<button dojoType=\"dijit.form.Button\"
476 onclick=\"return filterDlgCheckDate()\">".
477 __('Check it')."</button>";
478 print "</span>";
479
480 print "<hr/>" . __("on field") . " ";
481 print_select_hash("filter_type", 1, $filter_types,
482 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
483
484 print "<hr/>";
485
486 print __("in") . " ";
ba975b2e
AD
487
488 print "<span id='filterDlg_feeds'>";
3f363052
AD
489 print_feed_select($this->link, "feed_id", $active_feed_id,
490 'dojoType="dijit.form.FilteringSelect"');
ba975b2e
AD
491 print "</span>";
492
493 print "<span id='filterDlg_cats' style='display : none'>";
494 print_feed_cat_select($this->link, "cat_id", $active_cat_id,
495 'dojoType="dijit.form.FilteringSelect"');
496 print "</span>";
3f363052
AD
497
498 print "</div>";
499
500 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
501
502 print "<div class=\"dlgSecCont\">";
503
504 print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
505 onchange=\"filterDlgCheckAction(this)\">";
506
507 $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions
508 ORDER BY name");
509
510 while ($line = db_fetch_assoc($result)) {
511 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
512 }
513
514 print "</select>";
515
516 print "<span id=\"filterDlg_paramBox\" style=\"display : none\">";
517 print " " . __("with parameters:") . " ";
518 print "<input dojoType=\"dijit.form.TextBox\"
519 id=\"filterDlg_actionParam\"
520 name=\"action_param\">";
521
522 print_label_select($this->link, "action_param_label", $action_param,
523 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
524
525 print "</span>";
526
527 print "&nbsp;"; // tiny layout hack
528
529 print "</div>";
530
531 print "<div class=\"dlgSec\">".__("Options")."</div>";
532 print "<div class=\"dlgSecCont\">";
533
534 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
535 <label for=\"enabled\">".__('Enabled')."</label><hr/>";
536
537 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
ba975b2e
AD
538 <label for=\"inverse\">".__('Inverse match')."</label><hr/>";
539
540 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\">
541 <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
542
3f363052
AD
543
544 print "</div>";
545
546 print "<div class=\"dlgButtons\">";
547
548 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
549 __('Test')."</button> ";
550
551 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
552 __('Create')."</button> ";
553
554 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
555 __('Cancel')."</button>";
556
557 print "</div>";
558 }
559
560 function inactiveFeeds() {
46da73c2 561
3f363052
AD
562 if (DB_TYPE == "pgsql") {
563 $interval_qpart = "NOW() - INTERVAL '3 months'";
564 } else {
565 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
566 }
567
568 $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
569 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
570 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
571 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
572 ttrss_entries.id = ref_id AND
573 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
574 AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND
575 ttrss_user_entries.feed_id = ttrss_feeds.id AND
576 ttrss_entries.id = ref_id
577 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
578 ORDER BY last_article");
579
ca6a0741 580 print "<div class=\"dialogNotice\">" . __("These feeds have not been updated with new content for 3 months (oldest first):") . "</div>";
3f363052 581
ddb575c7
AD
582 print "<div dojoType=\"dijit.Toolbar\">";
583 print "<div dojoType=\"dijit.form.DropDownButton\">".
584 "<span>" . __('Select')."</span>";
585 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
586 print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\"
587 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
588 print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\"
589 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
590 print "</div></div>";
591 print "</div>"; #toolbar
592
3f363052
AD
593 print "<div class=\"inactiveFeedHolder\">";
594
595 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
596
597 $lnum = 1;
598
599 while ($line = db_fetch_assoc($result)) {
600
601 $class = ($lnum % 2) ? "even" : "odd";
602 $feed_id = $line["id"];
603 $this_row_id = "id=\"FUPDD-$feed_id\"";
604
ddb575c7
AD
605 # class needed for selectTableRows()
606 print "<tr class=\"placeholder\" $this_row_id>";
3f363052
AD
607
608 $edit_title = htmlspecialchars($line["title"]);
609
ddb575c7 610 # id needed for selectTableRows()
3f363052
AD
611 print "<td width='5%' align='center'><input
612 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
ddb575c7 613 type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>";
3f363052
AD
614 print "<td>";
615
616 print "<a class=\"visibleLink\" href=\"#\" ".
617 "title=\"".__("Click to edit feed")."\" ".
618 "onclick=\"editFeed(".$line["id"].")\">".
619 htmlspecialchars($line["title"])."</a>";
620
621 print "</td><td class=\"insensitive\" align='right'>";
622 print make_local_datetime($this->link, $line['last_article'], false);
623 print "</td>";
624 print "</tr>";
625
626 ++$lnum;
627 }
628
629 print "</table>";
630 print "</div>";
631
632 print "<div class='dlgButtons'>";
633 print "<div style='float : left'>";
634 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
635 .__('Unsubscribe from selected feeds')."</button> ";
636 print "</div>";
637
638 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">".
639 __('Close this window')."</button>";
640
641 print "</div>";
642
643 }
644
645 function feedsWithErrors() {
ca6a0741 646 print "<div class=\"dialogNotice\">" . __("These feeds have not been updated because of errors:") . "</div>";
3f363052
AD
647
648 $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
649 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
650
ddb575c7
AD
651 print "<div dojoType=\"dijit.Toolbar\">";
652 print "<div dojoType=\"dijit.form.DropDownButton\">".
653 "<span>" . __('Select')."</span>";
654 print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
655 print "<div onclick=\"selectTableRows('prefErrorFeedList', 'all')\"
656 dojoType=\"dijit.MenuItem\">".__('All')."</div>";
657 print "<div onclick=\"selectTableRows('prefErrorFeedList', 'none')\"
658 dojoType=\"dijit.MenuItem\">".__('None')."</div>";
659 print "</div></div>";
660 print "</div>"; #toolbar
661
3f363052
AD
662 print "<div class=\"inactiveFeedHolder\">";
663
664 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
665
666 $lnum = 1;
667
668 while ($line = db_fetch_assoc($result)) {
669
670 $class = ($lnum % 2) ? "even" : "odd";
671 $feed_id = $line["id"];
672 $this_row_id = "id=\"FUPDD-$feed_id\"";
673
ddb575c7
AD
674 # class needed for selectTableRows()
675 print "<tr class=\"placeholder\" $this_row_id>";
3f363052
AD
676
677 $edit_title = htmlspecialchars($line["title"]);
678
ddb575c7 679 # id needed for selectTableRows()
3f363052
AD
680 print "<td width='5%' align='center'><input
681 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
ddb575c7 682 type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>";
3f363052
AD
683 print "<td>";
684
685 print "<a class=\"visibleLink\" href=\"#\" ".
686 "title=\"".__("Click to edit feed")."\" ".
687 "onclick=\"editFeed(".$line["id"].")\">".
688 htmlspecialchars($line["title"])."</a>: ";
689
690 print "<span class=\"insensitive\">";
691 print htmlspecialchars($line["last_error"]);
692 print "</span>";
693
694 print "</td>";
695 print "</tr>";
696
697 ++$lnum;
698 }
699
700 print "</table>";
701 print "</div>";
702
703 print "<div class='dlgButtons'>";
704 print "<div style='float : left'>";
705 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
706 .__('Unsubscribe from selected feeds')."</button> ";
707 print "</div>";
708
709 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
710 __('Close this window')."</button>";
711
712 print "</div>";
713 }
714
715 function editArticleTags() {
716
717 print __("Tags for this article (separated by commas):")."<br>";
718
719 $tags = get_article_tags($this->link, $this->param);
720
721 $tags_str = join(", ", $tags);
722
723 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">";
724 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
725 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
726
727 print "<table width='100%'><tr><td>";
728
729 print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
730 style='font-size : 12px; width : 100%' id=\"tags_str\"
731 name='tags_str'>$tags_str</textarea>
732 <div class=\"autocomplete\" id=\"tags_choices\"
733 style=\"display:none\"></div>";
734
735 print "</td></tr></table>";
736
737 print "<div class='dlgButtons'>";
738
739 print "<button dojoType=\"dijit.form.Button\"
740 onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> ";
741 print "<button dojoType=\"dijit.form.Button\"
742 onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>";
743 print "</div>";
744
745 }
746
747 function printTagCloud() {
748 print "<title>".__('Tag Cloud')."</title>";
749 print "<content><![CDATA[";
750
751 print "<div class=\"tagCloudContainer\">";
752
79178062
AD
753 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
754
755 $query = "SELECT tag_name, COUNT(post_int_id) AS count
756 FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
757 GROUP BY tag_name ORDER BY count DESC LIMIT 50";
758
759 $result = db_query($this->link, $query);
760
761 $tags = array();
762
763 while ($line = db_fetch_assoc($result)) {
764 $tags[$line["tag_name"]] = $line["count"];
765 }
766
767 if( count($tags) == 0 ){ return; }
768
769 ksort($tags);
770
771 $max_size = 32; // max font size in pixels
772 $min_size = 11; // min font size in pixels
773
774 // largest and smallest array values
775 $max_qty = max(array_values($tags));
776 $min_qty = min(array_values($tags));
777
778 // find the range of values
779 $spread = $max_qty - $min_qty;
780 if ($spread == 0) { // we don't want to divide by zero
781 $spread = 1;
782 }
783
784 // set the font-size increment
785 $step = ($max_size - $min_size) / ($spread);
786
787 // loop through the tag array
788 foreach ($tags as $key => $value) {
789 // calculate font-size
790 // find the $value in excess of $min_qty
791 // multiply by the font-size increment ($size)
792 // and add the $min_size set above
793 $size = round($min_size + (($value - $min_qty) * $step));
794
795 $key_escaped = str_replace("'", "\\'", $key);
796
797 echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " .
798 $size . "px\" title=\"$value articles tagged with " .
799 $key . '">' . $key . '</a> ';
800 }
801
802
3f363052
AD
803
804 print "</div>";
805
806 print "<div align='center'>";
807 print "<button dojoType=\"dijit.form.Button\"
808 onclick=\"return closeInfoBox()\">".
809 __('Close this window')."</button>";
810 print "</div>";
811
812 print "]]></content>";
813 }
814
815 function printTagSelect() {
46da73c2 816
3f363052
AD
817 print "<title>" . __('Select item(s) by tags') . "</title>";
818 print "<content><![CDATA[";
819
820 print __("Match:"). "&nbsp;" .
821 "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\">&nbsp;Any&nbsp;";
822 print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\">&nbsp;All&nbsp;";
823 print "&nbsp;tags.";
824
825 print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
826 $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
827 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
828
829 while ($row = db_fetch_assoc($result)) {
830 $tmp = htmlspecialchars($row["tag_name"]);
831 print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
832 }
833
834 print "</select>";
835
836 print "<div align='right'>";
837 print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
838 get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
839 print "&nbsp;";
840 print "<button dojoType=\"dijit.form.Button\"
841 onclick=\"return closeInfoBox()\">" .
842 __('Close this window') . "</button>";
843 print "</div>";
844
845 print "]]></content>";
846 }
847
3f363052 848 function generatedFeed() {
46da73c2 849
3f363052
AD
850 print "<title>".__('View as RSS')."</title>";
851 print "<content><![CDATA[";
852
853 $this->params = explode(":", $this->param, 3);
854 $feed_id = db_escape_string($this->params[0]);
855 $is_cat = (bool) $this->params[1];
856
857 $key = get_feed_access_key($this->link, $feed_id, $is_cat);
858
859 $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
860
ca6a0741 861 print "<div class=\"dialogNotice\">" . __("You can view this feed as RSS using the following URL:") . "</div>";
3f363052
AD
862
863 print "<div class=\"tagCloudContainer\">";
864 print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
865 print "</div>";
866
867 print "<div align='center'>";
868
869 print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
870 __('Generate new URL')."</button> ";
871
872 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
873 __('Close this window')."</button>";
874
875 print "</div>";
876 print "]]></content>";
877
878 //return;
879 }
880
881 function newVersion() {
46da73c2 882
3f363052
AD
883 $version_data = check_for_update($this->link);
884 $version = $version_data['version'];
885 $id = $version_data['version_id'];
886
887 print "<div class='tagCloudContainer'>";
888
889 print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
890 "<b>$version</b>");
891
892 print "</div>";
893
894 $details = "http://tt-rss.org/redmine/versions/show/$id";
895 $download = "http://tt-rss.org/#Download";
896
897 print "<div style='text-align : center'>";
898 print "<button dojoType=\"dijit.form.Button\"
899 onclick=\"return window.open('$details')\">".__("Details")."</button>";
900 print "<button dojoType=\"dijit.form.Button\"
901 onclick=\"return window.open('$download')\">".__("Download")."</button>";
902 print "<button dojoType=\"dijit.form.Button\"
903 onclick=\"return dijit.byId('newVersionDlg').hide()\">".
904 __('Close this window')."</button>";
905 print "</div>";
906
907 }
908
909 function customizeCSS() {
910 $value = get_pref($this->link, "USER_STYLESHEET");
911
912 $value = str_replace("<br/>", "\n", $value);
913
ca6a0741 914 print "<div class=\"dialogNotice\">";
3f363052 915 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");
ca6a0741 916 print "</div>";
3f363052
AD
917
918 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
919 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
920 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
921
922 print "<table width='100%'><tr><td>";
923 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
924 style='font-size : 12px; width : 100%; height: 200px;'
925 placeHolder='body#ttrssMain { font-size : 14px; };'
926 name='value'>$value</textarea>";
927 print "</td></tr></table>";
928
929 print "<div class='dlgButtons'>";
930 print "<button dojoType=\"dijit.form.Button\"
931 onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
932 print "<button dojoType=\"dijit.form.Button\"
933 onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
934 print "</div>";
935
936 }
937
3f363052
AD
938 function addInstance() {
939 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
940 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
941
942 print "<div class=\"dlgSec\">".__("Instance")."</div>";
943
944 print "<div class=\"dlgSecCont\">";
945
946 /* URL */
947
948 print __("URL:") . " ";
949
950 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
951 placeHolder=\"".__("Instance URL")."\"
952 regExp='^(http|https)://.*'
953 style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
954
955 print "<hr/>";
956
957 $access_key = sha1(uniqid(rand(), true));
958
959 /* Access key */
960
961 print __("Access key:") . " ";
962
963 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
964 placeHolder=\"".__("Access key")."\" regExp='\w{40}'
965 style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
966 value=\"$access_key\">";
967
968 print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
969
970 print "</div>";
971
972 print "<div class=\"dlgButtons\">
973 <div style='float : left'>
974 <button dojoType=\"dijit.form.Button\"
975 onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
976 __('Generate new key')."</button>
977 </div>
978 <button dojoType=\"dijit.form.Button\"
979 onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
980 __('Create link')."</button>
981 <button dojoType=\"dijit.form.Button\"
982 onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
983 __('Cancel')."</button></div>";
984
985 return;
986 }
987
55f34b81
AD
988 function dataImport() {
989 header("Content-Type: text/html"); # required for iframe
990
991 print "<div style='text-align : center'>";
992
993 if (is_file($_FILES['export_file']['tmp_name'])) {
994
995 perform_data_import($this->link, $_FILES['export_file']['tmp_name'], $_SESSION['uid']);
996
997 } else {
998 print "<p>" . T_sprintf("Could not upload file. You might need to adjust upload_max_filesize
999 in PHP.ini (current value = %s)", ini_get("upload_max_filesize")) . " or use CLI import tool.</p>";
1000
1001 }
1002
1003 print "<button dojoType=\"dijit.form.Button\"
1004 onclick=\"dijit.byId('dataImportDlg').hide()\">".
1005 __('Close this window')."</button>";
1006
1007 print "</div>";
1008
1009 }
1010
33f0fdd0
AD
1011 function batchSubscribe() {
1012 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
1013 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchaddfeeds\">";
1014
1015 print "<table width='100%'><tr><td>
1016 ".__("Add one valid RSS feed per line (no feed detection is done)")."
1017 </td><td align='right'>";
1018 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
1019 print __('Place in category:') . " ";
1020 print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
1021 }
1022 print "</td></tr><tr><td colspan='2'>";
1023 print "<textarea
1024 style='font-size : 12px; width : 100%; height: 200px;'
1025 placeHolder=\"".__("Feeds to subscribe, One per line")."\"
1026 dojoType=\"dijit.form.SimpleTextarea\" required=\"1\" name=\"feeds\"></textarea>";
1027
1028 print "</td></tr><tr><td colspan='2'>";
1029
1030 print "<div id='feedDlg_loginContainer' style='display : none'>
1031 " .
1032 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
1033 placeHolder=\"".__("Login")."\"
1034 style=\"width : 10em;\"> ".
1035 " <input
1036 placeHolder=\"".__("Password")."\"
1037 dojoType=\"dijit.form.TextBox\" type='password'
1038 style=\"width : 10em;\" name='pass'\">".
1039 " <p class='insensitive'>".__("OAuth will be used automatically for Twitter feeds.")."</p>
1040 </div>";
1041
1042 print "</td></tr><tr><td colspan='2'>";
1043
1044 print "<div style=\"clear : both\">
1045 <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
1046 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
1047 <label for=\"feedDlg_loginCheck\">".
1048 __('Feeds require authentication.')."</div>";
1049
1050 print "</form>";
1051
1052 print "</td></tr></table>";
1053
1054 print "<div class=\"dlgButtons\">
1055 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').execute()\">".__('Subscribe')."</button>
1056 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button>
1057 </div>";
1058 }
1059
3f363052
AD
1060}
1061?>