popup-dialog.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. <?php
  2. function module_popup_dialog($link) {
  3. $id = $_REQUEST["id"];
  4. $param = db_escape_string($_REQUEST["param"]);
  5. print "<dlg id=\"$id\">";
  6. if ($id == "importOpml") {
  7. print "<div class=\"prefFeedOPMLHolder\">";
  8. header("Content-Type: text/html"); # required for iframe
  9. $owner_uid = $_SESSION["uid"];
  10. db_query($link, "BEGIN");
  11. /* create Imported feeds category just in case */
  12. $result = db_query($link, "SELECT id FROM
  13. ttrss_feed_categories WHERE title = 'Imported feeds' AND
  14. owner_uid = '$owner_uid' LIMIT 1");
  15. if (db_num_rows($result) == 0) {
  16. db_query($link, "INSERT INTO ttrss_feed_categories
  17. (title,owner_uid)
  18. VALUES ('Imported feeds', '$owner_uid')");
  19. }
  20. db_query($link, "COMMIT");
  21. /* Handle OPML import by DOMXML/DOMDocument */
  22. if (function_exists('domxml_open_file')) {
  23. print "<ul class='nomarks'>";
  24. print "<li>".__("Importing using DOMXML.")."</li>";
  25. require_once "opml_domxml.php";
  26. opml_import_domxml($link, $owner_uid);
  27. print "</ul>";
  28. } else if (PHP_VERSION >= 5) {
  29. print "<ul class='nomarks'>";
  30. print "<li>".__("Importing using DOMDocument.")."</li>";
  31. require_once "opml_domdoc.php";
  32. opml_import_domdoc($link, $owner_uid);
  33. print "</ul>";
  34. } else {
  35. print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
  36. }
  37. print "</div>";
  38. print "<div align='center'>";
  39. print "<button dojoType=\"dijit.form.Button\"
  40. onclick=\"dijit.byId('opmlImportDlg').hide()\">".
  41. __('Close this window')."</button>";
  42. print "</div>";
  43. print "</div>";
  44. //return;
  45. }
  46. if ($id == "editPrefProfiles") {
  47. print "<div dojoType=\"dijit.Toolbar\">";
  48. # TODO: depends on selectTableRows() being broken for this list
  49. # print "<div dojoType=\"dijit.form.DropDownButton\">".
  50. # "<span>" . __('Select')."</span>";
  51. # print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
  52. # print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
  53. # dojoType=\"dijit.MenuItem\">".__('All')."</div>";
  54. # print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
  55. # dojoType=\"dijit.MenuItem\">".__('None')."</div>";
  56. # print "</div></div>";
  57. # print "<div style='float : right'>";
  58. print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
  59. required=\"1\">
  60. <button dojoType=\"dijit.form.Button\"
  61. onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
  62. __('Create profile')."</button></div>";
  63. # print "</div>";
  64. $result = db_query($link, "SELECT title,id FROM ttrss_settings_profiles
  65. WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
  66. print "<div class=\"prefFeedCatHolder\">";
  67. print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
  68. print "<table width=\"100%\" class=\"prefFeedProfileList\"
  69. cellspacing=\"0\" id=\"prefFeedProfileList\">";
  70. print "<tr class=\"\" id=\"FCATR-0\">"; #odd
  71. print "<td width='5%' align='center'><input
  72. onclick='toggleSelectRow2(this);'
  73. dojoType=\"dijit.form.CheckBox\"
  74. type=\"checkbox\"></td>";
  75. if (!$_SESSION["profile"]) {
  76. $is_active = __("(active)");
  77. } else {
  78. $is_active = "";
  79. }
  80. print "<td><span>" .
  81. __("Default profile") . " $is_active</span></td>";
  82. print "</tr>";
  83. $lnum = 1;
  84. while ($line = db_fetch_assoc($result)) {
  85. $class = ($lnum % 2) ? "even" : "odd";
  86. $profile_id = $line["id"];
  87. $this_row_id = "id=\"FCATR-$profile_id\"";
  88. print "<tr class=\"\" $this_row_id>";
  89. $edit_title = htmlspecialchars($line["title"]);
  90. print "<td width='5%' align='center'><input
  91. onclick='toggleSelectRow2(this);'
  92. dojoType=\"dijit.form.CheckBox\"
  93. type=\"checkbox\"></td>";
  94. if ($_SESSION["profile"] == $line["id"]) {
  95. $is_active = __("(active)");
  96. } else {
  97. $is_active = "";
  98. }
  99. print "<td><span dojoType=\"dijit.InlineEditBox\"
  100. width=\"300px\" autoSave=\"false\"
  101. profile-id=\"$profile_id\">" . $edit_title .
  102. "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
  103. var elem = this;
  104. dojo.xhrPost({
  105. url: 'backend.php',
  106. content: {op: 'rpc', method: 'saveprofile',
  107. value: this.value,
  108. id: this.srcNodeRef.getAttribute('profile-id')},
  109. load: function(response) {
  110. elem.attr('value', response);
  111. }
  112. });
  113. </script>
  114. </span> $is_active</td>";
  115. print "</tr>";
  116. ++$lnum;
  117. }
  118. print "</table>";
  119. print "</form>";
  120. print "</div>";
  121. print "<div class='dlgButtons'>
  122. <div style='float : left'>
  123. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">".
  124. __('Remove selected profiles')."</button>
  125. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">".
  126. __('Activate profile')."</button>
  127. </div>";
  128. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">".
  129. __('Close this window')."</button>";
  130. print "</div>";
  131. }
  132. if ($id == "pubOPMLUrl") {
  133. print "<title>".__('Public OPML URL')."</title>";
  134. print "<content><![CDATA[";
  135. $url_path = opml_publish_url($link);
  136. print __("Your Public OPML URL is:");
  137. print "<div class=\"tagCloudContainer\">";
  138. print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
  139. print "</div>";
  140. print "<div align='center'>";
  141. print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">".
  142. __('Generate new URL')."</button> ";
  143. print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
  144. __('Close this window')."</button>";
  145. print "</div>";
  146. print "]]></content>";
  147. //return;
  148. }
  149. if ($id == "explainError") {
  150. print "<title>".__('Notice')."</title>";
  151. print "<content><![CDATA[";
  152. print "<div class=\"errorExplained\">";
  153. if ($param == 1) {
  154. 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.");
  155. $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
  156. print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
  157. }
  158. if ($param == 3) {
  159. 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.");
  160. $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
  161. print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
  162. }
  163. print "</div>";
  164. print "<div align='center'>";
  165. print "<button onclick=\"return closeInfoBox()\">".
  166. __('Close this window')."</button>";
  167. print "</div>";
  168. print "]]></content>";
  169. //return;
  170. }
  171. if ($id == "quickAddFeed") {
  172. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  173. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
  174. print "<div class=\"dlgSec\">".__("Feed")."</div>";
  175. print "<div class=\"dlgSecCont\">";
  176. print "<input style=\"font-size : 16px; width : 20em;\"
  177. placeHolder=\"".__("Feed URL")."\"
  178. dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
  179. print "<hr/>";
  180. if (get_pref($link, 'ENABLE_FEED_CATS')) {
  181. print __('Place in category:') . " ";
  182. print_feed_cat_select($link, "cat", false, 'dojoType="dijit.form.Select"');
  183. }
  184. print "</div>";
  185. print '<div id="feedDlg_feedsContainer" style="display : none">
  186. <div class="dlgSec">' . __('Available feeds') . '</div>
  187. <div class="dlgSecCont">'.
  188. '<select id="feedDlg_feedContainerSelect"
  189. dojoType="dijit.form.Select" size="3">
  190. <script type="dojo/method" event="onChange" args="value">
  191. dijit.byId("feedDlg_feedUrl").attr("value", value);
  192. </script>
  193. </select>'.
  194. '</div></div>';
  195. print "<div id='feedDlg_loginContainer' style='display : none'>
  196. <div class=\"dlgSec\">".__("Authentication")."</div>
  197. <div class=\"dlgSecCont\">".
  198. " <input dojoType=\"dijit.form.TextBox\" name='login'\"
  199. placeHolder=\"".__("Login")."\"
  200. style=\"width : 10em;\"> ".
  201. " <input
  202. placeHolder=\"".__("Password")."\"
  203. dojoType=\"dijit.form.TextBox\" type='password'
  204. style=\"width : 10em;\" name='pass'\">
  205. </div></div>";
  206. print "<div style=\"clear : both\">
  207. <input type=\"checkbox\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
  208. onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
  209. <label for=\"feedDlg_loginCheck\">".
  210. __('This feed requires authentication.')."</div>";
  211. print "</form>";
  212. print "<div class=\"dlgButtons\">
  213. <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>
  214. <button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>
  215. <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
  216. </div>";
  217. //return;
  218. }
  219. if ($id == "feedBrowser") {
  220. $browser_search = db_escape_string($_REQUEST["search"]);
  221. # print "<form onsubmit='return false;' display='inline'
  222. # name='feed_browser' id='feed_browser'>";
  223. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  224. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
  225. print "<div dojoType=\"dijit.Toolbar\">
  226. <div style='float : right'>
  227. <img style='display : none'
  228. id='feed_browser_spinner' src='".
  229. theme_image($link, 'images/indicator_white.gif')."'>
  230. <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
  231. onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
  232. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
  233. </div>";
  234. print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
  235. <option value='1'>" . __('Popular feeds') . "</option>
  236. <option value='2'>" . __('Feed archive') . "</option>
  237. </select> ";
  238. print __("limit:");
  239. print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
  240. foreach (array(25, 50, 100, 200) as $l) {
  241. $issel = ($l == $limit) ? "selected=\"1\"" : "";
  242. print "<option $issel value=\"$l\">$l</option>";
  243. }
  244. print "</select> ";
  245. print "</div>";
  246. $owner_uid = $_SESSION["uid"];
  247. print "<ul class='browseFeedList' id='browseFeedList'>";
  248. print make_feed_browser($link, $search, 25);
  249. print "</ul>";
  250. print "<div align='center'>
  251. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
  252. <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
  253. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
  254. }
  255. if ($id == "search") {
  256. $params = explode(":", db_escape_string($_REQUEST["param"]), 2);
  257. $active_feed_id = sprintf("%d", $params[0]);
  258. $is_cat = $params[1] != "false";
  259. print "<div class=\"dlgSec\">".__('Look for')."</div>";
  260. print "<div class=\"dlgSecCont\">";
  261. if (!SPHINX_ENABLED) {
  262. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  263. style=\"font-size : 16px; width : 12em;\"
  264. required=\"1\" name=\"query\" type=\"search\" value=''>";
  265. print " " . __('match on')." ";
  266. $search_fields = array(
  267. "title" => __("Title"),
  268. "content" => __("Content"),
  269. "both" => __("Title or content"));
  270. print_select_hash("match_on", 3, $search_fields,
  271. 'dojoType="dijit.form.Select"');
  272. } else {
  273. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  274. style=\"font-size : 16px; width : 20em;\"
  275. required=\"1\" name=\"query\" type=\"search\" value=''>";
  276. }
  277. print "<hr/>".__('Limit search to:')." ";
  278. print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
  279. <option value=\"all_feeds\">".__('All feeds')."</option>";
  280. $feed_title = getFeedTitle($link, $active_feed_id);
  281. if (!$is_cat) {
  282. $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
  283. } else {
  284. $feed_cat_title = getCategoryTitle($link, $active_feed_id);
  285. }
  286. if ($active_feed_id && !$is_cat) {
  287. print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
  288. } else {
  289. print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
  290. }
  291. if ($is_cat) {
  292. $cat_preselected = "selected=\"1\"";
  293. }
  294. if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
  295. print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
  296. } else {
  297. //print "<option disabled>".__('This category')."</option>";
  298. }
  299. print "</select>";
  300. print "</div>";
  301. print "<div class=\"dlgButtons\">";
  302. if (!SPHINX_ENABLED) {
  303. print "<div style=\"float : left\">
  304. <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/redmine/wiki/tt-rss/SearchSyntax\">Search syntax</a>
  305. </div>";
  306. }
  307. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
  308. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
  309. </div>";
  310. }
  311. if ($id == "quickAddFilter") {
  312. $active_feed_id = db_escape_string($_REQUEST["param"]);
  313. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
  314. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">";
  315. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
  316. $result = db_query($link, "SELECT id,description
  317. FROM ttrss_filter_types ORDER BY description");
  318. $filter_types = array();
  319. while ($line = db_fetch_assoc($result)) {
  320. //array_push($filter_types, $line["description"]);
  321. $filter_types[$line["id"]] = __($line["description"]);
  322. }
  323. print "<div class=\"dlgSec\">".__("Match")."</div>";
  324. print "<div class=\"dlgSecCont\">";
  325. print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">";
  326. $filter_params = array(
  327. "before" => __("before"),
  328. "after" => __("after"));
  329. print_select_hash("filter_date_modifier", "before",
  330. $filter_params, 'dojoType="dijit.form.Select"');
  331. print "&nbsp;</span>";
  332. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  333. required=\"true\" id=\"filterDlg_regExp\"
  334. style=\"font-size : 16px\"
  335. name=\"reg_exp\" value=\"$reg_exp\"/>";
  336. print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">";
  337. print "&nbsp;<button dojoType=\"dijit.form.Button\"
  338. onclick=\"return filterDlgCheckDate()\">".
  339. __('Check it')."</button>";
  340. print "</span>";
  341. print "<hr/>" . __("on field") . " ";
  342. print_select_hash("filter_type", 1, $filter_types,
  343. 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
  344. print "<hr/>";
  345. print __("in") . " ";
  346. print_feed_select($link, "feed_id", $active_feed_id,
  347. 'dojoType="dijit.form.FilteringSelect"');
  348. print "</div>";
  349. print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
  350. print "<div class=\"dlgSecCont\">";
  351. print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
  352. onchange=\"filterDlgCheckAction(this)\">";
  353. $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
  354. ORDER BY name");
  355. while ($line = db_fetch_assoc($result)) {
  356. printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
  357. }
  358. print "</select>";
  359. print "<span id=\"filterDlg_paramBox\" style=\"display : none\">";
  360. print " " . __("with parameters:") . " ";
  361. print "<input dojoType=\"dijit.form.TextBox\"
  362. id=\"filterDlg_actionParam\"
  363. name=\"action_param\">";
  364. print_label_select($link, "action_param_label", $action_param,
  365. 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
  366. print "</span>";
  367. print "&nbsp;"; // tiny layout hack
  368. print "</div>";
  369. print "<div class=\"dlgSec\">".__("Options")."</div>";
  370. print "<div class=\"dlgSecCont\">";
  371. print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
  372. <label for=\"enabled\">".__('Enabled')."</label><hr/>";
  373. print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
  374. <label for=\"inverse\">".__('Inverse match')."</label>";
  375. print "</div>";
  376. print "<div class=\"dlgButtons\">";
  377. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
  378. __('Test')."</button> ";
  379. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
  380. __('Create')."</button> ";
  381. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
  382. __('Cancel')."</button>";
  383. print "</div>";
  384. //return;
  385. }
  386. if ($id == "inactiveFeeds") {
  387. if (DB_TYPE == "pgsql") {
  388. $interval_qpart = "NOW() - INTERVAL '3 months'";
  389. } else {
  390. $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
  391. }
  392. $result = db_query($link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
  393. ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
  394. FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
  395. (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
  396. ttrss_entries.id = ref_id AND
  397. ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
  398. AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND
  399. ttrss_user_entries.feed_id = ttrss_feeds.id AND
  400. ttrss_entries.id = ref_id
  401. GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
  402. ORDER BY last_article");
  403. print __("These feeds have not been updated with new content for 3 months (oldest first):");
  404. print "<div class=\"inactiveFeedHolder\">";
  405. print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
  406. $lnum = 1;
  407. while ($line = db_fetch_assoc($result)) {
  408. $class = ($lnum % 2) ? "even" : "odd";
  409. $feed_id = $line["id"];
  410. $this_row_id = "id=\"FUPDD-$feed_id\"";
  411. print "<tr class=\"\" $this_row_id>";
  412. $edit_title = htmlspecialchars($line["title"]);
  413. print "<td width='5%' align='center'><input
  414. onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
  415. type=\"checkbox\"></td>";
  416. print "<td>";
  417. print "<a class=\"visibleLink\" href=\"#\" ".
  418. "title=\"".__("Click to edit feed")."\" ".
  419. "onclick=\"editFeed(".$line["id"].")\">".
  420. htmlspecialchars($line["title"])."</a>";
  421. print "</td><td class=\"insensitive\" align='right'>";
  422. print make_local_datetime($link, $line['last_article'], false);
  423. print "</td>";
  424. print "</tr>";
  425. ++$lnum;
  426. }
  427. print "</table>";
  428. print "</div>";
  429. print "<div class='dlgButtons'>";
  430. print "<div style='float : left'>";
  431. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
  432. .__('Unsubscribe from selected feeds')."</button> ";
  433. print "</div>";
  434. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">".
  435. __('Close this window')."</button>";
  436. print "</div>";
  437. }
  438. if ($id == "feedsWithErrors") {
  439. # print "<title>".__('Feeds with update errors')."</title>";
  440. # print "<content><![CDATA[";
  441. print __("These feeds have not been updated because of errors:");
  442. $result = db_query($link, "SELECT id,title,feed_url,last_error,site_url
  443. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  444. print "<div class=\"inactiveFeedHolder\">";
  445. print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
  446. $lnum = 1;
  447. while ($line = db_fetch_assoc($result)) {
  448. $class = ($lnum % 2) ? "even" : "odd";
  449. $feed_id = $line["id"];
  450. $this_row_id = "id=\"FUPDD-$feed_id\"";
  451. print "<tr class=\"\" $this_row_id>";
  452. $edit_title = htmlspecialchars($line["title"]);
  453. print "<td width='5%' align='center'><input
  454. onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
  455. type=\"checkbox\"></td>";
  456. print "<td>";
  457. print "<a class=\"visibleLink\" href=\"#\" ".
  458. "title=\"".__("Click to edit feed")."\" ".
  459. "onclick=\"editFeed(".$line["id"].")\">".
  460. htmlspecialchars($line["title"])."</a>: ";
  461. print "<span class=\"insensitive\">";
  462. print htmlspecialchars($line["last_error"]);
  463. print "</span>";
  464. print "</td>";
  465. print "</tr>";
  466. ++$lnum;
  467. }
  468. print "</table>";
  469. print "</div>";
  470. print "<div class='dlgButtons'>";
  471. print "<div style='float : left'>";
  472. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
  473. .__('Unsubscribe from selected feeds')."</button> ";
  474. print "</div>";
  475. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
  476. __('Close this window')."</button>";
  477. print "</div>";
  478. }
  479. if ($id == "editArticleTags") {
  480. # print "<form id=\"tag_edit_form\" onsubmit='return false'>";
  481. print __("Tags for this article (separated by commas):")."<br>";
  482. $tags = get_article_tags($link, $param);
  483. $tags_str = join(", ", $tags);
  484. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$param\">";
  485. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  486. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
  487. print "<table width='100%'><tr><td>";
  488. print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
  489. style='font-size : 12px; width : 100%' id=\"tags_str\"
  490. name='tags_str'>$tags_str</textarea>
  491. <div class=\"autocomplete\" id=\"tags_choices\"
  492. style=\"display:none\"></div>";
  493. print "</td></tr></table>";
  494. # print "</form>";
  495. print "<div class='dlgButtons'>";
  496. print "<button dojoType=\"dijit.form.Button\"
  497. onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> ";
  498. print "<button dojoType=\"dijit.form.Button\"
  499. onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>";
  500. print "</div>";
  501. }
  502. if ($id == "printTagCloud") {
  503. print "<title>".__('Tag Cloud')."</title>";
  504. print "<content><![CDATA[";
  505. # print __("Showing most popular tags ")." (<a
  506. # href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
  507. print "<div class=\"tagCloudContainer\">";
  508. printTagCloud($link);
  509. print "</div>";
  510. print "<div align='center'>";
  511. print "<button dojoType=\"dijit.form.Button\"
  512. onclick=\"return closeInfoBox()\">".
  513. __('Close this window')."</button>";
  514. print "</div>";
  515. print "]]></content>";
  516. }
  517. if ($id == 'printTagSelect') {
  518. print "<title>" . __('Select item(s) by tags') . "</title>";
  519. print "<content><![CDATA[";
  520. print __("Match:"). "&nbsp;" .
  521. "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\">&nbsp;Any&nbsp;";
  522. print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\">&nbsp;All&nbsp;";
  523. print "&nbsp;tags.";
  524. print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
  525. $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
  526. AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
  527. while ($row = db_fetch_assoc($result)) {
  528. $tmp = htmlspecialchars($row["tag_name"]);
  529. print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
  530. }
  531. print "</select>";
  532. print "<div align='right'>";
  533. print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
  534. get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
  535. print "&nbsp;";
  536. print "<button dojoType=\"dijit.form.Button\"
  537. onclick=\"return closeInfoBox()\">" .
  538. __('Close this window') . "</button>";
  539. print "</div>";
  540. print "]]></content>";
  541. }
  542. if ($id == "emailArticle") {
  543. $secretkey = sha1(uniqid(rand(), true));
  544. $_SESSION['email_secretkey'] = $secretkey;
  545. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"secretkey\" value=\"$secretkey\">";
  546. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  547. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"sendEmail\">";
  548. $result = db_query($link, "SELECT email, full_name FROM ttrss_users WHERE
  549. id = " . $_SESSION["uid"]);
  550. $user_email = htmlspecialchars(db_fetch_result($result, 0, "email"));
  551. $user_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
  552. if (!$user_name) $user_name = $_SESSION['name'];
  553. $_SESSION['email_replyto'] = $user_email;
  554. $_SESSION['email_fromname'] = $user_name;
  555. require_once "lib/MiniTemplator.class.php";
  556. $tpl = new MiniTemplator;
  557. $tpl_t = new MiniTemplator;
  558. $tpl->readTemplateFromFile("templates/email_article_template.txt");
  559. $tpl->setVariable('USER_NAME', $_SESSION["name"]);
  560. $tpl->setVariable('USER_EMAIL', $user_email);
  561. $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]);
  562. // $tpl->addBlock('header');
  563. $result = db_query($link, "SELECT link, content, title
  564. FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
  565. id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
  566. if (db_num_rows($result) > 1) {
  567. $subject = __("[Forwarded]") . " " . __("Multiple articles");
  568. }
  569. while ($line = db_fetch_assoc($result)) {
  570. if (!$subject)
  571. $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
  572. $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
  573. $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
  574. $tpl->addBlock('article');
  575. }
  576. $tpl->addBlock('email');
  577. $content = "";
  578. $tpl->generateOutputToString($content);
  579. print "<table width='100%'><tr><td>";
  580. print __('From:');
  581. print "</td><td>";
  582. print "<input dojoType=\"dijit.form.TextBox\" disabled=\"1\" style=\"width : 30em;\"
  583. value=\"$user_name <$user_email>\">";
  584. print "</td></tr><tr><td>";
  585. print __('To:');
  586. print "</td><td>";
  587. print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"
  588. style=\"width : 30em;\"
  589. name=\"destination\" id=\"emailArticleDlg_destination\">";
  590. print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\"
  591. style=\"z-index: 30; display : none\"></div>";
  592. print "</td></tr><tr><td>";
  593. print __('Subject:');
  594. print "</td><td>";
  595. print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"
  596. style=\"width : 30em;\"
  597. name=\"subject\" value=\"$subject\" id=\"subject\">";
  598. print "</td></tr>";
  599. print "<tr><td colspan='2'><textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 100%' rows=\"20\"
  600. name='content'>$content</textarea>";
  601. print "</td></tr></table>";
  602. print "<div class='dlgButtons'>";
  603. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> ";
  604. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>";
  605. print "</div>";
  606. //return;
  607. }
  608. if ($id == "generatedFeed") {
  609. print "<title>".__('View as RSS')."</title>";
  610. print "<content><![CDATA[";
  611. $params = explode(":", $param, 3);
  612. $feed_id = db_escape_string($params[0]);
  613. $is_cat = (bool) $params[1];
  614. $key = get_feed_access_key($link, $feed_id, $is_cat);
  615. $url_path = htmlspecialchars($params[2]) . "&key=" . $key;
  616. print __("You can view this feed as RSS using the following URL:");
  617. print "<div class=\"tagCloudContainer\">";
  618. print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
  619. print "</div>";
  620. print "<div align='center'>";
  621. print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
  622. __('Generate new URL')."</button> ";
  623. print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
  624. __('Close this window')."</button>";
  625. print "</div>";
  626. print "]]></content>";
  627. //return;
  628. }
  629. if ($id == "newVersion") {
  630. $version_data = check_for_update($link);
  631. $version = $version_data['version'];
  632. $id = $version_data['version_id'];
  633. print "<div class='tagCloudContainer'>";
  634. print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
  635. "<b>$version</b>");
  636. print "</div>";
  637. $details = "http://tt-rss.org/redmine/versions/show/$id";
  638. $download = "http://tt-rss.org/#Download";
  639. print "<div style='text-align : center'>";
  640. print "<button dojoType=\"dijit.form.Button\"
  641. onclick=\"return window.open('$details')\">".__("Details")."</button>";
  642. print "<button dojoType=\"dijit.form.Button\"
  643. onclick=\"return window.open('$download')\">".__("Download")."</button>";
  644. print "<button dojoType=\"dijit.form.Button\"
  645. onclick=\"return dijit.byId('newVersionDlg').hide()\">".
  646. __('Close this window')."</button>";
  647. print "</div>";
  648. }
  649. if ($id == "customizeCSS") {
  650. $value = get_pref($link, "USER_STYLESHEET");
  651. $value = str_replace("<br/>", "\n", $value);
  652. 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");
  653. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  654. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
  655. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
  656. print "<table width='100%'><tr><td>";
  657. print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
  658. style='font-size : 12px; width : 100%; height: 200px;'
  659. placeHolder='body#ttrssMain { font-size : 14px; };'
  660. name='value'>$value</textarea>";
  661. print "</td></tr></table>";
  662. print "<div class='dlgButtons'>";
  663. print "<button dojoType=\"dijit.form.Button\"
  664. onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
  665. print "<button dojoType=\"dijit.form.Button\"
  666. onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
  667. print "</div>";
  668. }
  669. if ($id == "editArticleNote") {
  670. $result = db_query($link, "SELECT note FROM ttrss_user_entries WHERE
  671. ref_id = '$param' AND owner_uid = " . $_SESSION['uid']);
  672. $note = db_fetch_result($result, 0, "note");
  673. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$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=\"setNote\">";
  676. print "<table width='100%'><tr><td>";
  677. print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
  678. style='font-size : 12px; width : 100%; height: 100px;'
  679. placeHolder='body#ttrssMain { font-size : 14px; };'
  680. name='note'>$note</textarea>";
  681. print "</td></tr></table>";
  682. print "<div class='dlgButtons'>";
  683. print "<button dojoType=\"dijit.form.Button\"
  684. onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> ";
  685. print "<button dojoType=\"dijit.form.Button\"
  686. onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>";
  687. print "</div>";
  688. }
  689. if ($id == "about") {
  690. print "<table width='100%'><tr><td align='center'>";
  691. print "<img src=\"images/logo_big.png\">";
  692. print "</td>";
  693. print "<td width='70%'>";
  694. print "<h1>Tiny Riny RSS</h1>
  695. <strong>Version ".VERSION."</strong>
  696. <p>Copyright &copy; 2005-".date('Y')."
  697. <a target=\"_blank\" class=\"visibleLink\"
  698. href=\"http://fakecake.org/\">Andrew Dolgov</a>
  699. and other contributors.</p>
  700. <p class=\"insensitive\">Licensed under GNU GPL version 2.</p>";
  701. print "<p class=\"insensitive\">
  702. <a class=\"visibleLink\" target=\"_blank\"
  703. href=\"http://tt-rss.org/\">Official site</a> &mdash;
  704. <a href=\"http://tt-rss.org/redmine/wiki/tt-rss/Donate\"
  705. target=\"_blank\" class=\"visibleLink\">
  706. Support the project.</a></p>";
  707. print "</td></tr>";
  708. print "</table>";
  709. print "<div align='center'>";
  710. print "<button dojoType=\"dijit.form.Button\"
  711. type=\"submit\">".
  712. __('Close this window')."</button>";
  713. print "</div>";
  714. }
  715. if ($id == "addInstance") {
  716. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
  717. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
  718. print "<div class=\"dlgSec\">".__("Instance")."</div>";
  719. print "<div class=\"dlgSecCont\">";
  720. /* URL */
  721. print __("URL:") . " ";
  722. print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
  723. placeHolder=\"".__("Instance URL")."\"
  724. regExp='^(http|https)://.*'
  725. style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
  726. print "<hr/>";
  727. $access_key = sha1(uniqid(rand(), true));
  728. /* Access key */
  729. print __("Access key:") . " ";
  730. print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
  731. placeHolder=\"".__("Access key")."\" regExp='\w{40}'
  732. style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
  733. value=\"$access_key\">";
  734. print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
  735. print "</div>";
  736. print "<div class=\"dlgButtons\">
  737. <div style='float : left'>
  738. <button dojoType=\"dijit.form.Button\"
  739. onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
  740. __('Generate new key')."</button>
  741. </div>
  742. <button dojoType=\"dijit.form.Button\"
  743. onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
  744. __('Create link')."</button>
  745. <button dojoType=\"dijit.form.Button\"
  746. onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
  747. __('Cancel')."</button></div>";
  748. return;
  749. }
  750. if ($id == "shareArticle") {
  751. $result = db_query($link, "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '$param'
  752. AND owner_uid = " . $_SESSION['uid']);
  753. if (db_num_rows($result) == 0) {
  754. print "Article not found.";
  755. } else {
  756. $uuid = db_fetch_result($result, 0, "uuid");
  757. $ref_id = db_fetch_result($result, 0, "ref_id");
  758. if (!$uuid) {
  759. $uuid = db_escape_string(sha1(uniqid(rand(), true)));
  760. db_query($link, "UPDATE ttrss_user_entries SET uuid = '$uuid' WHERE int_id = '$param'
  761. AND owner_uid = " . $_SESSION['uid']);
  762. }
  763. print __("You can share this article by the following unique URL:");
  764. $url_path = get_self_url_prefix();
  765. $url_path .= "/public.php?op=share&key=$uuid";
  766. print "<div class=\"tagCloudContainer\">";
  767. print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
  768. print "</div>";
  769. /* if (!label_find_id($link, __('Shared'), $_SESSION["uid"]))
  770. label_create($link, __('Shared'), $_SESSION["uid"]);
  771. label_add_article($link, $ref_id, __('Shared'), $_SESSION['uid']); */
  772. }
  773. print "<div align='center'>";
  774. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
  775. __('Close this window')."</button>";
  776. print "</div>";
  777. return;
  778. }
  779. print "</dlg>";
  780. }
  781. ?>