]> git.mxchange.org Git - friendica.git/commitdiff
Move another function
authorAdam Magness <adam.magness@gmail.com>
Wed, 7 Nov 2018 12:19:39 +0000 (07:19 -0500)
committerAdam Magness <adam.magness@gmail.com>
Wed, 7 Nov 2018 12:19:39 +0000 (07:19 -0500)
move get_plink to Item class, and also fix up getApp since we extend BaseObject

include/conversation.php
include/text.php
src/Model/Item.php
src/Object/Post.php

index 3e953db7da6db106d1b6ffd6b5ae65de7eb41e0e..e276fef139ee88dd0e94685b9b744afeecabe5c2 100644 (file)
@@ -689,7 +689,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                                        'owner_name' => $owner_name_e,
                                        'owner_url' => $owner_url,
                                        'owner_photo' => System::removedBaseUrl(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
-                                       'plink' => get_plink($item),
+                                       'plink' => Item::getPlink($item),
                                        'edpost' => false,
                                        'isstarred' => $isstarred,
                                        'star' => $star,
index db8ebcc4eb17adac7acfe218dc1fc7e071c84355..876cdbdb8a7d1ac30d5fddb70d8705c14893f704 100644 (file)
@@ -493,42 +493,6 @@ function get_cats_and_terms($item)
        return [$categories, $folders];
 }
 
-
-/**
- * get private link for item
- * @param array $item
- * @return boolean|array False if item has not plink, otherwise array('href'=>plink url, 'title'=>translated title)
- */
-function get_plink($item) {
-       $a = get_app();
-
-       if ($a->user['nickname'] != "") {
-               $ret = [
-                               //'href' => "display/" . $a->user['nickname'] . "/" . $item['id'],
-                               'href' => "display/" . $item['guid'],
-                               'orig' => "display/" . $item['guid'],
-                               'title' => L10n::t('View on separate page'),
-                               'orig_title' => L10n::t('view on separate page'),
-                       ];
-
-               if (x($item, 'plink')) {
-                       $ret["href"] = $a->removeBaseURL($item['plink']);
-                       $ret["title"] = L10n::t('link to source');
-               }
-
-       } elseif (x($item, 'plink') && ($item['private'] != 1)) {
-               $ret = [
-                               'href' => $item['plink'],
-                               'orig' => $item['plink'],
-                               'title' => L10n::t('link to source'),
-                       ];
-       } else {
-               $ret = [];
-       }
-
-       return $ret;
-}
-
 /**
  * return number of bytes in size (K, M, G)
  * @param string $size_str
index d6a6d02085e54a18b07ba207e09e0a7b78872dae..4f88c2ed9d1da95d0780d30509a2bf70e37a1f3e 100644 (file)
@@ -3297,7 +3297,7 @@ class Item extends BaseObject
                        || $rendered_hash != hash("md5", $item["body"])
                        || Config::get("system", "ignore_cache")
                ) {
-                       $a = get_app();
+                       $a = self::getApp();
                        redir_private_images($a, $item);
 
                        $item["rendered-html"] = prepare_text($item["body"]);
@@ -3348,7 +3348,7 @@ class Item extends BaseObject
         */
        public static function prepareBody(array &$item, $attach = false, $is_preview = false)
        {
-               $a = get_app();
+               $a = self::getApp();
                Addon::callHooks('prepare_body_init', $item);
 
                // In order to provide theme developers more possibilities, event items
@@ -3509,4 +3509,39 @@ class Item extends BaseObject
 
                return $hook_data['html'];
        }
+
+       /**
+        * get private link for item
+        * @param array $item
+        * @return boolean|array False if item has not plink, otherwise array('href'=>plink url, 'title'=>translated title)
+        */
+       public static function getPlink($item)
+       {
+               $a = self::getApp();
+
+               if ($a->user['nickname'] != "") {
+                       $ret = [
+                                       'href' => "display/" . $item['guid'],
+                                       'orig' => "display/" . $item['guid'],
+                                       'title' => L10n::t('View on separate page'),
+                                       'orig_title' => L10n::t('view on separate page'),
+                               ];
+
+                       if (x($item, 'plink')) {
+                               $ret["href"] = $a->removeBaseURL($item['plink']);
+                               $ret["title"] = L10n::t('link to source');
+                       }
+
+               } elseif (x($item, 'plink') && ($item['private'] != 1)) {
+                       $ret = [
+                                       'href' => $item['plink'],
+                                       'orig' => $item['plink'],
+                                       'title' => L10n::t('link to source'),
+                               ];
+               } else {
+                       $ret = [];
+               }
+
+               return $ret;
+       }
 }
index e5a18e691dbe1fc2b0aa6932d624b6cb50721b0e..e0e3beadb3ec53200bfe9549395f987773d1d9ef 100644 (file)
@@ -392,7 +392,7 @@ class Post extends BaseObject
                        'owner_url'       => $this->getOwnerUrl(),
                        'owner_photo'     => $a->removeBaseURL(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
                        'owner_name'      => htmlentities($owner_name_e),
-                       'plink'           => get_plink($item),
+                       'plink'           => Item::getPlink($item),
                        'edpost'          => Feature::isEnabled($conv->getProfileOwner(), 'edit_posts') ? $edpost : '',
                        'isstarred'       => $isstarred,
                        'star'            => Feature::isEnabled($conv->getProfileOwner(), 'star_posts') ? $star : '',