diff --git a/.gitignore b/.gitignore index 6aad45ceb..77216b695 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +Thumbs.db /deploy.exclude /deploy.sh /messages.mo diff --git a/classes/api.php b/classes/api.php index 3c5d08408..8267572f4 100644 --- a/classes/api.php +++ b/classes/api.php @@ -222,11 +222,10 @@ class API extends Handler { /* do not rely on params below */ $search = $this->dbh->escape_string($_REQUEST["search"]); - $search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]); $headlines = $this->api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order, - $include_attachments, $since_id, $search, $search_mode, + $include_attachments, $since_id, $search, $include_nested, $sanitize_content, $force_update, $excerpt_length); $this->wrap(self::STATUS_OK, $headlines); @@ -636,8 +635,7 @@ class API extends Handler { static function api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, - $search = "", $search_mode = "", - $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100) { + $search = "", $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100) { if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { // Update the feed if required with some basic flood control @@ -661,7 +659,7 @@ class API extends Handler { } $qfh_ret = queryFeedHeadlines($feed_id, $limit, - $view_mode, $is_cat, $search, $search_mode, + $view_mode, $is_cat, $search, false, $order, $offset, 0, false, $since_id, $include_nested); $result = $qfh_ret[0]; diff --git a/classes/dlg.php b/classes/dlg.php index eee720ed4..7b1abca3a 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -161,37 +161,6 @@ class Dlg extends Handler_Protected { } - function printTagSelect() { - - print __("Match:"). " " . - ""; - print "".__("Any").""; - print " "; - print ""; - print "".__("All tags.").""; - - print ""; - $result = $this->dbh->query("SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']." - AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC"); - - while ($row = $this->dbh->fetch_assoc($result)) { - $tmp = htmlspecialchars($row["tag_name"]); - print "$tmp"; - } - - print ""; - - print ""; - print "" . __('Display entries') . ""; - print " "; - print "" . - __('Close this window') . ""; - print ""; - - } - function generatedFeed() { $this->params = explode(":", $this->param, 3); diff --git a/classes/feeds.php b/classes/feeds.php index bedfe6499..ed66be291 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -13,7 +13,7 @@ class Feeds extends Handler_Protected { private function format_headline_subtoolbar($feed_site_url, $feed_title, $feed_id, $is_cat, $search, - $search_mode, $view_mode, $error, $feed_last_updated) { + $view_mode, $error, $feed_last_updated) { $catchup_sel_link = "catchupSelection()"; @@ -34,7 +34,7 @@ class Feeds extends Handler_Protected { if ($is_cat) $cat_q = "&is_cat=$is_cat"; if ($search) { - $search_q = "&q=$search&smode=$search_mode"; + $search_q = "&q=$search"; } else { $search_q = ""; } @@ -207,29 +207,19 @@ class Feeds extends Handler_Protected { $disable_cache = true; } - @$search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]); - if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info); -// error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]"); - if($search_mode == '' && $method != '' ){ - $search_mode = $method; - } -// error_log("search_mode: " . $search_mode); if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { $handler = PluginHost::getInstance()->get_feed_handler( PluginHost::feed_to_pfeed_id($feed)); - // function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) { - if ($handler) { $options = array( "limit" => $limit, "view_mode" => $view_mode, "cat_view" => $cat_view, "search" => $search, - "search_mode" => $search_mode, "override_order" => $override_order, "offset" => $offset, "owner_uid" => $_SESSION["uid"], @@ -243,7 +233,7 @@ class Feeds extends Handler_Protected { } else { $qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, - $search, $search_mode, $override_order, $offset, 0, + $search, false, $override_order, $offset, 0, false, 0, $include_children); } @@ -263,7 +253,7 @@ class Feeds extends Handler_Protected { $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, - $feed, $cat_view, $search, $search_mode, $view_mode, + $feed, $cat_view, $search, $view_mode, $last_error, $last_updated); $headlines_count = $this->dbh->num_rows($result); @@ -1118,36 +1108,7 @@ class Feeds extends Handler_Protected { style=\"font-size : 16px; width : 20em;\" required=\"1\" name=\"query\" type=\"search\" value=''>"; - print "".__('Limit search to:')." "; - - print " - ".__('All feeds').""; - - $feed_title = getFeedTitle($active_feed_id); - - if (!$is_cat) { - $feed_cat_title = getFeedCatTitle($active_feed_id); - } else { - $feed_cat_title = getCategoryTitle($active_feed_id); - } - - if ($active_feed_id && !$is_cat) { - print "$feed_title"; - } else { - print "".__('This feed').""; - } - - if ($is_cat) { - $cat_preselected = "selected=\"1\""; - } - - if (get_pref('ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) { - print "$feed_cat_title"; - } else { - //print "".__('This category').""; - } - - print ""; + print "".T_sprintf('in %s', getFeedTitle($active_feed_id, $is_cat)).""; print ""; diff --git a/classes/handler/public.php b/classes/handler/public.php index 46c74041c..74e837846 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -2,7 +2,7 @@ class Handler_Public extends Handler { private function generate_syndicated_feed($owner_uid, $feed, $is_cat, - $limit, $offset, $search, $search_mode, + $limit, $offset, $search, $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) { require_once "lib/MiniTemplator.class.php"; @@ -37,10 +37,8 @@ class Handler_Public extends Handler { break; } - //function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false) { - $qfh_ret = queryFeedHeadlines($feed, - 1, $view_mode, $is_cat, $search, $search_mode, + 1, $view_mode, $is_cat, $search, false, $date_sort_field, $offset, $owner_uid, false, 0, true, true, false, false, $start_ts); @@ -61,7 +59,7 @@ class Handler_Public extends Handler { } $qfh_ret = queryFeedHeadlines($feed, - $limit, $view_mode, $is_cat, $search, $search_mode, + $limit, $view_mode, $is_cat, $search, false, $date_sort_field, $offset, $owner_uid, false, 0, true, true, false, false, $start_ts); @@ -374,7 +372,6 @@ class Handler_Public extends Handler { $offset = (int)$this->dbh->escape_string($_REQUEST["offset"]); $search = $this->dbh->escape_string($_REQUEST["q"]); - $search_mode = $this->dbh->escape_string($_REQUEST["smode"]); $view_mode = $this->dbh->escape_string($_REQUEST["view-mode"]); $order = $this->dbh->escape_string($_REQUEST["order"]); $start_ts = $this->dbh->escape_string($_REQUEST["ts"]); @@ -400,7 +397,7 @@ class Handler_Public extends Handler { if ($owner_id) { $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit, - $offset, $search, $search_mode, $view_mode, $format, $order, $orig_guid, $start_ts); + $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts); } else { header('HTTP/1.1 403 Forbidden'); } diff --git a/include/functions2.php b/include/functions2.php index 1936d146d..e3b6e535c 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -425,6 +425,7 @@ return $rv; } + // $search_mode is obsolete/unused function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; @@ -532,33 +533,11 @@ $vfeed_query_part = ""; - // override query strategy and enable feed display when searching globally - if ($search && $search_mode == "all_feeds") { - $query_strategy_part = "true"; - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; /* tags */ - } else if (!is_numeric($feed)) { + if (!is_numeric($feed)) { $query_strategy_part = "true"; $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE id = feed_id) as feed_title,"; - } else if ($search && $search_mode == "this_cat") { - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; - - if ($feed > 0) { - if ($include_children) { - $subcats = getChildCategories($feed, $owner_uid); - array_push($subcats, $feed); - $cats_qpart = join(",", $subcats); - } else { - $cats_qpart = $feed; - } - - $query_strategy_part = "ttrss_feeds.cat_id IN ($cats_qpart)"; - - } else { - $query_strategy_part = "ttrss_feeds.cat_id IS NULL"; - } - } else if ($feed > 0) { if ($cat_view) { @@ -628,10 +607,6 @@ if (!$override_order) $override_order = "last_read DESC"; -/* } else if ($feed == -7) { // shared - $query_strategy_part = "uuid != ''"; - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; - $allow_archived = true; */ } else if ($feed == -3) { // fresh virtual feed $query_strategy_part = "unread = true AND score >= 0"; @@ -702,19 +677,13 @@ $content_query_part = "content, "; + if ($limit_query_part) { + $offset_query_part = "OFFSET $offset"; + } else { + $offset_query_part = ""; + } if (is_numeric($feed)) { - - if ($feed >= 0) { - $feed_kind = "Feeds"; - } else { - $feed_kind = "Labels"; - } - - if ($limit_query_part) { - $offset_query_part = "OFFSET $offset"; - } - // proper override_order applied above if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) { if (!$override_order) { @@ -733,8 +702,7 @@ LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; } - if ($vfeed_query_part) - $vfeed_query_part .= "favicon_avg_color,"; + if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,"; if ($start_ts) { $start_ts_formatted = date("Y/m/d H:i:s", strtotime($start_ts)); @@ -785,73 +753,45 @@ } else { // browsing by tag - $select_qpart = "SELECT DISTINCT " . - "date_entered," . - "guid," . - "note," . - "ttrss_entries.id as id," . - "title," . - "updated," . - "unread," . - "feed_id," . - "orig_feed_id," . - "marked," . - "num_comments, " . - "comments, " . - "tag_cache," . - "label_cache," . - "link," . - "lang," . - "uuid," . - "last_read," . - "(SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images," . - "last_marked, last_published, " . - $since_id_part . - $vfeed_query_part . - $content_query_part . - "score "; + $query = "SELECT DISTINCT + date_entered, + guid, + note, + ttrss_entries.id as id, + title, + updated, + unread, + feed_id, + orig_feed_id, + marked, + num_comments, + comments, + tag_cache, + label_cache, + link, + lang, + uuid, + last_read, + (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images, + last_marked, last_published, + $since_id_part + $vfeed_query_part + $content_query_part + author, score + FROM ttrss_entries, ttrss_user_entries, ttrss_tags + WHERE + ref_id = ttrss_entries.id AND + ttrss_user_entries.owner_uid = $owner_uid AND + post_int_id = int_id AND + tag_name = '$feed' AND + $view_query_part + $search_query_part + $query_strategy_part ORDER BY $order_by + $limit_query_part $offset_query_part"; - $feed_kind = "Tags"; - $all_tags = explode(",", $feed); - if ($search_mode == 'any') { - $tag_sql = "tag_name in (" . implode(", ", array_map("db_quote", $all_tags)) . ")"; - $from_qpart = " FROM ttrss_entries,ttrss_user_entries,ttrss_tags "; - $where_qpart = " WHERE " . - "ref_id = ttrss_entries.id AND " . - "ttrss_user_entries.owner_uid = $owner_uid AND " . - "post_int_id = int_id AND $tag_sql AND " . - $view_query_part . - $search_query_part . - $query_strategy_part . " ORDER BY $order_by " . - $limit_query_part; + if ($_REQUEST["debug"]) print $query; - } else { - $i = 1; - $sub_selects = array(); - $sub_ands = array(); - foreach ($all_tags as $term) { - array_push($sub_selects, "(SELECT post_int_id from ttrss_tags WHERE tag_name = " . db_quote($term) . " AND owner_uid = $owner_uid) as A$i"); - $i++; - } - if ($i > 2) { - $x = 1; - $y = 2; - do { - array_push($sub_ands, "A$x.post_int_id = A$y.post_int_id"); - $x++; - $y++; - } while ($y < $i); - } - array_push($sub_ands, "A1.post_int_id = ttrss_user_entries.int_id and ttrss_user_entries.owner_uid = $owner_uid"); - array_push($sub_ands, "ttrss_user_entries.ref_id = ttrss_entries.id"); - $from_qpart = " FROM " . implode(", ", $sub_selects) . ", ttrss_user_entries, ttrss_entries"; - $where_qpart = " WHERE " . implode(" AND ", $sub_ands); - } - // error_log("TAG SQL: " . $tag_sql); - // $tag_sql = "tag_name = '$feed'"; DEFAULT way - - // error_log("[". $select_qpart . "][" . $from_qpart . "][" .$where_qpart . "]"); - $result = db_query($select_qpart . $from_qpart . $where_qpart); + $result = db_query($query); } return array($result, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words); diff --git a/index.php b/index.php index f7ff97c68..95fb91d22 100644 --- a/index.php +++ b/index.php @@ -235,7 +235,6 @@ - diff --git a/js/tt-rss.js b/js/tt-rss.js index 602c953b1..f2a65b539 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -652,9 +652,6 @@ function quickMenuGo(opid) { case "qmcTagCloud": displayDlg(__("Tag cloud"), "printTagCloud"); break; - case "qmcTagSelect": - displayDlg(__("Select item(s) by tags"), "printTagSelect"); - break; case "qmcSearch": search(); break; diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index ae500c521..7eafec682 100644 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -114,8 +114,8 @@ class Af_RedditImgur extends Plugin { } $matches = array(); - if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) || - preg_match("/\/\/www\.youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) || + if (preg_match("/\.youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) || + preg_match("/\.youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) || preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) { $vid_id = $matches[1]; diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index b851479c0..f1341a350 100644 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -6,7 +6,7 @@ class Cache_Starred_Images extends Plugin implements IHandler { function about() { return array(1.0, - "Automatically cache images in Starred articles", + "Automatically cache Starred articles' images and HTML5 video files", "fox", true); } @@ -59,7 +59,8 @@ class Cache_Starred_Images extends Plugin implements IHandler { if ($hash) { - $filename = $this->cache_dir . "/" . $hash . '.png'; + $filename = $this->cache_dir . "/" . $hash; + $is_video = strpos($filename, ".mp4") !== FALSE; if (file_exists($filename)) { /* See if we can use X-Sendfile */ @@ -73,7 +74,7 @@ class Cache_Starred_Images extends Plugin implements IHandler { header("Content-type: application/octet-stream"); header('Content-Disposition: attachment; filename="' . basename($filename) . '"'); } else { - header("Content-type: image/png"); + header("Content-type: " . ($is_video ? "video/mp4" : "image/png")); $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)). " GMT"; header("Last-Modified: $stamp", true); readfile($filename); @@ -86,7 +87,7 @@ class Cache_Starred_Images extends Plugin implements IHandler { } function hook_house_keeping() { - $files = glob($this->cache_dir . "/*.png"); + $files = glob($this->cache_dir . "/*.{png,mp4}", GLOB_BRACE); $last_article_id = 0; $article_exists = 1; @@ -113,18 +114,19 @@ class Cache_Starred_Images extends Plugin implements IHandler { $xpath = new DOMXpath($doc); if ($article_id) { - $entries = $xpath->query('(//img[@src])'); + $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); foreach ($entries as $entry) { if ($entry->hasAttribute('src')) { $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); - $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . ".png"; + $extension = $entry->tagName == 'source' ? '.mp4' : '.png'; + $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . $extension; if (file_exists($local_filename)) { $entry->setAttribute("src", get_self_url_prefix() . "/public.php?op=cache_starred_images_getimage&method=image&hash=" . - $article_id . "-" . sha1($src)); + $article_id . "-" . sha1($src) . $extension); } } @@ -140,12 +142,11 @@ class Cache_Starred_Images extends Plugin implements IHandler { (ttrss_user_entries.feed_id = ttrss_feeds.id) WHERE ref_id = ttrss_entries.id AND marked = true AND - UPPER(content) LIKE '%cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); @@ -170,17 +171,20 @@ class Cache_Starred_Images extends Plugin implements IHandler { $doc->loadHTML($charset_hack . $content); $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//img[@src])'); + $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); $success = false; $has_images = false; foreach ($entries as $entry) { + if ($entry->hasAttribute('src')) { $has_images = true; $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); - $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . ".png"; + $extension = $entry->tagName == 'source' ? '.mp4' : '.png'; + + $local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . $extension; //_debug("cache_images: downloading: $src to $local_filename"); diff --git a/plugins/shorten_expanded/init.css b/plugins/shorten_expanded/init.css index 5e1bfa8f3..920e38415 100644 --- a/plugins/shorten_expanded/init.css +++ b/plugins/shorten_expanded/init.css @@ -1,7 +1,7 @@ div.contentSizeWrapper { overflow : hidden; text-overflow: ellipsis; - height : 700px; + height : 800px; } button.expandPrompt { diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index ba82b643b..4d80f8407 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -1,4 +1,4 @@ -var _shorten_expanded_threshold = 900; //px, longer than css height so that we would only clip articles significantly longer than limit +var _shorten_expanded_threshold = 1.5; //window heights function expandSizeWrapper(id) { try { @@ -28,7 +28,7 @@ dojo.addOnLoad(function() { window.setTimeout(function() { if (row) { - if (row.offsetHeight >= _shorten_expanded_threshold) { + if (row.offsetHeight >= _shorten_expanded_threshold * window.innerHeight) { var content = row.select(".cdmContentInner")[0]; if (content) {