feeds.php 39 KB

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