]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Move another function
[friendica.git] / src / Model / Item.php
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;
+       }
 }