feeds.php 39 KB

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