$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;
}
/**
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;
*
* @param string $user The user to search for
*
- * @return ResultList|null
+ * @return ContactResultList|null
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
$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,
defaults($user_data, 'tags', '')
);
- return new ResultList(1, 1, 1, [$result]);
+ return new ContactResultList(1, 1, 1, [$result]);
} else {
return null;
* @param string $search
* @param int $page
*
- * @return ResultList|null
+ * @return ContactResultList|null
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function searchDirectory($search, $page = 1)
$results = json_decode($resultJson, true);
- $resultList = new ResultList(
+ $resultList = new ContactResultList(
defaults($results, 'page', 1),
defaults($results, 'count', 1),
defaults($results, 'itemsperpage', 1)
$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,
* @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)
return null;
}
- $resultList = new ResultList($start, $itemPage, $count);
+ $resultList = new ContactResultList($start, $itemPage, $count);
while ($row = DBA::fetch($data)) {
if (PortableContact::alternateOStatusUrl($row["nurl"])) {
$contact["name"] = end(explode("/", $urlparts["path"]));
}
- $result = new Result(
+ $result = new ContactResult(
$contact["name"],
$contact["addr"],
$contact["addr"],
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;
/**
* 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);
$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)) {
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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;
+ }
+}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}