Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ServiceAPI/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public function fetch(callable $resolve, callable $reject): void
}

$tplDir = __DIR__ . "/../Web/Presenters/templates/components/notifications/";
$tplId = "$tplDir$data->actionCode/_$data->originModelType" . "_" . $data->targetModelType . "_.xml";
$tplId = "$tplDir$data->actionCode/_$data->originModelType" . "_" . $data->targetModelType . "_.latte";
$latte = new TemplatingEngine();
$latte->setTempDirectory(CHANDLER_ROOT . "/tmp/cache/templates");
$latte->addFilter("translate", fn($trId) => tr($trId));
$latte->addExtension(new \Latte\Essential\TranslatorExtension(tr(...)));
$resolve([
"title" => tr("notif_" . $data->actionCode . "_" . $data->originModelType . "_" . $data->targetModelType),
"body" => trim(preg_replace('%(\s){2,}%', "$1", $latte->renderToString($tplId, ["notification" => $notification]))),
Expand Down
2 changes: 1 addition & 1 deletion Web/Models/Entities/Notifications/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getTemplatePath(): string
"./../components/notifications/$this->actionCode/",
$this->encodeType($this->originModel),
$this->encodeType($this->targetModel),
".xml",
".latte",
]);
}

Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/AudioPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function renderNew(): void
public function renderList(?int $owner = null, ?string $mode = "list"): void
{
$this->assertUserLoggedIn();
$this->template->_template = "Audio/List.xml";
$this->template->_template = "Audio/List.latte";
$page = (int) ($this->queryParam("p") ?? 1);
$audios = [];

Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/AuthPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function renderLogin(): void
$secret = $user->related("profiles.user")->fetch()["2fa_secret"];
$code = $this->postParam("code");
if (!is_null($secret)) {
$this->template->_template = "Auth/LoginSecondFactor.xml";
$this->template->_template = "Auth/LoginSecondFactor.latte";
$this->template->login = $this->postParam("login");
$this->template->password = $this->postParam("password");

Expand Down
4 changes: 2 additions & 2 deletions Web/Presenters/DocumentsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function renderList(?int $owner_id = null): void
{
$this->assertUserLoggedIn();

$this->template->_template = "Documents/List.xml";
$this->template->_template = "Documents/List.latte";
if ($owner_id > 0) {
$this->notFound();
}
Expand Down Expand Up @@ -61,7 +61,7 @@ public function renderList(?int $owner_id = null): void
$this->template->page = $page;
$this->template->count = $docs->size();
$this->template->pagesCount = ceil($this->template->count / OPENVK_DEFAULT_PER_PAGE);
$this->template->_template = "Documents/ApiGetContext.xml";
$this->template->_template = "Documents/ApiGetContext.latte";
return;
}

Expand Down
6 changes: 3 additions & 3 deletions Web/Presenters/GiftsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function renderGiftMenu(): void
$this->template->user = $user;
$this->template->iterator = $cats;
$this->template->count = $this->gifts->getCategoriesCount();
$this->template->_template = "Gifts/Menu.xml";
$this->template->_template = "Gifts/Menu.latte";
}

public function renderGiftList(): void
Expand All @@ -73,7 +73,7 @@ public function renderGiftList(): void
$this->template->user = $user;
$this->template->cat = $cat;
$this->template->gifts = iterator_to_array($gifts);
$this->template->_template = "Gifts/Pick.xml";
$this->template->_template = "Gifts/Pick.latte";
}

public function renderConfirmGift(): void
Expand All @@ -98,7 +98,7 @@ public function renderConfirmGift(): void
$this->flashFail("err", tr("error_when_gifting"), tr("error_no_money"));
}

$this->template->_template = "Gifts/Confirm.xml";
$this->template->_template = "Gifts/Confirm.latte";
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
$this->template->user = $user;
$this->template->cat = $cat;
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/GroupPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function renderView(int $id): void
$this->notFound();
} else {
if ($club->isBanned()) {
$this->template->_template = "Group/Banned.xml";
$this->template->_template = "Group/Banned.latte";
} else {
$docs = (new Documents())->getDocumentsByOwner($club->getRealId());
$this->template->albums = (new Albums())->getClubAlbums($club, 1, 3);
Expand Down
4 changes: 2 additions & 2 deletions Web/Presenters/InternalAPIPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ public function renderGetPostTemplate(int $owner_id, int $post_id)
header("Content-Type: text/plain");

if ($type == 'post') {
$this->template->_template = 'components/post.xml';
$this->template->_template = 'components/post.latte';
$this->template->post = $post;
$this->template->commentSection = $this->queryParam("from_page") == "another";
} elseif ($type == 'comment') {
$this->template->_template = 'components/comment.xml';
$this->template->_template = 'components/comment.latte';
$this->template->comment = $post;
} else {
exit('');
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/NoSpamPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function renderIndex(): void

$this->template->models = $sortedModels;
} elseif ($mode === "templates") {
$this->template->_template = "NoSpam/Templates.xml";
$this->template->_template = "NoSpam/Templates.latte";
$this->template->disable_ajax = 1;
$filter = [];
if ($this->queryParam("id")) {
Expand Down
10 changes: 4 additions & 6 deletions Web/Presenters/OpenVKPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ protected function sendmail(string $to, string $template, array $params = []): v
public function getTemplatingEngine(): TemplatingEngine
{
$latte = parent::getTemplatingEngine();
$latte->addFilter("translate", function ($s) {
return tr($s);
});
$latte->addExtension(new \Latte\Essential\TranslatorExtension(tr(...)));

return $latte;
}
Expand Down Expand Up @@ -241,7 +239,7 @@ public function onStartup(): void
if ($this->user->identity->isDeleted() && !$this->deactivationTolerant) {
if ($this->user->identity->isDeactivated()) {
header("HTTP/1.1 403 Forbidden");
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@deactivated.xml", [
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@deactivated.latte", [
"thisUser" => $this->user->identity,
"csrfToken" => $GLOBALS["csrfToken"],
"isTimezoned" => Session::i()->get("_timezoneOffset"),
Expand All @@ -257,7 +255,7 @@ public function onStartup(): void

if ($this->user->identity->isBanned() && !$this->banTolerant) {
header("HTTP/1.1 403 Forbidden");
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@banned.xml", [
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@banned.latte", [
"thisUser" => $this->user->identity,
"csrfToken" => $GLOBALS["csrfToken"],
"isTimezoned" => Session::i()->get("_timezoneOffset"),
Expand All @@ -268,7 +266,7 @@ public function onStartup(): void
# ето для емейл уже надо (и по хорошему надо бы избавится от повторяющегося кода мда)
if (!$this->user->identity->isActivated() && !$this->activationTolerant) {
header("HTTP/1.1 403 Forbidden");
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@email.xml", [
$this->getTemplatingEngine()->render(__DIR__ . "/templates/@email.latte", [
"thisUser" => $this->user->identity,
"csrfToken" => $GLOBALS["csrfToken"],
"isTimezoned" => Session::i()->get("_timezoneOffset"),
Expand Down
2 changes: 1 addition & 1 deletion Web/Presenters/PhotosPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function renderAbsolutePhoto($id): void
$this->notFound();
}

$this->template->_template = "Photos/Photo.xml";
$this->template->_template = "Photos/Photo.latte";
$this->renderPhoto($photo->getOwner(true)->getId(), $photo->getVirtualId());
}

Expand Down
4 changes: 2 additions & 2 deletions Web/Presenters/PollPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function renderView(int $id): void
if ((is_null($this->user) || $poll->canVote($this->user->identity)) && !$ended) {
$this->template->options = $poll->getOptions();

$this->template->_template = "Poll/Poll.xml";
$this->template->_template = "Poll/Poll.latte";
return;
}

Expand All @@ -49,7 +49,7 @@ public function renderView(int $id): void
$this->template->results = $poll->getResults($this->user->identity);
}

$this->template->_template = "Poll/PollResults.xml";
$this->template->_template = "Poll/PollResults.latte";
}

public function renderVoters(int $pollId): void
Expand Down
12 changes: 6 additions & 6 deletions Web/Presenters/UserPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ public function renderView(int $id): void

if (!$user || $user->isDeleted() || !$user->canBeViewedBy($this->user->identity)) {
if (!is_null($user) && $user->isDeactivated()) {
$this->template->_template = "User/deactivated.xml";
$this->template->_template = "User/deactivated.latte";

$this->template->user = $user;
} elseif (!is_null($user) && $this->user->identity && $this->user->identity->isBlacklistedBy($user)) {
$this->template->_template = "User/blacklisted.xml";
$this->template->_template = "User/blacklisted.latte";

$this->template->blacklist_status = $user->isBlacklistedBy($this->user->identity);
$this->template->ignore_status = $user->isIgnoredBy($this->user->identity);
$this->template->user = $user;
} elseif (!is_null($user) && $user->isBlacklistedBy($this->user->identity)) {
$this->template->_template = "User/blacklisted_pov.xml";
$this->template->_template = "User/blacklisted_pov.latte";

$this->template->ignore_status = $user->isIgnoredBy($this->user->identity);
$this->template->user = $user;
} elseif (!is_null($user) && !$user->canBeViewedBy($this->user->identity)) {
$this->template->_template = "User/private.xml";
$this->template->_template = "User/private.latte";

$this->template->user = $user;
} else {
$this->template->_template = "User/deleted.xml";
$this->template->_template = "User/deleted.latte";
}
} else {
$this->template->albums = (new Albums())->getUserAlbums($user);
Expand Down Expand Up @@ -762,7 +762,7 @@ public function renderTwoFactorAuthSettings(): void
}

$this->user->identity->generate2faBackupCodes();
$this->template->_template = "User/TwoFactorAuthCodes.xml";
$this->template->_template = "User/TwoFactorAuthCodes.latte";
$this->template->codes = $this->user->identity->get2faBackupCodes();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Web/Presenters/WallPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function renderWall(int $user, bool $embedded = false): void
}

if ($embedded == true) {
$this->template->_template = "components/wall.xml";
$this->template->_template = "components/wall.latte";
}
$this->template->oObj = $owner;
if ($user < 0) {
Expand Down Expand Up @@ -233,7 +233,7 @@ public function renderGlobalFeed(): void
$posts = DatabaseConnection::i()->getConnection()->query("SELECT `posts`.`id` " . $queryBase . " ORDER BY `created` DESC LIMIT " . $pPage . " OFFSET " . ($page - 1) * $pPage);
$count = DatabaseConnection::i()->getConnection()->query("SELECT COUNT(*) " . $queryBase)->fetch()->{"COUNT(*)"};

$this->template->_template = "Wall/Feed.xml";
$this->template->_template = "Wall/Feed.latte";
$this->template->globalFeed = true;
$this->template->paginatorConf = (object) [
"count" => $count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
</div>

<div style="padding: 8px;">
{include "components/paginator.xml", conf => (object) [
{include "components/paginator.latte", conf => (object) [
"page" => $page,
"count" => $count,
"amount" => sizeof($data),
"perPage" => $perPage ?? OPENVK_DEFAULT_PER_PAGE,
"perPage" => $perPage ?? \OPENVK_DEFAULT_PER_PAGE,
]}
</div>
{else}
{ifset customErrorMessage}
{include customErrorMessage}
{else}
{include "components/nothing.xml"}
{include "components/nothing.latte"}
{/ifset}
{/if}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{extends "@layout.xml"}
{extends "@layout.latte"}

{block wrap}
<div class="ovk-lw-container">
Expand Down Expand Up @@ -32,18 +32,18 @@
<br/>

<div style="padding: 8px;">
{include "components/paginator.xml", conf => (object) [
{include "components/paginator.latte", conf => (object) [
"page" => $page,
"count" => $count,
"amount" => sizeof($data),
"perPage" => $perPage ?? OPENVK_DEFAULT_PER_PAGE,
"perPage" => $perPage ?? \OPENVK_DEFAULT_PER_PAGE,
]}
</div>
{else}
{ifset customErrorMessage}
{include customErrorMessage}
{else}
{include "components/nothing.xml"}
{include "components/nothing.latte"}
{/ifset}
{/if}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{extends "@layout.xml"}
{extends "@layout.latte"}
{block title}{_banned_title}{/block}

{block header}
Expand All @@ -19,7 +19,7 @@
<div>
Эта страница была заморожена {$ban[0]|noescape}
{if $ban[1] !== "app"}
{include "Report/ViewContent.xml", type => $ban[1], object => $ban[2]}
{include "Report/ViewContent.latte", type => $ban[1], object => $ban[2]}
{/if}
</div>
{/if}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{extends "@layout.xml"}
{extends "@layout.latte"}
{block title}{$thisUser->getCanonicalName()}{/block}

{block header}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{extends "@layout.xml"}
{extends "@layout.latte"}
{block title}{_ec_header}{/block}

{block header}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{var $instance_name = OPENVK_ROOT_CONF['openvk']['appearance']['name']}
{var $instance_name = \OPENVK_ROOT_CONF['openvk']['appearance']['name']}
<!DOCTYPE html>
<html>
<head>
Expand Down
Loading
Loading