]> git.wh0rd.org - tt-rss.git/blob - classes/dlg.php
fix OPML import
[tt-rss.git] / classes / dlg.php
1 <?php
2 class Dlg extends Protected_Handler {
3 private $param;
4
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 }
14
15 function after() {
16 print "</dlg>";
17 }
18
19 function importOpml() {
20 header("Content-Type: text/html"); # required for iframe
21
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
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>";
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\">";
420
421 $result = db_query($this->link, "SELECT id,description
422 FROM ttrss_filter_types ORDER BY description");
423
424 $filter_types = array();
425
426 while ($line = db_fetch_assoc($result)) {
427 //array_push($filter_types, $line["description"]);
428 $filter_types[$line["id"]] = __($line["description"]);
429 }
430
431 print "<div class=\"dlgSec\">".__("Match")."</div>";
432
433 print "<div class=\"dlgSecCont\">";
434
435 print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">";
436
437 $filter_params = array(
438 "before" => __("before"),
439 "after" => __("after"));
440
441 print_select_hash("filter_date_modifier", "before",
442 $filter_params, 'dojoType="dijit.form.Select"');
443
444 print "&nbsp;</span>";
445
446 print "<input dojoType=\"dijit.form.ValidationTextBox\"
447 required=\"true\" id=\"filterDlg_regExp\"
448 style=\"font-size : 16px\"
449 name=\"reg_exp\" value=\"$reg_exp\"/>";
450
451 print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">";
452 print "&nbsp;<button dojoType=\"dijit.form.Button\"
453 onclick=\"return filterDlgCheckDate()\">".
454 __('Check it')."</button>";
455 print "</span>";
456
457 print "<hr/>" . __("on field") . " ";
458 print_select_hash("filter_type", 1, $filter_types,
459 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
460
461 print "<hr/>";
462
463 print __("in") . " ";
464 print_feed_select($this->link, "feed_id", $active_feed_id,
465 'dojoType="dijit.form.FilteringSelect"');
466
467 print "</div>";
468
469 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
470
471 print "<div class=\"dlgSecCont\">";
472
473 print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
474 onchange=\"filterDlgCheckAction(this)\">";
475
476 $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions
477 ORDER BY name");
478
479 while ($line = db_fetch_assoc($result)) {
480 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
481 }
482
483 print "</select>";
484
485 print "<span id=\"filterDlg_paramBox\" style=\"display : none\">";
486 print " " . __("with parameters:") . " ";
487 print "<input dojoType=\"dijit.form.TextBox\"
488 id=\"filterDlg_actionParam\"
489 name=\"action_param\">";
490
491 print_label_select($this->link, "action_param_label", $action_param,
492 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
493
494 print "</span>";
495
496 print "&nbsp;"; // tiny layout hack
497
498 print "</div>";
499
500 print "<div class=\"dlgSec\">".__("Options")."</div>";
501 print "<div class=\"dlgSecCont\">";
502
503 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
504 <label for=\"enabled\">".__('Enabled')."</label><hr/>";
505
506 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
507 <label for=\"inverse\">".__('Inverse match')."</label>";
508
509 print "</div>";
510
511 print "<div class=\"dlgButtons\">";
512
513 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
514 __('Test')."</button> ";
515
516 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
517 __('Create')."</button> ";
518
519 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
520 __('Cancel')."</button>";
521
522 print "</div>";
523 }
524
525 function inactiveFeeds() {
526
527 if (DB_TYPE == "pgsql") {
528 $interval_qpart = "NOW() - INTERVAL '3 months'";
529 } else {
530 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
531 }
532
533 $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
534 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
535 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
536 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
537 ttrss_entries.id = ref_id AND
538 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
539 AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND
540 ttrss_user_entries.feed_id = ttrss_feeds.id AND
541 ttrss_entries.id = ref_id
542 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
543 ORDER BY last_article");
544
545 print __("These feeds have not been updated with new content for 3 months (oldest first):");
546
547 print "<div class=\"inactiveFeedHolder\">";
548
549 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
550
551 $lnum = 1;
552
553 while ($line = db_fetch_assoc($result)) {
554
555 $class = ($lnum % 2) ? "even" : "odd";
556 $feed_id = $line["id"];
557 $this_row_id = "id=\"FUPDD-$feed_id\"";
558
559 print "<tr class=\"\" $this_row_id>";
560
561 $edit_title = htmlspecialchars($line["title"]);
562
563 print "<td width='5%' align='center'><input
564 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
565 type=\"checkbox\"></td>";
566 print "<td>";
567
568 print "<a class=\"visibleLink\" href=\"#\" ".
569 "title=\"".__("Click to edit feed")."\" ".
570 "onclick=\"editFeed(".$line["id"].")\">".
571 htmlspecialchars($line["title"])."</a>";
572
573 print "</td><td class=\"insensitive\" align='right'>";
574 print make_local_datetime($this->link, $line['last_article'], false);
575 print "</td>";
576 print "</tr>";
577
578 ++$lnum;
579 }
580
581 print "</table>";
582 print "</div>";
583
584 print "<div class='dlgButtons'>";
585 print "<div style='float : left'>";
586 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
587 .__('Unsubscribe from selected feeds')."</button> ";
588 print "</div>";
589
590 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">".
591 __('Close this window')."</button>";
592
593 print "</div>";
594
595 }
596
597 function feedsWithErrors() {
598 print __("These feeds have not been updated because of errors:");
599
600 $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
601 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
602
603 print "<div class=\"inactiveFeedHolder\">";
604
605 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
606
607 $lnum = 1;
608
609 while ($line = db_fetch_assoc($result)) {
610
611 $class = ($lnum % 2) ? "even" : "odd";
612 $feed_id = $line["id"];
613 $this_row_id = "id=\"FUPDD-$feed_id\"";
614
615 print "<tr class=\"\" $this_row_id>";
616
617 $edit_title = htmlspecialchars($line["title"]);
618
619 print "<td width='5%' align='center'><input
620 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
621 type=\"checkbox\"></td>";
622 print "<td>";
623
624 print "<a class=\"visibleLink\" href=\"#\" ".
625 "title=\"".__("Click to edit feed")."\" ".
626 "onclick=\"editFeed(".$line["id"].")\">".
627 htmlspecialchars($line["title"])."</a>: ";
628
629 print "<span class=\"insensitive\">";
630 print htmlspecialchars($line["last_error"]);
631 print "</span>";
632
633 print "</td>";
634 print "</tr>";
635
636 ++$lnum;
637 }
638
639 print "</table>";
640 print "</div>";
641
642 print "<div class='dlgButtons'>";
643 print "<div style='float : left'>";
644 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
645 .__('Unsubscribe from selected feeds')."</button> ";
646 print "</div>";
647
648 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
649 __('Close this window')."</button>";
650
651 print "</div>";
652 }
653
654 function editArticleTags() {
655
656 print __("Tags for this article (separated by commas):")."<br>";
657
658 $tags = get_article_tags($this->link, $this->param);
659
660 $tags_str = join(", ", $tags);
661
662 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">";
663 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
664 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
665
666 print "<table width='100%'><tr><td>";
667
668 print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
669 style='font-size : 12px; width : 100%' id=\"tags_str\"
670 name='tags_str'>$tags_str</textarea>
671 <div class=\"autocomplete\" id=\"tags_choices\"
672 style=\"display:none\"></div>";
673
674 print "</td></tr></table>";
675
676 print "<div class='dlgButtons'>";
677
678 print "<button dojoType=\"dijit.form.Button\"
679 onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> ";
680 print "<button dojoType=\"dijit.form.Button\"
681 onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>";
682 print "</div>";
683
684 }
685
686 function printTagCloud() {
687 print "<title>".__('Tag Cloud')."</title>";
688 print "<content><![CDATA[";
689
690 print "<div class=\"tagCloudContainer\">";
691
692 // from here: http://www.roscripts.com/Create_tag_cloud-71.html
693
694 $query = "SELECT tag_name, COUNT(post_int_id) AS count
695 FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
696 GROUP BY tag_name ORDER BY count DESC LIMIT 50";
697
698 $result = db_query($this->link, $query);
699
700 $tags = array();
701
702 while ($line = db_fetch_assoc($result)) {
703 $tags[$line["tag_name"]] = $line["count"];
704 }
705
706 if( count($tags) == 0 ){ return; }
707
708 ksort($tags);
709
710 $max_size = 32; // max font size in pixels
711 $min_size = 11; // min font size in pixels
712
713 // largest and smallest array values
714 $max_qty = max(array_values($tags));
715 $min_qty = min(array_values($tags));
716
717 // find the range of values
718 $spread = $max_qty - $min_qty;
719 if ($spread == 0) { // we don't want to divide by zero
720 $spread = 1;
721 }
722
723 // set the font-size increment
724 $step = ($max_size - $min_size) / ($spread);
725
726 // loop through the tag array
727 foreach ($tags as $key => $value) {
728 // calculate font-size
729 // find the $value in excess of $min_qty
730 // multiply by the font-size increment ($size)
731 // and add the $min_size set above
732 $size = round($min_size + (($value - $min_qty) * $step));
733
734 $key_escaped = str_replace("'", "\\'", $key);
735
736 echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " .
737 $size . "px\" title=\"$value articles tagged with " .
738 $key . '">' . $key . '</a> ';
739 }
740
741
742
743 print "</div>";
744
745 print "<div align='center'>";
746 print "<button dojoType=\"dijit.form.Button\"
747 onclick=\"return closeInfoBox()\">".
748 __('Close this window')."</button>";
749 print "</div>";
750
751 print "]]></content>";
752 }
753
754 function printTagSelect() {
755
756 print "<title>" . __('Select item(s) by tags') . "</title>";
757 print "<content><![CDATA[";
758
759 print __("Match:"). "&nbsp;" .
760 "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\">&nbsp;Any&nbsp;";
761 print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\">&nbsp;All&nbsp;";
762 print "&nbsp;tags.";
763
764 print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
765 $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
766 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
767
768 while ($row = db_fetch_assoc($result)) {
769 $tmp = htmlspecialchars($row["tag_name"]);
770 print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
771 }
772
773 print "</select>";
774
775 print "<div align='right'>";
776 print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
777 get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
778 print "&nbsp;";
779 print "<button dojoType=\"dijit.form.Button\"
780 onclick=\"return closeInfoBox()\">" .
781 __('Close this window') . "</button>";
782 print "</div>";
783
784 print "]]></content>";
785 }
786
787 function generatedFeed() {
788
789 print "<title>".__('View as RSS')."</title>";
790 print "<content><![CDATA[";
791
792 $this->params = explode(":", $this->param, 3);
793 $feed_id = db_escape_string($this->params[0]);
794 $is_cat = (bool) $this->params[1];
795
796 $key = get_feed_access_key($this->link, $feed_id, $is_cat);
797
798 $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
799
800 print __("You can view this feed as RSS using the following URL:");
801
802 print "<div class=\"tagCloudContainer\">";
803 print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
804 print "</div>";
805
806 print "<div align='center'>";
807
808 print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
809 __('Generate new URL')."</button> ";
810
811 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
812 __('Close this window')."</button>";
813
814 print "</div>";
815 print "]]></content>";
816
817 //return;
818 }
819
820 function newVersion() {
821
822 $version_data = check_for_update($this->link);
823 $version = $version_data['version'];
824 $id = $version_data['version_id'];
825
826 print "<div class='tagCloudContainer'>";
827
828 print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
829 "<b>$version</b>");
830
831 print "</div>";
832
833 $details = "http://tt-rss.org/redmine/versions/show/$id";
834 $download = "http://tt-rss.org/#Download";
835
836 print "<div style='text-align : center'>";
837 print "<button dojoType=\"dijit.form.Button\"
838 onclick=\"return window.open('$details')\">".__("Details")."</button>";
839 print "<button dojoType=\"dijit.form.Button\"
840 onclick=\"return window.open('$download')\">".__("Download")."</button>";
841 print "<button dojoType=\"dijit.form.Button\"
842 onclick=\"return dijit.byId('newVersionDlg').hide()\">".
843 __('Close this window')."</button>";
844 print "</div>";
845
846 }
847
848 function customizeCSS() {
849 $value = get_pref($this->link, "USER_STYLESHEET");
850
851 $value = str_replace("<br/>", "\n", $value);
852
853 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");
854
855 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
856 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
857 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
858
859 print "<table width='100%'><tr><td>";
860 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
861 style='font-size : 12px; width : 100%; height: 200px;'
862 placeHolder='body#ttrssMain { font-size : 14px; };'
863 name='value'>$value</textarea>";
864 print "</td></tr></table>";
865
866 print "<div class='dlgButtons'>";
867 print "<button dojoType=\"dijit.form.Button\"
868 onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
869 print "<button dojoType=\"dijit.form.Button\"
870 onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
871 print "</div>";
872
873 }
874
875 function addInstance() {
876 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
877 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
878
879 print "<div class=\"dlgSec\">".__("Instance")."</div>";
880
881 print "<div class=\"dlgSecCont\">";
882
883 /* URL */
884
885 print __("URL:") . " ";
886
887 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
888 placeHolder=\"".__("Instance URL")."\"
889 regExp='^(http|https)://.*'
890 style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
891
892 print "<hr/>";
893
894 $access_key = sha1(uniqid(rand(), true));
895
896 /* Access key */
897
898 print __("Access key:") . " ";
899
900 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
901 placeHolder=\"".__("Access key")."\" regExp='\w{40}'
902 style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
903 value=\"$access_key\">";
904
905 print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
906
907 print "</div>";
908
909 print "<div class=\"dlgButtons\">
910 <div style='float : left'>
911 <button dojoType=\"dijit.form.Button\"
912 onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
913 __('Generate new key')."</button>
914 </div>
915 <button dojoType=\"dijit.form.Button\"
916 onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
917 __('Create link')."</button>
918 <button dojoType=\"dijit.form.Button\"
919 onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
920 __('Cancel')."</button></div>";
921
922 return;
923 }
924
925 }
926 ?>