]> git.wh0rd.org - tt-rss.git/blame - modules/popup-dialog.php
misc code cleanup, allow ctrl-key selection in prefs
[tt-rss.git] / modules / popup-dialog.php
CommitLineData
ef8be8ea
AD
1<?php
2 function module_popup_dialog($link) {
b4e75b2a
AD
3 $id = $_REQUEST["id"];
4 $param = db_escape_string($_REQUEST["param"]);
ef8be8ea 5
b6a6e262
AD
6 if ($id == "importOpml") {
7 print "<div id=\"infoBoxTitle\">".__('OPML Import')."</div>";
8 print "<div class=\"infoBoxContents\">";
9
10 print "<div class=\"prefFeedCatHolder\">";
11
12 $owner_uid = $_SESSION["uid"];
13
14 db_query($link, "BEGIN");
15
16 /* create Imported feeds category just in case */
17
18 $result = db_query($link, "SELECT id FROM
19 ttrss_feed_categories WHERE title = 'Imported feeds' AND
20 owner_uid = '$owner_uid' LIMIT 1");
21
22 if (db_num_rows($result) == 0) {
23 db_query($link, "INSERT INTO ttrss_feed_categories
24 (title,owner_uid)
25 VALUES ('Imported feeds', '$owner_uid')");
26 }
27
28 db_query($link, "COMMIT");
29
30 /* Handle OPML import by DOMXML/DOMDocument */
31
32 if (function_exists('domxml_open_file')) {
33 print "<ul class='nomarks'>";
34 print "<li>".__("Importing using DOMXML.")."</li>";
eef20159 35 require_once "opml_domxml.php";
b6a6e262
AD
36 opml_import_domxml($link, $owner_uid);
37 print "</ul>";
38 } else if (PHP_VERSION >= 5) {
39 print "<ul class='nomarks'>";
40 print "<li>".__("Importing using DOMDocument.")."</li>";
eef20159 41 require_once "opml_domdoc.php";
b6a6e262
AD
42 opml_import_domdoc($link, $owner_uid);
43 print "</ul>";
44 } else {
45 print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
46 }
47
48 print "</div>";
49
50 print "<div align='center'>";
51
f94ba975
AD
52 print "<button onclick=\"return opmlImportDone()\">".
53 __('Close this window')."</button>";
b6a6e262
AD
54
55 print "</div>";
56
57 print "<script type=\"text/javascript\">";
c3b7b797 58 print "parent.opmlImportHandler(this)";
b6a6e262
AD
59 print "</script>";
60
61 print "</div></div>";
62
63 return;
64 }
65
d9084cf2
AD
66 if ($id == "editPrefProfiles") {
67
68 print "<div id=\"infoBoxTitle\">".__('Settings Profiles')."</div>";
69 print "<div class=\"infoBoxContents\">";
70
71 print "<div><input id=\"fadd_profile\"
72 onkeypress=\"return filterCR(event, addPrefProfile)\"
73 size=\"40\">
74 <button onclick=\"javascript:addPrefProfile()\">".
75 __('Create profile')."</button></div>";
76
77 print "<p>";
78
79 $result = db_query($link, "SELECT title,id FROM ttrss_settings_profiles
47179c0e 80 WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
d9084cf2
AD
81
82 print __('Select:')."
a998dbef
AD
83 <a href=\"#\" onclick=\"selectPrefRows('fcat', true)\">".__('All')."</a>,
84 <a href=\"#\" onclick=\"selectPrefRows('fcat', false)\">".__('None')."</a>";
d9084cf2
AD
85
86 print "<div class=\"prefFeedCatHolder\">";
87
88 print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
89
90 print "<table width=\"100%\" class=\"prefFeedCatList\"
91 cellspacing=\"0\" id=\"prefFeedCatList\">";
92
93 print "<tr class=\"odd\" id=\"FCATR-0\">";
94
95 print "<td width='5%' align='center'><input
a998dbef 96 onclick='toggleSelectRow(this);'
d9084cf2
AD
97 type=\"checkbox\" id=\"FCCHK-0\"></td>";
98
ac9dbf85
AD
99 if (!$_SESSION["profile"]) {
100 $is_active = __("(active)");
101 } else {
102 $is_active = "";
103 }
104
d9084cf2 105 print "<td><span id=\"FCATT-0\">" .
ac9dbf85 106 __("Default profile") . " $is_active</span></td>";
d9084cf2
AD
107
108 print "</tr>";
109
110 $lnum = 1;
111
112 while ($line = db_fetch_assoc($result)) {
113
114 $class = ($lnum % 2) ? "even" : "odd";
115
116 $cat_id = $line["id"];
117 $this_row_id = "id=\"FCATR-$cat_id\"";
118
119 print "<tr class=\"$class\" $this_row_id>";
120
121 $edit_title = htmlspecialchars($line["title"]);
122
123 print "<td width='5%' align='center'><input
a998dbef 124 onclick='toggleSelectRow(this);'
d9084cf2
AD
125 type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
126
127 if ($_SESSION["profile"] == $line["id"]) {
128 $is_active = __("(active)");
129 } else {
130 $is_active = "";
131 }
132
133 print "<td><span id=\"FCATT-$cat_id\">" .
134 $edit_title . "</span> $is_active</td>";
135
136 print "</tr>";
137
138 ++$lnum;
139 }
140
141 print "</table>";
142 print "</form>";
143 print "</div>";
144
145 print "<div class='dlgButtons'>
146 <div style='float : left'>
147 <button onclick=\"return removeSelectedPrefProfiles()\">".
148 __('Remove')."</button>
8ab4da5f
AD
149 <button onclick=\"return activatePrefProfile()\">".
150 __('Activate')."</button>
d9084cf2
AD
151 </div>";
152
8ab4da5f
AD
153 print "<button onclick=\"return closeInfoBox()\">".
154 __('Close this window')."</button>";
d9084cf2
AD
155
156 print "</div></div>";
157
158 return;
159 }
160
c8640eda
MK
161 if ($id == "pubOPMLUrl") {
162
163 print "<div id=\"infoBoxTitle\">".__('Public OPML URL')."</div>";
164 print "<div class=\"infoBoxContents\">";
f29033f8 165
c8640eda
MK
166 $url_path = opml_publish_url($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 onclick=\"return opmlRegenKey()\">".
177 __('Generate new URL')."</button> ";
178
179 print "<input class=\"button\"
180 type=\"submit\" onclick=\"return closeInfoBox()\"
cf9dc032
AD
181 value=\"".__('Close this window')."\">";
182
183 print "</div></div>";
184
185 return;
186 }
187
ef16ae37
AD
188 if ($id == "explainError") {
189
cc17c205 190 print "<div id=\"infoBoxTitle\">".__('Notice')."</div>";
ef16ae37
AD
191 print "<div class=\"infoBoxContents\">";
192
73495fd1
AD
193 print "<div class=\"errorExplained\">";
194
ef16ae37 195 if ($param == 1) {
73495fd1 196 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.");
f6854e44 197
1ea20897 198 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
f6854e44
AD
199
200 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
201
ef16ae37
AD
202 }
203
d9fa39f1 204 if ($param == 2) {
73495fd1 205 $msg = check_for_update($link);
4d1d0a45
AD
206
207 if (!$msg) {
73495fd1 208 print __("You are running the latest version of Tiny Tiny RSS. The fact that you are seeing this dialog is probably a bug.");
4d1d0a45
AD
209 } else {
210 print $msg;
211 }
d9fa39f1
AD
212
213 }
214
8e00ae9b 215 if ($param == 3) {
73495fd1 216 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.");
f6854e44 217
1ea20897 218 $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
f6854e44
AD
219
220 print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
221
8e00ae9b
AD
222 }
223
ef16ae37 224 print "</div>";
73495fd1 225
ef16ae37
AD
226 print "<div align='center'>";
227
228 print "<input class=\"button\"
229 type=\"submit\" onclick=\"return closeInfoBox()\"
cc17c205 230 value=\"".__('Close this window')."\">";
ef16ae37 231
73495fd1 232 print "</div></div>";
ef16ae37 233
5e6f933a 234 return;
ef16ae37
AD
235 }
236
ef8be8ea
AD
237 if ($id == "quickAddFeed") {
238
ecace165 239 print "<div id=\"infoBoxTitle\">".__('Subscribe to Feed')."</div>";
ef8be8ea
AD
240 print "<div class=\"infoBoxContents\">";
241
e6312f6c 242 print "<form id='feed_add_form' onsubmit='return false'>";
ef8be8ea 243
a5819bb3
AD
244 print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
245 print "<input type=\"hidden\" name=\"subop\" value=\"addfeed\">";
246 //print "<input type=\"hidden\" name=\"from\" value=\"tt-rss\">";
ef8be8ea 247
ecace165
AD
248 print "<div class=\"dlgSec\">".__("Feed")."</div>";
249 print "<div class=\"dlgSecCont\">";
250
251 print __("URL:") . " ";
252
f88c7814 253 print "<input size=\"40\"
18ab3d7a 254 onkeypress=\"return filterCR(event, subscribeToFeed)\"
31a53903 255 name=\"feed\" id=\"feed_url\">";
ecace165
AD
256
257 print "<br/>";
258
ef8be8ea 259 if (get_pref($link, 'ENABLE_FEED_CATS')) {
ecace165 260 print __('Place in category:') . " ";
a5819bb3 261 print_feed_cat_select($link, "cat");
ef8be8ea
AD
262 }
263
ecace165
AD
264 print "</div>";
265
5eeb3874
CW
266 print '<div id="fadd_feeds_container" style="display:none">
267
268 <div class="dlgSec">' . __('Available feeds') . '</div>
269 <div class="dlgSecCont">'
270
271 . ' <select name="feed" id="faad_feeds_container_select" size="3"></select>'
272 . '</div></div>';
273
b9073cd9 274 print "<div id='fadd_login_container' style='display:none'>
ecace165
AD
275
276 <div class=\"dlgSec\">".__("Authentication")."</div>
277 <div class=\"dlgSecCont\">".
278
a5819bb3 279 __('Login:') . " <input name='login' size=\"20\"
ecace165
AD
280 onkeypress=\"return filterCR(event, subscribeToFeed)\"> ".
281 __('Password:') . "<input type='password'
a5819bb3 282 name='pass' size=\"20\"
ecace165
AD
283 onkeypress=\"return filterCR(event, subscribeToFeed)\">
284 </div></div>";
285
286
287 print "<div style=\"clear : both\">
288 <input type=\"checkbox\" id=\"fadd_login_check\"
289 onclick='checkboxToggleElement(this, \"fadd_login_container\")'>
290 <label for=\"fadd_login_check\">".
291 __('This feed requires authentication.')."</div>";
f27de515 292
ef8be8ea
AD
293 print "</form>";
294
ecace165 295 print "<div class=\"dlgButtons\">
f88c7814
AD
296 <button class=\"button\" id=\"fadd_submit_btn\"
297 onclick=\"return subscribeToFeed()\">".__('Subscribe')."</button>
d002edc7 298 <button onclick=\"return displayDlg('feedBrowser')\">".__('More feeds')."</button>
f88c7814 299 <button onclick=\"return closeInfoBox()\">".__('Cancel')."</button></div>";
ecace165 300
5e6f933a 301 return;
ef8be8ea
AD
302 }
303
ef88b1cc
AD
304 if ($id == "feedBrowser") {
305
306 print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
307
308 print "<div class=\"infoBoxContents\">";
309
310 $browser_search = db_escape_string($_REQUEST["search"]);
311
312 print "<form onsubmit='return false;' display='inline'
313 name='feed_browser' id='feed_browser'>";
314
315 print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
316 print "<input type=\"hidden\" name=\"subop\" value=\"updateFeedBrowser\">";
317
318 print "
319 <div style='float : right'>
320 <img style='display : none'
883fee8d
AD
321 id='feed_browser_spinner' src='".
322 theme_image($link, 'images/indicator_white.gif')."'>
ef88b1cc
AD
323 <input name=\"search\" size=\"20\" type=\"search\"
324 onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
325 <button onclick=\"javascript:updateFeedBrowser()\">".__('Search')."</button>
326 </div>";
327
328 print " <select name=\"mode\" onchange=\"updateFeedBrowser()\">
329 <option value='1'>" . __('Popular feeds') . "</option>
330 <option value='2'>" . __('Feed archive') . "</option>
331 </select> ";
332
333 print __("limit:");
334
335 print " <select name=\"limit\" onchange='updateFeedBrowser()'>";
336
337 foreach (array(25, 50, 100, 200) as $l) {
338 $issel = ($l == $limit) ? "selected" : "";
339 print "<option $issel>$l</option>";
340 }
341
342 print "</select> ";
343
344 print "<p>";
345
346 $owner_uid = $_SESSION["uid"];
347
d9084cf2
AD
348/* print __('Select:')."
349 <a href=\"javascript:selectPrefRows('fbrowse', true)\">".__('All')."</a>,
350 <a href=\"javascript:selectPrefRows('fbrowse', false)\">".__('None')."</a>"; */
351
ef88b1cc
AD
352 print "<ul class='browseFeedList' id='browseFeedList'>";
353 print_feed_browser($link, $search, 25);
354 print "</ul>";
355
356 print "<div align='center'>
357 <button onclick=\"feedBrowserSubscribe()\">".__('Subscribe')."</button>
d9084cf2 358 <button style='display : none' id='feed_archive_remove' onclick=\"feedArchiveRemove()\">".__('Remove')."</button>
ef88b1cc
AD
359 <button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
360
361 print "</div>";
362 return;
363 }
364
ef8be8ea
AD
365 if ($id == "search") {
366
cc17c205 367 print "<div id=\"infoBoxTitle\">".__('Search')."</div>";
ef8be8ea
AD
368 print "<div class=\"infoBoxContents\">";
369
e6312f6c 370 print "<form id='search_form' onsubmit='return false'>";
ef8be8ea 371
b4e75b2a 372 #$active_feed_id = db_escape_string($_REQUEST["param"]);
ef8be8ea 373
2d1b7139 374 $params = explode(":", db_escape_string($_REQUEST["param"]), 2);
ef8be8ea
AD
375
376 $active_feed_id = sprintf("%d", $params[0]);
2d1b7139 377 $is_cat = (bool) $params[1];
ef8be8ea 378
de85cac2 379 print "<div class=\"dlgSec\">".__('Look for')."</div>";
5bac8c29
AD
380
381 print "<div class=\"dlgSecCont\">";
382
69d582f0
AD
383 print "<input onkeypress=\"return filterCR(event, search)\"
384 name=\"query\" size=\"20\" type=\"search\" value=''>";
5bac8c29 385
b1710666 386 print " " . __('match on')." ";
5bac8c29
AD
387
388 $search_fields = array(
389 "title" => __("Title"),
390 "content" => __("Content"),
391 "both" => __("Title or content"));
392
393 print_select_hash("match_on", 3, $search_fields);
394
395
396 print "<br/>".__('Limit search to:')." ";
ef8be8ea
AD
397
398 print "<select name=\"search_mode\">
cc17c205 399 <option value=\"all_feeds\">".__('All feeds')."</option>";
ef8be8ea
AD
400
401 $feed_title = getFeedTitle($link, $active_feed_id);
402
403 if (!$is_cat) {
404 $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
405 } else {
406 $feed_cat_title = getCategoryTitle($link, $active_feed_id);
407 }
408
409 if ($active_feed_id && !$is_cat) {
cc17c205 410 print "<option selected value=\"this_feed\">$feed_title</option>";
ef8be8ea 411 } else {
cc17c205 412 print "<option disabled>".__('This feed')."</option>";
ef8be8ea
AD
413 }
414
415 if ($is_cat) {
416 $cat_preselected = "selected";
417 }
418
419 if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
cc17c205 420 print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
ef8be8ea 421 } else {
c4b0f96c 422 //print "<option disabled>".__('This category')."</option>";
ef8be8ea
AD
423 }
424
5bac8c29 425 print "</select>";
ef8be8ea 426
5bac8c29 427 print "</div>";
ef8be8ea
AD
428
429 print "</form>";
430
5bac8c29 431 print "<div class=\"dlgButtons\">
d60009cd 432 <button onclick=\"javascript:search()\">".__('Search')."</button>
55132a45 433 <button onclick=\"javascript:closeInfoBox(true)\">".__('Cancel')."</button>
ad491d75 434 </div>";
ef8be8ea
AD
435
436 print "</div>";
437
5e6f933a
AD
438 return;
439
ef8be8ea
AD
440 }
441
ef8be8ea
AD
442 if ($id == "quickAddFilter") {
443
b4e75b2a 444 $active_feed_id = db_escape_string($_REQUEST["param"]);
ef8be8ea 445
ecace165 446 print "<div id=\"infoBoxTitle\">".__('Create Filter')."</div>";
ef8be8ea
AD
447 print "<div class=\"infoBoxContents\">";
448
e6312f6c 449 print "<form id=\"filter_add_form\" onsubmit='return false'>";
ef8be8ea
AD
450
451 print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
452 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
453 print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
ef8be8ea
AD
454
455 $result = db_query($link, "SELECT id,description
456 FROM ttrss_filter_types ORDER BY description");
457
458 $filter_types = array();
459
460 while ($line = db_fetch_assoc($result)) {
461 //array_push($filter_types, $line["description"]);
89cb787e 462 $filter_types[$line["id"]] = __($line["description"]);
ef8be8ea
AD
463 }
464
10fa6615
AD
465 print "<div class=\"dlgSec\">".__("Match")."</div>";
466
467 print "<div class=\"dlgSecCont\">";
468
d0da85c2 469 print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
6e278744 470 print __("Date") . " ";
44d0e774
AD
471
472 $filter_params = array(
473 "before" => __("before"),
474 "after" => __("after"));
475
476 print_select_hash("filter_date_modifier", "before", $filter_params);
477
478 print "&nbsp;</span>";
d0da85c2 479
8df90057 480 print "<input onkeypress=\"return filterCR(event, createFilter)\"
ad491d75 481 name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
10fa6615 482
6e278744 483 print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";
d0da85c2
AD
484 print "&nbsp;<input class=\"button\"
485 type=\"submit\" onclick=\"return filterDlgCheckDate()\"
6e278744 486 value=\"".__('Check it')."\">";
d0da85c2
AD
487 print "</span>";
488
489 print "<br/> " . __("on field") . " ";
490 print_select_hash("filter_type", 1, $filter_types,
491 'onchange="filterDlgCheckType(this)"');
10fa6615
AD
492
493 print "<br/>";
494
495 print __("in") . " ";
496 print_feed_select($link, "feed_id", $active_feed_id);
497
498 print "</div>";
499
ecace165 500 print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
10fa6615
AD
501
502 print "<div class=\"dlgSecCont\">";
503
504 print "<select name=\"action_id\"
505 onchange=\"filterDlgCheckAction(this)\">";
506
507 $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
508 ORDER BY name");
509
510 while ($line = db_fetch_assoc($result)) {
511 printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
512 }
513
514 print "</select>";
515
143a4973
AD
516 print "<span id=\"filter_dlg_param_box\" style=\"display : none\">";
517 print " " . __("with parameters:") . " ";
518 print "<input size=\"20\"
074bf20c 519 onkeypress=\"return filterCR(event, createFilter)\"
143a4973 520 name=\"action_param\">";
6427a306
AD
521
522 print_label_select($link, "action_param_label", $action_param);
523
143a4973 524 print "</span>";
10fa6615 525
143a4973 526 print "&nbsp;"; // tiny layout hack
10fa6615
AD
527
528 print "</div>";
529
530 print "<div class=\"dlgSec\">".__("Options")."</div>";
531 print "<div class=\"dlgSecCont\">";
532
ecace165
AD
533 print "<div style=\"line-height : 100%\">";
534
10fa6615
AD
535 print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
536 <label for=\"enabled\">".__('Enabled')."</label><br/>";
537
538 print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
539 <label for=\"inverse\">".__('Inverse match')."</label>";
540
541 print "</div>";
ecace165 542 print "</div>";
10fa6615 543
ef8be8ea
AD
544 print "</form>";
545
10fa6615 546 print "<div class=\"dlgButtons\">";
ef8be8ea 547
ad491d75
AD
548 print "<button onclick=\"return createFilter()\">".
549 __('Create')."</button> ";
ef8be8ea 550
ad491d75
AD
551 print "<button onclick=\"return closeInfoBox()\">".__('Cancel').
552 "</button>";
ef8be8ea
AD
553
554 print "</div>";
555
556// print "</td></tr></table>";
557
5e6f933a 558 return;
ef8be8ea
AD
559 }
560
a3656a41
AD
561 if ($id == "feedUpdateErrors") {
562
cc17c205 563 print "<div id=\"infoBoxTitle\">".__('Update Errors')."</div>";
a3656a41
AD
564 print "<div class=\"infoBoxContents\">";
565
cc17c205 566 print __("These feeds have not been updated because of errors:");
a3656a41
AD
567
568 $result = db_query($link, "SELECT id,title,feed_url,last_error
569 FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
570
e8dd519b 571 print "<ul class='feedErrorsList'>";
a3656a41
AD
572
573 while ($line = db_fetch_assoc($result)) {
574 print "<li><b>" . $line["title"] . "</b> (" . $line["feed_url"] . "): " .
575 "<em>" . $line["last_error"] . "</em>";
576 }
577
578 print "</ul>";
a3656a41
AD
579
580 print "<div align='center'>";
581
a522a767
AD
582 print "<button onclick=\"return closeInfoBox()\">".
583 __('Close this window')."</button>";
a3656a41
AD
584
585 print "</div>";
586
aa330b93 587 return;
a3656a41
AD
588 }
589
0b126ac2
AD
590 if ($id == "editArticleTags") {
591
cc17c205 592 print "<div id=\"infoBoxTitle\">".__('Edit Tags')."</div>";
0b126ac2
AD
593 print "<div class=\"infoBoxContents\">";
594
e6312f6c 595 print "<form id=\"tag_edit_form\" onsubmit='return false'>";
0b126ac2 596
cc17c205 597 print __("Tags for this article (separated by commas):")."<br>";
0b126ac2
AD
598
599 $tags = get_article_tags($link, $param);
600
601 $tags_str = join(", ", $tags);
602
d62a3b63
AD
603 print "<table width='100%'>";
604
605 print "<tr><td colspan='2'><input type=\"hidden\" name=\"id\" value=\"$param\"></td></tr>";
606
05fcdf52
AD
607 print "<tr><td colspan='2'><textarea rows='4' class='iedit' id='tags_str'
608 name='tags_str'>$tags_str</textarea>
609 <div class=\"autocomplete\" id=\"tags_choices\"
610 style=\"display:none\"></div>
611 </td></tr>";
d62a3b63 612
d62a3b63 613 print "</table>";
0b126ac2
AD
614
615 print "</form>";
616
617 print "<div align='right'>";
618
2ae69126
AD
619 print "<button onclick=\"return editTagsSave()\">".__('Save')."</button> ";
620 print "<button onclick=\"return closeInfoBox()\">".__('Cancel')."</button>";
0b126ac2
AD
621
622 print "</div>";
623
5e6f933a 624 return;
0b126ac2
AD
625 }
626
0979b696 627 if ($id == "printTagCloud") {
d60009cd 628 print "<div id=\"infoBoxTitle\">".__('Tag Cloud')."</div>";
0979b696
AD
629 print "<div class=\"infoBoxContents\">";
630
dcac082b 631 print __("Showing most popular tags ")." (<a
326469fc 632 href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
0979b696
AD
633
634 print "<div class=\"tagCloudContainer\">";
635
636 printTagCloud($link);
637
638 print "</div>";
639
640 print "<div align='center'>";
d60009cd
AD
641 print "<button onclick=\"return closeInfoBox()\">".
642 __('Close this window')."</button>";
0979b696
AD
643 print "</div>";
644
645 print "</div>";
646
647 return;
648 }
649
31a53903
AD
650 if ($id == "emailArticle") {
651
652 print "<div id=\"infoBoxTitle\">".__('Forward article by email')."</div>";
87b16a0a
AD
653 print "<div class=\"infoBoxContents\">";
654
31a53903 655 print "<form id=\"article_email_form\" onsubmit='return false'>";
87b16a0a 656
736e8977 657 $secretkey = sha1(uniqid(rand(), true));
87b16a0a 658
31a53903 659 $_SESSION['email_secretkey'] = $secretkey;
87b16a0a 660
31a53903
AD
661 print "<input type=\"hidden\" name=\"secretkey\" value=\"$secretkey\">";
662 print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
663 print "<input type=\"hidden\" name=\"subop\" value=\"sendEmail\">";
87b16a0a 664
73fe13af 665 $result = db_query($link, "SELECT email, full_name FROM ttrss_users WHERE
f72a7b66
AD
666 id = " . $_SESSION["uid"]);
667
668 $user_email = htmlspecialchars(db_fetch_result($result, 0, "email"));
73fe13af
AD
669 $user_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
670
671 if (!$user_name) $user_name = $_SESSION['name'];
f72a7b66
AD
672
673 $_SESSION['email_replyto'] = $user_email;
674 $_SESSION['email_fromname'] = $user_name;
675
31a53903 676 require_once "lib/MiniTemplator.class.php";
87b16a0a 677
31a53903
AD
678 $tpl = new MiniTemplator;
679 $tpl_t = new MiniTemplator;
87b16a0a 680
31a53903 681 $tpl->readTemplateFromFile("templates/email_article_template.txt");
6a1cd591 682
f72a7b66
AD
683 $tpl->setVariable('USER_NAME', $_SESSION["name"]);
684 $tpl->setVariable('USER_EMAIL', $user_email);
685 $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]);
31a53903 686
f72a7b66 687// $tpl->addBlock('header');
31a53903 688
f72a7b66
AD
689 $result = db_query($link, "SELECT link, content, title
690 FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
691 id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
31a53903 692
f72a7b66
AD
693 if (db_num_rows($result) > 1) {
694 $subject = __("[Forwarded]") . " " . __("Multiple articles");
695 }
31a53903 696
f72a7b66 697 while ($line = db_fetch_assoc($result)) {
31a53903 698
f72a7b66
AD
699 if (!$subject)
700 $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
31a53903 701
f72a7b66
AD
702 $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
703 $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
31a53903 704
f72a7b66
AD
705 $tpl->addBlock('article');
706 }
31a53903
AD
707
708 $tpl->addBlock('email');
f72a7b66 709
31a53903
AD
710 $content = "";
711 $tpl->generateOutputToString($content);
712
713 print "<table width='100%'><tr><td>";
714
715 print __('From:');
716
717 print "</td><td>";
718
719 print "<input size=\"40\" disabled
720 onkeypress=\"return filterCR(event, false)\"
721 value=\"$user_name <$user_email>\">";
722
723 print "</td></tr><tr><td>";
724
725 print __('To:');
726
727 print "</td><td>";
728
729 print "<input size=\"40\"
730 onkeypress=\"return filterCR(event, false)\"
731 name=\"destination\" id=\"destination\">";
732
733 print "<div class=\"autocomplete\" id=\"destination_choices\"
734 style=\"display:none\"></div>";
735
736 print "</td></tr><tr><td>";
737
738 print __('Subject:');
739
740 print "</td><td>";
741
742 print "<input size=\"60\" class=\"iedit\"
743 onkeypress=\"return filterCR(event, false)\"
744 name=\"subject\" value=\"$subject\" id=\"subject\">";
745
746 print "</td></tr></table>";
747
748 print "<textarea rows='10' class='iedit' style='font-size : small'
749 name='content'>$content</textarea>";
87b16a0a
AD
750
751 print "</form>";
752
31a53903
AD
753 print "<div class='dlgButtons'>";
754
755 print "<button onclick=\"return emailArticleDo()\">".__('Send e-mail')."</button> ";
756 print "<button onclick=\"return closeInfoBox()\">".__('Cancel')."</button>";
87b16a0a
AD
757
758 print "</div>";
759
760 return;
31a53903 761 }
87b16a0a 762
8801fb01
AD
763 if ($id == "generatedFeed") {
764
765 print "<div id=\"infoBoxTitle\">".__('View as RSS')."</div>";
766 print "<div class=\"infoBoxContents\">";
767
768 $params = explode(":", $param, 3);
769 $feed_id = db_escape_string($params[0]);
770 $is_cat = (bool) $params[1];
771
772 $key = get_feed_access_key($link, $feed_id, $is_cat);
773
774 $url_path = htmlspecialchars($params[2]) . "&key=" . $key;
775
776 print __("You can view this feed as RSS using the following URL:");
777
778 print "<div class=\"tagCloudContainer\">";
779 print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
780 print "</div>";
781
782 print "<div align='center'>";
783
784 print "<button onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
785 __('Generate new URL')."</button> ";
786
787 print "<input class=\"button\"
788 type=\"submit\" onclick=\"return closeInfoBox()\"
789 value=\"".__('Close this window')."\">";
790
791 print "</div></div>";
792
793 return;
794 }
795
5e6f933a
AD
796 print "<div id='infoBoxTitle'>Internal Error</div>
797 <div id='infoBoxContents'>
798 <p>Unknown dialog <b>$id</b></p>
799 </div></div>";
800
ef8be8ea
AD
801 }
802?>