feeds.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. <?php
  2. require_once "colors.php";
  3. class Feeds extends Handler_Protected {
  4. function csrf_ignore($method) {
  5. $csrf_ignored = array("index", "feedbrowser", "quickaddfeed", "search");
  6. return array_search($method, $csrf_ignored) !== false;
  7. }
  8. private function format_headline_subtoolbar($feed_site_url, $feed_title,
  9. $feed_id, $is_cat, $search,
  10. $search_mode, $view_mode, $error, $feed_last_updated) {
  11. $page_prev_link = "viewFeedGoPage(-1)";
  12. $page_next_link = "viewFeedGoPage(1)";
  13. $page_first_link = "viewFeedGoPage(0)";
  14. $catchup_page_link = "catchupPage()";
  15. $catchup_feed_link = "catchupCurrentFeed()";
  16. $catchup_sel_link = "catchupSelection()";
  17. $archive_sel_link = "archiveSelection()";
  18. $delete_sel_link = "deleteSelection()";
  19. $sel_all_link = "selectArticles('all')";
  20. $sel_unread_link = "selectArticles('unread')";
  21. $sel_none_link = "selectArticles('none')";
  22. $sel_inv_link = "selectArticles('invert')";
  23. $tog_unread_link = "selectionToggleUnread()";
  24. $tog_marked_link = "selectionToggleMarked()";
  25. $tog_published_link = "selectionTogglePublished()";
  26. $set_score_link = "setSelectionScore()";
  27. if ($is_cat) $cat_q = "&is_cat=$is_cat";
  28. if ($search) {
  29. $search_q = "&q=$search&smode=$search_mode";
  30. } else {
  31. $search_q = "";
  32. }
  33. $reply .= "<span class=\"holder\">";
  34. $rss_link = htmlspecialchars(get_self_url_prefix() .
  35. "/public.php?op=rss&id=$feed_id$cat_q$search_q");
  36. // right part
  37. $error_class = $error ? "error" : "";
  38. $reply .= "<span class='r'>
  39. <a href=\"#\"
  40. title=\"".__("View as RSS feed")."\"
  41. onclick=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">
  42. <img class=\"noborder\" src=\"images/pub_set.png\"></a>";
  43. # $reply .= "<span>";
  44. $reply .= "<span id='feed_title' class='$error_class'>";
  45. if ($feed_site_url) {
  46. $last_updated = T_sprintf("Last updated: %s",
  47. $feed_last_updated);
  48. $target = "target=\"_blank\"";
  49. $reply .= "<a title=\"$last_updated\" $target href=\"$feed_site_url\">".
  50. truncate_string($feed_title, 30)."</a>";
  51. if ($error) {
  52. $error = htmlspecialchars($error);
  53. $reply .= "&nbsp;<img title=\"$error\" src='images/error.png' alt='error' class=\"noborder\" style=\"vertical-align : middle\">";
  54. }
  55. } else {
  56. $reply .= $feed_title;
  57. }
  58. $reply .= "</span>";
  59. $reply .= "</span>";
  60. # $reply .= "</span>";
  61. // left part
  62. $reply .= "<span class=\"main\">";
  63. $reply .= "<span id='selected_prompt'></span>";
  64. $reply .= "
  65. <a href=\"#\" onclick=\"$sel_all_link\">".__('All')."</a>,
  66. <a href=\"#\" onclick=\"$sel_unread_link\">".__('Unread')."</a>,
  67. <a href=\"#\" onclick=\"$sel_inv_link\">".__('Invert')."</a>,
  68. <a href=\"#\" onclick=\"$sel_none_link\">".__('None')."</a></li>";
  69. $reply .= " ";
  70. $reply .= "<select dojoType=\"dijit.form.Select\"
  71. onchange=\"headlineActionsChange(this)\">";
  72. $reply .= "<option value=\"false\">".__('More...')."</option>";
  73. $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>";
  74. $reply .= "<option value=\"$tog_unread_link\">".__('Unread')."</option>
  75. <option value=\"$tog_marked_link\">".__('Starred')."</option>
  76. <option value=\"$tog_published_link\">".__('Published')."</option>";
  77. $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";
  78. $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";
  79. $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";
  80. if ($feed_id != "0") {
  81. $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";
  82. } else {
  83. $reply .= "<option value=\"$archive_sel_link\">".__('Move back')."</option>";
  84. $reply .= "<option value=\"$delete_sel_link\">".__('Delete')."</option>";
  85. }
  86. if (PluginHost::getInstance()->get_plugin("mail")) {
  87. $reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
  88. "</option>";
  89. }
  90. if (PluginHost::getInstance()->get_plugin("mailto")) {
  91. $reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email').
  92. "</option>";
  93. }
  94. $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
  95. //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
  96. $reply .= "<option value=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";
  97. $reply .= "</select>";
  98. //$reply .= "</h2";
  99. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) {
  100. echo $p->hook_headline_toolbar_button($feed_id, $is_cat);
  101. }
  102. $reply .= "</span></span>";
  103. return $reply;
  104. }
  105. private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
  106. $next_unread_feed, $offset, $vgr_last_feed = false,
  107. $override_order = false, $include_children = false) {
  108. if (isset($_REQUEST["DevForceUpdate"]))
  109. header("Content-Type: text/plain; charset=utf-8");
  110. $disable_cache = false;
  111. $reply = array();
  112. $rgba_cache = array();
  113. $timing_info = microtime(true);
  114. $topmost_article_ids = array();
  115. if (!$offset) $offset = 0;
  116. if ($method == "undefined") $method = "";
  117. $method_split = explode(":", $method);
  118. if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
  119. // Update the feed if required with some basic flood control
  120. $result = $this->dbh->query(
  121. "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
  122. FROM ttrss_feeds WHERE id = '$feed'");
  123. if ($this->dbh->num_rows($result) != 0) {
  124. $last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated"));
  125. $cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
  126. if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
  127. include "rssfuncs.php";
  128. update_rss_feed($feed, true, true);
  129. } else {
  130. $this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
  131. WHERE id = '$feed'");
  132. }
  133. }
  134. }
  135. if ($method_split[0] == "MarkAllReadGR") {
  136. catchup_feed($method_split[1], false);
  137. }
  138. // FIXME: might break tag display?
  139. if (is_numeric($feed) && $feed > 0 && !$cat_view) {
  140. $result = $this->dbh->query(
  141. "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
  142. if ($this->dbh->num_rows($result) == 0) {
  143. $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>";
  144. }
  145. }
  146. @$search = $this->dbh->escape_string($_REQUEST["query"]);
  147. if ($search) {
  148. $disable_cache = true;
  149. }
  150. @$search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]);
  151. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
  152. // error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
  153. if($search_mode == '' && $method != '' ){
  154. $search_mode = $method;
  155. }
  156. // error_log("search_mode: " . $search_mode);
  157. if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
  158. $handler = PluginHost::getInstance()->get_feed_handler(
  159. PluginHost::feed_to_pfeed_id($feed));
  160. // function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
  161. if ($handler) {
  162. $options = array(
  163. "limit" => $limit,
  164. "view_mode" => $view_mode,
  165. "cat_view" => $cat_view,
  166. "search" => $search,
  167. "search_mode" => $search_mode,
  168. "override_order" => $override_order,
  169. "offset" => $offset,
  170. "owner_uid" => $_SESSION["uid"],
  171. "filter" => false,
  172. "since_id" => 0,
  173. "include_children" => $include_children);
  174. $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed),
  175. $options);
  176. }
  177. } else {
  178. $qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
  179. $search, $search_mode, $override_order, $offset, 0,
  180. false, 0, $include_children);
  181. }
  182. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
  183. $result = $qfh_ret[0];
  184. $feed_title = $qfh_ret[1];
  185. $feed_site_url = $qfh_ret[2];
  186. $last_error = $qfh_ret[3];
  187. $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
  188. make_local_datetime($qfh_ret[4], false) : __("Never");
  189. $highlight_words = $qfh_ret[5];
  190. $vgroup_last_feed = $vgr_last_feed;
  191. $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
  192. $feed_title,
  193. $feed, $cat_view, $search, $search_mode, $view_mode,
  194. $last_error, $last_updated);
  195. $headlines_count = $this->dbh->num_rows($result);
  196. /* if (get_pref('COMBINED_DISPLAY_MODE')) {
  197. $button_plugins = array();
  198. foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
  199. $pclass = "button_" . trim($p);
  200. if (class_exists($pclass)) {
  201. $plugin = new $pclass();
  202. array_push($button_plugins, $plugin);
  203. }
  204. }
  205. } */
  206. if ($this->dbh->num_rows($result) > 0) {
  207. $lnum = $offset;
  208. $num_unread = 0;
  209. $cur_feed_title = '';
  210. $fresh_intl = get_pref("FRESH_ARTICLE_MAX_AGE") * 60 * 60;
  211. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
  212. $expand_cdm = get_pref('CDM_EXPANDED');
  213. while ($line = $this->dbh->fetch_assoc($result)) {
  214. $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
  215. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
  216. $line = $p->hook_query_headlines($line, 250, false);
  217. }
  218. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  219. $content_preview = $line["content_preview"];
  220. }
  221. $id = $line["id"];
  222. $feed_id = $line["feed_id"];
  223. $label_cache = $line["label_cache"];
  224. $labels = false;
  225. if ($label_cache) {
  226. $label_cache = json_decode($label_cache, true);
  227. if ($label_cache) {
  228. if ($label_cache["no-labels"] == 1)
  229. $labels = array();
  230. else
  231. $labels = $label_cache;
  232. }
  233. }
  234. if (!is_array($labels)) $labels = get_article_labels($id);
  235. $labels_str = "<span class=\"HLLCTR-$id\">";
  236. $labels_str .= format_article_labels($labels, $id);
  237. $labels_str .= "</span>";
  238. if (count($topmost_article_ids) < 3) {
  239. array_push($topmost_article_ids, $id);
  240. }
  241. $class = "";
  242. if (sql_bool_to_bool($line["unread"])) {
  243. $class .= " Unread";
  244. ++$num_unread;
  245. }
  246. if (sql_bool_to_bool($line["marked"])) {
  247. $marked_pic = "<img
  248. src=\"images/mark_set.png\"
  249. class=\"markedPic\" alt=\"Unstar article\"
  250. onclick='toggleMark($id)'>";
  251. $class .= " marked";
  252. } else {
  253. $marked_pic = "<img
  254. src=\"images/mark_unset.png\"
  255. class=\"markedPic\" alt=\"Star article\"
  256. onclick='toggleMark($id)'>";
  257. }
  258. if (sql_bool_to_bool($line["published"])) {
  259. $published_pic = "<img src=\"images/pub_set.png\"
  260. class=\"pubPic\"
  261. alt=\"Unpublish article\" onclick='togglePub($id)'>";
  262. $class .= " published";
  263. } else {
  264. $published_pic = "<img src=\"images/pub_unset.png\"
  265. class=\"pubPic\"
  266. alt=\"Publish article\" onclick='togglePub($id)'>";
  267. }
  268. # $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
  269. # $line["title"] . "</a>";
  270. # $content_link = "<a
  271. # href=\"" . htmlspecialchars($line["link"]) . "\"
  272. # onclick=\"view($id,$feed_id);\">" .
  273. # $line["title"] . "</a>";
  274. # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
  275. # $line["title"] . "</a>";
  276. $updated_fmt = make_local_datetime($line["updated"], false);
  277. $date_entered_fmt = T_sprintf("Imported at %s",
  278. make_local_datetime($line["date_entered"], false));
  279. $score = $line["score"];
  280. $score_pic = "images/" . get_score_pic($score);
  281. /* $score_title = __("(Click to change)");
  282. $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
  283. onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
  284. $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
  285. title=\"$score\">";
  286. if ($score > 500) {
  287. $hlc_suffix = "high";
  288. } else if ($score < -100) {
  289. $hlc_suffix = "low";
  290. } else {
  291. $hlc_suffix = "";
  292. }
  293. $entry_author = $line["author"];
  294. if ($entry_author) {
  295. $entry_author = " &mdash; $entry_author";
  296. }
  297. $has_feed_icon = feed_has_icon($feed_id);
  298. if ($has_feed_icon) {
  299. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  300. } else {
  301. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
  302. }
  303. $entry_site_url = $line["site_url"];
  304. //setting feed headline background color, needs to change text color based on dark/light
  305. $fav_color = $line['favicon_avg_color'];
  306. require_once "colors.php";
  307. if ($fav_color && $fav_color != 'fail') {
  308. if (!isset($rgba_cache[$feed_id])) {
  309. $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
  310. }
  311. }
  312. if (!get_pref('COMBINED_DISPLAY_MODE')) {
  313. if (get_pref('VFEED_GROUP_BY_FEED')) {
  314. if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
  315. $cur_feed_title = $line["feed_title"];
  316. $vgroup_last_feed = $feed_id;
  317. $cur_feed_title = htmlspecialchars($cur_feed_title);
  318. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  319. $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  320. "<div style='float : right'>$feed_icon_img</div>".
  321. "<a class='title' href=\"#\" onclick=\"viewfeed($feed_id)\">". $line["feed_title"]."</a>
  322. $vf_catchup_link</div>";
  323. }
  324. }
  325. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  326. onmouseout='postMouseOut($id)'";
  327. $reply['content'] .= "<div class='hl $class' orig-feed-id='$feed_id' id='RROW-$id' $mouseover_attrs>";
  328. $reply['content'] .= "<div class='hlLeft'>";
  329. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  330. type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
  331. class='rchk'>";
  332. $reply['content'] .= "$marked_pic";
  333. $reply['content'] .= "$published_pic";
  334. $reply['content'] .= "</div>";
  335. $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
  336. class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
  337. $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
  338. href=\"" . htmlspecialchars($line["link"]) . "\"
  339. onclick=\"\">" .
  340. truncate_string($line["title"], 200);
  341. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  342. $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
  343. }
  344. $reply['content'] .= "</a></span>";
  345. $reply['content'] .= $labels_str;
  346. $reply['content'] .= "</div>";
  347. if (!get_pref('VFEED_GROUP_BY_FEED')) {
  348. if (@$line["feed_title"]) {
  349. $rgba = @$rgba_cache[$feed_id];
  350. $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed($feed_id)\">".
  351. truncate_string($line["feed_title"],30)."</a></span>";
  352. }
  353. }
  354. $reply['content'] .= "<span class=\"hlUpdated\">";
  355. $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
  356. </span>";
  357. $reply['content'] .= "<div class=\"hlRight\">";
  358. $reply['content'] .= $score_pic;
  359. if ($line["feed_title"] && !get_pref('VFEED_GROUP_BY_FEED')) {
  360. $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"
  361. style=\"cursor : pointer\"
  362. title=\"".htmlspecialchars($line['feed_title'])."\">
  363. $feed_icon_img<span>";
  364. }
  365. $reply['content'] .= "</div>";
  366. $reply['content'] .= "</div>";
  367. } else {
  368. if ($line["tag_cache"])
  369. $tags = explode(",", $line["tag_cache"]);
  370. else
  371. $tags = false;
  372. $line["content"] = sanitize($line["content"],
  373. sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
  374. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
  375. $line = $p->hook_render_article_cdm($line);
  376. }
  377. if (get_pref('VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
  378. if ($feed_id != $vgroup_last_feed) {
  379. $cur_feed_title = $line["feed_title"];
  380. $vgroup_last_feed = $feed_id;
  381. $cur_feed_title = htmlspecialchars($cur_feed_title);
  382. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  383. $has_feed_icon = feed_has_icon($feed_id);
  384. if ($has_feed_icon) {
  385. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  386. } else {
  387. //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
  388. }
  389. $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  390. "<div style=\"float : right\">$feed_icon_img</div>".
  391. "<a href=\"#\" class='title' onclick=\"viewfeed($feed_id)\">".
  392. $line["feed_title"]."</a> $vf_catchup_link</div>";
  393. }
  394. }
  395. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  396. onmouseout='postMouseOut($id)'";
  397. $expanded_class = $expand_cdm ? "expanded" : "expandable";
  398. $reply['content'] .= "<div class=\"cdm $hlc_suffix $expanded_class $class\"
  399. id=\"RROW-$id\" orig-feed-id='$feed_id' $mouseover_attrs>";
  400. $reply['content'] .= "<div class=\"cdmHeader\" style=\"$row_background\">";
  401. $reply['content'] .= "<div style=\"vertical-align : middle\">";
  402. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  403. type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
  404. class='rchk'>";
  405. $reply['content'] .= "$marked_pic";
  406. $reply['content'] .= "$published_pic";
  407. $reply['content'] .= "</div>";
  408. if ($highlight_words && count($highlight_words > 0)) {
  409. foreach ($highlight_words as $word) {
  410. $line["title"] = preg_replace("/(\Q$word\E)/i",
  411. "<span class=\"highlight\">$1</span>", $line["title"]);
  412. }
  413. }
  414. $reply['content'] .= "<span id=\"RTITLE-$id\"
  415. onclick=\"return cdmClicked(event, $id);\"
  416. class=\"titleWrap $hlc_suffix\">
  417. <a class=\"title $hlc_suffix\"
  418. target=\"_blank\" href=\"".
  419. htmlspecialchars($line["link"])."\">".
  420. $line["title"] .
  421. "</a> <span class=\"author\">$entry_author</span>";
  422. $reply['content'] .= $labels_str;
  423. $reply['content'] .= "<span class='collapseBtn' style='display : none'>
  424. <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
  425. title=\"".__("Collapse article")."\"/></span>";
  426. if (!$expand_cdm)
  427. $content_hidden = "style=\"display : none\"";
  428. else
  429. $excerpt_hidden = "style=\"display : none\"";
  430. $reply['content'] .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
  431. $reply['content'] .= "</span>";
  432. if (!get_pref('VFEED_GROUP_BY_FEED')) {
  433. if (@$line["feed_title"]) {
  434. $rgba = @$rgba_cache[$feed_id];
  435. $reply['content'] .= "<div class=\"hlFeed\">
  436. <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
  437. onclick=\"viewfeed($feed_id)\">".
  438. truncate_string($line["feed_title"],30)."</a>
  439. </div>";
  440. }
  441. }
  442. $reply['content'] .= "<span class='updated' title='$date_entered_fmt'>
  443. $updated_fmt</span>";
  444. $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
  445. $reply['content'] .= "$score_pic";
  446. if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
  447. $reply['content'] .= "<span style=\"cursor : pointer\"
  448. title=\"".htmlspecialchars($line["feed_title"])."\"
  449. onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
  450. }
  451. $reply['content'] .= "</div>";
  452. $reply['content'] .= "</div>";
  453. $reply['content'] .= "<div class=\"cdmContent\" $content_hidden
  454. onclick=\"return cdmClicked(event, $id);\"
  455. id=\"CICD-$id\">";
  456. $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
  457. if ($line['note']) {
  458. $reply['content'] .= format_article_note($id, $line['note']);
  459. }
  460. $reply['content'] .= "</div>";
  461. if (!$line['lang']) $line['lang'] = 'en';
  462. $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
  463. if ($line["orig_feed_id"]) {
  464. $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
  465. WHERE id = ".$line["orig_feed_id"]);
  466. if ($this->dbh->num_rows($tmp_result) != 0) {
  467. $reply['content'] .= "<div clear='both'>";
  468. $reply['content'] .= __("Originally from:");
  469. $reply['content'] .= "&nbsp;";
  470. $tmp_line = $this->dbh->fetch_assoc($tmp_result);
  471. $reply['content'] .= "<a target='_blank'
  472. href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
  473. $tmp_line['title'] . "</a>";
  474. $reply['content'] .= "&nbsp;";
  475. $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
  476. $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
  477. $reply['content'] .= "</div>";
  478. }
  479. }
  480. $reply['content'] .= "<span id=\"CWRAP-$id\">";
  481. // if (!$expand_cdm) {
  482. $reply['content'] .= "<span id=\"CENCW-$id\" style=\"display : none\">";
  483. $reply['content'] .= htmlspecialchars($line["content"]);
  484. $reply['content'] .= "</span.";
  485. // } else {
  486. // $reply['content'] .= $line["content"];
  487. // }
  488. $reply['content'] .= "</span>";
  489. $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
  490. $reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
  491. $reply['content'] .= "</div>";
  492. $reply['content'] .= "<div class=\"cdmFooter\">";
  493. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
  494. $reply['content'] .= $p->hook_article_left_button($line);
  495. }
  496. $tags_str = format_tags_string($tags, $id);
  497. $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'>
  498. <span id=\"ATSTR-$id\">$tags_str</span>
  499. <a title=\"".__('Edit tags for this article')."\"
  500. href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
  501. $num_comments = $line["num_comments"];
  502. $entry_comments = "";
  503. if ($num_comments > 0) {
  504. if ($line["comments"]) {
  505. $comments_url = htmlspecialchars($line["comments"]);
  506. } else {
  507. $comments_url = htmlspecialchars($line["link"]);
  508. }
  509. $entry_comments = "<a class=\"postComments\"
  510. target='_blank' href=\"$comments_url\">$num_comments ".
  511. _ngettext("comment", "comments", $num_comments)."</a>";
  512. } else {
  513. if ($line["comments"] && $line["link"] != $line["comments"]) {
  514. $entry_comments = "<a class=\"postComments\" target='_blank' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
  515. }
  516. }
  517. if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";
  518. $reply['content'] .= "<div style=\"float : right\">";
  519. // $reply['content'] .= "$marked_pic";
  520. // $reply['content'] .= "$published_pic";
  521. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
  522. $reply['content'] .= $p->hook_article_button($line);
  523. }
  524. $reply['content'] .= "</div>";
  525. $reply['content'] .= "</div>";
  526. $reply['content'] .= "</div>";
  527. $reply['content'] .= "</div>";
  528. }
  529. ++$lnum;
  530. }
  531. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
  532. } else {
  533. $message = "";
  534. switch ($view_mode) {
  535. case "unread":
  536. $message = __("No unread articles found to display.");
  537. break;
  538. case "updated":
  539. $message = __("No updated articles found to display.");
  540. break;
  541. case "marked":
  542. $message = __("No starred articles found to display.");
  543. break;
  544. default:
  545. if ($feed < LABEL_BASE_INDEX) {
  546. $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
  547. } else {
  548. $message = __("No articles found to display.");
  549. }
  550. }
  551. if (!$offset && $message) {
  552. $reply['content'] .= "<div class='whiteBox'>$message";
  553. $reply['content'] .= "<p><span class=\"insensitive\">";
  554. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  555. WHERE owner_uid = " . $_SESSION['uid']);
  556. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  557. $last_updated = make_local_datetime($last_updated, false);
  558. $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  559. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  560. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  561. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  562. if ($num_errors > 0) {
  563. $reply['content'] .= "<br/>";
  564. $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  565. __('Some feeds have update errors (click for details)')."</a>";
  566. }
  567. $reply['content'] .= "</span></p></div>";
  568. }
  569. }
  570. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
  571. return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
  572. $vgroup_last_feed, $reply);
  573. }
  574. function catchupAll() {
  575. $this->dbh->query("UPDATE ttrss_user_entries SET
  576. last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
  577. ccache_zero_all($_SESSION["uid"]);
  578. }
  579. function view() {
  580. $timing_info = microtime(true);
  581. $reply = array();
  582. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
  583. $omode = $this->dbh->escape_string($_REQUEST["omode"]);
  584. $feed = $this->dbh->escape_string($_REQUEST["feed"]);
  585. $method = $this->dbh->escape_string($_REQUEST["m"]);
  586. $view_mode = $this->dbh->escape_string($_REQUEST["view_mode"]);
  587. $limit = 30;
  588. @$cat_view = $_REQUEST["cat"] == "true";
  589. @$next_unread_feed = $this->dbh->escape_string($_REQUEST["nuf"]);
  590. @$offset = $this->dbh->escape_string($_REQUEST["skip"]);
  591. @$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
  592. $order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
  593. if (is_numeric($feed)) $feed = (int) $feed;
  594. /* Feed -5 is a special case: it is used to display auxiliary information
  595. * when there's nothing to load - e.g. no stuff in fresh feed */
  596. if ($feed == -5) {
  597. print json_encode($this->generate_dashboard_feed());
  598. return;
  599. }
  600. $result = false;
  601. if ($feed < LABEL_BASE_INDEX) {
  602. $label_feed = feed_to_label_id($feed);
  603. $result = $this->dbh->query("SELECT id FROM ttrss_labels2 WHERE
  604. id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
  605. } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
  606. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  607. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  608. } else if ($cat_view && is_numeric($feed) && $feed > 0) {
  609. $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
  610. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  611. }
  612. if ($result && $this->dbh->num_rows($result) == 0) {
  613. print json_encode($this->generate_error_feed(__("Feed not found.")));
  614. return;
  615. }
  616. /* Updating a label ccache means recalculating all of the caches
  617. * so for performance reasons we don't do that here */
  618. if ($feed >= 0) {
  619. ccache_update($feed, $_SESSION["uid"], $cat_view);
  620. }
  621. set_pref("_DEFAULT_VIEW_MODE", $view_mode);
  622. set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
  623. /* bump login timestamp if needed */
  624. if (time() - $_SESSION["last_login_update"] > 3600) {
  625. $this->dbh->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
  626. $_SESSION["uid"]);
  627. $_SESSION["last_login_update"] = time();
  628. }
  629. if (!$cat_view && is_numeric($feed) && $feed > 0) {
  630. $this->dbh->query("UPDATE ttrss_feeds SET last_viewed = NOW()
  631. WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
  632. }
  633. $reply['headlines'] = array();
  634. if (!$next_unread_feed)
  635. $reply['headlines']['id'] = $feed;
  636. else
  637. $reply['headlines']['id'] = $next_unread_feed;
  638. $reply['headlines']['is_cat'] = (bool) $cat_view;
  639. $override_order = false;
  640. switch ($order_by) {
  641. case "title":
  642. $override_order = "ttrss_entries.title";
  643. break;
  644. case "date_reverse":
  645. $override_order = "score DESC, date_entered, updated";
  646. break;
  647. case "feed_dates":
  648. $override_order = "updated DESC";
  649. break;
  650. }
  651. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
  652. $ret = $this->format_headlines_list($feed, $method,
  653. $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
  654. $vgroup_last_feed, $override_order, true);
  655. //$topmost_article_ids = $ret[0];
  656. $headlines_count = $ret[1];
  657. $returned_feed = $ret[2];
  658. $disable_cache = $ret[3];
  659. $vgroup_last_feed = $ret[4];
  660. $reply['headlines']['content'] =& $ret[5]['content'];
  661. $reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
  662. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
  663. $reply['headlines-info'] = array("count" => (int) $headlines_count,
  664. "vgroup_last_feed" => $vgroup_last_feed,
  665. "disable_cache" => (bool) $disable_cache);
  666. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
  667. $reply['runtime-info'] = make_runtime_info();
  668. print json_encode($reply);
  669. }
  670. private function generate_dashboard_feed() {
  671. $reply = array();
  672. $reply['headlines']['id'] = -5;
  673. $reply['headlines']['is_cat'] = false;
  674. $reply['headlines']['toolbar'] = '';
  675. $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');
  676. $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
  677. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  678. WHERE owner_uid = " . $_SESSION['uid']);
  679. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  680. $last_updated = make_local_datetime($last_updated, false);
  681. $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  682. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  683. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  684. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  685. if ($num_errors > 0) {
  686. $reply['headlines']['content'] .= "<br/>";
  687. $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  688. __('Some feeds have update errors (click for details)')."</a>";
  689. }
  690. $reply['headlines']['content'] .= "</span></p>";
  691. $reply['headlines-info'] = array("count" => 0,
  692. "vgroup_last_feed" => '',
  693. "unread" => 0,
  694. "disable_cache" => true);
  695. return $reply;
  696. }
  697. private function generate_error_feed($error) {
  698. $reply = array();
  699. $reply['headlines']['id'] = -6;
  700. $reply['headlines']['is_cat'] = false;
  701. $reply['headlines']['toolbar'] = '';
  702. $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";
  703. $reply['headlines-info'] = array("count" => 0,
  704. "vgroup_last_feed" => '',
  705. "unread" => 0,
  706. "disable_cache" => true);
  707. return $reply;
  708. }
  709. function quickAddFeed() {
  710. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  711. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
  712. print "<div id='fadd_multiple_notify' style='display : none'>";
  713. print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
  714. print "<p></div>";
  715. print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
  716. print "<div class=\"dlgSecCont\">";
  717. print "<div style='float : right'>
  718. <img style='display : none'
  719. id='feed_add_spinner' src='images/indicator_white.gif'></div>";
  720. print "<input style=\"font-size : 16px; width : 20em;\"
  721. placeHolder=\"".__("Feed or site URL")."\"
  722. dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
  723. print "<hr/>";
  724. if (get_pref('ENABLE_FEED_CATS')) {
  725. print __('Place in category:') . " ";
  726. print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
  727. }
  728. print "</div>";
  729. print '<div id="feedDlg_feedsContainer" style="display : none">
  730. <div class="dlgSec">' . __('Available feeds') . '</div>
  731. <div class="dlgSecCont">'.
  732. '<select id="feedDlg_feedContainerSelect"
  733. dojoType="dijit.form.Select" size="3">
  734. <script type="dojo/method" event="onChange" args="value">
  735. dijit.byId("feedDlg_feedUrl").attr("value", value);
  736. </script>
  737. </select>'.
  738. '</div></div>';
  739. print "<div id='feedDlg_loginContainer' style='display : none'>
  740. <div class=\"dlgSec\">".__("Authentication")."</div>
  741. <div class=\"dlgSecCont\">".
  742. " <input dojoType=\"dijit.form.TextBox\" name='login'\"
  743. placeHolder=\"".__("Login")."\"
  744. style=\"width : 10em;\"> ".
  745. " <input
  746. placeHolder=\"".__("Password")."\"
  747. dojoType=\"dijit.form.TextBox\" type='password'
  748. style=\"width : 10em;\" name='pass'\">
  749. </div></div>";
  750. print "<div style=\"clear : both\">
  751. <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
  752. onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
  753. <label for=\"feedDlg_loginCheck\">".
  754. __('This feed requires authentication.')."</div>";
  755. print "</form>";
  756. print "<div class=\"dlgButtons\">
  757. <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
  758. if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
  759. print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
  760. }
  761. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
  762. </div>";
  763. //return;
  764. }
  765. function feedBrowser() {
  766. if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
  767. $browser_search = $this->dbh->escape_string($_REQUEST["search"]);
  768. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  769. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
  770. print "<div dojoType=\"dijit.Toolbar\">
  771. <div style='float : right'>
  772. <img style='display : none'
  773. id='feed_browser_spinner' src='images/indicator_white.gif'>
  774. <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
  775. onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
  776. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
  777. </div>";
  778. print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
  779. <option value='1'>" . __('Popular feeds') . "</option>
  780. <option value='2'>" . __('Feed archive') . "</option>
  781. </select> ";
  782. print __("limit:");
  783. print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
  784. foreach (array(25, 50, 100, 200) as $l) {
  785. $issel = ($l == $limit) ? "selected=\"1\"" : "";
  786. print "<option $issel value=\"$l\">$l</option>";
  787. }
  788. print "</select> ";
  789. print "</div>";
  790. $owner_uid = $_SESSION["uid"];
  791. require_once "feedbrowser.php";
  792. print "<ul class='browseFeedList' id='browseFeedList'>";
  793. print make_feed_browser($search, 25);
  794. print "</ul>";
  795. print "<div align='center'>
  796. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
  797. <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
  798. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
  799. }
  800. function search() {
  801. $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2);
  802. $active_feed_id = sprintf("%d", $this->params[0]);
  803. $is_cat = $this->params[1] != "false";
  804. print "<div class=\"dlgSec\">".__('Look for')."</div>";
  805. print "<div class=\"dlgSecCont\">";
  806. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  807. style=\"font-size : 16px; width : 20em;\"
  808. required=\"1\" name=\"query\" type=\"search\" value=''>";
  809. print "<hr/>".__('Limit search to:')." ";
  810. print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">
  811. <option value=\"all_feeds\">".__('All feeds')."</option>";
  812. $feed_title = getFeedTitle($active_feed_id);
  813. if (!$is_cat) {
  814. $feed_cat_title = getFeedCatTitle($active_feed_id);
  815. } else {
  816. $feed_cat_title = getCategoryTitle($active_feed_id);
  817. }
  818. if ($active_feed_id && !$is_cat) {
  819. print "<option selected=\"1\" value=\"this_feed\">$feed_title</option>";
  820. } else {
  821. print "<option disabled=\"1\" value=\"false\">".__('This feed')."</option>";
  822. }
  823. if ($is_cat) {
  824. $cat_preselected = "selected=\"1\"";
  825. }
  826. if (get_pref('ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
  827. print "<option $cat_preselected value=\"this_cat\">$feed_cat_title</option>";
  828. } else {
  829. //print "<option disabled>".__('This category')."</option>";
  830. }
  831. print "</select>";
  832. print "</div>";
  833. print "<div class=\"dlgButtons\">";
  834. if (!SPHINX_ENABLED) {
  835. print "<div style=\"float : left\">
  836. <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a>
  837. </div>";
  838. }
  839. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
  840. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
  841. </div>";
  842. }
  843. }
  844. ?>