feeds.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  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. $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";
  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, $check_first_id = 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. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
  145. if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
  146. $handler = PluginHost::getInstance()->get_feed_handler(
  147. PluginHost::feed_to_pfeed_id($feed));
  148. if ($handler) {
  149. $options = array(
  150. "limit" => $limit,
  151. "view_mode" => $view_mode,
  152. "cat_view" => $cat_view,
  153. "search" => $search,
  154. "override_order" => $override_order,
  155. "offset" => $offset,
  156. "owner_uid" => $_SESSION["uid"],
  157. "filter" => false,
  158. "since_id" => 0,
  159. "include_children" => $include_children);
  160. $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed),
  161. $options);
  162. }
  163. } else {
  164. /*$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
  165. $search, false, $override_order, $offset, 0,
  166. false, 0, $include_children, $topid);*/
  167. //function queryFeedHeadlines($feed, $limit,
  168. // $view_mode, $cat_view, $search, $search_mode,
  169. // $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false,
  170. // $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
  171. $params = array(
  172. "feed" => $feed,
  173. "limit" => $limit,
  174. "view_mode" => $view_mode,
  175. "cat_view" => $cat_view,
  176. "search" => $search,
  177. "override_order" => $override_order,
  178. "offset" => $offset,
  179. "include_children" => $include_children,
  180. "check_first_id" => $check_first_id
  181. );
  182. $qfh_ret = queryFeedHeadlines($params);
  183. }
  184. $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && $feed != -6;
  185. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
  186. $result = $qfh_ret[0];
  187. $feed_title = $qfh_ret[1];
  188. $feed_site_url = $qfh_ret[2];
  189. $last_error = $qfh_ret[3];
  190. $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
  191. make_local_datetime($qfh_ret[4], false) : __("Never");
  192. $highlight_words = $qfh_ret[5];
  193. $reply['first_id'] = $qfh_ret[6];
  194. $vgroup_last_feed = $vgr_last_feed;
  195. $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
  196. $feed_title,
  197. $feed, $cat_view, $search, $view_mode,
  198. $last_error, $last_updated);
  199. $headlines_count = $this->dbh->num_rows($result);
  200. /* if (get_pref('COMBINED_DISPLAY_MODE')) {
  201. $button_plugins = array();
  202. foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
  203. $pclass = "button_" . trim($p);
  204. if (class_exists($pclass)) {
  205. $plugin = new $pclass();
  206. array_push($button_plugins, $plugin);
  207. }
  208. }
  209. } */
  210. if ($offset == 0) {
  211. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) {
  212. $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret);
  213. }
  214. }
  215. $reply['content'] = '';
  216. if (!is_numeric($result) && $this->dbh->num_rows($result) > 0) {
  217. $lnum = $offset;
  218. $num_unread = 0;
  219. $cur_feed_title = '';
  220. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
  221. $expand_cdm = get_pref('CDM_EXPANDED');
  222. while ($line = $this->dbh->fetch_assoc($result)) {
  223. $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content"]), 250);
  224. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
  225. $line = $p->hook_query_headlines($line, 250, false);
  226. }
  227. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  228. $content_preview = $line["content_preview"];
  229. }
  230. $id = $line["id"];
  231. $feed_id = $line["feed_id"];
  232. $label_cache = $line["label_cache"];
  233. $labels = false;
  234. if ($label_cache) {
  235. $label_cache = json_decode($label_cache, true);
  236. if ($label_cache) {
  237. if ($label_cache["no-labels"] == 1)
  238. $labels = array();
  239. else
  240. $labels = $label_cache;
  241. }
  242. }
  243. if (!is_array($labels)) $labels = get_article_labels($id);
  244. $labels_str = "<span class=\"HLLCTR-$id\">";
  245. $labels_str .= format_article_labels($labels, $id);
  246. $labels_str .= "</span>";
  247. if (count($topmost_article_ids) < 3) {
  248. array_push($topmost_article_ids, $id);
  249. }
  250. $class = "";
  251. if (sql_bool_to_bool($line["unread"])) {
  252. $class .= " Unread";
  253. ++$num_unread;
  254. }
  255. if (sql_bool_to_bool($line["marked"])) {
  256. $marked_pic = "<img
  257. src=\"images/mark_set.png\"
  258. class=\"markedPic\" alt=\"Unstar article\"
  259. onclick='toggleMark($id)'>";
  260. $class .= " marked";
  261. } else {
  262. $marked_pic = "<img
  263. src=\"images/mark_unset.png\"
  264. class=\"markedPic\" alt=\"Star article\"
  265. onclick='toggleMark($id)'>";
  266. }
  267. if (sql_bool_to_bool($line["published"])) {
  268. $published_pic = "<img src=\"images/pub_set.png\"
  269. class=\"pubPic\"
  270. alt=\"Unpublish article\" onclick='togglePub($id)'>";
  271. $class .= " published";
  272. } else {
  273. $published_pic = "<img src=\"images/pub_unset.png\"
  274. class=\"pubPic\"
  275. alt=\"Publish article\" onclick='togglePub($id)'>";
  276. }
  277. # $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
  278. # $line["title"] . "</a>";
  279. # $content_link = "<a
  280. # href=\"" . htmlspecialchars($line["link"]) . "\"
  281. # onclick=\"view($id,$feed_id);\">" .
  282. # $line["title"] . "</a>";
  283. # $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
  284. # $line["title"] . "</a>";
  285. $updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
  286. $date_entered_fmt = T_sprintf("Imported at %s",
  287. make_local_datetime($line["date_entered"], false));
  288. $score = $line["score"];
  289. $score_pic = "images/" . get_score_pic($score);
  290. /* $score_title = __("(Click to change)");
  291. $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
  292. onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
  293. $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"
  294. title=\"$score\">";
  295. if ($score > 500) {
  296. $hlc_suffix = "high";
  297. } else if ($score < -100) {
  298. $hlc_suffix = "low";
  299. } else {
  300. $hlc_suffix = "";
  301. }
  302. $entry_author = $line["author"];
  303. if ($entry_author) {
  304. $entry_author = " &mdash; $entry_author";
  305. }
  306. $has_feed_icon = feed_has_icon($feed_id);
  307. if ($has_feed_icon) {
  308. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  309. } else {
  310. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
  311. }
  312. $entry_site_url = $line["site_url"];
  313. //setting feed headline background color, needs to change text color based on dark/light
  314. $fav_color = $line['favicon_avg_color'];
  315. require_once "colors.php";
  316. if ($fav_color && $fav_color != 'fail') {
  317. if (!isset($rgba_cache[$feed_id])) {
  318. $rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
  319. }
  320. }
  321. if (!get_pref('COMBINED_DISPLAY_MODE')) {
  322. if ($vfeed_group_enabled) {
  323. if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
  324. $cur_feed_title = $line["feed_title"];
  325. $vgroup_last_feed = $feed_id;
  326. $cur_feed_title = htmlspecialchars($cur_feed_title);
  327. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  328. $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  329. "<div style='float : right'>$feed_icon_img</div>".
  330. "<a class='title' href=\"#\" onclick=\"viewfeed($feed_id)\">".
  331. $line["feed_title"]."</a>
  332. $vf_catchup_link</div>";
  333. }
  334. }
  335. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  336. onmouseout='postMouseOut($id)'";
  337. $reply['content'] .= "<div class='hl $class' orig-feed-id='$feed_id' id='RROW-$id' $mouseover_attrs>";
  338. $reply['content'] .= "<div class='hlLeft'>";
  339. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  340. type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
  341. class='rchk'>";
  342. $reply['content'] .= "$marked_pic";
  343. $reply['content'] .= "$published_pic";
  344. $reply['content'] .= "</div>";
  345. $reply['content'] .= "<div onclick='return hlClicked(event, $id)'
  346. class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
  347. $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
  348. href=\"" . htmlspecialchars($line["link"]) . "\"
  349. onclick=\"\">" .
  350. truncate_string($line["title"], 200);
  351. if (get_pref('SHOW_CONTENT_PREVIEW')) {
  352. $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
  353. }
  354. $reply['content'] .= "</a></span>";
  355. $reply['content'] .= $labels_str;
  356. $reply['content'] .= "</div>";
  357. if (!$vfeed_group_enabled) {
  358. if (@$line["feed_title"]) {
  359. $rgba = @$rgba_cache[$feed_id];
  360. $reply['content'] .= "<span class=\"hlFeed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed($feed_id)\">".
  361. truncate_string($line["feed_title"],30)."</a></span>";
  362. }
  363. }
  364. $reply['content'] .= "<span class=\"hlUpdated\">";
  365. $reply['content'] .= "<div title='$date_entered_fmt'>$updated_fmt</div>
  366. </span>";
  367. $reply['content'] .= "<div class=\"hlRight\">";
  368. $reply['content'] .= $score_pic;
  369. if ($line["feed_title"] && !$vfeed_group_enabled) {
  370. $reply['content'] .= "<span onclick=\"viewfeed($feed_id)\"
  371. style=\"cursor : pointer\"
  372. title=\"".htmlspecialchars($line['feed_title'])."\">
  373. $feed_icon_img</span>";
  374. }
  375. $reply['content'] .= "</div>";
  376. $reply['content'] .= "</div>";
  377. } else {
  378. if ($line["tag_cache"])
  379. $tags = explode(",", $line["tag_cache"]);
  380. else
  381. $tags = false;
  382. $line["content"] = sanitize($line["content"],
  383. sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
  384. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
  385. $line = $p->hook_render_article_cdm($line);
  386. }
  387. if ($vfeed_group_enabled && $line["feed_title"]) {
  388. if ($feed_id != $vgroup_last_feed) {
  389. $cur_feed_title = $line["feed_title"];
  390. $vgroup_last_feed = $feed_id;
  391. $cur_feed_title = htmlspecialchars($cur_feed_title);
  392. $vf_catchup_link = "<a class='catchup' onclick='catchupFeedInGroup($feed_id);' href='#'>".__('mark feed as read')."</a>";
  393. $has_feed_icon = feed_has_icon($feed_id);
  394. if ($has_feed_icon) {
  395. $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
  396. } else {
  397. //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
  398. }
  399. $reply['content'] .= "<div id='FTITLE-$feed_id' class='cdmFeedTitle'>".
  400. "<div style=\"float : right\">$feed_icon_img</div>".
  401. "<a href=\"#\" class='title' onclick=\"viewfeed($feed_id)\">".
  402. $line["feed_title"]."</a> $vf_catchup_link</div>";
  403. }
  404. }
  405. $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
  406. onmouseout='postMouseOut($id)'";
  407. $expanded_class = $expand_cdm ? "expanded" : "expandable";
  408. $reply['content'] .= "<div class=\"cdm $hlc_suffix $expanded_class $class\"
  409. id=\"RROW-$id\" orig-feed-id='$feed_id' $mouseover_attrs>";
  410. $reply['content'] .= "<div class=\"cdmHeader\">";
  411. $reply['content'] .= "<div style=\"vertical-align : middle\">";
  412. $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
  413. type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
  414. class='rchk'>";
  415. $reply['content'] .= "$marked_pic";
  416. $reply['content'] .= "$published_pic";
  417. $reply['content'] .= "</div>";
  418. if ($highlight_words && count($highlight_words > 0)) {
  419. foreach ($highlight_words as $word) {
  420. $line["title"] = preg_replace("/(\Q$word\E)/i",
  421. "<span class=\"highlight\">$1</span>", $line["title"]);
  422. }
  423. }
  424. $reply['content'] .= "<span id=\"RTITLE-$id\"
  425. onclick=\"return cdmClicked(event, $id);\"
  426. class=\"titleWrap $hlc_suffix\">
  427. <a class=\"title $hlc_suffix\"
  428. title=\"".htmlspecialchars($line["title"])."\"
  429. target=\"_blank\" href=\"".
  430. htmlspecialchars($line["link"])."\">".
  431. $line["title"] .
  432. "</a> <span class=\"author\">$entry_author</span>";
  433. $reply['content'] .= $labels_str;
  434. $reply['content'] .= "<span class='collapseBtn' style='display : none'>
  435. <img src=\"images/collapse.png\" onclick=\"cdmCollapseArticle(event, $id)\"
  436. title=\"".__("Collapse article")."\"/></span>";
  437. if (!$expand_cdm)
  438. $content_hidden = "style=\"display : none\"";
  439. else
  440. $excerpt_hidden = "style=\"display : none\"";
  441. $reply['content'] .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $content_preview . "</span>";
  442. $reply['content'] .= "</span>";
  443. if (!$vfeed_group_enabled) {
  444. if (@$line["feed_title"]) {
  445. $rgba = @$rgba_cache[$feed_id];
  446. $reply['content'] .= "<div class=\"hlFeed\">
  447. <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
  448. onclick=\"viewfeed($feed_id)\">".
  449. truncate_string($line["feed_title"],30)."</a>
  450. </div>";
  451. }
  452. }
  453. $reply['content'] .= "<span class='updated' title='$date_entered_fmt'>
  454. $updated_fmt</span>";
  455. $reply['content'] .= "<div class='scoreWrap' style=\"vertical-align : middle\">";
  456. $reply['content'] .= "$score_pic";
  457. if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
  458. $reply['content'] .= "<span style=\"cursor : pointer\"
  459. title=\"".htmlspecialchars($line["feed_title"])."\"
  460. onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
  461. }
  462. $reply['content'] .= "</div>";
  463. $reply['content'] .= "</div>";
  464. $reply['content'] .= "<div class=\"cdmContent\" $content_hidden
  465. onclick=\"return cdmClicked(event, $id);\"
  466. id=\"CICD-$id\">";
  467. $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
  468. if ($line['note']) {
  469. $reply['content'] .= format_article_note($id, $line['note']);
  470. }
  471. $reply['content'] .= "</div>";
  472. if (!$line['lang']) $line['lang'] = 'en';
  473. $reply['content'] .= "<div class=\"cdmContentInner\" lang=\"".$line['lang']."\">";
  474. if ($line["orig_feed_id"]) {
  475. $tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
  476. WHERE id = ".$line["orig_feed_id"]);
  477. if ($this->dbh->num_rows($tmp_result) != 0) {
  478. $reply['content'] .= "<div clear='both'>";
  479. $reply['content'] .= __("Originally from:");
  480. $reply['content'] .= "&nbsp;";
  481. $tmp_line = $this->dbh->fetch_assoc($tmp_result);
  482. $reply['content'] .= "<a target='_blank'
  483. href=' " . htmlspecialchars($tmp_line['site_url']) . "'>" .
  484. $tmp_line['title'] . "</a>";
  485. $reply['content'] .= "&nbsp;";
  486. $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
  487. $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
  488. $reply['content'] .= "</div>";
  489. }
  490. }
  491. $reply['content'] .= "<span id=\"CWRAP-$id\">";
  492. // if (!$expand_cdm) {
  493. $reply['content'] .= "<span id=\"CENCW-$id\" style=\"display : none\">";
  494. $reply['content'] .= htmlspecialchars($line["content"]);
  495. $reply['content'] .= "</span.";
  496. // } else {
  497. // $reply['content'] .= $line["content"];
  498. // }
  499. $reply['content'] .= "</span>";
  500. $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
  501. $reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
  502. $reply['content'] .= "</div>";
  503. $reply['content'] .= "<div class=\"cdmFooter\" onclick=\"cdmFooterClick(event)\">";
  504. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
  505. $reply['content'] .= $p->hook_article_left_button($line);
  506. }
  507. $tags_str = format_tags_string($tags, $id);
  508. $reply['content'] .= "<img src='images/tag.png' alt='Tags' title='Tags'>
  509. <span id=\"ATSTR-$id\">$tags_str</span>
  510. <a title=\"".__('Edit tags for this article')."\"
  511. href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
  512. $num_comments = $line["num_comments"];
  513. $entry_comments = "";
  514. if ($num_comments > 0) {
  515. if ($line["comments"]) {
  516. $comments_url = htmlspecialchars($line["comments"]);
  517. } else {
  518. $comments_url = htmlspecialchars($line["link"]);
  519. }
  520. $entry_comments = "<a class=\"postComments\"
  521. target='_blank' href=\"$comments_url\">$num_comments ".
  522. _ngettext("comment", "comments", $num_comments)."</a>";
  523. } else {
  524. if ($line["comments"] && $line["link"] != $line["comments"]) {
  525. $entry_comments = "<a class=\"postComments\" target='_blank' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
  526. }
  527. }
  528. if ($entry_comments) $reply['content'] .= "&nbsp;($entry_comments)";
  529. $reply['content'] .= "<div style=\"float : right\">";
  530. // $reply['content'] .= "$marked_pic";
  531. // $reply['content'] .= "$published_pic";
  532. foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
  533. $reply['content'] .= $p->hook_article_button($line);
  534. }
  535. $reply['content'] .= "</div>";
  536. $reply['content'] .= "</div>";
  537. $reply['content'] .= "</div>";
  538. $reply['content'] .= "</div>";
  539. }
  540. ++$lnum;
  541. }
  542. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
  543. } else if (!is_numeric($result)) {
  544. $message = "";
  545. switch ($view_mode) {
  546. case "unread":
  547. $message = __("No unread articles found to display.");
  548. break;
  549. case "updated":
  550. $message = __("No updated articles found to display.");
  551. break;
  552. case "marked":
  553. $message = __("No starred articles found to display.");
  554. break;
  555. default:
  556. if ($feed < LABEL_BASE_INDEX) {
  557. $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.");
  558. } else {
  559. $message = __("No articles found to display.");
  560. }
  561. }
  562. if (!$offset && $message) {
  563. $reply['content'] = "<div class='whiteBox'>$message";
  564. $reply['content'] .= "<p><span class=\"insensitive\">";
  565. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  566. WHERE owner_uid = " . $_SESSION['uid']);
  567. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  568. $last_updated = make_local_datetime($last_updated, false);
  569. $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  570. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  571. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  572. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  573. if ($num_errors > 0) {
  574. $reply['content'] .= "<br/>";
  575. $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  576. __('Some feeds have update errors (click for details)')."</a>";
  577. }
  578. $reply['content'] .= "</span></p></div>";
  579. }
  580. } else if (is_numeric($result) && $result == -1) {
  581. $reply['first_id_changed'] = true;
  582. }
  583. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
  584. return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
  585. $vgroup_last_feed, $reply);
  586. }
  587. function catchupAll() {
  588. $this->dbh->query("UPDATE ttrss_user_entries SET
  589. last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
  590. ccache_zero_all($_SESSION["uid"]);
  591. }
  592. function view() {
  593. $timing_info = microtime(true);
  594. $reply = array();
  595. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
  596. $feed = $this->dbh->escape_string($_REQUEST["feed"]);
  597. $method = $this->dbh->escape_string($_REQUEST["m"]);
  598. $view_mode = $this->dbh->escape_string($_REQUEST["view_mode"]);
  599. $limit = 30;
  600. @$cat_view = $_REQUEST["cat"] == "true";
  601. @$next_unread_feed = $this->dbh->escape_string($_REQUEST["nuf"]);
  602. @$offset = $this->dbh->escape_string($_REQUEST["skip"]);
  603. @$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
  604. $order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
  605. $check_first_id = $this->dbh->escape_string($_REQUEST["fid"]);
  606. if (is_numeric($feed)) $feed = (int) $feed;
  607. /* Feed -5 is a special case: it is used to display auxiliary information
  608. * when there's nothing to load - e.g. no stuff in fresh feed */
  609. if ($feed == -5) {
  610. print json_encode($this->generate_dashboard_feed());
  611. return;
  612. }
  613. $result = false;
  614. if ($feed < LABEL_BASE_INDEX) {
  615. $label_feed = feed_to_label_id($feed);
  616. $result = $this->dbh->query("SELECT id FROM ttrss_labels2 WHERE
  617. id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
  618. } else if (!$cat_view && is_numeric($feed) && $feed > 0) {
  619. $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
  620. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  621. } else if ($cat_view && is_numeric($feed) && $feed > 0) {
  622. $result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
  623. id = '$feed' AND owner_uid = " . $_SESSION['uid']);
  624. }
  625. if ($result && $this->dbh->num_rows($result) == 0) {
  626. print json_encode($this->generate_error_feed(__("Feed not found.")));
  627. return;
  628. }
  629. /* Updating a label ccache means recalculating all of the caches
  630. * so for performance reasons we don't do that here */
  631. if ($feed >= 0) {
  632. ccache_update($feed, $_SESSION["uid"], $cat_view);
  633. }
  634. set_pref("_DEFAULT_VIEW_MODE", $view_mode);
  635. set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
  636. /* bump login timestamp if needed */
  637. if (time() - $_SESSION["last_login_update"] > 3600) {
  638. $this->dbh->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
  639. $_SESSION["uid"]);
  640. $_SESSION["last_login_update"] = time();
  641. }
  642. if (!$cat_view && is_numeric($feed) && $feed > 0) {
  643. $this->dbh->query("UPDATE ttrss_feeds SET last_viewed = NOW()
  644. WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
  645. }
  646. $reply['headlines'] = array();
  647. $override_order = false;
  648. switch ($order_by) {
  649. case "title":
  650. $override_order = "ttrss_entries.title";
  651. break;
  652. case "date_reverse":
  653. $override_order = "score DESC, date_entered, updated";
  654. break;
  655. case "feed_dates":
  656. $override_order = "updated DESC";
  657. break;
  658. }
  659. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
  660. $ret = $this->format_headlines_list($feed, $method,
  661. $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
  662. $vgroup_last_feed, $override_order, true, $check_first_id);
  663. //$topmost_article_ids = $ret[0];
  664. $headlines_count = $ret[1];
  665. /* $returned_feed = $ret[2]; */
  666. $disable_cache = $ret[3];
  667. $vgroup_last_feed = $ret[4];
  668. //$reply['headlines']['content'] =& $ret[5]['content'];
  669. //$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
  670. $reply['headlines'] =& $ret[5];
  671. if (!$next_unread_feed)
  672. $reply['headlines']['id'] = $feed;
  673. else
  674. $reply['headlines']['id'] = $next_unread_feed;
  675. $reply['headlines']['is_cat'] = (bool) $cat_view;
  676. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
  677. $reply['headlines-info'] = array("count" => (int) $headlines_count,
  678. "vgroup_last_feed" => $vgroup_last_feed,
  679. "disable_cache" => (bool) $disable_cache);
  680. if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
  681. $reply['runtime-info'] = make_runtime_info();
  682. print json_encode($reply);
  683. }
  684. private function generate_dashboard_feed() {
  685. $reply = array();
  686. $reply['headlines']['id'] = -5;
  687. $reply['headlines']['is_cat'] = false;
  688. $reply['headlines']['toolbar'] = '';
  689. $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.');
  690. $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
  691. $result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
  692. WHERE owner_uid = " . $_SESSION['uid']);
  693. $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
  694. $last_updated = make_local_datetime($last_updated, false);
  695. $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
  696. $result = $this->dbh->query("SELECT COUNT(id) AS num_errors
  697. FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
  698. $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
  699. if ($num_errors > 0) {
  700. $reply['headlines']['content'] .= "<br/>";
  701. $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">".
  702. __('Some feeds have update errors (click for details)')."</a>";
  703. }
  704. $reply['headlines']['content'] .= "</span></p>";
  705. $reply['headlines-info'] = array("count" => 0,
  706. "vgroup_last_feed" => '',
  707. "unread" => 0,
  708. "disable_cache" => true);
  709. return $reply;
  710. }
  711. private function generate_error_feed($error) {
  712. $reply = array();
  713. $reply['headlines']['id'] = -7;
  714. $reply['headlines']['is_cat'] = false;
  715. $reply['headlines']['toolbar'] = '';
  716. $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>";
  717. $reply['headlines-info'] = array("count" => 0,
  718. "vgroup_last_feed" => '',
  719. "unread" => 0,
  720. "disable_cache" => true);
  721. return $reply;
  722. }
  723. function quickAddFeed() {
  724. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  725. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
  726. print "<div id='fadd_multiple_notify' style='display : none'>";
  727. print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
  728. print "<p></div>";
  729. print "<div class=\"dlgSec\">".__("Feed or site URL")."</div>";
  730. print "<div class=\"dlgSecCont\">";
  731. print "<div style='float : right'>
  732. <img style='display : none'
  733. id='feed_add_spinner' src='images/indicator_white.gif'></div>";
  734. print "<input style=\"font-size : 16px; width : 20em;\"
  735. placeHolder=\"".__("Feed or site URL")."\"
  736. dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
  737. print "<hr/>";
  738. if (get_pref('ENABLE_FEED_CATS')) {
  739. print __('Place in category:') . " ";
  740. print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
  741. }
  742. print "</div>";
  743. print '<div id="feedDlg_feedsContainer" style="display : none">
  744. <div class="dlgSec">' . __('Available feeds') . '</div>
  745. <div class="dlgSecCont">'.
  746. '<select id="feedDlg_feedContainerSelect"
  747. dojoType="dijit.form.Select" size="3">
  748. <script type="dojo/method" event="onChange" args="value">
  749. dijit.byId("feedDlg_feedUrl").attr("value", value);
  750. </script>
  751. </select>'.
  752. '</div></div>';
  753. print "<div id='feedDlg_loginContainer' style='display : none'>
  754. <div class=\"dlgSec\">".__("Authentication")."</div>
  755. <div class=\"dlgSecCont\">".
  756. " <input dojoType=\"dijit.form.TextBox\" name='login'\"
  757. placeHolder=\"".__("Login")."\"
  758. style=\"width : 10em;\"> ".
  759. " <input
  760. placeHolder=\"".__("Password")."\"
  761. dojoType=\"dijit.form.TextBox\" type='password'
  762. style=\"width : 10em;\" name='pass'\">
  763. </div></div>";
  764. print "<div style=\"clear : both\">
  765. <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
  766. onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
  767. <label for=\"feedDlg_loginCheck\">".
  768. __('This feed requires authentication.')."</div>";
  769. print "</form>";
  770. print "<div class=\"dlgButtons\">
  771. <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>";
  772. if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
  773. print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">".__('More feeds')."</button>";
  774. }
  775. print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>
  776. </div>";
  777. //return;
  778. }
  779. function feedBrowser() {
  780. if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
  781. $browser_search = $this->dbh->escape_string($_REQUEST["search"]);
  782. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
  783. print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"updateFeedBrowser\">";
  784. print "<div dojoType=\"dijit.Toolbar\">
  785. <div style='float : right'>
  786. <img style='display : none'
  787. id='feed_browser_spinner' src='images/indicator_white.gif'>
  788. <input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"
  789. onchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"$browser_search\">
  790. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">".__('Search')."</button>
  791. </div>";
  792. print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">
  793. <option value='1'>" . __('Popular feeds') . "</option>
  794. <option value='2'>" . __('Feed archive') . "</option>
  795. </select> ";
  796. print __("limit:");
  797. print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
  798. foreach (array(25, 50, 100, 200) as $l) {
  799. //$issel = ($l == $limit) ? "selected=\"1\"" : "";
  800. print "<option value=\"$l\">$l</option>";
  801. }
  802. print "</select> ";
  803. print "</div>";
  804. require_once "feedbrowser.php";
  805. print "<ul class='browseFeedList' id='browseFeedList'>";
  806. print make_feed_browser("", 25);
  807. print "</ul>";
  808. print "<div align='center'>
  809. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">".__('Subscribe')."</button>
  810. <button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">".__('Remove')."</button>
  811. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >".__('Cancel')."</button></div>";
  812. }
  813. function search() {
  814. $this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2);
  815. $active_feed_id = sprintf("%d", $this->params[0]);
  816. $is_cat = $this->params[1] != "false";
  817. print "<div class=\"dlgSec\">".__('Look for')."</div>";
  818. print "<div class=\"dlgSecCont\">";
  819. print "<input dojoType=\"dijit.form.ValidationTextBox\"
  820. style=\"font-size : 16px; width : 20em;\"
  821. required=\"1\" name=\"query\" type=\"search\" value=''>";
  822. print "<hr/><span style='float : right'>".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat))."</span>";
  823. print "</div>";
  824. print "<div class=\"dlgButtons\">";
  825. if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) {
  826. print "<div style=\"float : left\">
  827. <a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/wiki/SearchSyntax\">".__("Search syntax")."</a>
  828. </div>";
  829. }
  830. print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button>
  831. <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>
  832. </div>";
  833. }
  834. function update_debugger() {
  835. header("Content-type: text/html");
  836. $feed_id = (int)$_REQUEST["feed_id"];
  837. @$do_update = $_REQUEST["action"] == "do_update";
  838. $csrf_token = $_REQUEST["csrf_token"];
  839. $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : "";
  840. $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : "";
  841. ?>
  842. <html>
  843. <head>
  844. <link rel="stylesheet" type="text/css" href="css/utility.css">
  845. <title>Feed Debugger</title>
  846. </head>
  847. <body class="small_margins">
  848. <h1>Feed Debugger: <?php echo "$feed_id: " . getFeedTitle($feed_id) ?></h1>
  849. <form method="GET" action="">
  850. <input type="hidden" name="op" value="feeds">
  851. <input type="hidden" name="method" value="update_debugger">
  852. <input type="hidden" name="xdebug" value="1">
  853. <input type="hidden" name="csrf_token" value="<?php echo $csrf_token ?>">
  854. <input type="hidden" name="action" value="do_update">
  855. <input type="hidden" name="feed_id" value="<?php echo $feed_id ?>">
  856. <input type="checkbox" name="force_refetch" value="1" <?php echo $refetch_checked ?>> Force refetch<br/>
  857. <input type="checkbox" name="force_rehash" value="1" <?php echo $rehash_checked ?>> Force rehash<br/>
  858. <p/><button type="submit">Continue</button>
  859. </form>
  860. <hr>
  861. <pre><?php
  862. if ($do_update) {
  863. include "rssfuncs.php";
  864. update_rss_feed($feed_id, true, true);
  865. }
  866. ?></pre>
  867. </body>
  868. </html>
  869. <?php
  870. }
  871. }
  872. ?>