feeds.php 39 KB

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