mirror of
https://github.com/openvk/openvk
synced 2024-11-15 03:31:18 +03:00
Compare commits
1 commit
5b5de87068
...
43751c6d65
Author | SHA1 | Date | |
---|---|---|---|
|
43751c6d65 |
10 changed files with 28 additions and 45 deletions
|
@ -254,28 +254,17 @@ final class Groups extends VKAPIRequestHandler
|
|||
|
||||
function search(string $q, int $offset = 0, int $count = 100, string $fields = "screen_name,is_admin,is_member,is_advertiser,photo_50,photo_100,photo_200")
|
||||
{
|
||||
if($count > 100) {
|
||||
$this->fail(100, "One of the parameters specified was missing or invalid: count should be less or equal to 100");
|
||||
}
|
||||
|
||||
$clubs = new ClubsRepo;
|
||||
|
||||
$array = [];
|
||||
$find = $clubs->find($q);
|
||||
|
||||
foreach ($find->offsetLimit($offset, $count) as $group)
|
||||
foreach ($find as $group)
|
||||
$array[] = $group->getId();
|
||||
|
||||
if(!$array || sizeof($array) < 1) {
|
||||
return (object) [
|
||||
"count" => 0,
|
||||
"items" => [],
|
||||
];
|
||||
}
|
||||
|
||||
return (object) [
|
||||
"count" => $find->size(),
|
||||
"items" => $this->getById(implode(',', $array), "", $fields)
|
||||
"items" => $this->getById(implode(',', $array), "", $fields, $offset, $count)
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -329,10 +329,6 @@ final class Users extends VKAPIRequestHandler
|
|||
string $fav_books = ""
|
||||
)
|
||||
{
|
||||
if($count > 100) {
|
||||
$this->fail(100, "One of the parameters specified was missing or invalid: count should be less or equal to 100");
|
||||
}
|
||||
|
||||
$users = new UsersRepo;
|
||||
$output_sort = ['type' => 'id', 'invert' => false];
|
||||
$output_params = [
|
||||
|
@ -388,19 +384,12 @@ final class Users extends VKAPIRequestHandler
|
|||
$array = [];
|
||||
$find = $users->find($q, $output_params, $output_sort);
|
||||
|
||||
foreach ($find->offsetLimit($offset, $count) as $user)
|
||||
foreach ($find as $user)
|
||||
$array[] = $user->getId();
|
||||
|
||||
if(!$array || sizeof($array) < 1) {
|
||||
return (object) [
|
||||
"count" => 0,
|
||||
"items" => [],
|
||||
];
|
||||
}
|
||||
|
||||
return (object) [
|
||||
"count" => $find->size(),
|
||||
"items" => $this->get(implode(',', $array), $fields)
|
||||
"count" => $find->size(),
|
||||
"items" => $this->get(implode(',', $array), $fields, $offset, $count)
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ class Applications
|
|||
|
||||
function find(string $query = "", array $params = [], array $order = ['type' => 'id', 'invert' => false]): Util\EntityStream
|
||||
{
|
||||
$query = "%$query%";
|
||||
$result = $this->apps->where("CONCAT_WS(' ', name, description) LIKE ?", $query)->where("enabled", 1);
|
||||
$result = $this->apps->where("CONCAT_WS(' ', name, description) LIKE ?", "%$query%")->where("enabled", 1);
|
||||
$order_str = 'id';
|
||||
|
||||
switch($order['type']) {
|
||||
|
|
|
@ -246,7 +246,6 @@ class Audios
|
|||
|
||||
function find(string $query, array $params = [], array $order = ['type' => 'id', 'invert' => false], int $page = 1, ?int $perPage = NULL): \Traversable
|
||||
{
|
||||
$query = "%$query%";
|
||||
$result = $this->audios->where([
|
||||
"unlisted" => 0,
|
||||
"deleted" => 0,
|
||||
|
@ -266,9 +265,9 @@ class Audios
|
|||
}
|
||||
|
||||
if($params["only_performers"] == "1") {
|
||||
$result->where("performer LIKE ?", $query);
|
||||
$result->where("performer LIKE ?", "%$query%");
|
||||
} else {
|
||||
$result->where("name LIKE ? OR performer LIKE ?", $query, $query);
|
||||
$result->where("name LIKE ? OR performer LIKE ?", "%$query%", "%$query%");
|
||||
}
|
||||
|
||||
foreach($params as $paramName => $paramValue) {
|
||||
|
@ -300,15 +299,26 @@ class Audios
|
|||
|
||||
function findPlaylists(string $query, array $params = [], array $order = ['type' => 'id', 'invert' => false]): \Traversable
|
||||
{
|
||||
$query = "%$query%";
|
||||
$result = $this->playlists->where([
|
||||
"deleted" => 0,
|
||||
])->where("CONCAT_WS(' ', name, description) LIKE ?", $query);
|
||||
$order_str = (['id', 'length', 'listens'][$order['type']] ?? 'id') . ' ' . ($order['invert'] ? 'ASC' : 'DESC');
|
||||
])->where("CONCAT_WS(' ', name, description) LIKE ?", "%$query%");
|
||||
$order_str = 'id';
|
||||
|
||||
if(is_null($params['from_me']) || empty($params['from_me']))
|
||||
$result->where(["unlisted" => 0]);
|
||||
|
||||
switch($order['type']) {
|
||||
case 'id':
|
||||
$order_str = 'id ' . ($order['invert'] ? 'ASC' : 'DESC');
|
||||
break;
|
||||
case 'length':
|
||||
$order_str = 'length ' . ($order['invert'] ? 'ASC' : 'DESC');
|
||||
break;
|
||||
case 'listens':
|
||||
$order_str = 'listens ' . ($order['invert'] ? 'ASC' : 'DESC');
|
||||
break;
|
||||
}
|
||||
|
||||
foreach($params as $paramName => $paramValue) {
|
||||
if(is_null($paramValue) || $paramValue == '') continue;
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ class Clubs
|
|||
|
||||
function find(string $query, array $params = [], array $order = ['type' => 'id', 'invert' => false], int $page = 1, ?int $perPage = NULL): \Traversable
|
||||
{
|
||||
$query = "%$query%";
|
||||
$result = $this->clubs;
|
||||
$order_str = 'id';
|
||||
|
||||
|
@ -55,7 +54,7 @@ class Clubs
|
|||
break;
|
||||
}
|
||||
|
||||
$result = $result->where("name LIKE ? OR about LIKE ?", $query, $query);
|
||||
$result = $result->where("name LIKE ? OR about LIKE ?", "%$query%", "%$query%");
|
||||
|
||||
if($order_str)
|
||||
$result->order($order_str);
|
||||
|
|
|
@ -156,8 +156,7 @@ class Posts
|
|||
|
||||
function find(string $query = "", array $params = [], array $order = ['type' => 'id', 'invert' => false]): Util\EntityStream
|
||||
{
|
||||
$query = "%$query%";
|
||||
$result = $this->posts->where("content LIKE ?", $query)->where("deleted", 0)->where("suggested", 0);
|
||||
$result = $this->posts->where("content LIKE ?", "%$query%")->where("deleted", 0)->where("suggested", 0);
|
||||
$order_str = 'id';
|
||||
|
||||
switch($order['type']) {
|
||||
|
|
|
@ -56,8 +56,7 @@ class Users
|
|||
|
||||
function find(string $query, array $params = [], array $order = ['type' => 'id', 'invert' => false]): Util\EntityStream
|
||||
{
|
||||
$query = "%$query%";
|
||||
$result = $this->users->where("CONCAT_WS(' ', first_name, last_name, pseudo, shortcode) LIKE ?", $query)->where("deleted", 0);
|
||||
$result = $this->users->where("CONCAT_WS(' ', first_name, last_name, pseudo, shortcode) LIKE ?", "%$query%")->where("deleted", 0);
|
||||
$order_str = 'id';
|
||||
|
||||
switch($order['type']) {
|
||||
|
|
|
@ -48,8 +48,7 @@ class Videos
|
|||
|
||||
function find(string $query = "", array $params = [], array $order = ['type' => 'id', 'invert' => false]): Util\EntityStream
|
||||
{
|
||||
$query = "%$query%";
|
||||
$result = $this->videos->where("CONCAT_WS(' ', name, description) LIKE ?", $query)->where("deleted", 0);
|
||||
$result = $this->videos->where("CONCAT_WS(' ', name, description) LIKE ?", "%$query%")->where("deleted", 0);
|
||||
$order_str = 'id';
|
||||
|
||||
switch($order['type']) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="playlistInfo">
|
||||
<div class="playlistInfoTopPart">
|
||||
<span class="playlistName noOverflow">
|
||||
{$playlist->getName()}
|
||||
{$playlist->getName(), 15}
|
||||
</span>
|
||||
<span n:if='!empty($playlist->getDescription())' class="playlistDesc noOverflow">
|
||||
{$playlist->getDescription()}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
|
||||
<div class='page_wrap_content' id='search_page'>
|
||||
<div n:class='page_wrap_content_main, $section == "audios" && $count > 0 ? audios_padding'>
|
||||
<div n:class='page_wrap_content_main, $section == "audios" ? audios_padding'>
|
||||
{if $count > 0}
|
||||
{if $section === 'users'}
|
||||
<div class='search_content def_row_content' n:foreach="$data as $dat">
|
||||
|
|
Loading…
Reference in a new issue