]> git.wh0rd.org - tt-rss.git/blob - classes/dlg.php
implement tiny-OOP routing
[tt-rss.git] / classes / dlg.php
1 <?php
2 class Dlg extends 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 if (function_exists('domxml_open_file')) {
44 print "<ul class='nomarks'>";
45 print "<li>".__("Importing using DOMXML.")."</li>";
46 require_once "opml_domxml.php";
47 opml_import_domxml($this->link, $owner_uid);
48 print "</ul>";
49 } else if (PHP_VERSION >= 5) {
50 print "<ul class='nomarks'>";
51 print "<li>".__("Importing using DOMDocument.")."</li>";
52 require_once "opml_domdoc.php";
53 opml_import_domdoc($this->link, $owner_uid);
54 print "</ul>";
55 } else {
56 print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
57 }
58
59 print "</div>";
60
61 print "<div align='center'>";
62 print "<button dojoType=\"dijit.form.Button\"
63 onclick=\"dijit.byId('opmlImportDlg').hide()\">".
64 __('Close this window')."</button>";
65 print "</div>";
66
67 print "</div>";
68
69 //return;
70 }
71
72 function editPrefProfiles() {
73 print "<div dojoType=\"dijit.Toolbar\">";
74
75 print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
76 required=\"1\">
77 <button dojoType=\"dijit.form.Button\"
78 onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
79 __('Create profile')."</button></div>";
80
81 $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
82 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
83
84 print "<div class=\"prefFeedCatHolder\">";
85
86 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
87
88 print "<table width=\"100%\" class=\"prefFeedProfileList\"
89 cellspacing=\"0\" id=\"prefFeedProfileList\">";
90
91 print "<tr class=\"\" id=\"FCATR-0\">"; #odd
92
93 print "<td width='5%' align='center'><input
94 onclick='toggleSelectRow2(this);'
95 dojoType=\"dijit.form.CheckBox\"
96 type=\"checkbox\"></td>";
97
98 if (!$_SESSION["profile"]) {
99 $is_active = __("(active)");
100 } else {
101 $is_active = "";
102 }
103
104 print "<td><span>" .
105 __("Default profile") . " $is_active</span></td>";
106
107 print "</tr>";
108
109 $lnum = 1;
110
111 while ($line = db_fetch_assoc($result)) {
112
113 $class = ($lnum % 2) ? "even" : "odd";
114
115 $profile_id = $line["id"];
116 $this_row_id = "id=\"FCATR-$profile_id\"";
117
118 print "<tr class=\"\" $this_row_id>";
119
120 $edit_title = htmlspecialchars($line["title"]);
121
122 print "<td width='5%' align='center'><input
123 onclick='toggleSelectRow2(this);'
124 dojoType=\"dijit.form.CheckBox\"
125 type=\"checkbox\"></td>";
126
127 if ($_SESSION["profile"] == $line["id"]) {
128 $is_active = __("(active)");
129 } else {
130 $is_active = "";
131 }
132
133 print "<td><span dojoType=\"dijit.InlineEditBox\"
134 width=\"300px\" autoSave=\"false\"
135 profile-id=\"$profile_id\">" . $edit_title .
136 "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
137 var elem = this;
138 dojo.xhrPost({
139 url: 'backend.php',
140 content: {op: 'rpc', method: 'saveprofile',
141 value: this.value,
142 id: this.srcNodeRef.getAttribute('profile-id')},
143 load: function(response) {
144 elem.attr('value', response);
145 }
146 });
147 </script>
148 </span> $is_active</td>";
149
150 print "</tr>";
151
152 ++$lnum;
153 }
154
155 print "</table>";
156 print "</form>";
157 print "</div>";
158
159 print "<div class='dlgButtons'>
160 <div style='float : left'>
161 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">".
162 __('Remove selected profiles')."</button>
163 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">".
164 __('Activate profile')."</button>
165 </div>";
166
167 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">".
168 __('Close this window')."</button>";
169 print "</div>";
170
171 }
172
173 function pubOPMLUrl() {
174 print "<title>".__('Public OPML URL')."</title>";
175 print "<content><![CDATA[";
176
177 $url_path = opml_publish_url($this->link);
178
179 print __("Your Public OPML URL is:");
180
181 print "<div class=\"tagCloudContainer\">";
182 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
183 print "</div>";
184
185 print "<div align='center'>";
186
187 print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
188 __('Generate new URL')."</button> ";
189
190 print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
191 __('Close this window')."</button>";
192
193 print "</div>";
194 print "]]></content>";
195
196 //return;
197 }
198
199 function explainError() {
200 print "<title>".__('Notice')."</title>";
201 print "<content><![CDATA[";
202
203 print "<div class=\"errorExplained\">";
204
205 if ($this->param == 1) {
206 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.");
207
208 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
209
210 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
211
212 }
213
214 if ($this->param == 3) {
215 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.");
216
217 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
218
219 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
220
221 }
222
223 print "</div>";
224
225 print "<div align='center'>";
226
227 print "<button onclick=\"return closeInfoBox()\">".
228 __('Close this window')."</button>";
229
230 print "</div>";
231 print "]]></content>";
232
233 //return;
234 }
235
236 function quickAddFeed() {
237 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
238 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
239
240 print "<div class=\"dlgSec\">".__("Feed")."</div>";
241 print "<div class=\"dlgSecCont\">";
242
243 print "<input style=\"font-size : 16px; width : 20em;\"
244 placeHolder=\"".__("Feed URL")."\"
245 dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
246
247 print "<hr/>";
248
249 if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
250 print __('Place in category:') . " ";
251 print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
252 }
253
254 print "</div>";
255
256 print '<div id="feedDlg_feedsContainer" style="display : none">
257
258 <div class="dlgSec">' . __('Available feeds') . '</div>
259 <div class="dlgSecCont">'.
260 '<select id="feedDlg_feedContainerSelect"
261 dojoType="dijit.form.Select" size="3">
262 <script type="dojo/method" event="onChange" args="value">
263 dijit.byId("feedDlg_feedUrl").attr("value", value);
264 </script>
265 </select>'.
266 '</div></div>';
267
268 print "<div id='feedDlg_loginContainer' style='display : none'>
269
270 <div class=\"dlgSec\">".__("Authentication")."</div>
271 <div class=\"dlgSecCont\">".
272
273 " <input dojoType=\"dijit.form.TextBox\" name='login'\"
274 placeHolder=\"".__("Login")."\"
275 style=\"width : 10em;\"> ".
276 " <input
277 placeHolder=\"".__("Password")."\"
278 dojoType=\"dijit.form.TextBox\" type='password'
279 style=\"width : 10em;\" name='pass'\">
280 </div></div>";
281
282
283 print "<div style=\"clear : both\">
284 <input type=\"checkbox\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
285 onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
286 <label for=\"feedDlg_loginCheck\">".
287 __('This feed requires authentication.')."</div>";
288
289 print "</form>";
290
291 print "<div class=\"dlgButtons\">
292 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>
293 <button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>
294 <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
295 </div>";
296
297 //return;
298 }
299
300 function feedBrowser() {
301 $browser_search = db_escape_string($_REQUEST["search"]);
302
303 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
304 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
305
306 print "<div dojoType=\"dijit.Toolbar\">
307 <div style='float : right'>
308 <img style='display : none'
309 id='feed_browser_spinner' src='".
310 theme_image($this->link, 'images/indicator_white.gif')."'>
311 <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
312 onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
313 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
314 </div>";
315
316 print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
317 <option value='1'>" . __('Popular feeds') . "</option>
318 <option value='2'>" . __('Feed archive') . "</option>
319 </select> ";
320
321 print __("limit:");
322
323 print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
324
325 foreach (array(25, 50, 100, 200) as $l) {
326 $issel = ($l == $limit) ? "selected=\"1\"" : "";
327 print "<option $issel value=\"$l\">$l</option>";
328 }
329
330 print "</select> ";
331
332 print "</div>";
333
334 $owner_uid = $_SESSION["uid"];
335
336 print "<ul class='browseFeedList' id='browseFeedList'>";
337 print make_feed_browser($this->link, $search, 25);
338 print "</ul>";
339
340 print "<div align='center'>
341 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
342 <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
343 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
344
345 }
346
347 function search() {
348 $this->params = explode(":", db_escape_string($_REQUEST["param"]), 2);
349
350 $active_feed_id = sprintf("%d", $this->params[0]);
351 $is_cat = $this->params[1] != "false";
352
353 print "<div class=\"dlgSec\">".__('Look for')."</div>";
354
355 print "<div class=\"dlgSecCont\">";
356
357 if (!SPHINX_ENABLED) {
358
359 print "<input dojoType=\"dijit.form.ValidationTextBox\"
360 style=\"font-size : 16px; width : 12em;\"
361 required=\"1\" name=\"query\" type=\"search\" value=''>";
362
363 print " " . __('match on')." ";
364
365 $search_fields = array(
366 "title" => __("Title"),
367 "content" => __("Content"),
368 "both" => __("Title or content"));
369
370 print_select_hash("match_on", 3, $search_fields,
371 'dojoType="dijit.form.Select"');
372 } else {
373 print "<input dojoType=\"dijit.form.ValidationTextBox\"
374 style=\"font-size : 16px; width : 20em;\"
375 required=\"1\" name=\"query\" type=\"search\" value=''>";
376 }
377
378
379 print "<hr/>".__('Limit search to:')." ";
380
381 print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
382 <option value=\"all_feeds\">".__('All feeds')."</option>";
383
384 $feed_title = getFeedTitle($this->link, $active_feed_id);
385
386 if (!$is_cat) {
387 $feed_cat_title = getFeedCatTitle($this->link, $active_feed_id);
388 } else {
389 $feed_cat_title = getCategoryTitle($this->link, $active_feed_id);
390 }
391
392 if ($active_feed_id && !$is_cat) {
393 print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
394 } else {
395 print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
396 }
397
398 if ($is_cat) {
399 $cat_preselected = "selected=\"1\"";
400 }
401
402 if (get_pref($this->link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
403 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
404 } else {
405 //print "<option disabled>".__('This category')."</option>";
406 }
407
408 print "</select>";
409
410 print "</div>";
411
412 print "<div class=\"dlgButtons\">";
413
414 if (!SPHINX_ENABLED) {
415 print "<div style=\"float : left\">
416 <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/redmine/wiki/tt-rss/SearchSyntax\">Search syntax</a>
417 </div>";
418 }
419
420 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
421 <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
422 </div>";
423 }
424
425 function quickAddFilter() {
426 $active_feed_id = db_escape_string($_REQUEST["param"]);
427
428 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
429 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">";
430 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
431
432 $result = db_query($this->link, "SELECT id,description
433 FROM ttrss_filter_types ORDER BY description");
434
435 $filter_types = array();
436
437 while ($line = db_fetch_assoc($result)) {
438 //array_push($filter_types, $line["description"]);
439 $filter_types[$line["id"]] = __($line["description"]);
440 }
441
442 print "<div class=\"dlgSec\">".__("Match")."</div>";
443
444 print "<div class=\"dlgSecCont\">";
445
446 print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">";
447
448 $filter_params = array(
449 "before" => __("before"),
450 "after" => __("after"));
451
452 print_select_hash("filter_date_modifier", "before",
453 $filter_params, 'dojoType="dijit.form.Select"');
454
455 print "&nbsp;</span>";
456
457 print "<input dojoType=\"dijit.form.ValidationTextBox\"
458 required=\"true\" id=\"filterDlg_regExp\"
459 style=\"font-size : 16px\"
460 name=\"reg_exp\" value=\"$reg_exp\"/>";
461
462 print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">";
463 print "&nbsp;<button dojoType=\"dijit.form.Button\"
464 onclick=\"return filterDlgCheckDate()\">".
465 __('Check it')."</button>";
466 print "</span>";
467
468 print "<hr/>" . __("on field") . " ";
469 print_select_hash("filter_type", 1, $filter_types,
470 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
471
472 print "<hr/>";
473
474 print __("in") . " ";
475 print_feed_select($this->link, "feed_id", $active_feed_id,
476 'dojoType="dijit.form.FilteringSelect"');
477
478 print "</div>";
479
480 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
481
482 print "<div class=\"dlgSecCont\">";
483
484 print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
485 onchange=\"filterDlgCheckAction(this)\">";
486
487 $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions
488 ORDER BY name");
489
490 while ($line = db_fetch_assoc($result)) {
491 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
492 }
493
494 print "</select>";
495
496 print "<span id=\"filterDlg_paramBox\" style=\"display : none\">";
497 print " " . __("with parameters:") . " ";
498 print "<input dojoType=\"dijit.form.TextBox\"
499 id=\"filterDlg_actionParam\"
500 name=\"action_param\">";
501
502 print_label_select($this->link, "action_param_label", $action_param,
503 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
504
505 print "</span>";
506
507 print "&nbsp;"; // tiny layout hack
508
509 print "</div>";
510
511 print "<div class=\"dlgSec\">".__("Options")."</div>";
512 print "<div class=\"dlgSecCont\">";
513
514 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
515 <label for=\"enabled\">".__('Enabled')."</label><hr/>";
516
517 print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
518 <label for=\"inverse\">".__('Inverse match')."</label>";
519
520 print "</div>";
521
522 print "<div class=\"dlgButtons\">";
523
524 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
525 __('Test')."</button> ";
526
527 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
528 __('Create')."</button> ";
529
530 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
531 __('Cancel')."</button>";
532
533 print "</div>";
534 }
535
536 function inactiveFeeds() {
537
538 if (DB_TYPE == "pgsql") {
539 $interval_qpart = "NOW() - INTERVAL '3 months'";
540 } else {
541 $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
542 }
543
544 $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
545 ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
546 FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
547 (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
548 ttrss_entries.id = ref_id AND
549 ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
550 AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND
551 ttrss_user_entries.feed_id = ttrss_feeds.id AND
552 ttrss_entries.id = ref_id
553 GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
554 ORDER BY last_article");
555
556 print __("These feeds have not been updated with new content for 3 months (oldest first):");
557
558 print "<div class=\"inactiveFeedHolder\">";
559
560 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
561
562 $lnum = 1;
563
564 while ($line = db_fetch_assoc($result)) {
565
566 $class = ($lnum % 2) ? "even" : "odd";
567 $feed_id = $line["id"];
568 $this_row_id = "id=\"FUPDD-$feed_id\"";
569
570 print "<tr class=\"\" $this_row_id>";
571
572 $edit_title = htmlspecialchars($line["title"]);
573
574 print "<td width='5%' align='center'><input
575 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
576 type=\"checkbox\"></td>";
577 print "<td>";
578
579 print "<a class=\"visibleLink\" href=\"#\" ".
580 "title=\"".__("Click to edit feed")."\" ".
581 "onclick=\"editFeed(".$line["id"].")\">".
582 htmlspecialchars($line["title"])."</a>";
583
584 print "</td><td class=\"insensitive\" align='right'>";
585 print make_local_datetime($this->link, $line['last_article'], false);
586 print "</td>";
587 print "</tr>";
588
589 ++$lnum;
590 }
591
592 print "</table>";
593 print "</div>";
594
595 print "<div class='dlgButtons'>";
596 print "<div style='float : left'>";
597 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
598 .__('Unsubscribe from selected feeds')."</button> ";
599 print "</div>";
600
601 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">".
602 __('Close this window')."</button>";
603
604 print "</div>";
605
606 }
607
608 function feedsWithErrors() {
609 print __("These feeds have not been updated because of errors:");
610
611 $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
612 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
613
614 print "<div class=\"inactiveFeedHolder\">";
615
616 print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
617
618 $lnum = 1;
619
620 while ($line = db_fetch_assoc($result)) {
621
622 $class = ($lnum % 2) ? "even" : "odd";
623 $feed_id = $line["id"];
624 $this_row_id = "id=\"FUPDD-$feed_id\"";
625
626 print "<tr class=\"\" $this_row_id>";
627
628 $edit_title = htmlspecialchars($line["title"]);
629
630 print "<td width='5%' align='center'><input
631 onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
632 type=\"checkbox\"></td>";
633 print "<td>";
634
635 print "<a class=\"visibleLink\" href=\"#\" ".
636 "title=\"".__("Click to edit feed")."\" ".
637 "onclick=\"editFeed(".$line["id"].")\">".
638 htmlspecialchars($line["title"])."</a>: ";
639
640 print "<span class=\"insensitive\">";
641 print htmlspecialchars($line["last_error"]);
642 print "</span>";
643
644 print "</td>";
645 print "</tr>";
646
647 ++$lnum;
648 }
649
650 print "</table>";
651 print "</div>";
652
653 print "<div class='dlgButtons'>";
654 print "<div style='float : left'>";
655 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
656 .__('Unsubscribe from selected feeds')."</button> ";
657 print "</div>";
658
659 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
660 __('Close this window')."</button>";
661
662 print "</div>";
663 }
664
665 function editArticleTags() {
666
667 print __("Tags for this article (separated by commas):")."<br>";
668
669 $tags = get_article_tags($this->link, $this->param);
670
671 $tags_str = join(", ", $tags);
672
673 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">";
674 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
675 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
676
677 print "<table width='100%'><tr><td>";
678
679 print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
680 style='font-size : 12px; width : 100%' id=\"tags_str\"
681 name='tags_str'>$tags_str</textarea>
682 <div class=\"autocomplete\" id=\"tags_choices\"
683 style=\"display:none\"></div>";
684
685 print "</td></tr></table>";
686
687 print "<div class='dlgButtons'>";
688
689 print "<button dojoType=\"dijit.form.Button\"
690 onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> ";
691 print "<button dojoType=\"dijit.form.Button\"
692 onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>";
693 print "</div>";
694
695 }
696
697 function printTagCloud() {
698 print "<title>".__('Tag Cloud')."</title>";
699 print "<content><![CDATA[";
700
701 print "<div class=\"tagCloudContainer\">";
702
703 printTagCloud($this->link);
704
705 print "</div>";
706
707 print "<div align='center'>";
708 print "<button dojoType=\"dijit.form.Button\"
709 onclick=\"return closeInfoBox()\">".
710 __('Close this window')."</button>";
711 print "</div>";
712
713 print "]]></content>";
714 }
715
716 function printTagSelect() {
717
718 print "<title>" . __('Select item(s) by tags') . "</title>";
719 print "<content><![CDATA[";
720
721 print __("Match:"). "&nbsp;" .
722 "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\">&nbsp;Any&nbsp;";
723 print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\">&nbsp;All&nbsp;";
724 print "&nbsp;tags.";
725
726 print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
727 $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
728 AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
729
730 while ($row = db_fetch_assoc($result)) {
731 $tmp = htmlspecialchars($row["tag_name"]);
732 print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
733 }
734
735 print "</select>";
736
737 print "<div align='right'>";
738 print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
739 get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
740 print "&nbsp;";
741 print "<button dojoType=\"dijit.form.Button\"
742 onclick=\"return closeInfoBox()\">" .
743 __('Close this window') . "</button>";
744 print "</div>";
745
746 print "]]></content>";
747 }
748
749 function emailArticle() {
750
751 $secretkey = sha1(uniqid(rand(), true));
752
753 $_SESSION['email_secretkey'] = $secretkey;
754
755 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"secretkey\" value=\"$secretkey\">";
756 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
757 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"sendEmail\">";
758
759 $result = db_query($this->link, "SELECT email, full_name FROM ttrss_users WHERE
760 id = " . $_SESSION["uid"]);
761
762 $user_email = htmlspecialchars(db_fetch_result($result, 0, "email"));
763 $user_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
764
765 if (!$user_name) $user_name = $_SESSION['name'];
766
767 $_SESSION['email_replyto'] = $user_email;
768 $_SESSION['email_fromname'] = $user_name;
769
770 require_once "lib/MiniTemplator.class.php";
771
772 $tpl = new MiniTemplator;
773 $tpl_t = new MiniTemplator;
774
775 $tpl->readTemplateFromFile("templates/email_article_template.txt");
776
777 $tpl->setVariable('USER_NAME', $_SESSION["name"]);
778 $tpl->setVariable('USER_EMAIL', $user_email);
779 $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]);
780
781
782 $result = db_query($this->link, "SELECT link, content, title
783 FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
784 id IN ($this->param) AND owner_uid = " . $_SESSION["uid"]);
785
786 if (db_num_rows($result) > 1) {
787 $subject = __("[Forwarded]") . " " . __("Multiple articles");
788 }
789
790 while ($line = db_fetch_assoc($result)) {
791
792 if (!$subject)
793 $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
794
795 $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
796 $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
797
798 $tpl->addBlock('article');
799 }
800
801 $tpl->addBlock('email');
802
803 $content = "";
804 $tpl->generateOutputToString($content);
805
806 print "<table width='100%'><tr><td>";
807
808 print __('From:');
809
810 print "</td><td>";
811
812 print "<input dojoType=\"dijit.form.TextBox\" disabled=\"1\" style=\"width : 30em;\"
813 value=\"$user_name <$user_email>\">";
814
815 print "</td></tr><tr><td>";
816
817 print __('To:');
818
819 print "</td><td>";
820
821 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"
822 style=\"width : 30em;\"
823 name=\"destination\" id=\"emailArticleDlg_destination\">";
824
825 print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\"
826 style=\"z-index: 30; display : none\"></div>";
827
828 print "</td></tr><tr><td>";
829
830 print __('Subject:');
831
832 print "</td><td>";
833
834 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"
835 style=\"width : 30em;\"
836 name=\"subject\" value=\"$subject\" id=\"subject\">";
837
838 print "</td></tr>";
839
840 print "<tr><td colspan='2'><textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 100%' rows=\"20\"
841 name='content'>$content</textarea>";
842
843 print "</td></tr></table>";
844
845 print "<div class='dlgButtons'>";
846 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> ";
847 print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>";
848 print "</div>";
849
850 //return;
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 __("You can view this feed as RSS using the following URL:");
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 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");
920
921 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
922 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
923 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
924
925 print "<table width='100%'><tr><td>";
926 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
927 style='font-size : 12px; width : 100%; height: 200px;'
928 placeHolder='body#ttrssMain { font-size : 14px; };'
929 name='value'>$value</textarea>";
930 print "</td></tr></table>";
931
932 print "<div class='dlgButtons'>";
933 print "<button dojoType=\"dijit.form.Button\"
934 onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
935 print "<button dojoType=\"dijit.form.Button\"
936 onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
937 print "</div>";
938
939 }
940
941 function editArticleNote() {
942 $result = db_query($this->link, "SELECT note FROM ttrss_user_entries WHERE
943 ref_id = '$this->param' AND owner_uid = " . $_SESSION['uid']);
944
945 $note = db_fetch_result($result, 0, "note");
946
947 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">";
948 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
949 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setNote\">";
950
951 print "<table width='100%'><tr><td>";
952 print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
953 style='font-size : 12px; width : 100%; height: 100px;'
954 placeHolder='body#ttrssMain { font-size : 14px; };'
955 name='note'>$note</textarea>";
956 print "</td></tr></table>";
957
958 print "<div class='dlgButtons'>";
959 print "<button dojoType=\"dijit.form.Button\"
960 onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> ";
961 print "<button dojoType=\"dijit.form.Button\"
962 onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>";
963 print "</div>";
964
965 }
966
967 function about() {
968 print "<table width='100%'><tr><td align='center'>";
969 print "<img src=\"images/logo_big.png\">";
970 print "</td>";
971 print "<td width='70%'>";
972
973 print "<h1>Tiny Riny RSS</h1>
974 <strong>Version ".VERSION."</strong>
975 <p>Copyright &copy; 2005-".date('Y')."
976 <a target=\"_blank\" class=\"visibleLink\"
977 href=\"http://fakecake.org/\">Andrew Dolgov</a>
978 and other contributors.</p>
979 <p class=\"insensitive\">Licensed under GNU GPL version 2.</p>";
980
981 print "<p class=\"insensitive\">
982 <a class=\"visibleLink\" target=\"_blank\"
983 href=\"http://tt-rss.org/\">Official site</a> &mdash;
984 <a href=\"http://tt-rss.org/redmine/wiki/tt-rss/Donate\"
985 target=\"_blank\" class=\"visibleLink\">
986 Support the project.</a></p>";
987
988 print "</td></tr>";
989 print "</table>";
990
991 print "<div align='center'>";
992 print "<button dojoType=\"dijit.form.Button\"
993 type=\"submit\">".
994 __('Close this window')."</button>";
995 print "</div>";
996 }
997
998 function addInstance() {
999 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
1000 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
1001
1002 print "<div class=\"dlgSec\">".__("Instance")."</div>";
1003
1004 print "<div class=\"dlgSecCont\">";
1005
1006 /* URL */
1007
1008 print __("URL:") . " ";
1009
1010 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
1011 placeHolder=\"".__("Instance URL")."\"
1012 regExp='^(http|https)://.*'
1013 style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
1014
1015 print "<hr/>";
1016
1017 $access_key = sha1(uniqid(rand(), true));
1018
1019 /* Access key */
1020
1021 print __("Access key:") . " ";
1022
1023 print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
1024 placeHolder=\"".__("Access key")."\" regExp='\w{40}'
1025 style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
1026 value=\"$access_key\">";
1027
1028 print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
1029
1030 print "</div>";
1031
1032 print "<div class=\"dlgButtons\">
1033 <div style='float : left'>
1034 <button dojoType=\"dijit.form.Button\"
1035 onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
1036 __('Generate new key')."</button>
1037 </div>
1038 <button dojoType=\"dijit.form.Button\"
1039 onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
1040 __('Create link')."</button>
1041 <button dojoType=\"dijit.form.Button\"
1042 onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
1043 __('Cancel')."</button></div>";
1044
1045 return;
1046 }
1047
1048 function shareArticle() {
1049 $result = db_query($this->link, "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$this->param'
1050 AND owner_uid = " . $_SESSION['uid']);
1051
1052 if (db_num_rows($result) == 0) {
1053 print "Article not found.";
1054 } else {
1055
1056 $uuid = db_fetch_result($result, 0, "uuid");
1057 $ref_id = db_fetch_result($result, 0, "ref_id");
1058
1059 if (!$uuid) {
1060 $uuid = db_escape_string(sha1(uniqid(rand(), true)));
1061 db_query($this->link, "UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$this->param'
1062 AND owner_uid = " . $_SESSION['uid']);
1063 }
1064
1065 print __("You can share this article by the following unique URL:");
1066
1067 $url_path = get_self_url_prefix();
1068 $url_path .= "/public.php?op=share&key=$uuid";
1069
1070 print "<div class=\"tagCloudContainer\">";
1071 print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
1072 print "</div>";
1073
1074 /* if (!label_find_id($this->link, __('Shared'), $_SESSION["uid"]))
1075 label_create($this->link, __('Shared'), $_SESSION["uid"]);
1076
1077 label_add_article($this->link, $ref_id, __('Shared'), $_SESSION['uid']); */
1078 }
1079
1080 print "<div align='center'>";
1081
1082 print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
1083 __('Close this window')."</button>";
1084
1085 print "</div>";
1086 }
1087
1088 }
1089 ?>