renaming
authorPhilipp Holzer <admin+github@philipp.info>
Sun, 19 May 2019 03:13:06 +0000 (05:13 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Sun, 19 May 2019 03:13:06 +0000 (05:13 +0200)
src/Database/DBA.php
src/Model/Search.php
src/Module/BaseSearchModule.php
src/Object/Search/ContactResult.php [new file with mode: 0644]
src/Object/Search/ContactResultList.php [new file with mode: 0644]
src/Object/Search/Result.php [deleted file]
src/Object/Search/ResultList.php [deleted file]

index 9367e26..2327e4a 100644 (file)
@@ -1540,7 +1540,7 @@ class DBA
                        $limit_string = " LIMIT " . intval($params['limit'][0]) . ", " . intval($params['limit'][1]);
                }
 
-               return $groupby_string.$order_string.$limit_string;
+               return $groupby_string . $order_string . $limit_string;
        }
 
        /**
index 815f2dc..80d5e66 100644 (file)
@@ -7,8 +7,8 @@ use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Network\Probe;
-use Friendica\Object\Search\Result;
-use Friendica\Object\Search\ResultList;
+use Friendica\Object\Search\ContactResult;
+use Friendica\Object\Search\ContactResultList;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
@@ -46,7 +46,7 @@ class Search extends BaseObject
         *
         * @param string $user The user to search for
         *
-        * @return ResultList|null
+        * @return ContactResultList|null
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
@@ -67,7 +67,7 @@ class Search extends BaseObject
                        $contactDetails = Contact::getDetailsByURL(defaults($user_data, 'url', ''), local_user());
                        $itemurl = (($contactDetails["addr"] != "") ? $contactDetails["addr"] : defaults($user_data, 'url', ''));
 
-                       $result = new Result(
+                       $result = new ContactResult(
                                defaults($user_data, 'name', ''),
                                defaults($user_data, 'addr', ''),
                                $itemurl,
@@ -79,7 +79,7 @@ class Search extends BaseObject
                                defaults($user_data, 'tags', '')
                        );
 
-                       return new ResultList(1, 1, 1, [$result]);
+                       return new ContactResultList(1, 1, 1, [$result]);
 
                } else {
                        return null;
@@ -93,7 +93,7 @@ class Search extends BaseObject
         * @param string $search
         * @param int    $page
         *
-        * @return ResultList|null
+        * @return ContactResultList|null
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function searchDirectory($search, $page = 1)
@@ -112,7 +112,7 @@ class Search extends BaseObject
 
                $results    = json_decode($resultJson, true);
 
-               $resultList = new ResultList(
+               $resultList = new ContactResultList(
                        defaults($results, 'page', 1),
                        defaults($results, 'count', 1),
                        defaults($results, 'itemsperpage', 1)
@@ -124,7 +124,7 @@ class Search extends BaseObject
                        $contactDetails = Contact::getDetailsByURL(defaults($profile, 'profile_url', ''), local_user());
                        $itemurl = (!empty($contactDetails['addr']) ? $contactDetails['addr'] : defaults($profile, 'profile_url', ''));
 
-                       $result = new Result(
+                       $result = new ContactResult(
                                defaults($profile, 'name', ''),
                                defaults($profile, 'addr', ''),
                                $itemurl,
@@ -149,7 +149,7 @@ class Search extends BaseObject
         * @param int    $itemPage
         * @param bool   $community
         *
-        * @return ResultList|null
+        * @return ContactResultList|null
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function searchLocal($search, $start = 0, $itemPage = 80, $community = false)
@@ -199,7 +199,7 @@ class Search extends BaseObject
                        return null;
                }
 
-               $resultList = new ResultList($start, $itemPage, $count);
+               $resultList = new ContactResultList($start, $itemPage, $count);
 
                while ($row = DBA::fetch($data)) {
                        if (PortableContact::alternateOStatusUrl($row["nurl"])) {
@@ -220,7 +220,7 @@ class Search extends BaseObject
                                $contact["name"] = end(explode("/", $urlparts["path"]));
                        }
 
-                       $result = new Result(
+                       $result = new ContactResult(
                                $contact["name"],
                                $contact["addr"],
                                $contact["addr"],
index 7028208..9430ec1 100644 (file)
@@ -7,7 +7,7 @@ use Friendica\Content\ContactSelector;
 use Friendica\Content\Pager;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
-use Friendica\Object\Search\ResultList;
+use Friendica\Object\Search\ContactResultList;
 use Friendica\Util\Proxy as ProxyUtils;
 use Friendica\Model;
 use Friendica\Util\Strings;
@@ -72,15 +72,15 @@ class BaseSearchModule extends BaseModule
        /**
         * Prints a human readable search result
         *
-        * @param ResultList $results
-        * @param Pager      $pager
-        * @param string     $header
+        * @param ContactResultList $results
+        * @param Pager             $pager
+        * @param string            $header
         *
         * @return string The result
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       protected static function printResult(ResultList $results, Pager $pager, $header = '')
+       protected static function printResult(ContactResultList $results, Pager $pager, $header = '')
        {
                if (empty($results) || empty($results->getResults())) {
                        info(L10n::t('No matches') . EOL);
@@ -100,11 +100,11 @@ class BaseSearchModule extends BaseModule
                        $photo_menu  = [];
 
                        // If We already know this contact then don't show the "connect" button
-                       if ($result->getCid() > 0 || $result->getPcid() > 0) {
+                       if ($result->getCid() > 0 || $result->getPCid() > 0) {
                                $connLink = "";
                                $connTxt = "";
                                $contact = Model\Contact::getById(
-                                       ($result->getCid() > 0) ? $result->getCid() : $result->getPcid()
+                                       ($result->getCid() > 0) ? $result->getCid() : $result->getPCid()
                                );
 
                                if (!empty($contact)) {
diff --git a/src/Object/Search/ContactResult.php b/src/Object/Search/ContactResult.php
new file mode 100644 (file)
index 0000000..699afa8
--- /dev/null
@@ -0,0 +1,146 @@
+<?php
+
+namespace Friendica\Object\Search;
+
+use Friendica\Model\Search;
+
+/**
+ * A search result for contact searching
+ *
+ * @see Search for details
+ */
+class ContactResult
+{
+       /**
+        * @var int
+        */
+       private $cid;
+       /**
+        * @var int
+        */
+       private $pCid;
+       /**
+        * @var string
+        */
+       private $name;
+       /**
+        * @var string
+        */
+       private $addr;
+       /**
+        * @var string
+        */
+       private $item;
+       /**
+        * @var string
+        */
+       private $url;
+       /**
+        * @var string
+        */
+       private $photo;
+       /**
+        * @var string
+        */
+       private $tags;
+       /**
+        * @var string
+        */
+       private $network;
+
+       /**
+        * @return int
+        */
+       public function getCid()
+       {
+               return $this->cid;
+       }
+
+       /**
+        * @return int
+        */
+       public function getPCid()
+       {
+               return $this->pCid;
+       }
+
+       /**
+        * @return string
+        */
+       public function getName()
+       {
+               return $this->name;
+       }
+
+       /**
+        * @return string
+        */
+       public function getAddr()
+       {
+               return $this->addr;
+       }
+
+       /**
+        * @return string
+        */
+       public function getItem()
+       {
+               return $this->item;
+       }
+
+       /**
+        * @return string
+        */
+       public function getUrl()
+       {
+               return $this->url;
+       }
+
+       /**
+        * @return string
+        */
+       public function getPhoto()
+       {
+               return $this->photo;
+       }
+
+       /**
+        * @return string
+        */
+       public function getTags()
+       {
+               return $this->tags;
+       }
+
+       /**
+        * @return string
+        */
+       public function getNetwork()
+       {
+               return $this->network;
+       }
+
+       /**
+        * @param string $name
+        * @param string $addr
+        * @param string $url
+        * @param string $photo
+        * @param string $network
+        * @param int    $cid
+        * @param int    $pcid
+        * @param string $tags
+        */
+       public function __construct($name, $addr, $item, $url, $photo, $network, $cid = 0, $pcid = 0, $tags = '')
+       {
+               $this->name    = $name;
+               $this->addr    = $addr;
+               $this->item    = $item;
+               $this->url     = $url;
+               $this->photo   = $photo;
+               $this->network = $network;
+
+               $this->cid  = $cid;
+               $this->pCid = $pcid;
+               $this->tags = $tags;
+       }
+}
diff --git a/src/Object/Search/ContactResultList.php b/src/Object/Search/ContactResultList.php
new file mode 100644 (file)
index 0000000..f3014d3
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+
+namespace Friendica\Object\Search;
+
+use Friendica\Model\Search;
+
+/**
+ * A list of search results for contacts with metadata
+ *
+ * @see Search for details
+ */
+class ContactResultList
+{
+       /**
+        * Page of the result list
+        * @var int
+        */
+       private $page;
+       /**
+        * Total count of results
+        * @var int
+        */
+       private $total;
+       /**
+        * items per page
+        * @var int
+        */
+       private $itemsPage;
+       /**
+        * Array of results
+        *
+        * @var ContactResult[]
+        */
+       private $results;
+
+       /**
+        * @return int
+        */
+       public function getPage()
+       {
+               return $this->page;
+       }
+
+       /**
+        * @return int
+        */
+       public function getTotal()
+       {
+               return $this->total;
+       }
+
+       /**
+        * @return int
+        */
+       public function getItemsPage()
+       {
+               return $this->itemsPage;
+       }
+
+       /**
+        * @return ContactResult[]
+        */
+       public function getResults()
+       {
+               return $this->results;
+       }
+
+       /**
+        * @param int             $page
+        * @param int             $total
+        * @param int             $itemsPage
+        * @param ContactResult[] $results
+        */
+       public function __construct($page = 0, $total = 0, $itemsPage = 0, array $results = [])
+       {
+               $this->page      = $page;
+               $this->total     = $total;
+               $this->itemsPage = $itemsPage;
+
+               $this->results = $results;
+       }
+
+       /**
+        * Adds a result to the result list
+        *
+        * @param ContactResult $result
+        */
+       public function addResult(ContactResult $result)
+       {
+               $this->results[] = $result;
+       }
+}
diff --git a/src/Object/Search/Result.php b/src/Object/Search/Result.php
deleted file mode 100644 (file)
index 10d6b0a..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-
-namespace Friendica\Object\Search;
-
-use Friendica\Model\Search;
-
-/**
- * A search result
- *
- * @see Search for defails
- */
-class Result
-{
-       /**
-        * @var int
-        */
-       private $cid;
-       /**
-        * @var int
-        */
-       private $pcid;
-       /**
-        * @var string
-        */
-       private $name;
-       /**
-        * @var string
-        */
-       private $addr;
-       /**
-        * @var string
-        */
-       private $item;
-       /**
-        * @var string
-        */
-       private $url;
-       /**
-        * @var string
-        */
-       private $photo;
-       /**
-        * @var string
-        */
-       private $tags;
-       /**
-        * @var string
-        */
-       private $network;
-
-       /**
-        * @return int
-        */
-       public function getCid()
-       {
-               return $this->cid;
-       }
-
-       /**
-        * @return int
-        */
-       public function getPcid()
-       {
-               return $this->pcid;
-       }
-
-       /**
-        * @return string
-        */
-       public function getName()
-       {
-               return $this->name;
-       }
-
-       /**
-        * @return string
-        */
-       public function getAddr()
-       {
-               return $this->addr;
-       }
-
-       /**
-        * @return string
-        */
-       public function getItem()
-       {
-               return $this->item;
-       }
-
-       /**
-        * @return string
-        */
-       public function getUrl()
-       {
-               return $this->url;
-       }
-
-       /**
-        * @return string
-        */
-       public function getPhoto()
-       {
-               return $this->photo;
-       }
-
-       /**
-        * @return string
-        */
-       public function getTags()
-       {
-               return $this->tags;
-       }
-
-       /**
-        * @return string
-        */
-       public function getNetwork()
-       {
-               return $this->network;
-       }
-
-       /**
-        * @param string $name
-        * @param string $addr
-        * @param string $url
-        * @param string $photo
-        * @param string $network
-        * @param int    $cid
-        * @param int    $pcid
-        * @param string $tags
-        */
-       public function __construct($name, $addr, $item, $url, $photo, $network, $cid = 0, $pcid = 0, $tags = '')
-       {
-               $this->name    = $name;
-               $this->addr    = $addr;
-               $this->item    = $item;
-               $this->url     = $url;
-               $this->photo   = $photo;
-               $this->network = $network;
-
-               $this->cid  = $cid;
-               $this->pcid = $pcid;
-               $this->tags = $tags;
-       }
-}
diff --git a/src/Object/Search/ResultList.php b/src/Object/Search/ResultList.php
deleted file mode 100644 (file)
index 88caaa7..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-
-namespace Friendica\Object\Search;
-
-use Friendica\Model\Search;
-
-/**
- * A list of search results with details
- *
- * @see Search for details
- */
-class ResultList
-{
-       /**
-        * Page of the result list
-        * @var int
-        */
-       private $page;
-       /**
-        * Total count of results
-        * @var int
-        */
-       private $total;
-       /**
-        * items per page
-        * @var int
-        */
-       private $itemsPage;
-       /**
-        * Array of results
-        * @var Result[]
-        */
-       private $results;
-
-       /**
-        * @return int
-        */
-       public function getPage()
-       {
-               return $this->page;
-       }
-
-       /**
-        * @return int
-        */
-       public function getTotal()
-       {
-               return $this->total;
-       }
-
-       /**
-        * @return int
-        */
-       public function getItemsPage()
-       {
-               return $this->itemsPage;
-       }
-
-       /**
-        * @return Result[]
-        */
-       public function getResults()
-       {
-               return $this->results;
-       }
-
-       /**
-        * @param int      $page
-        * @param int      $total
-        * @param int      $itemsPage
-        * @param Result[] $results
-        */
-       public function __construct($page = 0, $total = 0, $itemsPage = 0, array $results = [])
-       {
-               $this->page      = $page;
-               $this->total     = $total;
-               $this->itemsPage = $itemsPage;
-
-               $this->results = $results;
-       }
-
-       /**
-        * Adds a result to the result list
-        *
-        * @param Result $result
-        */
-       public function addResult(Result $result)
-       {
-               $this->results[] = $result;
-       }
-}