dlg.php 34 KB

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