feeds.php 40 KB

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