diff --git a/ServiceAPI/Notifications.php b/ServiceAPI/Notifications.php index b78486e25..45f8fabaf 100644 --- a/ServiceAPI/Notifications.php +++ b/ServiceAPI/Notifications.php @@ -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]))), diff --git a/Web/Models/Entities/Notifications/Notification.php b/Web/Models/Entities/Notifications/Notification.php index 8b39c3803..279d758d9 100644 --- a/Web/Models/Entities/Notifications/Notification.php +++ b/Web/Models/Entities/Notifications/Notification.php @@ -55,7 +55,7 @@ public function getTemplatePath(): string "./../components/notifications/$this->actionCode/", $this->encodeType($this->originModel), $this->encodeType($this->targetModel), - ".xml", + ".latte", ]); } diff --git a/Web/Presenters/AudioPresenter.php b/Web/Presenters/AudioPresenter.php index c5c1eecca..43f4cb373 100644 --- a/Web/Presenters/AudioPresenter.php +++ b/Web/Presenters/AudioPresenter.php @@ -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 = []; diff --git a/Web/Presenters/AuthPresenter.php b/Web/Presenters/AuthPresenter.php index 20d8775a7..f2f04933f 100644 --- a/Web/Presenters/AuthPresenter.php +++ b/Web/Presenters/AuthPresenter.php @@ -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"); diff --git a/Web/Presenters/DocumentsPresenter.php b/Web/Presenters/DocumentsPresenter.php index dce7e4e3b..038fd5950 100644 --- a/Web/Presenters/DocumentsPresenter.php +++ b/Web/Presenters/DocumentsPresenter.php @@ -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(); } @@ -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; } diff --git a/Web/Presenters/GiftsPresenter.php b/Web/Presenters/GiftsPresenter.php index ec2993a46..7ea909d80 100644 --- a/Web/Presenters/GiftsPresenter.php +++ b/Web/Presenters/GiftsPresenter.php @@ -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 @@ -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 @@ -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; diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 99d5fa332..a2401f90b 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -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); diff --git a/Web/Presenters/InternalAPIPresenter.php b/Web/Presenters/InternalAPIPresenter.php index eb9daac2e..a28aa4c3f 100644 --- a/Web/Presenters/InternalAPIPresenter.php +++ b/Web/Presenters/InternalAPIPresenter.php @@ -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(''); diff --git a/Web/Presenters/NoSpamPresenter.php b/Web/Presenters/NoSpamPresenter.php index 0c940c4f5..edc32852f 100644 --- a/Web/Presenters/NoSpamPresenter.php +++ b/Web/Presenters/NoSpamPresenter.php @@ -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")) { diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index 48e1bedbe..a59f53cd8 100644 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -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; } @@ -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"), @@ -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"), @@ -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"), diff --git a/Web/Presenters/PhotosPresenter.php b/Web/Presenters/PhotosPresenter.php index fc37f448f..2a90ade6d 100644 --- a/Web/Presenters/PhotosPresenter.php +++ b/Web/Presenters/PhotosPresenter.php @@ -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()); } diff --git a/Web/Presenters/PollPresenter.php b/Web/Presenters/PollPresenter.php index 95a32d2ca..655ea09e8 100644 --- a/Web/Presenters/PollPresenter.php +++ b/Web/Presenters/PollPresenter.php @@ -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; } @@ -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 diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 869d601e1..d49de4a62 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -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); @@ -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; } diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index 3198bad27..64a7841f2 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -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) { @@ -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, diff --git a/Web/Presenters/templates/@CanonicalListView.xml b/Web/Presenters/templates/@CanonicalListView.latte similarity index 89% rename from Web/Presenters/templates/@CanonicalListView.xml rename to Web/Presenters/templates/@CanonicalListView.latte index a0c8f7d79..2a87726e2 100644 --- a/Web/Presenters/templates/@CanonicalListView.xml +++ b/Web/Presenters/templates/@CanonicalListView.latte @@ -32,18 +32,18 @@
- {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, ]}
{else} {ifset customErrorMessage} {include customErrorMessage} {else} - {include "components/nothing.xml"} + {include "components/nothing.latte"} {/ifset} {/if} diff --git a/Web/Presenters/templates/@MilkshakeListView.xml b/Web/Presenters/templates/@MilkshakeListView.latte similarity index 90% rename from Web/Presenters/templates/@MilkshakeListView.xml rename to Web/Presenters/templates/@MilkshakeListView.latte index 699da82b3..01691dd55 100644 --- a/Web/Presenters/templates/@MilkshakeListView.xml +++ b/Web/Presenters/templates/@MilkshakeListView.latte @@ -1,4 +1,4 @@ -{extends "@layout.xml"} +{extends "@layout.latte"} {block wrap}
@@ -32,18 +32,18 @@
- {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, ]}
{else} {ifset customErrorMessage} {include customErrorMessage} {else} - {include "components/nothing.xml"} + {include "components/nothing.latte"} {/ifset} {/if}
diff --git a/Web/Presenters/templates/@banned.xml b/Web/Presenters/templates/@banned.latte similarity index 91% rename from Web/Presenters/templates/@banned.xml rename to Web/Presenters/templates/@banned.latte index 7640838c1..0b3be2f00 100644 --- a/Web/Presenters/templates/@banned.xml +++ b/Web/Presenters/templates/@banned.latte @@ -1,4 +1,4 @@ -{extends "@layout.xml"} +{extends "@layout.latte"} {block title}{_banned_title}{/block} {block header} @@ -19,7 +19,7 @@
Эта страница была заморожена {$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}
{/if} diff --git a/Web/Presenters/templates/@deactivated.xml b/Web/Presenters/templates/@deactivated.latte similarity index 97% rename from Web/Presenters/templates/@deactivated.xml rename to Web/Presenters/templates/@deactivated.latte index 0be411411..b7b999639 100644 --- a/Web/Presenters/templates/@deactivated.xml +++ b/Web/Presenters/templates/@deactivated.latte @@ -1,4 +1,4 @@ -{extends "@layout.xml"} +{extends "@layout.latte"} {block title}{$thisUser->getCanonicalName()}{/block} {block header} diff --git a/Web/Presenters/templates/@email.xml b/Web/Presenters/templates/@email.latte similarity index 91% rename from Web/Presenters/templates/@email.xml rename to Web/Presenters/templates/@email.latte index 3de8b2e1c..d864fe9b2 100755 --- a/Web/Presenters/templates/@email.xml +++ b/Web/Presenters/templates/@email.latte @@ -1,4 +1,4 @@ -{extends "@layout.xml"} +{extends "@layout.latte"} {block title}{_ec_header}{/block} {block header} diff --git a/Web/Presenters/templates/@error.xml b/Web/Presenters/templates/@error.latte similarity index 96% rename from Web/Presenters/templates/@error.xml rename to Web/Presenters/templates/@error.latte index 64359f7ec..a8c35151d 100644 --- a/Web/Presenters/templates/@error.xml +++ b/Web/Presenters/templates/@error.latte @@ -1,4 +1,4 @@ -{var $instance_name = OPENVK_ROOT_CONF['openvk']['appearance']['name']} +{var $instance_name = \OPENVK_ROOT_CONF['openvk']['appearance']['name']} diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.latte similarity index 90% rename from Web/Presenters/templates/@layout.xml rename to Web/Presenters/templates/@layout.latte index aa5f2fddc..1e39094f4 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.latte @@ -1,4 +1,4 @@ -{var $instance_name = OPENVK_ROOT_CONF['openvk']['appearance']['name']} +{var $instance_name = \OPENVK_ROOT_CONF['openvk']['appearance']['name']} {if !isset($parentModule) || substr($parentModule, 0, 21) === 'libchandler:absolute.'} @@ -39,7 +39,7 @@ {script "js/timezone.js"} {/if} - {include "_includeCSS.xml"} + {include "_includeCSS.latte"} {ifset headIncludes} {include headIncludes} @@ -53,7 +53,7 @@

-
FOR TESTING PURPOSES ONLY
+
FOR TESTING PURPOSES ONLY
@@ -102,8 +102,8 @@
-
- {if $instance_name != OPENVK_DEFAULT_INSTANCE_NAME}{$instance_name}{/if} +
+ {if $instance_name != \OPENVK_DEFAULT_INSTANCE_NAME}{$instance_name}{/if}
{ifset $thisUser} {if $thisUser->isDeactivated()} @@ -210,7 +210,7 @@ {var $canAccessReports = $thisUser->getChandlerUser()->can("admin")->model('openvk\Web\Models\Entities\Report')->whichBelongsTo(0)} {var $canAccessNsp = $thisUser->getChandlerUser()->can("write")->model('openvk\Web\Models\Entities\Ban')->whichBelongsTo(0)} - {var $menuLinksAvaiable = sizeof(OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links']) > 0 && $thisUser->getLeftMenuItemStatus('links')} + {var $menuLinksAvaiable = sizeof(\OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links']) > 0 && $thisUser->getLeftMenuItemStatus('links')} {_admin} {_helpdesk} @@ -228,7 +228,7 @@ @@ -248,7 +248,7 @@
-
+
{_news}
{$newsText}... @@ -262,14 +262,14 @@ {var $bdayListHtml = ''} {foreach $bdayUsers as $u} - {var $bdayListHtml .= '' . $u->getMorphedName(startWithLastName: false) . ''} + {$bdayListHtml .= '' . $u->getMorphedName(startWithLastName: false) . ''} {if $bdayCount == 2} - {if $iterator->isFirst()}{var $bdayListHtml .= tr("bday_and")}{/if} + {if $iterator->isFirst()}{$bdayListHtml .= tr("bday_and")}{/if} {elseif $bdayCount != 1} {if $iterator->isLast(2) and !$iterator->isLast()} - {var $bdayListHtml .= tr("bday_and")} + {$bdayListHtml .= tr("bday_and")} {elseif !$iterator->isLast()} - {var $bdayListHtml .= ', '} + {$bdayListHtml .= ', '} {/if} {/if} {/foreach} @@ -277,15 +277,15 @@
-
+
{tr("you_still_have_x_points", $thisUser->getCoins())|noescape}

{_top_up_your_account} »
- - {php echo OPENVK_ROOT_CONF['openvk']['preferences']['adPoster']['caption']} + + {php echo \OPENVK_ROOT_CONF['openvk']['preferences']['adPoster']['caption']}
@@ -340,7 +340,7 @@

- {if !OPENVK_ROOT_CONF['openvk']['preferences']['security']['disablePasswordRestoring']}{_forgot_password}{/if} + {if !\OPENVK_ROOT_CONF['openvk']['preferences']['security']['disablePasswordRestoring']}{_forgot_password}{/if} {/ifset}
@@ -411,7 +411,7 @@
- {include "components/cookies.xml"} + {include "components/cookies.latte"} {script "js/node_modules/msgpack-lite/dist/msgpack.min.js"} {script "js/node_modules/soundjs/lib/soundjs.min.js"} @@ -445,10 +445,10 @@ - + - -