mirror of
https://github.com/openvk/openvk
synced 2025-07-07 08:19:49 +03:00
rrrrrrrrrrrrrrrr
Добавил параметры в vkapi users.search(), пофиксил проверку коммерции, сузил параметры ещё больше и добавил анимацию выдвижения поиска чтобы красиво было
This commit is contained in:
parent
c0fb978786
commit
db0a53f769
5 changed files with 118 additions and 23 deletions
|
@ -150,7 +150,10 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "interests":
|
||||
$response[$i]->interests = $usr->getInterests();
|
||||
break;
|
||||
break;
|
||||
case "rating":
|
||||
$response[$i]->rating = $usr->getRating();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,19 +191,94 @@ final class Users extends VKAPIRequestHandler
|
|||
];
|
||||
}
|
||||
|
||||
function search(string $q, string $fields = "", int $offset = 0, int $count = 100)
|
||||
function search(string $q,
|
||||
string $fields = "",
|
||||
int $offset = 0,
|
||||
int $count = 100,
|
||||
string $city = "",
|
||||
string $hometown = "",
|
||||
int $sex = 2,
|
||||
int $status = 0, # это про marital status
|
||||
bool $online = false,
|
||||
# дальше идут параметры которых нету в vkapi но есть на сайте
|
||||
string $profileStatus = "", # а это уже нормальный статус
|
||||
int $sort = 0,
|
||||
int $before = 0,
|
||||
int $politViews = 0,
|
||||
int $after = 0,
|
||||
string $interests = "",
|
||||
string $fav_music = "",
|
||||
string $fav_films = "",
|
||||
string $fav_shows = "",
|
||||
string $fav_books = "",
|
||||
string $fav_quotes = ""
|
||||
)
|
||||
{
|
||||
$users = new UsersRepo;
|
||||
|
||||
$sortg = "id ASC";
|
||||
|
||||
$nfilds = $fields;
|
||||
|
||||
switch($sort) {
|
||||
case 0:
|
||||
$sortg = "id DESC";
|
||||
break;
|
||||
case 1:
|
||||
$sortg = "id ASC";
|
||||
break;
|
||||
case 2:
|
||||
$sortg = "first_name DESC";
|
||||
break;
|
||||
case 3:
|
||||
$sortg = "first_name ASC";
|
||||
break;
|
||||
case 4:
|
||||
$sortg = "rating DESC";
|
||||
|
||||
if(!str_contains($nfilds, "rating")) {
|
||||
$nfilds .= "rating";
|
||||
}
|
||||
|
||||
break;
|
||||
case 5:
|
||||
$sortg = "rating DESC";
|
||||
|
||||
if(!str_contains($nfilds, "rating")) {
|
||||
$nfilds .= "rating";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$array = [];
|
||||
$find = $users->find($q);
|
||||
|
||||
$parameters = [
|
||||
"city" => !empty($city) ? $city : NULL,
|
||||
"hometown" => !empty($hometown) ? $hometown : NULL,
|
||||
"gender" => $sex < 2 ? $sex : NULL,
|
||||
"maritalstatus" => (bool)$status ? $status : NULL,
|
||||
"politViews" => (bool)$politViews ? $politViews : NULL,
|
||||
"is_online" => $online ? 1 : NULL,
|
||||
"status" => !empty($profileStatus) ? $profileStatus : NULL,
|
||||
"before" => $before != 0 ? $before : NULL,
|
||||
"after" => $after != 0 ? $after : NULL,
|
||||
"interests" => !empty($interests) ? $interests : NULL,
|
||||
"fav_music" => !empty($fav_music) ? $fav_music : NULL,
|
||||
"fav_films" => !empty($fav_films) ? $fav_films : NULL,
|
||||
"fav_shows" => !empty($fav_shows) ? $fav_shows : NULL,
|
||||
"fav_books" => !empty($fav_books) ? $fav_books : NULL,
|
||||
"fav_quotes" => !empty($fav_quotes) ? $fav_quotes : NULL,
|
||||
];
|
||||
|
||||
$find = $users->find($q, $parameters, $sortg);
|
||||
|
||||
foreach ($find as $user)
|
||||
$array[] = $user->getId();
|
||||
|
||||
return (object) [
|
||||
"count" => $find->size(),
|
||||
"items" => $this->get(implode(',', $array), $fields, $offset, $count)
|
||||
"items" => $this->get(implode(',', $array), $nfilds, $offset, $count)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<a href="/logout?hash={urlencode($csrfToken)}">{_header_log_out}</a>
|
||||
</div>
|
||||
{var $atSearch = str_contains($_SERVER['REQUEST_URI'], "/search")}
|
||||
<div class="{if $atSearch}nodivider{else}link{/if}">
|
||||
<div id="srch" class="{if $atSearch}nodivider{else}link{/if}">
|
||||
|
||||
{if !$atSearch}
|
||||
<form action="/search" method="get" id="searcher" style="position:relative;">
|
||||
|
@ -105,7 +105,7 @@
|
|||
</form>
|
||||
{else}
|
||||
<form action="/search" method="get" id="searcher" style="margin-top: -1px;position:relative;">
|
||||
<input id="searchInput" value="{$_GET['query'] ?? ''}" type="search" class="sr" name="query" placeholder="{_header_search}" style="height: 20px;background: url('/assets/packages/static/openvk/img/search_icon.png') no-repeat 3px 4px; background-color: #fff; padding-left: 18px;width: 555px;" title="{_header_search} [Alt+Shift+F]" accesskey="f" />
|
||||
<input id="searchInput" value="{$_GET['query'] ?? ''}" type="search" class="sr" name="query" placeholder="{_header_search}" style="height: 20px; background-color: #fff; padding-left: 6px;width: 555px;" title="{_header_search} [Alt+Shift+F]" accesskey="f" />
|
||||
<select name="type" class="whatFind">
|
||||
<option value="users" {if str_contains($_SERVER['REQUEST_URI'], "type=users")}selected{/if}>{_s_by_people}</option>
|
||||
<option value="groups" {if str_contains($_SERVER['REQUEST_URI'], "type=groups")}selected{/if}>{_s_by_groups}</option>
|
||||
|
@ -114,7 +114,7 @@
|
|||
<option value="videos" {if str_contains($_SERVER['REQUEST_URI'], "type=videos")}selected{/if}>{_s_by_videos}</option>
|
||||
<option value="apps" {if str_contains($_SERVER['REQUEST_URI'], "type=apps")}selected{/if}>{_s_by_apps}</option>
|
||||
</select>
|
||||
<button class="searchBtn">{_search_button}</button>
|
||||
<button class="searchBtn"><span style="color:white;font-weight: 600;font-size:12px;">{_header_search}</span></button>
|
||||
</form>
|
||||
<script>
|
||||
let els = document.querySelectorAll("div.dec")
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
{if $type != "apps"}
|
||||
<text style="overflow: hidden;"> {$x->getCanonicalName()}
|
||||
{if $_GET['sort'] == "rating"}({$x->getRating()}%)
|
||||
{elseif $_GET['sort'] == "id" || $_GET['sort'] == "random"}(id{$x->getId()}){/if}</text>
|
||||
{elseif $_GET['sort'] == "id"}(id{$x->getId()}){/if}</text>
|
||||
<img n:if="$x->isVerified()"
|
||||
class="name-checkmark"
|
||||
src="/assets/packages/static/openvk/img/checkmark.png"
|
||||
|
@ -154,7 +154,7 @@
|
|||
{include searchOptions}
|
||||
|
||||
{var $data = is_array($iterator) ? $iterator : iterator_to_array($iterator)}
|
||||
<div class="container_gray borderup" style="float:left;width:70%;">
|
||||
<div class="container_gray borderup" style="float:left;width:73.3%;">
|
||||
{if sizeof($data) > 0}
|
||||
{if $type == "users" || $type == "groups" || $type == "apps"}
|
||||
<div class="content" n:foreach="$data as $dat">
|
||||
|
@ -247,16 +247,16 @@
|
|||
<div class="searchOption">
|
||||
<div class="searchOptionName" id="n_sort" onclick="hideParams('sort')"><img src="/assets/packages/static/openvk/img/hide.png" class="searchHide">{_s_order_by}</div>
|
||||
<div class="searchOptionBlock" id="s_sort">
|
||||
<select name="sort" form="searcher" id="sortyor" onchange="this.value == 'random' ? document.getElementById('invertor').setAttribute('hidden', 'hidden') : document.getElementById('invertor').removeAttribute('hidden')">
|
||||
<select name="sort" form="searcher" id="sortyor">
|
||||
<option value="id" {if $_GET["sort"] == "name"}selected{/if}>{_s_order_by_id}</option>
|
||||
{if $type == "users"}
|
||||
<option value="name" {if $_GET["sort"] == "name"}selected{/if}>{_s_order_by_name}</option>
|
||||
{if OPENVK_ROOT_CONF["preferences"]["commerce"] != "false"}
|
||||
{if OPENVK_ROOT_CONF["openvk"]["preferences"]["commerce"]}
|
||||
<option value="rating" {if $_GET["sort"] == "rating"}selected{/if}>{_s_order_by_rating}</option>
|
||||
{/if}
|
||||
{/if}
|
||||
</select>
|
||||
<div id="invertor" {if $_GET["sort"] == "random"}hidden{/if}>
|
||||
<div id="invertor">
|
||||
<input type="checkbox" name="invert" value="1" form="searcher" {if !is_null($_GET['invert']) && $_GET['invert'] == "1"}checked{/if}>{_s_order_invert}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -307,7 +307,7 @@
|
|||
</div>
|
||||
|
||||
<div class="searchOption">
|
||||
<div class="searchOptionName" id="n_relationship" onclick="hideParams('relationship')"><img src="/assets/packages/static/openvk/img/hide.png" class="searchHide">{_relationship}</div>
|
||||
<div class="searchOptionName" id="n_relationship" onclick="hideParams('relationship')"><img src="/assets/packages/static/openvk/img/hide.png" class="searchHide">{ovk_proc_strtr(tr("relationship"), 14)}</div>
|
||||
<div class="searchOptionBlock" id="s_relationship">
|
||||
<select name="maritalstatus" form="searcher">
|
||||
<option n:foreach="range(0, 8) as $i" value="{$i}" {if $_GET['maritalstatus'] == $i}selected{/if} form="searcher">
|
||||
|
|
|
@ -2312,9 +2312,8 @@ a.poll-retract-vote {
|
|||
|
||||
.searchOptions
|
||||
{
|
||||
overflow-y: hidden;
|
||||
overflow-x:hidden;
|
||||
width:28.8%;
|
||||
overflow: hidden;
|
||||
width:25.5%;
|
||||
border-top:1px solid #E5E7E6;
|
||||
float:right;
|
||||
scrollbar-width: none;
|
||||
|
@ -2333,6 +2332,7 @@ a.poll-retract-vote {
|
|||
width:80px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0px 2px 0px 0px rgba(255, 255, 255, 0.18) inset;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.searchBtn:active
|
||||
|
@ -2360,8 +2360,8 @@ a.poll-retract-vote {
|
|||
border: solid 0.125rem #696969;
|
||||
background:linear-gradient(#888888,#858585);
|
||||
margin-bottom:2px;
|
||||
padding-left:5px;
|
||||
width:90%;
|
||||
padding-left:9px;
|
||||
width:87%;
|
||||
}
|
||||
|
||||
.searchList #used a
|
||||
|
@ -2388,7 +2388,7 @@ a.poll-retract-vote {
|
|||
padding-top:5px;
|
||||
padding-bottom:5px;
|
||||
margin-bottom:2px;
|
||||
padding-left:5px;
|
||||
padding-left:9px;
|
||||
}
|
||||
|
||||
.searchList li a
|
||||
|
@ -2405,7 +2405,7 @@ a.poll-retract-vote {
|
|||
padding-top:5px;
|
||||
padding-bottom:5px;
|
||||
margin-bottom:2px;
|
||||
padding-left:5px;
|
||||
padding-left:9px;
|
||||
width:91%;
|
||||
}
|
||||
|
||||
|
@ -2419,6 +2419,7 @@ a.poll-retract-vote {
|
|||
cursor:pointer;
|
||||
right:80px;
|
||||
text-align:right;
|
||||
margin-top: 0.5px;
|
||||
}
|
||||
|
||||
.searchOptionName
|
||||
|
@ -2431,6 +2432,7 @@ a.poll-retract-vote {
|
|||
width: 90%;
|
||||
font-weight: 600;
|
||||
color: #585858;
|
||||
border-bottom: 2px solid #E4E4E4;
|
||||
}
|
||||
|
||||
.searchOption
|
||||
|
@ -2464,6 +2466,11 @@ a.poll-retract-vote {
|
|||
border-top:1px solid #E5E7E6;
|
||||
}
|
||||
|
||||
#searchInput
|
||||
{
|
||||
transition: .3s linear;
|
||||
}
|
||||
|
||||
#standaloneCommentBox {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
|
|
|
@ -580,6 +580,10 @@ function expandSearch()
|
|||
document.querySelector(".whatFind").style.display = "block";
|
||||
document.querySelector(".whatFind").style.marginRight = "-80px";
|
||||
document.getElementById("searchInput").style.width = "627px";
|
||||
document.getElementById("searchInput").style.background = "none";
|
||||
document.getElementById("searchInput").style.backgroundColor = "#fff";
|
||||
document.getElementById("searchInput").style.paddingLeft = "6px";
|
||||
srch.classList.add("nodivider")
|
||||
}
|
||||
|
||||
async function decreaseSearch()
|
||||
|
@ -589,14 +593,20 @@ async function decreaseSearch()
|
|||
// console.log("search decreased")
|
||||
if(document.activeElement !== searchInput)
|
||||
{
|
||||
document.getElementById("searchInput").style.background = "url('/assets/packages/static/openvk/img/search_icon.png') no-repeat 3px 4px";
|
||||
document.getElementById("searchInput").style.backgroundColor = "#fff";
|
||||
document.getElementById("searchInput").style.paddingLeft = "18px";
|
||||
document.getElementById("searchInput").style.width = "120px";
|
||||
document.querySelector(".whatFind").style.display = "none";
|
||||
|
||||
await new Promise(r => setTimeout(r, 300));
|
||||
srch.classList.remove("nodivider")
|
||||
|
||||
let els = document.querySelectorAll("div.dec")
|
||||
for(const element of els)
|
||||
{
|
||||
element.style.display = "inline-block"
|
||||
}
|
||||
|
||||
document.querySelector(".whatFind").style.display = "none";
|
||||
document.getElementById("searchInput").style.width = "120px";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue