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