Compare commits

..

1 commit

Author SHA1 Message Date
mrilyew
43751c6d65
Merge 3d2036345b into b3e57147b7 2024-10-22 18:46:33 +03:00
10 changed files with 28 additions and 45 deletions

View file

@ -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)
];
}

View file

@ -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)
"items" => $this->get(implode(',', $array), $fields, $offset, $count)
];
}

View file

@ -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']) {

View file

@ -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;

View file

@ -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);

View file

@ -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']) {

View file

@ -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']) {

View file

@ -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']) {

View file

@ -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()}

View file

@ -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">