]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Item.php
Enhanced test data
[friendica.git] / src / Content / Item.php
index 40deb976c778386df3ba3793cb5386b0983b6e00..06190dc88f5ff2f8584432de6765de0ac6041374 100644 (file)
@@ -23,8 +23,8 @@ namespace Friendica\Content;
 
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
-use Friendica\Model\FileTag;
 use Friendica\Model\Tag;
+use Friendica\Model\Post;
 
 /**
  * A content helper class for displaying items
@@ -64,7 +64,7 @@ class Item
                $folders = [];
                $first = true;
 
-               foreach (FileTag::fileToArray($item['file'] ?? '', 'category') as $savedFolderName) {
+               foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::CATEGORY) as $savedFolderName) {
                        if (!empty($item['author-link'])) {
                                $url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
                        } else {
@@ -85,7 +85,7 @@ class Item
                }
 
                if (local_user() == $item['uid']) {
-                       foreach (FileTag::fileToArray($item['file'] ?? '') as $savedFolderName) {
+                       foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::FILE) as $savedFolderName) {
                                $folders[] = [
                                        'name' => $savedFolderName,
                                        'url' => "#",
@@ -130,7 +130,7 @@ class Item
                                // Checking for the alias that is used for OStatus
                                $pattern = '/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism';
                                if (preg_match($pattern, $tag, $matches)) {
-                                       $data = Contact::getDetailsByURL($matches[1]);
+                                       $data = Contact::getByURL($matches[1], false, ['alias', 'nick']);
 
                                        if ($data['alias'] != '') {
                                                $newtag = '@[url=' . $data['alias'] . ']' . $data['nick'] . '[/url]';
@@ -149,15 +149,8 @@ class Item
                        $name = $nameparts[0];
 
                        // Try to detect the contact in various ways
-                       if (strpos($name, 'http://')) {
-                               // At first we have to ensure that the contact exists
-                               Contact::getIdForURL($name);
-
-                               // Now we should have something
-                               $contact = Contact::getDetailsByURL($name, $profile_uid);
-                       } elseif (strpos($name, '@')) {
-                               // This function automatically probes when no entry was found
-                               $contact = Contact::getDetailsByAddr($name, $profile_uid);
+                       if (strpos($name, 'http://') || strpos($name, '@')) {
+                               $contact = Contact::getByURLForUser($name, $profile_uid);
                        } else {
                                $contact = false;
                                $fields = ['id', 'url', 'nick', 'name', 'alias', 'network', 'forum', 'prv'];
@@ -168,10 +161,17 @@ class Item
                                        $contact = DBA::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]);
                                }
 
-                               // select someone by nick or attag in the current network
+                               // select someone by nick in the current network
                                if (!DBA::isResult($contact) && ($network != '')) {
-                                       $condition = ["(`nick` = ? OR `attag` = ?) AND `network` = ? AND `uid` = ?",
-                                               $name, $name, $network, $profile_uid];
+                                       $condition = ["`nick` = ? AND `network` = ? AND `uid` = ?",
+                                               $name, $network, $profile_uid];
+                                       $contact = DBA::selectFirst('contact', $fields, $condition);
+                               }
+
+                               // select someone by attag in the current network
+                               if (!DBA::isResult($contact) && ($network != '')) {
+                                       $condition = ["`attag` = ? AND `network` = ? AND `uid` = ?",
+                                               $name, $network, $profile_uid];
                                        $contact = DBA::selectFirst('contact', $fields, $condition);
                                }
 
@@ -181,9 +181,15 @@ class Item
                                        $contact = DBA::selectFirst('contact', $fields, $condition);
                                }
 
-                               // select someone by nick or attag in any network
+                               // select someone by nick in any network
+                               if (!DBA::isResult($contact)) {
+                                       $condition = ["`nick` = ? AND `uid` = ?", $name, $profile_uid];
+                                       $contact = DBA::selectFirst('contact', $fields, $condition);
+                               }
+
+                               // select someone by attag in any network
                                if (!DBA::isResult($contact)) {
-                                       $condition = ["(`nick` = ? OR `attag` = ?) AND `uid` = ?", $name, $name, $profile_uid];
+                                       $condition = ["`attag` = ? AND `uid` = ?", $name, $profile_uid];
                                        $contact = DBA::selectFirst('contact', $fields, $condition);
                                }