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