This commit is contained in:
Philipp Holzer 2019-05-19 05:13:06 +02:00
parent a7aae9603a
commit 419cc81ef1
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
5 changed files with 37 additions and 36 deletions

View 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;
}
/**

View 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"],

View 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)) {

View file

@ -5,11 +5,11 @@ namespace Friendica\Object\Search;
use Friendica\Model\Search;
/**
* A search result
* A search result for contact searching
*
* @see Search for defails
* @see Search for details
*/
class Result
class ContactResult
{
/**
* @var int
@ -18,7 +18,7 @@ class Result
/**
* @var int
*/
private $pcid;
private $pCid;
/**
* @var string
*/
@ -59,9 +59,9 @@ class Result
/**
* @return int
*/
public function getPcid()
public function getPCid()
{
return $this->pcid;
return $this->pCid;
}
/**
@ -140,7 +140,7 @@ class Result
$this->network = $network;
$this->cid = $cid;
$this->pcid = $pcid;
$this->pCid = $pcid;
$this->tags = $tags;
}
}

View file

@ -5,11 +5,11 @@ namespace Friendica\Object\Search;
use Friendica\Model\Search;
/**
* A list of search results with details
* A list of search results for contacts with metadata
*
* @see Search for details
*/
class ResultList
class ContactResultList
{
/**
* Page of the result list
@ -28,7 +28,8 @@ class ResultList
private $itemsPage;
/**
* Array of results
* @var Result[]
*
* @var ContactResult[]
*/
private $results;
@ -57,7 +58,7 @@ class ResultList
}
/**
* @return Result[]
* @return ContactResult[]
*/
public function getResults()
{
@ -65,10 +66,10 @@ class ResultList
}
/**
* @param int $page
* @param int $total
* @param int $itemsPage
* @param Result[] $results
* @param int $page
* @param int $total
* @param int $itemsPage
* @param ContactResult[] $results
*/
public function __construct($page = 0, $total = 0, $itemsPage = 0, array $results = [])
{
@ -82,9 +83,9 @@ class ResultList
/**
* Adds a result to the result list
*
* @param Result $result
* @param ContactResult $result
*/
public function addResult(Result $result)
public function addResult(ContactResult $result)
{
$this->results[] = $result;
}