]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
Merge pull request #5106 from tobiasd/20180521-en
[friendica.git] / include / items.php
index 0ed444da289a2e63c5eeb2dcaa37eafc37c00a35..c04bef01c3de0ecb72a8e0c98d52d303f60313e1 100644 (file)
@@ -19,20 +19,17 @@ use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
 use Friendica\Util\Temporal;
 
-require_once 'include/bbcode.php';
-require_once 'include/tags.php';
 require_once 'include/text.php';
-require_once 'include/threads.php';
 require_once 'mod/share.php';
 require_once 'include/enotify.php';
 
-function add_page_info_data($data) {
+function add_page_info_data($data, $no_photos = false) {
        Addon::callHooks('page_info_data', $data);
 
        // It maybe is a rich content, but if it does have everything that a link has,
        // then treat it that way
        if (($data["type"] == "rich") && is_string($data["title"]) &&
-               is_string($data["text"]) && (sizeof($data["images"]) > 0)) {
+               is_string($data["text"]) && !empty($data["images"])) {
                $data["type"] = "link";
        }
 
@@ -66,7 +63,7 @@ function add_page_info_data($data) {
                $text .= " title='".$data["title"]."'";
        }
 
-       if (sizeof($data["images"]) > 0) {
+       if (!empty($data["images"])) {
                $preview = str_replace(["[", "]"], ["[", "]"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
                // if the preview picture is larger than 500 pixels then show it in a larger mode
                // But only, if the picture isn't higher than large (To prevent huge posts)
@@ -94,7 +91,7 @@ function add_page_info_data($data) {
        return "\n".$text.$hashtags;
 }
 
-function query_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
+function query_page_info($url, $photo = "", $keywords = false, $keyword_blacklist = "") {
 
        $data = ParseUrl::getSiteinfoCached($url, true);
 
@@ -122,8 +119,8 @@ function query_page_info($url, $no_photos = false, $photo = "", $keywords = fals
        return $data;
 }
 
-function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
-       $data = query_page_info($url, $no_photos, $photo, $keywords, $keyword_blacklist);
+function add_page_keywords($url, $photo = "", $keywords = false, $keyword_blacklist = "") {
+       $data = query_page_info($url, $photo, $keywords, $keyword_blacklist);
 
        $tags = "";
        if (isset($data["keywords"]) && count($data["keywords"])) {
@@ -143,9 +140,9 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
 }
 
 function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
-       $data = query_page_info($url, $no_photos, $photo, $keywords, $keyword_blacklist);
+       $data = query_page_info($url, $photo, $keywords, $keyword_blacklist);
 
-       $text = add_page_info_data($data);
+       $text = add_page_info_data($data, $no_photos);
 
        return $text;
 }
@@ -231,7 +228,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
  *
  * @TODO find proper type-hints
  */
-function consume_feed($xml, $importer, &$contact, &$hub, $datedir = 0, $pass = 0) {
+function consume_feed($xml, $importer, $contact, &$hub, $datedir = 0, $pass = 0) {
        if ($contact['network'] === NETWORK_OSTATUS) {
                if ($pass < 2) {
                        // Test - remove before flight
@@ -293,7 +290,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
                return;
        }
 
-       $push_url = Config::get('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
+       $push_url = System::baseUrl() . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
 
        // Use a single verify token, even if multiple hubs
        $verify_token = ((strlen($contact['hub-verify'])) ? $contact['hub-verify'] : random_string());
@@ -324,7 +321,7 @@ function drop_items($items) {
 
        if (count($items)) {
                foreach ($items as $item) {
-                       $owner = Item::delete($item);
+                       $owner = Item::deleteById($item);
                        if ($owner && !$uid)
                                $uid = $owner;
                }
@@ -396,7 +393,7 @@ function drop_item($id) {
                }
 
                // delete the item
-               Item::delete($item['id']);
+               Item::deleteById($item['id']);
 
                goaway(System::baseUrl() . '/' . $_SESSION['return_url']);
                //NOTREACHED