Maybe it works

This commit is contained in:
lalka2016 2023-08-11 10:01:54 +03:00
parent 7f46d683c3
commit dafc18c118
23 changed files with 163 additions and 26 deletions

View file

@ -1113,6 +1113,11 @@ class User extends RowModel
return true; return true;
} }
function getPaginatorType()
{
return $this->getRecord()->paginator_type;
}
function toVkApiStruct(): object function toVkApiStruct(): object
{ {
$res = (object) []; $res = (object) [];

View file

@ -27,7 +27,7 @@ final class PhotosPresenter extends OpenVKPresenter
if(!$user) $this->notFound(); if(!$user) $this->notFound();
if (!$user->getPrivacyPermission('photos.read', $this->user->identity ?? NULL)) if (!$user->getPrivacyPermission('photos.read', $this->user->identity ?? NULL))
$this->flashFail("err", tr("forbidden"), tr("forbidden_comment")); $this->flashFail("err", tr("forbidden"), tr("forbidden_comment"));
$this->template->albums = $this->albums->getUserAlbums($user, $this->queryParam("p") ?? 1); $this->template->albums = $this->albums->getUserAlbums($user, (int)($this->queryParam("p") ?? 1));
$this->template->count = $this->albums->getUserAlbumsCount($user); $this->template->count = $this->albums->getUserAlbumsCount($user);
$this->template->owner = $user; $this->template->owner = $user;
$this->template->canEdit = false; $this->template->canEdit = false;
@ -36,7 +36,7 @@ final class PhotosPresenter extends OpenVKPresenter
} else { } else {
$club = (new Clubs)->get(abs($owner)); $club = (new Clubs)->get(abs($owner));
if(!$club) $this->notFound(); if(!$club) $this->notFound();
$this->template->albums = $this->albums->getClubAlbums($club, $this->queryParam("p") ?? 1); $this->template->albums = $this->albums->getClubAlbums($club, (int)($this->queryParam("p") ?? 1));
$this->template->count = $this->albums->getClubAlbumsCount($club); $this->template->count = $this->albums->getClubAlbumsCount($club);
$this->template->owner = $club; $this->template->owner = $club;
$this->template->canEdit = false; $this->template->canEdit = false;

View file

@ -471,6 +471,9 @@ final class UserPresenter extends OpenVKPresenter
if(in_array($this->postParam("main_page"), [0, 1])) if(in_array($this->postParam("main_page"), [0, 1]))
$user->setMain_Page((int) $this->postParam("main_page")); $user->setMain_Page((int) $this->postParam("main_page"));
if(in_array($this->postParam("paginator"), [0, 1]))
$user->setPaginator_type((int) $this->postParam("paginator"));
} else if($_GET['act'] === "lMenu") { } else if($_GET['act'] === "lMenu") {
$settings = [ $settings = [
"menu_bildoj" => "photos", "menu_bildoj" => "photos",

View file

@ -15,11 +15,11 @@
{ifset specpage} {ifset specpage}
{include specpage, x => $dat} {include specpage, x => $dat}
{else} {else}
<div class="container_gray"> <div class="container_gray infContainer">
{var $data = is_array($iterator) ? $iterator : iterator_to_array($iterator)} {var $data = is_array($iterator) ? $iterator : iterator_to_array($iterator)}
{if sizeof($data) > 0} {if sizeof($data) > 0}
<div class="content" n:foreach="$data as $dat"> <div class="content infObj" n:foreach="$data as $dat">
<table> <table>
<tbody> <tbody>
<tr> <tr>

View file

@ -60,12 +60,12 @@
} }
</style> </style>
<div class="container_gray" style="background: white; border-top: none;"> <div class="container_gray infContainer" style="background: white; border-top: none;">
{var $data = is_array($iterator) ? $iterator : iterator_to_array($iterator)} {var $data = is_array($iterator) ? $iterator : iterator_to_array($iterator)}
{if sizeof($data) > 0} {if sizeof($data) > 0}
<div n:foreach="$data as $dat"> <div n:foreach="$data as $dat" class="infObj">
<div class="profile_thumb"> <div class="profile_thumb">
<a href="{$owner->getURL()}"> <a href="{$owner->getURL()}">
<img src="{$owner->getAvatarUrl('miniscule')}" style="width: 50px;"> <img src="{$owner->getAvatarUrl('miniscule')}" style="width: 50px;">

View file

@ -562,6 +562,17 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr>
<td width="120" valign="top">
<span class="nobold">{_ui_settings_paginator}</span>
</td>
<td>
<select name="paginator">
<option value="0" {if $user->getPaginatorType() == 0}selected{/if}>{_ui_settings_paginator_old}</option>
<option value="1" {if $user->getPaginatorType() == 1}selected{/if}>{_ui_settings_paginator_new}</option>
</select>
</td>
</tr>
<tr> <tr>
<td width="120" valign="top" align="right"> <td width="120" valign="top" align="right">
<input type="checkbox" name="theme_for_session" value="1"> <input type="checkbox" name="theme_for_session" value="1">

View file

@ -19,12 +19,14 @@
{include "../components/textArea.xml", route => "/wall" . $thisUser->getId() . "/makePost", graffiti => true, polls => true, notes => true} {include "../components/textArea.xml", route => "/wall" . $thisUser->getId() . "/makePost", graffiti => true, polls => true, notes => true}
</div> </div>
<div class="infContainer">
{foreach $posts as $post} {foreach $posts as $post}
<a name="postGarter={$post->getId()}"></a> <a name="postGarter={$post->getId()}"></a>
{include "../components/post.xml", post => $post, onWallOf => true, commentSection => true} {include "../components/post.xml", post => $post, onWallOf => true, commentSection => true}
{/foreach} {/foreach}
</div>
<div class="postFeedBottom"> <div class="postFeedBottom" n:if="$thisUser->getPaginatorType() == 0">
<div class="postFeedPaginator"> <div class="postFeedPaginator">
{include "../components/paginator.xml", conf => $paginatorConf} {include "../components/paginator.xml", conf => $paginatorConf}
</div> </div>
@ -43,6 +45,10 @@
</div> </div>
</div> </div>
{if $thisUser->getPaginatorType() == 1}
{include "../components/paginator.xml", conf => $paginatorConf}
{/if}
<script> <script>
u("#pageSelect").nodes[0].value = {$paginatorConf->perPage}; u("#pageSelect").nodes[0].value = {$paginatorConf->perPage};

View file

@ -6,7 +6,7 @@
{/block} {/block}
{block content} {block content}
<center> <center class="infContainer">
{foreach $posts as $post} {foreach $posts as $post}
<a name="postGarter={$post->getId()}"></a> <a name="postGarter={$post->getId()}"></a>

View file

@ -19,7 +19,7 @@
{include "../components/textArea.xml", route => "/wall$owner/makePost"} {include "../components/textArea.xml", route => "/wall$owner/makePost"}
</div> </div>
<div class="content"> <div class="content infContainer">
{if sizeof($posts) > 0} {if sizeof($posts) > 0}
{foreach $posts as $post} {foreach $posts as $post}
<a name="postGarter={$post->getId()}"></a> <a name="postGarter={$post->getId()}"></a>

View file

@ -3,7 +3,7 @@
{var $postId = $comment->getTarget() instanceof \openvk\Web\Models\Entities\Post ? $comment->getTarget()->getId() : NULL} {var $postId = $comment->getTarget() instanceof \openvk\Web\Models\Entities\Post ? $comment->getTarget()->getId() : NULL}
<a name="cid={$comment->getId()}"></a> <a name="cid={$comment->getId()}"></a>
<table border="0" style="font-size: 11px;" class="post comment" id="_comment{$comment->getId()}" data-comment-id="{$comment->getId()}" data-owner-id="{$author->getId()}" data-from-group="{$comment->getOwner() instanceof $Club}" n:attr="data-post-id => $postId"> <table border="0" style="font-size: 11px;" class="post comment infObj" id="_comment{$comment->getId()}" data-comment-id="{$comment->getId()}" data-owner-id="{$author->getId()}" data-from-group="{$comment->getOwner() instanceof $Club}" n:attr="data-post-id => $postId">
<tbody> <tbody>
<tr> <tr>
<td width="30" valign="top"> <td width="30" valign="top">

View file

@ -8,6 +8,7 @@
{/if} {/if}
</div> </div>
<div class="infContainer">
{if sizeof($comments) > 0} {if sizeof($comments) > 0}
{foreach $comments as $comment} {foreach $comments as $comment}
{include "comment.xml", comment => $comment} {include "comment.xml", comment => $comment}
@ -18,5 +19,6 @@
{else} {else}
{_comments_tip} {_comments_tip}
{/if} {/if}
</div>
{script "js/al_comments.js"} {script "js/al_comments.js"}

View file

@ -1,12 +1,7 @@
{var $space = 3} {var $isNewPaginator = isset($thisUser) && (bool)$thisUser->getPaginatorType()}
{var $pageCount = ceil($conf->count / $conf->perPage)}
<div n:if="!($conf->page === 1 && $conf->count <= $conf->perPage)" style="padding: 8px;"> {if $isNewPaginator}
<div n:class="paginator, ($conf->atBottom ?? false) ? paginator-at-bottom"> {include "paginators/new.xml", conf => $conf}
<a n:if="$conf->page > $space" n:attr="class => ($conf->page === 1 ? 'active')" href="?{http_build_query(array_merge($_GET, ['p' => 1]), 'k', '&', PHP_QUERY_RFC3986)}">&laquo;</a> {else}
{for $j = $conf->page - ($space-1); $j <= $conf->page + ($space-1); $j++} {include "paginators/old.xml", conf => $conf}
<a n:if="$j > 0 && $j <= $pageCount" n:attr="class => ($conf->page === $j ? 'active')" href="?{http_build_query(array_merge($_GET, ['p' => $j]), 'k', '&', PHP_QUERY_RFC3986)}">{$j}</a> {/if}
{/for}
<a n:if="$conf->page <= $pageCount-$space" n:attr="class => ($conf->page === $pageCount ? 'active')" href="?{http_build_query(array_merge($_GET, ['p' => $pageCount]), 'k', '&', PHP_QUERY_RFC3986)}">&raquo;</a>
</div>
</div>

View file

@ -0,0 +1,5 @@
{var $pageCount = ceil($conf->count / $conf->perPage)}
<div n:if="!($conf->page === 1 && $conf->count <= $conf->perPage) && $conf->page < $pageCount" class="showMore" data-pageсount="{$pageCount}" data-page="{$conf->page}">
{_show_more}
</div>

View file

@ -0,0 +1,12 @@
{var $space = 3}
{var $pageCount = ceil($conf->count / $conf->perPage)}
<div n:if="!($conf->page === 1 && $conf->count <= $conf->perPage)" style="padding: 8px;">
<div n:class="paginator, ($conf->atBottom ?? false) ? paginator-at-bottom">
<a n:if="$conf->page > $space" n:attr="class => ($conf->page === 1 ? 'active')" href="?{http_build_query(array_merge($_GET, ['p' => 1]), 'k', '&', PHP_QUERY_RFC3986)}">&laquo;</a>
{for $j = $conf->page - ($space-1); $j <= $conf->page + ($space-1); $j++}
<a n:if="$j > 0 && $j <= $pageCount" n:attr="class => ($conf->page === $j ? 'active')" href="?{http_build_query(array_merge($_GET, ['p' => $j]), 'k', '&', PHP_QUERY_RFC3986)}">{$j}</a>
{/for}
<a n:if="$conf->page <= $pageCount-$space" n:attr="class => ($conf->page === $pageCount ? 'active')" href="?{http_build_query(array_merge($_GET, ['p' => $pageCount]), 'k', '&', PHP_QUERY_RFC3986)}">&raquo;</a>
</div>
</div>

View file

@ -1,7 +1,9 @@
{var $microblogEnabled = isset($thisUser) ? $thisUser->hasMicroblogEnabled() : false} {var $microblogEnabled = isset($thisUser) ? $thisUser->hasMicroblogEnabled() : false}
<div class="infObj">
{if $microblogEnabled} {if $microblogEnabled}
{include "post/microblogpost.xml", post => $post, commentSection => $commentSection} {include "post/microblogpost.xml", post => $post, commentSection => $commentSection}
{else} {else}
{include "post/oldpost.xml", post => $post} {include "post/oldpost.xml", post => $post}
{/if} {/if}
</div>

View file

@ -11,7 +11,7 @@
{include "../components/textArea.xml", route => "/wall$owner/makePost", graffiti => true, polls => true, notes => true} {include "../components/textArea.xml", route => "/wall$owner/makePost", graffiti => true, polls => true, notes => true}
</div> </div>
<div class="content"> <div class="content infContainer">
{if sizeof($posts) > 0} {if sizeof($posts) > 0}
{foreach $posts as $post} {foreach $posts as $post}
<a name="postGarter={$post->getId()}"></a> <a name="postGarter={$post->getId()}"></a>

View file

@ -2695,4 +2695,24 @@ body.article .floating_sidebar, body.article .page_content {
position: absolute; position: absolute;
right: 22px; right: 22px;
font-size: 12px; font-size: 12px;
}
.small_red_button {
float: right;
font-weight: bold;
}
.small_red_button a {
color: #B0B0B0;
}
.small_red_button a:hover {
color: #a7a7a7;
}
.showMore {
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
cursor: pointer;
} }

View file

@ -1,4 +1,4 @@
u(".comment-reply").on("click", function(e) { $(document).on("click", ".comment-reply", function(e) {
let comment = u(e.target).closest(".post"); let comment = u(e.target).closest(".post");
let authorId = comment.data("owner-id"); let authorId = comment.data("owner-id");
let authorNm = u(".post-author > a > b", comment.first()).text().trim(); let authorNm = u(".post-author > a > b", comment.first()).text().trim();

View file

@ -19,6 +19,8 @@ var tooltipTemplate = Handlebars.compile(`
</table> </table>
`); `);
function initMentions() {
tippy(".mention", { tippy(".mention", {
theme: "light vk", theme: "light vk",
content: "⌛", content: "⌛",
@ -40,3 +42,6 @@ tippy(".mention", {
that.setContent(tooltipTemplate(res)); that.setContent(tooltipTemplate(res));
} }
}); });
}
initMentions()

View file

@ -75,7 +75,7 @@ function initGraffiti(id) {
}); });
} }
u(".post-like-button").on("click", function(e) { $(document).on("click", ".post-like-button", function(e) {
e.preventDefault(); e.preventDefault();
var thisBtn = u(this).first(); var thisBtn = u(this).first();
@ -118,7 +118,7 @@ function setupWallPostInputHandlers(id) {
}); });
} }
u("#write > form").on("keydown", function(event) { $(document).on("keydown", "#write > form", function(event) {
if(event.ctrlKey && event.keyCode === 13) if(event.ctrlKey && event.keyCode === 13)
this.submit(); this.submit();
}); });
@ -152,6 +152,8 @@ var tooltipClientNoInfoTemplate = Handlebars.compile(`
</table> </table>
`); `);
function initTooltips() {
tippy(".client_app", { tippy(".client_app", {
theme: "light vk", theme: "light vk",
content: "⌛", content: "⌛",
@ -189,6 +191,10 @@ tippy(".client_app", {
} }
}); });
}
initTooltips()
function addNote(textareaId, nid) function addNote(textareaId, nid)
{ {
if(nid > 0) { if(nid > 0) {
@ -262,4 +268,51 @@ async function showArticle(note_id) {
u("#articleText").html(`<h1 class="articleView_nameHeading">${note.title}</h1>` + note.html); u("#articleText").html(`<h1 class="articleView_nameHeading">${note.title}</h1>` + note.html);
u("body").removeClass("dimmed"); u("body").removeClass("dimmed");
u("body").addClass("article"); u("body").addClass("article");
} }
$(document).on("click", ".showMore", async (e) => {
e.currentTarget.innerHTML = `<img id="loader" src="/assets/packages/static/openvk/img/loading_mini.gif">`
let url = new URL(location.href)
let newPage = Number(e.currentTarget.dataset.page) + 1
url.searchParams.set("p", newPage)
let xhr = new XMLHttpRequest
xhr.open("GET", url)
let container = document.querySelector(".infContainer")
function _errorWhenLoading() {
e.currentTarget.innerHTML = tr("error_loading_objects")
}
function _updateButton() {
e.currentTarget.setAttribute("data-page", newPage)
e.currentTarget.innerHTML = tr("show_more")
container.append(e.currentTarget)
console.info("Page " + newPage + " of " + e.currentTarget.dataset.pageсount)
if(Number(e.currentTarget.dataset.pageсount) == newPage) {
e.currentTarget.remove()
}
}
xhr.onload = () => {
let parser = new DOMParser
let result = parser.parseFromString(xhr.responseText, "text/html");
let objects = result.querySelectorAll(".infObj")
for(const obj of objects) {
container.insertAdjacentHTML("beforeend", obj.outerHTML)
}
initMentions()
initTooltips()
_updateButton()
}
xhr.onerror = () => {_errorWhenLoading()}
xhr.ontimeout = () => {_errorWhenLoading()}
xhr.send()
})

View file

@ -0,0 +1 @@
ALTER TABLE `profiles` ADD `paginator_type` TINYINT(1) NOT NULL DEFAULT '0' AFTER `client_name`;

View file

@ -552,6 +552,10 @@
"ui_settings_view_of_posts_old" = "Old"; "ui_settings_view_of_posts_old" = "Old";
"ui_settings_view_of_posts_microblog" = "Microblog"; "ui_settings_view_of_posts_microblog" = "Microblog";
"ui_settings_main_page" = "Main page"; "ui_settings_main_page" = "Main page";
"ui_settings_paginator" = "Paginator";
"ui_settings_paginator_old" = "Old (pages)";
"ui_settings_paginator_new" = "New (infinite scroll)";
"ui_settings_sessions" = "Sessions"; "ui_settings_sessions" = "Sessions";
"additional_links" = "Additional links"; "additional_links" = "Additional links";
@ -1216,6 +1220,11 @@
"paginator_page" = "Page $1"; "paginator_page" = "Page $1";
"paginator_next" = "Next"; "paginator_next" = "Next";
/* Paginator (new) */
"show_more" = "show more";
"error_loading_objects" = "Error when loading new objects. Try to reload page";
/* About */ /* About */
"about_openvk" = "About OpenVK"; "about_openvk" = "About OpenVK";

View file

@ -523,6 +523,9 @@
"ui_settings_view_of_posts_old" = "Старый"; "ui_settings_view_of_posts_old" = "Старый";
"ui_settings_view_of_posts_microblog" = "Микроблог"; "ui_settings_view_of_posts_microblog" = "Микроблог";
"ui_settings_main_page" = "Главная страница"; "ui_settings_main_page" = "Главная страница";
"ui_settings_paginator" = "Пагинатор";
"ui_settings_paginator_old" = "Старый (постраничный)";
"ui_settings_paginator_new" = "Новый (бесконечная прокрутка)";
"ui_settings_sessions" = "Сессии"; "ui_settings_sessions" = "Сессии";
"additional_links" = "Дополнительные ссылки"; "additional_links" = "Дополнительные ссылки";
"ad_poster" = "Рекламный плакат"; "ad_poster" = "Рекламный плакат";
@ -1103,6 +1106,11 @@
"paginator_page" = "Страница $1"; "paginator_page" = "Страница $1";
"paginator_next" = "Дальше"; "paginator_next" = "Дальше";
/* Paginator (new) */
"show_more" = "показать больше";
"error_loading_objects" = "Не удалось загрузить новые объекты. Попробуйте обновить страницу";
/* About */ /* About */
"about_openvk" = "Об OpenVK"; "about_openvk" = "Об OpenVK";