return false;
}
- $r = q(
- "SELECT * FROM `parsed_url` WHERE `url` = '%s' AND `guessing` = %d AND `oembed` = %d",
- dbesc(normalise_link($url)),
- intval(!$no_guessing),
- intval($do_oembed)
+ $parsed_url = dba::selectFirst('parsed_url', ['content'],
+ ['url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed]
);
-
- if ($r) {
- $data = $r[0]["content"];
- }
-
- if (!is_null($data)) {
- $data = unserialize($data);
+ if (!empty($parsed_url['content'])) {
+ $data = unserialize($parsed_url['content']);
return $data;
}
[
'url' => normalise_link($url), 'guessing' => !$no_guessing,
'oembed' => $do_oembed, 'content' => serialize($data),
- 'created' => Temporal::utcNow()
+ 'created' => DateTimeFormat::utcNow()
],
true
);
if ($do_oembed) {
$oembed_data = OEmbed::fetchURL($url);
- if (!in_array($oembed_data->type, ["error", "rich", ""])) {
- $siteinfo["type"] = $oembed_data->type;
- }
-
- if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) {
- if (isset($oembed_data->title)) {
- $siteinfo["title"] = trim($oembed_data->title);
+ if (!empty($oembed_data->type)) {
+ if (!in_array($oembed_data->type, ["error", "rich", ""])) {
+ $siteinfo["type"] = $oembed_data->type;
}
- if (isset($oembed_data->description)) {
- $siteinfo["text"] = trim($oembed_data->description);
- }
- if (isset($oembed_data->thumbnail_url)) {
- $siteinfo["image"] = $oembed_data->thumbnail_url;
+
+ if (($oembed_data->type == "link") && ($siteinfo["type"] != "photo")) {
+ if (isset($oembed_data->title)) {
+ $siteinfo["title"] = trim($oembed_data->title);
+ }
+ if (isset($oembed_data->description)) {
+ $siteinfo["text"] = trim($oembed_data->description);
+ }
+ if (isset($oembed_data->thumbnail_url)) {
+ $siteinfo["image"] = $oembed_data->thumbnail_url;
+ }
}
}
}
}
}
- $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
+ if (!empty($attr["content"])) {
+ $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
- if ($attr["content"] != "") {
switch (strtolower($attr["name"])) {
case "fulltitle":
$siteinfo["title"] = trim($attr["content"]);
}
}
- $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
+ if (!empty($attr["content"])) {
+ $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
- if ($attr["content"] != "") {
switch (strtolower($attr["property"])) {
case "og:image":
$siteinfo["image"] = $attr["content"];
"height" => $photodata[1]];
}
}
- } elseif ($siteinfo["image"] != "") {
+ } elseif (!empty($siteinfo["image"])) {
$src = self::completeUrl($siteinfo["image"], $url);
unset($siteinfo["image"]);