feat(global): news on left menu

Co-Authored-By: Vladimir Barinov <22993408+veselcraft@users.noreply.github.com>
This commit is contained in:
Slava Petrov 2024-12-20 17:45:38 +03:00
parent 7977a84b49
commit 7d6a8fbbbf
6 changed files with 25 additions and 10 deletions

View file

@ -7,7 +7,7 @@ use Chandler\Security\Authenticator;
use Latte\Engine as TemplatingEngine;
use openvk\Web\Models\Entities\IP;
use openvk\Web\Themes\Themepacks;
use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets, Reports, CurrentUser};
use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets, Reports, CurrentUser, Posts};
use WhichBrowser;
abstract class OpenVKPresenter extends SimplePresenter
@ -207,6 +207,16 @@ abstract class OpenVKPresenter extends SimplePresenter
$userValidated = 0;
$cacheTime = OPENVK_ROOT_CONF["openvk"]["preferences"]["nginxCacheTime"] ?? 0;
if(OPENVK_ROOT_CONF['openvk']['preferences']['news']['show']) {
$post = (new Posts)->getPostsFromUsersWall(-OPENVK_ROOT_CONF['openvk']['preferences']['news']['groupId'], 1, 1);
$post = iterator_to_array($post)[0];
$text = wordwrap($post->getText(false), 150, '\n', false);
$text = explode('\n', $text)[0];
$this->template->newsText = $text;
$this->template->newsLink = '/wall' . $post->getPrettyId();
}
if(!is_null($user)) {
$this->user = (object) [];
$this->user->raw = $user;

View file

@ -240,12 +240,12 @@
</a>
</div>
<div id="news" n:if="OPENVK_ROOT_CONF['openvk']['preferences']['news']['enable']">
<div id="news" n:if="OPENVK_ROOT_CONF['openvk']['preferences']['news']['show']">
<b>{_news} </b>
<hr size="1">
<text>{php echo OPENVK_ROOT_CONF['openvk']['preferences']['news']['title'];}</text>
<text>{$newsText}...</text>
<br><br>
<a href="{php echo OPENVK_ROOT_CONF['openvk']['preferences']['news']['link'];}">{_news_more} »</a>
<a href="{$newsLink}">{_news_more}</a>
</div>
<div n:if="OPENVK_ROOT_CONF['openvk']['preferences']['commerce'] && $thisUser->getCoins() != 0" id="votesBalance">

View file

@ -2314,8 +2314,7 @@ li {
user-select: none;
}
#news b
{
#news b {
color: #8A0000;
font-size: 12px;
}

View file

@ -1059,11 +1059,12 @@
"time_today" = "today";
"time_yesterday" = "yesterday";
"news" = "News";
"news_more" = "More »";
"points" = "Votes";
"points_count" = "votes";
"on_your_account" = "on your account";
"top_up_your_account" = "Get more";
"news_more" = "More";
"you_still_have_x_points" = "You have <b>$1</b> unused votes.";
"vouchers" = "Vouchers";

View file

@ -1010,12 +1010,14 @@
"time_minutes_ago" = "$1 минут назад";
"time_today" = "сегодня";
"time_yesterday" = "вчера";
"news" = "Новости";
"news_more" = "Подробнее »";
"points" = "Голоса";
"points_count" = "голосов";
"on_your_account" = "на вашем счету";
"top_up_your_account" = "Пополнить баланс";
"you_still_have_x_points" = "У Вас <b>$1</b> неиспользованных голосов.";
"news_more" = "Подробнее";
"vouchers" = "Ваучеры";
"have_voucher" = "Есть ваучер";
"voucher_token" = "Код ваучера";

View file

@ -112,6 +112,9 @@ openvk:
defaultMobileTheme: ""
defaultFeaturePhoneTheme: ""
logs: true
news:
show: false
groupId: 1
telemetry:
plausible: