X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Farticle.php;h=43bcb50494dbd4365e40629ecaf4f3091f3b17c1;hb=07fd4f8d9d4f301f5ad88ff9e80f042fc3eb0c36;hp=7430fac33cf287a01cd707de1262953749b05d79;hpb=f76f773a16c70f745626e27b9981e6d815681da5;p=tt-rss.git diff --git a/classes/article.php b/classes/article.php old mode 100644 new mode 100755 index 7430fac3..43bcb504 --- a/classes/article.php +++ b/classes/article.php @@ -126,7 +126,7 @@ class Article extends Handler_Protected { if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; $pdo = Db::pdo(); - + $pdo->beginTransaction(); // only check for our user data here, others might have shared this with different content etc @@ -309,7 +309,7 @@ class Article extends Handler_Protected { if ($tag != '') { $sth = $this->pdo->prepare("INSERT INTO ttrss_tags - (post_int_id, owner_uid, tag_name) + (post_int_id, owner_uid, tag_name) VALUES (?, ?, ?)"); $sth->execute([$int_id, $_SESSION['uid'], $tag]); @@ -372,8 +372,7 @@ class Article extends Handler_Protected { $ids = explode(",", clean($_REQUEST["ids"])); $label_id = clean($_REQUEST["lid"]); - $label = db_escape_string(Labels::find_caption($label_id, - $_SESSION["uid"])); + $label = Labels::find_caption($label_id, $_SESSION["uid"]); $reply["info-for-headlines"] = array(); @@ -610,6 +609,8 @@ class Article extends Handler_Protected { $line = $p->hook_render_article($line); } + $line['content'] = rewrite_cached_urls($line['content']); + $num_comments = (int) $line["num_comments"]; $entry_comments = ""; @@ -619,31 +620,67 @@ class Article extends Handler_Protected { } else { $comments_url = htmlspecialchars($line["link"]); } - $entry_comments = "$num_comments ". _ngettext("comment", "comments", $num_comments).""; } else { if ($line["comments"] && $line["link"] != $line["comments"]) { - $entry_comments = "".__("comments").""; + $entry_comments = "".__("comments").""; } } + $enclosures = self::get_article_enclosures($line["id"]); + if ($zoom_mode) { header("Content-Type: text/html"); - $rv['content'] .= " + $rv['content'] .= " + ".$line["title"]."". stylesheet_tag("css/default.css")." - + "; + + $rv['content'] .= "\n"; + $rv['content'] .= "\n"; + $rv['content'] .= "\n"; + + $rv['content'] .= ""; + + $og_image = false; + + foreach ($enclosures as $enc) { + if (strpos($enc["content_type"], "image/") !== FALSE) { + $og_image = $enc["content_url"]; + break; + } + } + + if (!$og_image) { + $tmpdoc = new DOMDocument(); + + if (@$tmpdoc->loadHTML(mb_substr($line["content"], 0, 131070))) { + $tmpxpath = new DOMXPath($tmpdoc); + $first_img = $tmpxpath->query("//img")->item(0); - "; + if ($first_img) { + $og_image = $first_img->getAttribute("src"); + } + } + } + + if ($og_image) { + $rv['content'] .= ""; + } + + $rv['content'] .= ""; } - $rv['content'] .= "
"; + $rv['content'] .= "
"; - $rv['content'] .= "
"; + $rv['content'] .= "
"; $entry_author = $line["author"]; @@ -655,25 +692,25 @@ class Article extends Handler_Protected { $owner_uid, true); if (!$zoom_mode) - $rv['content'] .= "
$parsed_updated
"; + $rv['content'] .= "
$parsed_updated
"; if ($line["link"]) { - $rv['content'] .= "
" . $line["title"] . "" . "$entry_author
"; } else { - $rv['content'] .= "
" . $line["title"] . "$entry_author
"; + $rv['content'] .= "
" . $line["title"] . "$entry_author
"; } if ($zoom_mode) { $feed_title = htmlspecialchars($line["feed_title"]); - $rv['content'] .= "
$feed_title
"; + $rv['content'] .= "
$feed_title
"; - $rv['content'] .= "
$parsed_updated
"; + $rv['content'] .= "
$parsed_updated
"; } $tags_str = Article::format_tags_string($line["tags"], $id); @@ -683,7 +720,7 @@ class Article extends Handler_Protected { if (!$entry_comments) $entry_comments = " "; # placeholder - $rv['content'] .= "