dlg.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. <?php
  2. class Dlg extends Protected_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 exportData() {
  17. print "<p style='text-align : center' id='export_status_message'>You need to prepare exported data first by clicking the button below.</p>";
  18. print "<div align='center'>";
  19. print "<button dojoType=\"dijit.form.Button\"
  20. onclick=\"dijit.byId('dataExportDlg').prepare()\">".
  21. __('Prepare data')."</button>";
  22. print "<button dojoType=\"dijit.form.Button\"
  23. onclick=\"dijit.byId('dataExportDlg').hide()\">".
  24. __('Close this window')."</button>";
  25. print "</div>";
  26. }
  27. function importOpml() {
  28. header("Content-Type: text/html"); # required for iframe
  29. print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
  30. print "<div class=\"prefFeedOPMLHolder\">";
  31. $owner_uid = $_SESSION["uid"];
  32. db_query($this->link, "BEGIN");
  33. /* create Imported feeds category just in case */
  34. $result = db_query($this->link, "SELECT id FROM
  35. ttrss_feed_categories WHERE title = 'Imported feeds' AND
  36. owner_uid = '$owner_uid' LIMIT 1");
  37. if (db_num_rows($result) == 0) {
  38. db_query($this->link, "INSERT INTO ttrss_feed_categories
  39. (title,owner_uid)
  40. VALUES ('Imported feeds', '$owner_uid')");
  41. }
  42. db_query($this->link, "COMMIT");
  43. /* Handle OPML import by DOMXML/DOMDocument */
  44. print "<ul class='nomarks'>";
  45. require_once "opml.php";
  46. opml_import_domdoc($this->link, $owner_uid);
  47. print "</ul>";
  48. print "</div>";
  49. print "<div align='center'>";
  50. print "<button dojoType=\"dijit.form.Button\"
  51. onclick=\"dijit.byId('opmlImportDlg').execute()\">".
  52. __('Close this window')."</button>";
  53. print "</div>";
  54. print "</div>";
  55. //return;
  56. }
  57. function editPrefProfiles() {
  58. print "<div dojoType=\"dijit.Toolbar\">";
  59. print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
  60. required=\"1\">
  61. <button dojoType=\"dijit.form.Button\"
  62. onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
  63. __('Create profile')."</button></div>";
  64. $result = db_query($this->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. function pubOPMLUrl() {
  133. print "<title>".__('Public OPML URL')."</title>";
  134. print "<content><![CDATA[";
  135. $url_path = opml_publish_url($this->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. function explainError() {
  150. print "<title>".__('Notice')."</title>";
  151. print "<content><![CDATA[";
  152. print "<div class=\"errorExplained\">";
  153. if ($this->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 ($this->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. function 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($this->link, 'ENABLE_FEED_CATS')) {
  181. print __('Place in category:') . " ";
  182. print_feed_cat_select($this->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. function feedBrowser() {
  220. $browser_search = db_escape_string($_REQUEST["search"]);
  221. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  222. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
  223. print "<div dojoType=\"dijit.Toolbar\">
  224. <div style='float : right'>
  225. <img style='display : none'
  226. id='feed_browser_spinner' src='".
  227. theme_image($this->link, 'images/indicator_white.gif')."'>
  228. <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
  229. onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
  230. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
  231. </div>";
  232. print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
  233. <option value='1'>" . __('Popular feeds') . "</option>
  234. <option value='2'>" . __('Feed archive') . "</option>
  235. </select> ";
  236. print __("limit:");
  237. print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
  238. foreach (array(25, 50, 100, 200) as $l) {
  239. $issel = ($l == $limit) ? "selected=\"1\"" : "";
  240. print "<option $issel value=\"$l\">$l</option>";
  241. }
  242. print "</select> ";
  243. print "</div>";
  244. $owner_uid = $_SESSION["uid"];
  245. print "<ul class='browseFeedList' id='browseFeedList'>";
  246. print make_feed_browser($this->link, $search, 25);
  247. print "</ul>";
  248. print "<div align='center'>
  249. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
  250. <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
  251. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
  252. }
  253. function search() {
  254. $this->params = explode(":", db_escape_string($_REQUEST["param"]), 2);
  255. $active_feed_id = sprintf("%d", $this->params[0]);
  256. $is_cat = $this->params[1] != "false";
  257. print "<div class=\"dlgSec\">".__('Look for')."</div>";
  258. print "<div class=\"dlgSecCont\">";
  259. if (!SPHINX_ENABLED) {
  260. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  261. style=\"font-size : 16px; width : 12em;\"
  262. required=\"1\" name=\"query\" type=\"search\" value=''>";
  263. print " " . __('match on')." ";
  264. $search_fields = array(
  265. "title" => __("Title"),
  266. "content" => __("Content"),
  267. "both" => __("Title or content"));
  268. print_select_hash("match_on", 3, $search_fields,
  269. 'dojoType="dijit.form.Select"');
  270. } else {
  271. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  272. style=\"font-size : 16px; width : 20em;\"
  273. required=\"1\" name=\"query\" type=\"search\" value=''>";
  274. }
  275. print "<hr/>".__('Limit search to:')." ";
  276. print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
  277. <option value=\"all_feeds\">".__('All feeds')."</option>";
  278. $feed_title = getFeedTitle($this->link, $active_feed_id);
  279. if (!$is_cat) {
  280. $feed_cat_title = getFeedCatTitle($this->link, $active_feed_id);
  281. } else {
  282. $feed_cat_title = getCategoryTitle($this->link, $active_feed_id);
  283. }
  284. if ($active_feed_id && !$is_cat) {
  285. print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
  286. } else {
  287. print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
  288. }
  289. if ($is_cat) {
  290. $cat_preselected = "selected=\"1\"";
  291. }
  292. if (get_pref($this->link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
  293. print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
  294. } else {
  295. //print "<option disabled>".__('This category')."</option>";
  296. }
  297. print "</select>";
  298. print "</div>";
  299. print "<div class=\"dlgButtons\">";
  300. if (!SPHINX_ENABLED) {
  301. print "<div style=\"float : left\">
  302. <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/redmine/wiki/tt-rss/SearchSyntax\">Search syntax</a>
  303. </div>";
  304. }
  305. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
  306. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
  307. </div>";
  308. }
  309. function quickAddFilter() {
  310. $active_feed_id = db_escape_string($_REQUEST["param"]);
  311. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
  312. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">";
  313. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
  314. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
  315. $result = db_query($this->link, "SELECT id,description
  316. FROM ttrss_filter_types ORDER BY description");
  317. $filter_types = array();
  318. while ($line = db_fetch_assoc($result)) {
  319. //array_push($filter_types, $line["description"]);
  320. $filter_types[$line["id"]] = __($line["description"]);
  321. }
  322. print "<div class=\"dlgSec\">".__("Match")."</div>";
  323. print "<div class=\"dlgSecCont\">";
  324. print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">";
  325. $filter_params = array(
  326. "before" => __("before"),
  327. "after" => __("after"));
  328. print_select_hash("filter_date_modifier", "before",
  329. $filter_params, 'dojoType="dijit.form.Select"');
  330. print "&nbsp;</span>";
  331. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  332. required=\"true\" id=\"filterDlg_regExp\"
  333. style=\"font-size : 16px\"
  334. name=\"reg_exp\" value=\"$reg_exp\"/>";
  335. print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">";
  336. print "&nbsp;<button dojoType=\"dijit.form.Button\"
  337. onclick=\"return filterDlgCheckDate()\">".
  338. __('Check it')."</button>";
  339. print "</span>";
  340. print "<hr/>" . __("on field") . " ";
  341. print_select_hash("filter_type", 1, $filter_types,
  342. 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
  343. print "<hr/>";
  344. print __("in") . " ";
  345. print "<span id='filterDlg_feeds'>";
  346. print_feed_select($this->link, "feed_id", $active_feed_id,
  347. 'dojoType="dijit.form.FilteringSelect"');
  348. print "</span>";
  349. print "<span id='filterDlg_cats' style='display : none'>";
  350. print_feed_cat_select($this->link, "cat_id", $active_cat_id,
  351. 'dojoType="dijit.form.FilteringSelect"');
  352. print "</span>";
  353. print "</div>";
  354. print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
  355. print "<div class=\"dlgSecCont\">";
  356. print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
  357. onchange=\"filterDlgCheckAction(this)\">";
  358. $result = db_query($this->link, "SELECT id,description FROM ttrss_filter_actions
  359. ORDER BY name");
  360. while ($line = db_fetch_assoc($result)) {
  361. printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
  362. }
  363. print "</select>";
  364. print "<span id=\"filterDlg_paramBox\" style=\"display : none\">";
  365. print " " . __("with parameters:") . " ";
  366. print "<input dojoType=\"dijit.form.TextBox\"
  367. id=\"filterDlg_actionParam\"
  368. name=\"action_param\">";
  369. print_label_select($this->link, "action_param_label", $action_param,
  370. 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
  371. print "</span>";
  372. print "&nbsp;"; // tiny layout hack
  373. print "</div>";
  374. print "<div class=\"dlgSec\">".__("Options")."</div>";
  375. print "<div class=\"dlgSecCont\">";
  376. print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">
  377. <label for=\"enabled\">".__('Enabled')."</label><hr/>";
  378. print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
  379. <label for=\"inverse\">".__('Inverse match')."</label><hr/>";
  380. print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\">
  381. <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
  382. print "</div>";
  383. print "<div class=\"dlgButtons\">";
  384. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
  385. __('Test')."</button> ";
  386. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
  387. __('Create')."</button> ";
  388. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
  389. __('Cancel')."</button>";
  390. print "</div>";
  391. }
  392. function inactiveFeeds() {
  393. if (DB_TYPE == "pgsql") {
  394. $interval_qpart = "NOW() - INTERVAL '3 months'";
  395. } else {
  396. $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
  397. }
  398. $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
  399. ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
  400. FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
  401. (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
  402. ttrss_entries.id = ref_id AND
  403. ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
  404. AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND
  405. ttrss_user_entries.feed_id = ttrss_feeds.id AND
  406. ttrss_entries.id = ref_id
  407. GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
  408. ORDER BY last_article");
  409. print __("These feeds have not been updated with new content for 3 months (oldest first):");
  410. print "<div class=\"inactiveFeedHolder\">";
  411. print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
  412. $lnum = 1;
  413. while ($line = db_fetch_assoc($result)) {
  414. $class = ($lnum % 2) ? "even" : "odd";
  415. $feed_id = $line["id"];
  416. $this_row_id = "id=\"FUPDD-$feed_id\"";
  417. print "<tr class=\"\" $this_row_id>";
  418. $edit_title = htmlspecialchars($line["title"]);
  419. print "<td width='5%' align='center'><input
  420. onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
  421. type=\"checkbox\"></td>";
  422. print "<td>";
  423. print "<a class=\"visibleLink\" href=\"#\" ".
  424. "title=\"".__("Click to edit feed")."\" ".
  425. "onclick=\"editFeed(".$line["id"].")\">".
  426. htmlspecialchars($line["title"])."</a>";
  427. print "</td><td class=\"insensitive\" align='right'>";
  428. print make_local_datetime($this->link, $line['last_article'], false);
  429. print "</td>";
  430. print "</tr>";
  431. ++$lnum;
  432. }
  433. print "</table>";
  434. print "</div>";
  435. print "<div class='dlgButtons'>";
  436. print "<div style='float : left'>";
  437. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
  438. .__('Unsubscribe from selected feeds')."</button> ";
  439. print "</div>";
  440. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">".
  441. __('Close this window')."</button>";
  442. print "</div>";
  443. }
  444. function feedsWithErrors() {
  445. print __("These feeds have not been updated because of errors:");
  446. $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
  447. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  448. print "<div class=\"inactiveFeedHolder\">";
  449. print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
  450. $lnum = 1;
  451. while ($line = db_fetch_assoc($result)) {
  452. $class = ($lnum % 2) ? "even" : "odd";
  453. $feed_id = $line["id"];
  454. $this_row_id = "id=\"FUPDD-$feed_id\"";
  455. print "<tr class=\"\" $this_row_id>";
  456. $edit_title = htmlspecialchars($line["title"]);
  457. print "<td width='5%' align='center'><input
  458. onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
  459. type=\"checkbox\"></td>";
  460. print "<td>";
  461. print "<a class=\"visibleLink\" href=\"#\" ".
  462. "title=\"".__("Click to edit feed")."\" ".
  463. "onclick=\"editFeed(".$line["id"].")\">".
  464. htmlspecialchars($line["title"])."</a>: ";
  465. print "<span class=\"insensitive\">";
  466. print htmlspecialchars($line["last_error"]);
  467. print "</span>";
  468. print "</td>";
  469. print "</tr>";
  470. ++$lnum;
  471. }
  472. print "</table>";
  473. print "</div>";
  474. print "<div class='dlgButtons'>";
  475. print "<div style='float : left'>";
  476. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
  477. .__('Unsubscribe from selected feeds')."</button> ";
  478. print "</div>";
  479. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
  480. __('Close this window')."</button>";
  481. print "</div>";
  482. }
  483. function editArticleTags() {
  484. print __("Tags for this article (separated by commas):")."<br>";
  485. $tags = get_article_tags($this->link, $this->param);
  486. $tags_str = join(", ", $tags);
  487. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$this->param\">";
  488. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  489. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
  490. print "<table width='100%'><tr><td>";
  491. print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'
  492. style='font-size : 12px; width : 100%' id=\"tags_str\"
  493. name='tags_str'>$tags_str</textarea>
  494. <div class=\"autocomplete\" id=\"tags_choices\"
  495. style=\"display:none\"></div>";
  496. print "</td></tr></table>";
  497. print "<div class='dlgButtons'>";
  498. print "<button dojoType=\"dijit.form.Button\"
  499. onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> ";
  500. print "<button dojoType=\"dijit.form.Button\"
  501. onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>";
  502. print "</div>";
  503. }
  504. function printTagCloud() {
  505. print "<title>".__('Tag Cloud')."</title>";
  506. print "<content><![CDATA[";
  507. print "<div class=\"tagCloudContainer\">";
  508. // from here: http://www.roscripts.com/Create_tag_cloud-71.html
  509. $query = "SELECT tag_name, COUNT(post_int_id) AS count
  510. FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
  511. GROUP BY tag_name ORDER BY count DESC LIMIT 50";
  512. $result = db_query($this->link, $query);
  513. $tags = array();
  514. while ($line = db_fetch_assoc($result)) {
  515. $tags[$line["tag_name"]] = $line["count"];
  516. }
  517. if( count($tags) == 0 ){ return; }
  518. ksort($tags);
  519. $max_size = 32; // max font size in pixels
  520. $min_size = 11; // min font size in pixels
  521. // largest and smallest array values
  522. $max_qty = max(array_values($tags));
  523. $min_qty = min(array_values($tags));
  524. // find the range of values
  525. $spread = $max_qty - $min_qty;
  526. if ($spread == 0) { // we don't want to divide by zero
  527. $spread = 1;
  528. }
  529. // set the font-size increment
  530. $step = ($max_size - $min_size) / ($spread);
  531. // loop through the tag array
  532. foreach ($tags as $key => $value) {
  533. // calculate font-size
  534. // find the $value in excess of $min_qty
  535. // multiply by the font-size increment ($size)
  536. // and add the $min_size set above
  537. $size = round($min_size + (($value - $min_qty) * $step));
  538. $key_escaped = str_replace("'", "\\'", $key);
  539. echo "<a href=\"javascript:viewfeed('$key_escaped') \" style=\"font-size: " .
  540. $size . "px\" title=\"$value articles tagged with " .
  541. $key . '">' . $key . '</a> ';
  542. }
  543. print "</div>";
  544. print "<div align='center'>";
  545. print "<button dojoType=\"dijit.form.Button\"
  546. onclick=\"return closeInfoBox()\">".
  547. __('Close this window')."</button>";
  548. print "</div>";
  549. print "]]></content>";
  550. }
  551. function printTagSelect() {
  552. print "<title>" . __('Select item(s) by tags') . "</title>";
  553. print "<content><![CDATA[";
  554. print __("Match:"). "&nbsp;" .
  555. "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\">&nbsp;Any&nbsp;";
  556. print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\">&nbsp;All&nbsp;";
  557. print "&nbsp;tags.";
  558. print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
  559. $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
  560. AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
  561. while ($row = db_fetch_assoc($result)) {
  562. $tmp = htmlspecialchars($row["tag_name"]);
  563. print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">$tmp</option>";
  564. }
  565. print "</select>";
  566. print "<div align='right'>";
  567. print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags($('all_tags')),
  568. get_radio_checked($('tag_mode')));\">" . __('Display entries') . "</button>";
  569. print "&nbsp;";
  570. print "<button dojoType=\"dijit.form.Button\"
  571. onclick=\"return closeInfoBox()\">" .
  572. __('Close this window') . "</button>";
  573. print "</div>";
  574. print "]]></content>";
  575. }
  576. function generatedFeed() {
  577. print "<title>".__('View as RSS')."</title>";
  578. print "<content><![CDATA[";
  579. $this->params = explode(":", $this->param, 3);
  580. $feed_id = db_escape_string($this->params[0]);
  581. $is_cat = (bool) $this->params[1];
  582. $key = get_feed_access_key($this->link, $feed_id, $is_cat);
  583. $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
  584. print __("You can view this feed as RSS using the following URL:");
  585. print "<div class=\"tagCloudContainer\">";
  586. print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
  587. print "</div>";
  588. print "<div align='center'>";
  589. print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">".
  590. __('Generate new URL')."</button> ";
  591. print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".
  592. __('Close this window')."</button>";
  593. print "</div>";
  594. print "]]></content>";
  595. //return;
  596. }
  597. function newVersion() {
  598. $version_data = check_for_update($this->link);
  599. $version = $version_data['version'];
  600. $id = $version_data['version_id'];
  601. print "<div class='tagCloudContainer'>";
  602. print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
  603. "<b>$version</b>");
  604. print "</div>";
  605. $details = "http://tt-rss.org/redmine/versions/show/$id";
  606. $download = "http://tt-rss.org/#Download";
  607. print "<div style='text-align : center'>";
  608. print "<button dojoType=\"dijit.form.Button\"
  609. onclick=\"return window.open('$details')\">".__("Details")."</button>";
  610. print "<button dojoType=\"dijit.form.Button\"
  611. onclick=\"return window.open('$download')\">".__("Download")."</button>";
  612. print "<button dojoType=\"dijit.form.Button\"
  613. onclick=\"return dijit.byId('newVersionDlg').hide()\">".
  614. __('Close this window')."</button>";
  615. print "</div>";
  616. }
  617. function customizeCSS() {
  618. $value = get_pref($this->link, "USER_STYLESHEET");
  619. $value = str_replace("<br/>", "\n", $value);
  620. 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");
  621. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  622. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
  623. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
  624. print "<table width='100%'><tr><td>";
  625. print "<textarea dojoType=\"dijit.form.SimpleTextarea\"
  626. style='font-size : 12px; width : 100%; height: 200px;'
  627. placeHolder='body#ttrssMain { font-size : 14px; };'
  628. name='value'>$value</textarea>";
  629. print "</td></tr></table>";
  630. print "<div class='dlgButtons'>";
  631. print "<button dojoType=\"dijit.form.Button\"
  632. onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
  633. print "<button dojoType=\"dijit.form.Button\"
  634. onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
  635. print "</div>";
  636. }
  637. function addInstance() {
  638. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
  639. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
  640. print "<div class=\"dlgSec\">".__("Instance")."</div>";
  641. print "<div class=\"dlgSecCont\">";
  642. /* URL */
  643. print __("URL:") . " ";
  644. print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
  645. placeHolder=\"".__("Instance URL")."\"
  646. regExp='^(http|https)://.*'
  647. style=\"font-size : 16px; width: 20em\" name=\"access_url\">";
  648. print "<hr/>";
  649. $access_key = sha1(uniqid(rand(), true));
  650. /* Access key */
  651. print __("Access key:") . " ";
  652. print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"
  653. placeHolder=\"".__("Access key")."\" regExp='\w{40}'
  654. style=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"
  655. value=\"$access_key\">";
  656. print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
  657. print "</div>";
  658. print "<div class=\"dlgButtons\">
  659. <div style='float : left'>
  660. <button dojoType=\"dijit.form.Button\"
  661. onclick=\"return dijit.byId('instanceAddDlg').regenKey()\">".
  662. __('Generate new key')."</button>
  663. </div>
  664. <button dojoType=\"dijit.form.Button\"
  665. onclick=\"return dijit.byId('instanceAddDlg').execute()\">".
  666. __('Create link')."</button>
  667. <button dojoType=\"dijit.form.Button\"
  668. onclick=\"return dijit.byId('instanceAddDlg').hide()\"\">".
  669. __('Cancel')."</button></div>";
  670. return;
  671. }
  672. }
  673. ?>