feeds.php 39 KB

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