From 92016089c881880df0836e8a9192459f2917c738 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 1 Oct 2023 22:43:20 +0100 Subject: [PATCH 1/8] Add Smarty and Twig template engines --- core/classes/Core/Module.php | 10 +- core/classes/Database/PhinxAdapter.php | 2 + core/classes/Misc/DebugBarHelper.php | 28 ++- core/classes/Templates/FakeSmarty.php | 28 +++ core/classes/Templates/SmartyTemplateBase.php | 25 ++ .../Templates/SmartyTemplateEngine.php | 81 ++++++ core/classes/Templates/TemplateBase.php | 40 ++- core/classes/Templates/TemplateEngine.php | 78 ++++++ core/classes/Templates/TwigTemplateBase.php | 19 ++ core/classes/Templates/TwigTemplateEngine.php | 63 +++++ core/classes/Widgets/AbstractWidget.php | 25 +- core/includes/maintenance.php | 51 ++-- core/includes/tfa_signin.php | 38 +-- core/init.php | 76 +----- core/templates/backend_init.php | 30 ++- core/templates/cc_navbar.php | 17 +- core/templates/footer.php | 33 ++- core/templates/frontend_init.php | 109 ++++++-- core/templates/navbar.php | 22 +- core/templates/panel_navbar.php | 18 +- .../Default/core/announcements.tpl | 2 +- custom/panel_templates/Default/template.php | 22 +- custom/templates/DefaultRevamp/template.php | 30 ++- modules/Cookie Consent/module.php | 22 +- modules/Cookie Consent/pages/cookies.php | 32 ++- .../Cookie Consent/pages/panel/cookies.php | 40 +-- .../collections/panel/RecentPunishments.php | 14 +- .../collections/panel/RecentRegistrations.php | 18 +- .../Core/collections/panel/RecentReports.php | 14 +- .../Core/collections/panel/RecentUsers.php | 14 +- modules/Core/collections/panel/TotalUsers.php | 14 +- modules/Core/module.php | 104 ++++---- modules/Core/pages/authme_connector.php | 45 ++-- modules/Core/pages/complete_signup.php | 35 ++- modules/Core/pages/custom.php | 38 +-- modules/Core/pages/forgot_password.php | 46 ++-- modules/Core/pages/home.php | 49 ++-- modules/Core/pages/leaderboards.php | 40 +-- modules/Core/pages/login.php | 45 ++-- modules/Core/pages/panel/announcements.php | 54 ++-- modules/Core/pages/panel/api.php | 235 +++++++++--------- modules/Core/pages/panel/auth.php | 36 +-- modules/Core/pages/panel/avatars.php | 43 ++-- .../pages/panel/debugging_and_maintenance.php | 43 ++-- modules/Core/pages/panel/emails.php | 63 ++--- modules/Core/pages/panel/emails_errors.php | 57 +++-- .../Core/pages/panel/emails_mass_message.php | 43 ++-- modules/Core/pages/panel/errors.php | 47 ++-- modules/Core/pages/panel/general_settings.php | 39 +-- modules/Core/pages/panel/groups.php | 63 +++-- modules/Core/pages/panel/hooks.php | 51 ++-- modules/Core/pages/panel/images.php | 49 ++-- modules/Core/pages/panel/index.php | 45 ++-- modules/Core/pages/panel/integrations.php | 47 ++-- modules/Core/pages/panel/minecraft.php | 59 +++-- modules/Core/pages/panel/minecraft_authme.php | 43 ++-- .../pages/panel/minecraft_query_errors.php | 53 ++-- .../pages/panel/minecraft_server_banners.php | 63 +++-- .../Core/pages/panel/minecraft_servers.php | 65 ++--- modules/Core/pages/panel/modules.php | 43 ++-- modules/Core/pages/panel/navigation.php | 41 +-- modules/Core/pages/panel/pages.php | 57 +++-- modules/Core/pages/panel/panel_templates.php | 47 ++-- modules/Core/pages/panel/placeholders.php | 47 ++-- .../Core/pages/panel/privacy_and_terms.php | 41 +-- modules/Core/pages/panel/profile_fields.php | 57 +++-- modules/Core/pages/panel/queue.php | 55 ++-- modules/Core/pages/panel/reactions.php | 58 +++-- modules/Core/pages/panel/registration.php | 43 ++-- modules/Core/pages/panel/security.php | 55 ++-- modules/Core/pages/panel/seo.php | 58 +++-- modules/Core/pages/panel/social_media.php | 39 +-- modules/Core/pages/panel/templates.php | 86 ++++--- modules/Core/pages/panel/update.php | 47 ++-- modules/Core/pages/panel/user.php | 48 ++-- modules/Core/pages/panel/users.php | 81 +++--- modules/Core/pages/panel/users_edit.php | 54 ++-- .../Core/pages/panel/users_integrations.php | 55 ++-- modules/Core/pages/panel/users_ip_lookup.php | 57 +++-- modules/Core/pages/panel/users_oauth.php | 33 ++- .../Core/pages/panel/users_punishments.php | 75 +++--- modules/Core/pages/panel/users_reports.php | 83 ++++--- modules/Core/pages/panel/widgets.php | 48 ++-- modules/Core/pages/portal.php | 31 ++- modules/Core/pages/privacy.php | 37 +-- modules/Core/pages/profile.php | 99 ++++---- modules/Core/pages/register.php | 57 +++-- modules/Core/pages/status.php | 33 ++- modules/Core/pages/terms.php | 37 +-- modules/Core/pages/user/alerts.php | 37 +-- modules/Core/pages/user/connections.php | 37 +-- modules/Core/pages/user/index.php | 30 ++- modules/Core/pages/user/messaging.php | 135 +++++----- modules/Core/pages/user/oauth.php | 38 +-- modules/Core/pages/user/placeholders.php | 39 +-- modules/Core/pages/user/settings.php | 83 ++++--- modules/Core/queries/reactions.php | 19 +- modules/Core/queries/user.php | 21 +- modules/Core/widgets/FacebookWidget.php | 6 +- .../widgets/MinecraftAccountProfileWidget.php | 14 +- modules/Core/widgets/OnlineStaffWidget.php | 14 +- modules/Core/widgets/OnlineUsersWidget.php | 15 +- modules/Core/widgets/ProfilePostsWidget.php | 12 +- .../Core/widgets/ReactionsProfileWidget.php | 8 +- modules/Core/widgets/ServerStatusWidget.php | 15 +- modules/Core/widgets/StatsWidget.php | 14 +- modules/Core/widgets/TwitterWidget.php | 8 +- modules/Discord Integration/module.php | 15 +- .../pages/panel/discord.php | 43 ++-- .../widgets/DiscordWidget.php | 7 +- .../Forum/collections/panel/RecentPosts.php | 14 +- .../Forum/collections/panel/RecentTopics.php | 14 +- modules/Forum/front_page.php | 30 ++- modules/Forum/module.php | 48 ++-- modules/Forum/pages/forum/edit.php | 47 ++-- modules/Forum/pages/forum/index.php | 100 ++++---- modules/Forum/pages/forum/merge.php | 33 ++- modules/Forum/pages/forum/move.php | 36 ++- modules/Forum/pages/forum/new_topic.php | 40 +-- modules/Forum/pages/forum/search.php | 54 ++-- modules/Forum/pages/forum/view_forum.php | 135 +++++----- modules/Forum/pages/forum/view_topic.php | 103 ++++---- modules/Forum/pages/panel/forums.php | 74 +++--- modules/Forum/pages/panel/labels.php | 78 +++--- modules/Forum/pages/panel/settings.php | 42 ++-- modules/Forum/pages/user/following_topics.php | 46 ++-- modules/Forum/widgets/LatestPostsWidget.php | 10 +- modules/Members/module.php | 18 +- modules/Members/pages/members.php | 41 +-- modules/Members/pages/panel/member_lists.php | 33 ++- modules/Members/pages/panel/settings.php | 37 ++- 131 files changed, 3520 insertions(+), 2340 deletions(-) create mode 100644 core/classes/Templates/FakeSmarty.php create mode 100644 core/classes/Templates/SmartyTemplateBase.php create mode 100644 core/classes/Templates/SmartyTemplateEngine.php create mode 100644 core/classes/Templates/TemplateEngine.php create mode 100644 core/classes/Templates/TwigTemplateBase.php create mode 100644 core/classes/Templates/TwigTemplateEngine.php diff --git a/core/classes/Core/Module.php b/core/classes/Core/Module.php index 59d7b2d7ad..486da492bd 100644 --- a/core/classes/Core/Module.php +++ b/core/classes/Core/Module.php @@ -4,7 +4,7 @@ * * @package NamelessMC\Core * @author Samerton - * @version 2.0.0-pr13 + * @version 2.2.0 * @license MIT */ abstract class Module { @@ -51,12 +51,12 @@ public function __construct( * @param User $user User viewing the page. * @param Pages $pages Instance of pages class. * @param Cache $cache Instance of cache to pass. - * @param Smarty $smarty Instance of smarty to pass. + * @param FakeSmarty|Smarty|null $smarty Instance of Smarty to pass * @param Navigation[] $navs Array of loaded navigation menus. * @param Widgets $widgets Instance of widget class to pass. * @param TemplateBase $template Template to pass. */ - public static function loadPage(User $user, Pages $pages, Cache $cache, Smarty $smarty, iterable $navs, Widgets $widgets, TemplateBase $template): void { + public static function loadPage(User $user, Pages $pages, Cache $cache, $smarty, iterable $navs, Widgets $widgets, TemplateBase $template): void { foreach (self::getModules() as $module) { $module->onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template); } @@ -74,12 +74,12 @@ public static function getModules(): iterable { * @param User $user User viewing the page. * @param Pages $pages Instance of pages class. * @param Cache $cache Instance of cache to pass. - * @param Smarty $smarty Instance of smarty to pass. + * @param FakeSmarty|Smarty $smarty Instance of smarty to pass, to be removed in 2.3.0 * @param Navigation[] $navs Array of loaded navigation menus. * @param Widgets $widgets Instance of widget class to pass. * @param TemplateBase|null $template Active template to render. */ - abstract public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smarty, iterable $navs, Widgets $widgets, ?TemplateBase $template); + abstract public function onPageLoad(User $user, Pages $pages, Cache $cache, $smarty, iterable $navs, Widgets $widgets, ?TemplateBase $template); /** * Determine loading arrangement of modules. diff --git a/core/classes/Database/PhinxAdapter.php b/core/classes/Database/PhinxAdapter.php index e421ccc99b..db3dfcf581 100644 --- a/core/classes/Database/PhinxAdapter.php +++ b/core/classes/Database/PhinxAdapter.php @@ -19,6 +19,8 @@ public static function ensureUpToDate( ?string $migrationDir = null, bool $returnResults = false ) { + return; + $module = strtolower($module); if ($module === 'core') { diff --git a/core/classes/Misc/DebugBarHelper.php b/core/classes/Misc/DebugBarHelper.php index 7998d0934b..43d859fbf1 100644 --- a/core/classes/Misc/DebugBarHelper.php +++ b/core/classes/Misc/DebugBarHelper.php @@ -1,6 +1,8 @@ addCollector(new TimeDataCollector()); @@ -46,16 +51,27 @@ public function enable(Smarty $smarty): void { $pdoCollector->setRenderSqlWithParams(true, '`'); $debugbar->addCollector($pdoCollector); - $smartyCollector = new SmartyCollector($smarty); - $smartyCollector->useHtmlVarDumper(); - $debugbar->addCollector($smartyCollector); - $debugbar->addCollector(new PhpInfoCollector()); $debugbar->addCollector(new MemoryCollector()); $this->_debugBar = $debugbar; } + public function addCollector(DataCollector $collector): void { + $this->_debugBar->addCollector($collector); + } + + public function addSmartyCollector(Smarty $smarty): void { + $smartyCollector = new SmartyCollector($smarty); + $smartyCollector->useHtmlVarDumper(); + $this->addCollector($smartyCollector); + } + + public function addTwigCollector(Environment $twig, Profile $profile): void { + $twig->addExtension(new ProfilerExtension($profile)); + $this->addCollector(new NamespacedTwigProfileCollector($profile)); + } + public function getDebugBar(): ?DebugBar { return $this->_debugBar; } diff --git a/core/classes/Templates/FakeSmarty.php b/core/classes/Templates/FakeSmarty.php new file mode 100644 index 0000000000..811e9abdc0 --- /dev/null +++ b/core/classes/Templates/FakeSmarty.php @@ -0,0 +1,28 @@ +assign still works until 2.3.0, when this will be removed + * + * @author Samerton + * @license MIT + * @version 2.2.0 + * @deprecated + */ + +class FakeSmarty { + private TemplateEngine $_engine; + + public function __construct(TemplateEngine $engine) { + $this->_engine = $engine; + } + + public function assign($key, $value = null) { + if (is_string($key)) { + $this->_engine->addVariable($key, $value); + } + + if (is_array($key)) { + $this->_engine->addVariables($key); + } + } +} diff --git a/core/classes/Templates/SmartyTemplateBase.php b/core/classes/Templates/SmartyTemplateBase.php new file mode 100644 index 0000000000..2cb82ebe07 --- /dev/null +++ b/core/classes/Templates/SmartyTemplateBase.php @@ -0,0 +1,25 @@ +_engine = new SmartyTemplateEngine($name, $panelTemplate); + } +} diff --git a/core/classes/Templates/SmartyTemplateEngine.php b/core/classes/Templates/SmartyTemplateEngine.php new file mode 100644 index 0000000000..223c1d4fb0 --- /dev/null +++ b/core/classes/Templates/SmartyTemplateEngine.php @@ -0,0 +1,81 @@ +php_modifiers = [ + 'escape', + 'count', + 'key', + 'round', + 'ucfirst', + 'defined', + 'date', + 'explode', + 'implode', + 'strtolower', + 'strtoupper' + ]; + $securityPolicy->php_functions = [ + 'isset', + 'empty', + 'count', + 'sizeof', + 'in_array', + 'is_array', + 'time', + 'nl2br', + 'is_numeric', + 'file_exists', + 'array_key_exists' + ]; + $securityPolicy->secure_dir = [ROOT_PATH . '/custom/templates', ROOT_PATH . '/custom/panel_templates']; + $smarty->enableSecurity($securityPolicy); + + $smarty->setCompileDir(ROOT_PATH . '/cache/templates_c'); + + if ($panelTemplate) { + $smarty->setTemplateDir(ROOT_PATH . '/custom/panel_templates/' . $template); + } else { + $smarty->setTemplateDir(ROOT_PATH . '/custom/templates/' . $template); + } + + if (defined('PHPDEBUGBAR')) { + DebugBarHelper::getInstance()->addSmartyCollector($smarty); + } + + $this->_smarty = $smarty; + + parent::__construct(); + } + + public function render(string $templateFile): void { + echo $this->fetch($templateFile); + } + + public function fetch(string $templateFile): string { + $templateFile = str_replace('.tpl', '', $templateFile); + + $this->_smarty->assign($this->getVariables()); + return $this->_smarty->fetch("$templateFile.tpl"); + } + + public function clearCache(): void { + $this->_smarty->clearAllCache(); + } +} diff --git a/core/classes/Templates/TemplateBase.php b/core/classes/Templates/TemplateBase.php index 235b3cf856..e097b3cd68 100644 --- a/core/classes/Templates/TemplateBase.php +++ b/core/classes/Templates/TemplateBase.php @@ -46,6 +46,9 @@ abstract class TemplateBase { */ protected array $_js = []; + /** @var TemplateEngine Template engine instance */ + protected TemplateEngine $_engine; + public function __construct(string $name, string $version, string $nameless_version, string $author) { $this->_name = $name; $this->_version = $version; @@ -170,29 +173,31 @@ public function getSettings(): string { } /** - * Render this template with Smarty engine. + * Render this template. + * + * @param string $template Template file to render, relative to template base directory */ - public function displayTemplate(string $template, Smarty $smarty): void { + public function displayTemplate(string $template): void { [$css, $js] = $this->assets()->compile(); // Put the assets at the start of the arrays, so they load first (SBAdmin requires JQuery first, etc.) array_unshift($this->_css, ...$css); array_unshift($this->_js, ...$js); - $smarty->assign([ + $this->_engine->addVariables([ 'TEMPLATE_CSS' => $this->getCSS(), - 'TEMPLATE_JS' => $this->getJS() + 'TEMPLATE_JS' => $this->getJS(), ]); if (defined('PHPDEBUGBAR') && PHPDEBUGBAR) { $debugBar = DebugBarHelper::getInstance()->getDebugBar()->getJavascriptRenderer(); - $smarty->assign([ + $this->_engine->addVariables([ 'DEBUGBAR_JS' => $debugBar->renderHead(), - 'DEBUGBAR_HTML' => $debugBar->render() + 'DEBUGBAR_HTML' => $debugBar->render(), ]); } - $smarty->display($template); + $this->_engine->render($template); } /** @@ -213,12 +218,27 @@ public function getJS(): array { return $this->_js; } - public function getTemplate(string $template, Smarty $smarty): string { - $smarty->assign([ + /** + * Fetches template HTML instead of rendering it + * + * @param string $template + * @return string Generated HTML + */ + public function getTemplate(string $template): string { + $this->_engine->addVariables([ 'TEMPLATE_CSS' => $this->getCSS(), 'TEMPLATE_JS' => $this->getJS() ]); - return $smarty->fetch($template); + return $this->_engine->fetch($template); + } + + /** + * Get template engine + * + * @return TemplateEngine + */ + public function getEngine(): TemplateEngine { + return $this->_engine; } } diff --git a/core/classes/Templates/TemplateEngine.php b/core/classes/Templates/TemplateEngine.php new file mode 100644 index 0000000000..ed72a23855 --- /dev/null +++ b/core/classes/Templates/TemplateEngine.php @@ -0,0 +1,78 @@ +_variables = []; + } + + /** + * Register a template variable + * + * TODO: mixed type for $value + * + * @param string $key + * @param mixed $value + * @return void + */ + public function addVariable(string $key, $value): void { + $this->_variables[$key] = $value; + } + + /** + * Get a template variable + * + * @param string $key + * @return mixed + */ + public function getVariable(string $key) { + return $this->_variables[$key]; + } + + /** + * Register several template variables + * + * @param array $variables + * @return void + */ + public function addVariables(array $variables): void { + $this->_variables = array_merge($this->_variables, $variables); + } + + /** + * Get all template variables + * + * @return array + */ + public function getVariables(): array { + return $this->_variables; + } + + /** + * Render a template file using the set template engine + * + * @param string $templateFile Path to template file to render + */ + public abstract function render(string $templateFile): void; + + /** + * Fetch a generated template file using the set template engine + * + * @param string $templateFile Path to template file to render + * @return string HTML to render + */ + public abstract function fetch(string $templateFile): string; + + /** + * Clear template cache directory + */ + public abstract function clearCache(): void; +} diff --git a/core/classes/Templates/TwigTemplateBase.php b/core/classes/Templates/TwigTemplateBase.php new file mode 100644 index 0000000000..af7fb91442 --- /dev/null +++ b/core/classes/Templates/TwigTemplateBase.php @@ -0,0 +1,19 @@ +_engine = new TwigTemplateEngine($name); + } +} diff --git a/core/classes/Templates/TwigTemplateEngine.php b/core/classes/Templates/TwigTemplateEngine.php new file mode 100644 index 0000000000..fa728332a3 --- /dev/null +++ b/core/classes/Templates/TwigTemplateEngine.php @@ -0,0 +1,63 @@ + ROOT_PATH . '/cache/twig', + ]); + + $policy = new SecurityPolicy(); + $sandbox = new SandboxExtension($policy); + $twig->addExtension($sandbox); + + if (defined('PHPDEBUGBAR')) { + $profile = new Profile(); + DebugBarHelper::getInstance()->addTwigCollector($twig, $profile); + } + + $this->_twig = $twig; + + parent::__construct(); + } + + public function render(string $templateFile): void { + echo $this->fetch($templateFile); + } + + public function fetch(string $templateFile): string { + $templateFile = str_replace('.tpl', '', $templateFile); + + return $this->_twig->render("$templateFile.twig", $this->getVariables()); + } + + public function clearCache(): void { + $dir = ROOT_PATH . '/cache/twig'; + + foreach (glob($dir . '/*') as $file) { + if (is_dir($file)) { + Util::recursiveRemoveDirectory($file); + } else { + unlink($file); + } + } + } +} diff --git a/core/classes/Widgets/AbstractWidget.php b/core/classes/Widgets/AbstractWidget.php index 21dea1d9a5..b211159c96 100644 --- a/core/classes/Widgets/AbstractWidget.php +++ b/core/classes/Widgets/AbstractWidget.php @@ -8,7 +8,13 @@ abstract class AbstractWidget { protected string $_module; protected ?string $_settings = null; protected bool $_requires_cookies = false; - protected Smarty $_smarty; + /** + * Will be removed in 2.3.0 + * @var ?Smarty + * @deprecated + */ + protected ?Smarty $_smarty; + protected ?TemplateEngine $_engine; protected WidgetData $_data; private Cache $_cache; @@ -68,14 +74,24 @@ public function getOrder(): int { } /** - * Get Smarty instance in use by this widget. + * Get Smarty instance in use by this widget. Removed in 2.3.0 * * @return Smarty Instance in use. + * @deprecated */ public function getSmarty(): ?Smarty { return $this->_smarty; } + /** + * Get template engine in use by this widget. + * + * @return TemplateEngine Engine in use + */ + public function getTemplateEngine(): ?TemplateEngine { + return $this->_engine; + } + /** * Render this widget to be displayed on a template page. If this widget requires cookies and cookies are not allowed, a cookie notice is displayed instead. * Returns an empty string if this widget is not to be displayed. @@ -87,7 +103,10 @@ public function getSmarty(): ?Smarty { */ public function display(): string { if (defined('COOKIE_CHECK') && !COOKIES_ALLOWED && $this->_requires_cookies) { - return $this->_smarty->fetch('widgets/cookie_notice.tpl'); + return + $this->_engine ? + $this->_engine->fetch('widgets/cookie_notice.tpl') : + $this->_smarty->fetch('widgets/cookie_notice.tpl'); } return $this->_content; diff --git a/core/includes/maintenance.php b/core/includes/maintenance.php index 56d80c6717..bdfa95f2a3 100644 --- a/core/includes/maintenance.php +++ b/core/includes/maintenance.php @@ -1,37 +1,44 @@ get('errors', 'maintenance_title'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; if (!$user->isLoggedIn()) { - $smarty->assign( - [ - 'LOGIN' => $language->get('general', 'sign_in'), - 'LOGIN_LINK' => URL::build('/login') - ] - ); + $template->getEngine()->addVariables([ + 'LOGIN' => $language->get('general', 'sign_in'), + 'LOGIN_LINK' => URL::build('/login'), + ]); } -// Assign Smarty variables -$smarty->assign( - [ - 'MAINTENANCE_TITLE' => $language->get('errors', 'maintenance_title'), - 'MAINTENANCE_MESSAGE' => Output::getPurified(Settings::get('maintenance_message', 'Maintenance mode is enabled.')), - 'RETRY' => $language->get('errors', 'maintenance_retry') - ] -); +// Assign template variables +$template->getEngine()->addVariables([ + 'MAINTENANCE_TITLE' => $language->get('errors', 'maintenance_title'), + 'MAINTENANCE_MESSAGE' => Output::getPurified(Settings::get('maintenance_message', 'Maintenance mode is enabled.')), + 'RETRY' => $language->get('errors', 'maintenance_retry') +]); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -39,4 +46,4 @@ $template->onPageLoad(); // Display template -$template->displayTemplate('maintenance.tpl', $smarty); +$template->displayTemplate('maintenance'); diff --git a/core/includes/tfa_signin.php b/core/includes/tfa_signin.php index 80fc3a8b79..b200e594c6 100644 --- a/core/includes/tfa_signin.php +++ b/core/includes/tfa_signin.php @@ -1,15 +1,25 @@ assign([ + $template->getEngine()->addVariables([ 'ERROR_TITLE' => $language->get('general', 'error'), - 'ERROR' => Session::flash('tfa_signin') + 'ERROR' => Session::flash('tfa_signin'), ]); } -// Smarty variables -$smarty->assign([ +// Template variables +$template->getEngine()->addVariables([ 'TWO_FACTOR_AUTH' => $language->get('user', 'two_factor_auth'), 'TFA_ENTER_CODE' => $language->get('user', 'tfa_enter_code'), 'TOKEN' => Token::get(), @@ -42,8 +52,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('tfa.tpl', $smarty); +$template->displayTemplate('tfa'); diff --git a/core/init.php b/core/init.php index b02d0778a1..b342d69e61 100644 --- a/core/init.php +++ b/core/init.php @@ -122,11 +122,8 @@ } } - $smarty = $container->get(Smarty::class); - if ((defined('DEBUGGING') && DEBUGGING) && class_exists('DebugBar\DebugBar')) { define('PHPDEBUGBAR', true); - DebugBarHelper::getInstance()->enable($smarty); } // Get the Nameless version @@ -205,7 +202,7 @@ // Attempt to get the requested language from the browser if it exists $automatic_locale = Language::acceptFromHttp(HttpUtils::getHeader('Accept-Language') ?? ''); if ($automatic_locale !== false) { - $smarty->assign('AUTO_LANGUAGE_VALUE', $automatic_locale[1]); + define('AUTO_LANGUAGE_VALUE', $automatic_locale[1]); $default_language = $automatic_locale[0]; } } @@ -300,52 +297,6 @@ define('PANEL_TEMPLATE', $template); } - // Smarty - $securityPolicy = new Smarty_Security($smarty); - $securityPolicy->php_modifiers = [ - 'escape', - 'count', - 'key', - 'round', - 'ucfirst', - 'defined', - 'date', - 'explode', - 'implode', - 'strtolower', - 'strtoupper' - ]; - $securityPolicy->php_functions = [ - 'isset', - 'empty', - 'count', - 'sizeof', - 'in_array', - 'is_array', - 'time', - 'nl2br', - 'is_numeric', - 'file_exists', - 'array_key_exists' - ]; - $securityPolicy->secure_dir = [ROOT_PATH . '/custom/templates', ROOT_PATH . '/custom/panel_templates']; - $smarty->enableSecurity($securityPolicy); - - // Basic Smarty variables - $smarty->assign([ - 'CONFIG_PATH' => defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/', - 'OG_URL' => Output::getClean(rtrim(URL::getSelfURL(), '/') . $_SERVER['REQUEST_URI']), - 'SITE_NAME' => Output::getClean(SITE_NAME), - 'SITE_HOME' => URL::build('/'), - 'USER_INFO_URL' => URL::build('/queries/user/', 'id='), - 'GUEST' => $language->get('user', 'guest') - ]); - $cache->setCache('backgroundcache'); - if ($cache->isCached('og_image')) { - // Assign the image value now, some pages may override it (via Page Metadata config) - $smarty->assign('OG_IMAGE', rtrim(URL::getSelfURL(), '/') . $cache->retrieve('og_image')); - } - // Avatars $cache->setCache('avatar_settings_cache'); if ($cache->isCached('custom_avatars') && $cache->retrieve('custom_avatars') == 1) { @@ -459,7 +410,7 @@ // Load modules foreach ($enabled_modules as $module) { if (file_exists(ROOT_PATH . '/modules/' . $module['name'] . '/init.php')) { - require_once ROOT_PATH . '/modules/' . $module['name'] . '/init.php'; + require_once ROOT_PATH . '/modules/' . $module['name'] . '/init.php'; } } @@ -483,7 +434,7 @@ } } else { // Display notice to admin stating maintenance mode is enabled - $smarty->assign('MAINTENANCE_ENABLED', $language->get('admin', 'maintenance_enabled')); + define('BYPASS_MAINTENANCE', true); } } @@ -619,25 +570,6 @@ ]; } - // Basic user variables - $smarty->assign('LOGGED_IN_USER', [ - 'username' => $user->getDisplayname(true), - 'nickname' => $user->getDisplayname(), - 'profile' => $user->getProfileURL(), - 'panel_profile' => URL::build('/panel/user/' . urlencode($user->data()->id) . '-' . urlencode($user->data()->username)), - 'username_style' => $user->getGroupStyle(), - 'user_title' => Output::getClean($user->data()->user_title), - 'avatar' => $user->getAvatar(), - 'integrations' => $user_integrations - ]); - - // Panel access? - if ($user->canViewStaffCP()) { - $smarty->assign([ - 'PANEL_LINK' => URL::build('/panel'), - 'PANEL' => $language->get('moderator', 'staff_cp') - ]); - } } else { // Perform tasks for guests if (!$_SESSION['checked'] || (isset($_SESSION['checked']) && $_SESSION['checked'] <= strtotime('-5 minutes'))) { @@ -656,7 +588,7 @@ // Auto language enabled? if (Settings::get('auto_language_detection')) { - $smarty->assign('AUTO_LANGUAGE', true); + define('AUTO_LANGUAGE', true); } } diff --git a/core/templates/backend_init.php b/core/templates/backend_init.php index 8c16067063..4375bed412 100644 --- a/core/templates/backend_init.php +++ b/core/templates/backend_init.php @@ -1,26 +1,24 @@ setCompileDir(ROOT_PATH . '/cache/templates_c'); - if (file_exists(ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE . '/template.php')) { - $smarty->setTemplateDir(ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE); - + /** @var TemplateBase $template */ require(ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE . '/template.php'); } else { - $smarty->setTemplateDir(ROOT_PATH . '/custom/panel_templates/Default'); - + /** @var TemplateBase $template */ require(ROOT_PATH . '/custom/panel_templates/Default/template.php'); } @@ -28,13 +26,13 @@ $logo_image = $cache->retrieve('logo_image'); if (!empty($logo_image)) { - $smarty->assign('PANEL_LOGO_IMAGE', Output::getClean($logo_image)); + $template->getEngine()->addVariable('PANEL_LOGO_IMAGE', Output::getClean($logo_image)); } $favicon_image = $cache->retrieve('favicon_image'); if (!empty($favicon_image)) { - $smarty->assign('FAVICON', Output::getClean($favicon_image)); + $template->getEngine()->addVariable('FAVICON', Output::getClean($favicon_image)); } -$smarty->assign('TITLE', $page_title); +$template->getEngine()->addVariable('TITLE', $page_title); diff --git a/core/templates/cc_navbar.php b/core/templates/cc_navbar.php index 473d81c132..8a26035ab0 100644 --- a/core/templates/cc_navbar.php +++ b/core/templates/cc_navbar.php @@ -1,14 +1,13 @@ assign([ - 'CC_NAV_LINKS' => $cc_nav->returnNav('top') -]); \ No newline at end of file +$template->getEngine()->addVariable('CC_NAV_LINKS', $cc_nav->returnNav()); diff --git a/core/templates/footer.php b/core/templates/footer.php index 966c51fc74..e47b7707bb 100644 --- a/core/templates/footer.php +++ b/core/templates/footer.php @@ -1,12 +1,14 @@ assign([ +// Assign to template variables +$template->getEngine()->addVariables([ 'SOCIAL_MEDIA_ICONS' => $social_media_icons, 'PAGE_LOAD_TIME' => Settings::get('page_loading'), - 'FOOTER_NAVIGATION' => $navigation->returnNav('footer') + 'FOOTER_NAVIGATION' => $navigation->returnNav('footer'), + 'TERMS_LINK' => URL::build('/terms'), + 'TERMS_TEXT' => $language->get('user', 'terms_and_conditions'), + 'PRIVACY_LINK' => URL::build('/privacy'), + 'PRIVACY_TEXT' => $language->get('general', 'privacy_policy'), ]); - -// Terms -$smarty->assign('TERMS_LINK', URL::build('/terms')); -$smarty->assign('TERMS_TEXT', $language->get('user', 'terms_and_conditions')); - -// Privacy -$smarty->assign('PRIVACY_LINK', URL::build('/privacy')); -$smarty->assign('PRIVACY_TEXT', $language->get('general', 'privacy_policy')); diff --git a/core/templates/frontend_init.php b/core/templates/frontend_init.php index 9a0d438f2f..bea3baf368 100644 --- a/core/templates/frontend_init.php +++ b/core/templates/frontend_init.php @@ -1,18 +1,28 @@ setCompileDir(ROOT_PATH . '/cache/templates_c'); - if (file_exists(ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php')) { - $smarty->setTemplateDir(ROOT_PATH . '/custom/templates/' . TEMPLATE); - + /** @var TemplateBase $template */ require(ROOT_PATH . '/custom/templates/' . TEMPLATE . '/template.php'); } else { - $smarty->setTemplateDir(ROOT_PATH . '/custom/templates/DefaultRevamp'); - + /** @var TemplateBase $template */ require(ROOT_PATH . '/custom/templates/DefaultRevamp/template.php'); } +// Basic template variables +$template->getEngine()->addVariables([ + 'CONFIG_PATH' => defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/', + 'OG_URL' => Output::getClean(rtrim(URL::getSelfURL(), '/') . $_SERVER['REQUEST_URI']), + 'SITE_NAME' => Output::getClean(SITE_NAME), + 'SITE_HOME' => URL::build('/'), + 'USER_INFO_URL' => URL::build('/queries/user/', 'id='), + 'GUEST' => $language->get('user', 'guest') +]); + +$cache->setCache('backgroundcache'); +if ($cache->isCached('og_image')) { + // Assign the image value now, some pages may override it (via Page Metadata config) + $template->getEngine()->addVariable('OG_IMAGE', rtrim(URL::getSelfURL(), '/') . $cache->retrieve('og_image')); +} + // User related actions if ($user->isLoggedIn()) { // Warnings @@ -71,7 +97,7 @@ if (count($warnings)) { foreach ($warnings as $warning) { if ($warning->revoked == 0 && $warning->acknowledged == 0) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'GLOBAL_WARNING_TITLE' => $language->get('user', 'you_have_received_a_warning'), 'GLOBAL_WARNING_REASON' => Output::getClean($warning->reason), 'GLOBAL_WARNING_ACKNOWLEDGE' => $language->get('user', 'acknowledge'), @@ -109,56 +135,56 @@ $page_metadata = DB::getInstance()->get('page_descriptions', ['page', $route]); if ($page_metadata->count()) { $page_metadata = $page_metadata->first(); - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), Output::getPurified($page_metadata->description)), 'PAGE_KEYWORDS' => Output::getPurified($page_metadata->tags), ]); $og_image = $page_metadata->image; if ($og_image) { - $smarty->assign('OG_IMAGE', rtrim(URL::getSelfURL(), '/') . $og_image); + $template->getEngine()->addVariable('OG_IMAGE', rtrim(URL::getSelfURL(), '/') . $og_image); } } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), Output::getPurified(Settings::get('default_meta_description', ''))), 'PAGE_KEYWORDS' => Output::getPurified(Settings::get('default_meta_keywords', '')), ]); } } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), Output::getPurified(PAGE_DESCRIPTION)), 'PAGE_KEYWORDS' => (defined('PAGE_KEYWORDS') ? Output::getPurified(PAGE_KEYWORDS) : '') ]); } -$smarty->assign('TITLE', $page_title); +$template->getEngine()->addVariable('TITLE', $page_title); $cache->setCache('backgroundcache'); $banner_image = $cache->retrieve('banner_image'); if (!empty($banner_image)) { - $smarty->assign('BANNER_IMAGE', Output::getClean($banner_image)); + $template->getEngine()->addVariable('BANNER_IMAGE', Output::getClean($banner_image)); } $logo_image = $cache->retrieve('logo_image'); if (!empty($logo_image)) { - $smarty->assign('LOGO_IMAGE', Output::getClean($logo_image)); + $template->getEngine()->addVariable('LOGO_IMAGE', Output::getClean($logo_image)); } $favicon_image = $cache->retrieve('favicon_image'); if (!empty($favicon_image)) { - $smarty->assign('FAVICON', Output::getClean($favicon_image)); + $template->getEngine()->addVariable('FAVICON', Output::getClean($favicon_image)); } $analytics_id = Settings::get('ga_script'); if ($analytics_id) { - $smarty->assign('ANALYTICS_ID', Output::getClean($analytics_id)); + $template->getEngine()->addVariable('ANALYTICS_ID', Output::getClean($analytics_id)); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'FOOTER_LINKS_TITLE' => $language->get('general', 'links'), 'FOOTER_SOCIAL_TITLE' => $language->get('general', 'social'), 'AUTO_LANGUAGE_TEXT' => $language->get('general', 'auto_language'), @@ -167,3 +193,36 @@ 'DARK_LIGHT_MODE_ACTION' => URL::build('/queries/dark_light_mode'), 'DARK_LIGHT_MODE_TOKEN' => $user->isLoggedIn() ? Token::get() : null ]); + +if (defined('BYPASS_MAINTENANCE')) { + $template->getEngine()->addVariable('MAINTENANCE_ENABLED', $language->get('admin', 'maintenance_enabled')); +} + +if (defined('AUTO_LANGUAGE')) { + $template->getEngine()->addVariable('AUTO_LANGUAGE', AUTO_LANGUAGE); +} + +if ($user->isLoggedIn()) { + // Basic user variables + $template->getEngine()->addVariable('LOGGED_IN_USER', [ + 'username' => $user->getDisplayname(true), + 'nickname' => $user->getDisplayname(), + 'profile' => $user->getProfileURL(), + 'panel_profile' => URL::build('/panel/user/' . urlencode($user->data()->id) . '-' . urlencode($user->data()->username)), + 'username_style' => $user->getGroupStyle(), + 'user_title' => Output::getClean($user->data()->user_title), + 'avatar' => $user->getAvatar(), + 'integrations' => $user_integrations ?? [], + ]); + + // Panel access? + if ($user->canViewStaffCP()) { + $template->getEngine()->addVariables([ + 'PANEL_LINK' => URL::build('/panel'), + 'PANEL' => $language->get('moderator', 'staff_cp') + ]); + } +} + +// TODO: remove in 2.3.0 +$smarty = new FakeSmarty($template->getEngine()); diff --git a/core/templates/navbar.php b/core/templates/navbar.php index 694a2b9a8d..e267dbb41b 100644 --- a/core/templates/navbar.php +++ b/core/templates/navbar.php @@ -1,12 +1,16 @@ assign([ +// Assign to template variables +$template->getEngine()->addVariables([ 'NAVBAR_INVERSE' => '', 'SITE_NAME' => Output::getClean(SITE_NAME), 'NAV_LINKS' => $navigation->returnNav('top'), @@ -194,7 +198,7 @@ if ($user->isLoggedIn()) { // Get unread alerts and messages - $smarty->assign([ + $template->getEngine()->addVariables([ 'ALERTS_LINK' => URL::build('/user/alerts'), 'VIEW_ALERTS' => $language->get('user', 'view_alerts'), 'MESSAGING_LINK' => URL::build('/user/messaging'), diff --git a/core/templates/panel_navbar.php b/core/templates/panel_navbar.php index 35cd43a792..5c9a263cb3 100644 --- a/core/templates/panel_navbar.php +++ b/core/templates/panel_navbar.php @@ -1,16 +1,18 @@ assign([ +// Assign to template variables +$template->getEngine()->addVariables([ 'SITE_NAME' => Output::getClean(SITE_NAME), 'PANEL_INDEX' => URL::build('/panel'), 'NAV_LINKS' => $staffcp_nav->returnNav('top'), diff --git a/custom/panel_templates/Default/core/announcements.tpl b/custom/panel_templates/Default/core/announcements.tpl index a0ce68aa6a..58928980e1 100644 --- a/custom/panel_templates/Default/core/announcements.tpl +++ b/custom/panel_templates/Default/core/announcements.tpl @@ -36,7 +36,7 @@
-

{$ANNOUCEMENTS_INFO}

+

{$ANNOUNCEMENTS_INFO}

_language = $language; parent::__construct( 'Default', // Template name - '2.1.2', // Template version - '2.1.2', // Nameless version template is made for - 'Coldfire' // Author, you can use HTML here + '2.2.0', // Template version + '2.2.0', // Nameless version template is made for + 'Coldfire', // Author, you can use HTML here + true, // Set to true for panel templates ); $this->assets()->include([ @@ -133,7 +134,7 @@ public function __construct(Smarty $smarty, Language $language) { '); - $smarty->assign('NAMELESS_LOGO', (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/core/assets/img/namelessmc_logo.png'); + $this->getEngine()->addVariable('NAMELESS_LOGO', (URL::buildAssetPath('/core/assets/img/namelessmc_logo.png'))); } public function onPageLoad() { @@ -522,4 +523,5 @@ public function onPageLoad() { } } -$template = new Default_Panel_Template($smarty, $language); +/** @var Language $language */ +$template = new Default_Panel_Template($language); diff --git a/custom/templates/DefaultRevamp/template.php b/custom/templates/DefaultRevamp/template.php index 3a1b0fb768..2a0fa37bc8 100755 --- a/custom/templates/DefaultRevamp/template.php +++ b/custom/templates/DefaultRevamp/template.php @@ -2,14 +2,14 @@ /* * Made by Samerton | Revamped by Xemah * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.1.2 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * DefaultRevamp Template */ -class DefaultRevamp_Template extends TemplateBase { +class DefaultRevamp_Template extends SmartyTemplateBase { private array $_template; @@ -22,11 +22,11 @@ class DefaultRevamp_Template extends TemplateBase { /** @var Pages */ private Pages $_pages; - public function __construct($cache, $smarty, $language, $user, $pages) { + public function __construct(Cache $cache, Language $language, User $user, Pages $pages) { $template = [ 'name' => 'DefaultRevamp', - 'version' => '2.1.2', - 'nl_version' => '2.1.2', + 'version' => '2.2.0', + 'nl_version' => '2.2.0', 'author' => 'Xemah', ]; @@ -43,10 +43,10 @@ public function __construct($cache, $smarty, $language, $user, $pages) { AssetTree::FOMANTIC_UI, ]); - $smarty->assign('TEMPLATE', $template); + $this->getEngine()->addVariable('TEMPLATE', $template); // Other variables - $smarty->assign('FORUM_SPAM_WARNING_TITLE', $language->get('general', 'warning')); + $this->getEngine()->addVariable('FORUM_SPAM_WARNING_TITLE', $language->get('general', 'warning')); $cache->setCache('template_settings'); $smartyDarkMode = false; @@ -64,11 +64,15 @@ public function __construct($cache, $smarty, $language, $user, $pages) { } } - $smarty->assign([ + $this->getEngine()->addVariables([ 'DEFAULT_REVAMP_DARK_MODE' => $smartyDarkMode, 'DEFAULT_REVAMP_NAVBAR_EXTRA_CLASSES' => $smartyNavbarColour ]); + if (defined('AUTO_LANGUAGE_VALUE')) { + $this->getEngine()->addVariable('AUTO_LANGUAGE_VALUE', AUTO_LANGUAGE_VALUE); + } + $this->_template = $template; $this->_language = $language; $this->_user = $user; @@ -147,5 +151,11 @@ public function onPageLoad() { } } -$template = new DefaultRevamp_Template($cache, $smarty, $language, $user, $pages); +/** + * @var Cache $cache + * @var Language $language + * @var User $user + * @var Pages $pages + */ +$template = new DefaultRevamp_Template($cache, $language, $user, $pages); $template_pagination = ['div' => 'ui mini pagination menu', 'a' => '{x}item']; diff --git a/modules/Cookie Consent/module.php b/modules/Cookie Consent/module.php index 877db29b4d..cb22818566 100644 --- a/modules/Cookie Consent/module.php +++ b/modules/Cookie Consent/module.php @@ -1,12 +1,10 @@ _cookie_language = $cookie_language; $name = 'Cookie Consent'; - $author = 'Samerton'; - $module_version = '2.1.2'; - $nameless_version = '2.1.2'; + $author = 'Samerton'; + $module_version = '2.2.0'; + $nameless_version = '2.2.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -52,7 +50,7 @@ public function onDisable() { // Not necessary for CookieConsent } - public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smarty, $navs, Widgets $widgets, ?TemplateBase $template) { + public function onPageLoad(User $user, Pages $pages, Cache $cache, $smarty, $navs, Widgets $widgets, ?TemplateBase $template) { $language = $this->_language; // AdminCP @@ -97,7 +95,7 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart ); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'COOKIE_URL' => $cookie_url, 'COOKIE_NOTICE_HEADER' => $this->_cookie_language->get('cookie', 'cookie_notice'), 'COOKIE_NOTICE_BODY' => $this->_cookie_language->get('cookie', 'cookie_notice_info'), diff --git a/modules/Cookie Consent/pages/cookies.php b/modules/Cookie Consent/pages/cookies.php index a32e180171..28fc67c7cd 100644 --- a/modules/Cookie Consent/pages/cookies.php +++ b/modules/Cookie Consent/pages/cookies.php @@ -1,18 +1,28 @@ get('cookie', 'cookie_notice'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Retrieve cookie notice from database $cookie_notice = DB::getInstance()->query('SELECT value FROM nl2_privacy_terms WHERE `name` = ?', ['cookies'])->first()->value; @@ -20,7 +30,7 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -$smarty->assign([ +$template->getEngine()->addVariables([ 'COOKIE_NOTICE_HEADER' => $cookie_language->get('cookie', 'cookie_notice'), 'COOKIE_NOTICE' => Output::getPurified($cookie_notice), 'UPDATE_SETTINGS' => $cookie_language->get('cookie', 'update_settings'), @@ -30,8 +40,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('cookies.tpl', $smarty); +$template->displayTemplate('cookies'); diff --git a/modules/Cookie Consent/pages/panel/cookies.php b/modules/Cookie Consent/pages/panel/cookies.php index c7274f4155..f02da8bc3d 100644 --- a/modules/Cookie Consent/pages/panel/cookies.php +++ b/modules/Cookie Consent/pages/panel/cookies.php @@ -1,16 +1,26 @@ handlePanelPageLoad('admincp.cookies')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +28,7 @@ const PARENT_PAGE = 'cookie_divider'; const PANEL_PAGE = 'cookie_settings'; $page_title = $cookie_language->get('cookie', 'cookies'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (Input::exists()) { $errors = []; @@ -65,23 +75,23 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } // Get cookie notice $cookies = DB::getInstance()->query('SELECT value FROM nl2_privacy_terms WHERE `name` = ?', ['cookies'])->first()->value; -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'COOKIES' => $cookie_language->get('cookie', 'cookies'), @@ -94,7 +104,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('cookies/cookies.tpl', $smarty); +$template->displayTemplate('cookies/cookies'); diff --git a/modules/Core/collections/panel/RecentPunishments.php b/modules/Core/collections/panel/RecentPunishments.php index 38ccb36fa6..8cb1636887 100644 --- a/modules/Core/collections/panel/RecentPunishments.php +++ b/modules/Core/collections/panel/RecentPunishments.php @@ -2,20 +2,20 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Recent punishments dashboard collection item */ class RecentPunishmentsItem extends CollectionItemBase { - private Smarty $_smarty; + private TemplateEngine $_engine; private Language $_language; private Cache $_cache; - public function __construct(Smarty $smarty, Language $language, Cache $cache) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache) { $cache->setCache('dashboard_main_items_collection'); if ($cache->isCached('recent_punishments')) { $from_cache = $cache->retrieve('recent_punishments'); @@ -29,7 +29,7 @@ public function __construct(Smarty $smarty, Language $language, Cache $cache) { parent::__construct($order, $enabled); - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; $this->_cache = $cache; } @@ -114,7 +114,7 @@ public function getContent(): string { $this->_cache->store('recent_punishments_data', $data, 60); } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'RECENT_PUNISHMENTS' => $this->_language->get('moderator', 'recent_punishments'), 'PUNISHMENTS' => $data, 'NO_PUNISHMENTS' => $this->_language->get('moderator', 'no_punishments_found'), @@ -128,7 +128,7 @@ public function getContent(): string { 'VIEW' => $this->_language->get('general', 'view') ]); - return $this->_smarty->fetch('collections/dashboard_items/recent_punishments.tpl'); + return $this->_engine->fetch('collections/dashboard_items/recent_punishments'); } public function getWidth(): float { diff --git a/modules/Core/collections/panel/RecentRegistrations.php b/modules/Core/collections/panel/RecentRegistrations.php index 968d9637b6..0b53dec51d 100644 --- a/modules/Core/collections/panel/RecentRegistrations.php +++ b/modules/Core/collections/panel/RecentRegistrations.php @@ -2,20 +2,20 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Recent registrations dashboard collection item */ class RecentRegistrationsItem extends CollectionItemBase { - private Smarty $_smarty; + private TemplateEngine $_engine; private Language $_language; private Cache $_cache; - public function __construct(Smarty $smarty, Language $language, Cache $cache) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache) { $cache->setCache('dashboard_main_items_collection'); if ($cache->isCached('recent_registrations')) { $from_cache = $cache->retrieve('recent_registrations'); @@ -29,14 +29,14 @@ public function __construct(Smarty $smarty, Language $language, Cache $cache) { parent::__construct($order, $enabled); - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; $this->_cache = $cache; } public function getContent(): string { // Get recent registrations - $timeago = new TimeAgo(TIMEZONE); + $timeAgo = new TimeAgo(TIMEZONE); $this->_cache->setCache('dashboard_main_items_collection'); @@ -58,7 +58,7 @@ public function getContent(): string { 'style' => $target_user->getGroupStyle(), 'avatar' => $target_user->getAvatar(), 'groups' => $target_user->getAllGroupHtml(), - 'time' => $timeago->inWords($item->joined, $this->_language), + 'time' => $timeAgo->inWords($item->joined, $this->_language), 'time_full' => date(DATE_FORMAT, $item->joined), ]; @@ -71,14 +71,14 @@ public function getContent(): string { $this->_cache->store('recent_registrations_data', $data, 60); } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'RECENT_REGISTRATIONS' => $this->_language->get('moderator', 'recent_registrations'), 'REGISTRATIONS' => $data, 'REGISTERED' => $this->_language->get('user', 'registered'), 'VIEW' => $this->_language->get('general', 'view') ]); - return $this->_smarty->fetch('collections/dashboard_items/recent_registrations.tpl'); + return $this->_engine->fetch('collections/dashboard_items/recent_registrations'); } public function getWidth(): float { diff --git a/modules/Core/collections/panel/RecentReports.php b/modules/Core/collections/panel/RecentReports.php index 2afc0fd208..a004623327 100644 --- a/modules/Core/collections/panel/RecentReports.php +++ b/modules/Core/collections/panel/RecentReports.php @@ -2,20 +2,20 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr9 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Recent reports dashboard collection item */ class RecentReportsItem extends CollectionItemBase { - private Smarty $_smarty; + private TemplateEngine $_engine; private Language $_language; private Cache $_cache; - public function __construct(Smarty $smarty, Language $language, Cache $cache) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache) { $cache->setCache('dashboard_main_items_collection'); if ($cache->isCached('recent_reports')) { $from_cache = $cache->retrieve('recent_reports'); @@ -29,7 +29,7 @@ public function __construct(Smarty $smarty, Language $language, Cache $cache) { parent::__construct($order, $enabled); - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; $this->_cache = $cache; } @@ -96,7 +96,7 @@ public function getContent(): string { $this->_cache->store('recent_reports_data', $data, 60); } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'RECENT_REPORTS' => $this->_language->get('moderator', 'recent_reports'), 'REPORTS' => $data, 'NO_REPORTS' => $this->_language->get('moderator', 'no_open_reports'), @@ -108,7 +108,7 @@ public function getContent(): string { 'VIEW' => $this->_language->get('general', 'view') ]); - return $this->_smarty->fetch('collections/dashboard_items/recent_reports.tpl'); + return $this->_engine->fetch('collections/dashboard_items/recent_reports'); } public function getWidth(): float { diff --git a/modules/Core/collections/panel/RecentUsers.php b/modules/Core/collections/panel/RecentUsers.php index 5e1d938a37..85c5223921 100644 --- a/modules/Core/collections/panel/RecentUsers.php +++ b/modules/Core/collections/panel/RecentUsers.php @@ -2,19 +2,19 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Recent users dashboard collection item */ class RecentUsersItem extends CollectionItemBase { - private Smarty $_smarty; + private TemplateEngine $_engine; private Language $_language; - public function __construct(Smarty $smarty, Language $language, Cache $cache) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache) { $cache->setCache('dashboard_stats_collection'); if ($cache->isCached('recent_users')) { $from_cache = $cache->retrieve('recent_users'); @@ -28,7 +28,7 @@ public function __construct(Smarty $smarty, Language $language, Cache $cache) { parent::__construct($order, $enabled); - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; } @@ -39,11 +39,11 @@ public function getContent(): string { [strtotime('7 days ago')], )->first()->c; - $this->_smarty->assign([ + $this->_engine->addVariables([ 'TITLE' => $this->_language->get('admin', 'recent_users'), 'VALUE' => $users_query ]); - return $this->_smarty->fetch('collections/dashboard_stats/recent_users.tpl'); + return $this->_engine->fetch('collections/dashboard_stats/recent_users'); } } diff --git a/modules/Core/collections/panel/TotalUsers.php b/modules/Core/collections/panel/TotalUsers.php index bde27bbcb4..d36dac91da 100644 --- a/modules/Core/collections/panel/TotalUsers.php +++ b/modules/Core/collections/panel/TotalUsers.php @@ -2,19 +2,19 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Total users dashboard collection item */ class TotalUsersItem extends CollectionItemBase { - private Smarty $_smarty; + private TemplateEngine $_engine; private Language $_language; - public function __construct(Smarty $smarty, Language $language, Cache $cache) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache) { $cache->setCache('dashboard_stats_collection'); if ($cache->isCached('total_users')) { $from_cache = $cache->retrieve('total_users'); @@ -28,7 +28,7 @@ public function __construct(Smarty $smarty, Language $language, Cache $cache) { parent::__construct($order, $enabled); - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; } @@ -36,11 +36,11 @@ public function getContent(): string { // Get the number of total users $users_query = DB::getInstance()->query('SELECT COUNT(*) AS c FROM nl2_users')->first()->c; - $this->_smarty->assign([ + $this->_engine->addVariables([ 'TITLE' => $this->_language->get('admin', 'total_users'), 'VALUE' => $users_query ]); - return $this->_smarty->fetch('collections/dashboard_stats/total_users.tpl'); + return $this->_engine->fetch('collections/dashboard_stats/total_users'); } } diff --git a/modules/Core/module.php b/modules/Core/module.php index 8008679297..f4cc0fdf77 100644 --- a/modules/Core/module.php +++ b/modules/Core/module.php @@ -1,12 +1,10 @@ Samerton'; - $module_version = '2.1.2'; - $nameless_version = '2.1.2'; + $module_version = '2.2.0'; + $nameless_version = '2.2.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -587,7 +585,15 @@ public function onDisable() { // Not necessary for Core } - public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smarty, $navs, Widgets $widgets, ?TemplateBase $template) { + public function onPageLoad( + User $user, + Pages $pages, + Cache $cache, + $smarty, + iterable $navs, + Widgets $widgets, + ?TemplateBase $template + ) { $language = $this->_language; // Permissions @@ -677,7 +683,7 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart $cache->setCache('social_media'); $fb_url = Settings::get('fb_url'); if ($fb_url) { - $widgets->add(new FacebookWidget($smarty, $fb_url)); + $widgets->add(new FacebookWidget($template->getEngine(), $fb_url)); } // Twitter @@ -685,30 +691,30 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart if ($twitter) { $theme = Settings::get('twitter_style'); - $widgets->add(new TwitterWidget($smarty, $twitter, $theme)); + $widgets->add(new TwitterWidget($template->getEngine(), $twitter, $theme)); } // Profile Posts - $widgets->add(new ProfilePostsWidget($smarty, $language, $cache, $user, new TimeAgo(TIMEZONE))); + $widgets->add(new ProfilePostsWidget($template->getEngine(), $language, $cache, $user, new TimeAgo(TIMEZONE))); // Online staff - $widgets->add(new OnlineStaffWidget($smarty, $language, $cache)); + $widgets->add(new OnlineStaffWidget($template->getEngine(), $language, $cache)); // Online users - $widgets->add(new OnlineUsersWidget($cache, $smarty, $language)); + $widgets->add(new OnlineUsersWidget($cache, $template->getEngine(), $language)); // Online users - $widgets->add(new ServerStatusWidget($smarty, $language, $cache)); + $widgets->add(new ServerStatusWidget($template->getEngine(), $language, $cache)); // Statistics - $widgets->add(new StatsWidget($smarty, $language, $cache)); + $widgets->add(new StatsWidget($template->getEngine(), $language, $cache)); // Reactions profile widget - $widgets->add(new ReactionsProfileWidget($smarty, $language)); + $widgets->add(new ReactionsProfileWidget($template->getEngine(), $language)); // Minecraft account profile widget if (Settings::get('mc_integration')) { - $widgets->add(new MinecraftAccountProfileWidget($smarty, $cache, $language)); + $widgets->add(new MinecraftAccountProfileWidget($template->getEngine(), $cache, $language)); } } @@ -747,7 +753,7 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart } if (!is_string($update_check) && $update_check->updateAvailable()) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'NEW_UPDATE' => $update_check->isUrgent() ? $language->get('admin', 'new_urgent_update_available') : $language->get('admin', 'new_update_available'), @@ -910,49 +916,53 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart } } - $smarty->assign('MINECRAFT', true); + $template->getEngine()->addVariable('MINECRAFT', true); if (isset($result)) { - $smarty->assign('SERVER_QUERY', $result); + $template->getEngine()->addVariable('SERVER_QUERY', $result); } if (!is_null($default) && isset($default->ip)) { - $smarty->assign('CONNECT_WITH', $language->get('general', 'connect_with_ip_x', [ - 'address' => '' . Output::getClean($default->ip . ($default->port && $default->port != 25565 ? ':' . $default->port : '')) . '', - ])); - $smarty->assign('DEFAULT_IP', Output::getClean($default->ip . ($default->port != 25565 ? ':' . $default->port : ''))); - $smarty->assign('CLICK_TO_COPY_TOOLTIP', $language->get('general', 'click_to_copy_tooltip')); - $smarty->assign('COPIED', $language->get('general', 'copied')); + $template->getEngine()->addVariables([ + 'CONNECT_WITH' => $language->get('general', 'connect_with_ip_x', [ + 'address' => '' . Output::getClean($default->ip . ($default->port && $default->port != 25565 ? ':' . $default->port : '')) . '', + ]), + 'DEFAULT_IP' => Output::getClean($default->ip . ($default->port != 25565 ? ':' . $default->port : '')), + 'CLICK_TO_COPY_TOOLTIP' => $language->get('general', 'click_to_copy_tooltip'), + 'COPIED' => $language->get('general', 'copied'), + ]); } else { - $smarty->assign('CONNECT_WITH', ''); - $smarty->assign('DEFAULT_IP', ''); + $template->getEngine()->addVariables([ + 'CONNECT_WITH' => '', + 'DEFAULT_IP' => '', + ]); } - $smarty->assign('SERVER_OFFLINE', $language->get('general', 'server_offline')); + $template->getEngine()->addVariable('SERVER_OFFLINE', $language->get('general', 'server_offline')); } if (defined('PAGE') && PAGE == 'user_query') { // Collection - $user_id = $smarty->getTemplateVars('USER_ID'); + $user_id = $template->getEngine()->getVariable('USER_ID'); - $timeago = new TimeAgo(TIMEZONE); + $timeAgo = new TimeAgo(TIMEZONE); if ($user_id) { $user_query = DB::getInstance()->get('users', ['id', $user_id])->results(); if (count($user_query)) { $user_query = new UserData($user_query[0]); - $smarty->assign([ + $template->getEngine()->addVariables([ 'REGISTERED' => $language->get('user', 'registered_x', [ - 'registeredAt' => $timeago->inWords($user_query->joined, $language), + 'registeredAt' => $timeAgo->inWords($user_query->joined, $language), ]), 'REGISTERED_DATE' => date(DATE_FORMAT, $user_query->joined), ]); if ($user->canBypassPrivateProfile() || (!Settings::get('private_profile') || !$user_query->private_profile)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'LAST_SEEN' => $language->get('user', 'last_seen_x', [ - 'lastSeenAt' => $timeago->inWords($user_query->last_online, $language), + 'lastSeenAt' => $timeAgo->inWords($user_query->last_online, $language), ]), 'LAST_SEEN_DATE' => date(DATE_FORMAT, $user_query->last_online) ]); @@ -1482,26 +1492,26 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart self::addDataToDashboardGraph($language->get('admin', 'overview'), $data); // Dashboard stats - require_once(ROOT_PATH . '/modules/Core/collections/panel/TotalUsers.php'); - CollectionManager::addItemToCollection('dashboard_stats', new TotalUsersItem($smarty, $language, $cache)); + require_once ROOT_PATH . '/modules/Core/collections/panel/TotalUsers.php'; + CollectionManager::addItemToCollection('dashboard_stats', new TotalUsersItem($template->getEngine(), $language, $cache)); - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentUsers.php'); - CollectionManager::addItemToCollection('dashboard_stats', new RecentUsersItem($smarty, $language, $cache)); + require_once ROOT_PATH . '/modules/Core/collections/panel/RecentUsers.php'; + CollectionManager::addItemToCollection('dashboard_stats', new RecentUsersItem($template->getEngine(), $language, $cache)); // Dashboard items if ($user->hasPermission('modcp.punishments')) { - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentPunishments.php'); - CollectionManager::addItemToCollection('dashboard_main_items', new RecentPunishmentsItem($smarty, $language, $cache)); + require_once ROOT_PATH . '/modules/Core/collections/panel/RecentPunishments.php'; + CollectionManager::addItemToCollection('dashboard_main_items', new RecentPunishmentsItem($template->getEngine(), $language, $cache)); } if ($user->hasPermission('modcp.reports')) { - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentReports.php'); - CollectionManager::addItemToCollection('dashboard_main_items', new RecentReportsItem($smarty, $language, $cache)); + require_once ROOT_PATH . '/modules/Core/collections/panel/RecentReports.php'; + CollectionManager::addItemToCollection('dashboard_main_items', new RecentReportsItem($template->getEngine(), $language, $cache)); } if ($user->hasPermission('admincp.users')) { - require_once(ROOT_PATH . '/modules/Core/collections/panel/RecentRegistrations.php'); - CollectionManager::addItemToCollection('dashboard_main_items', new RecentRegistrationsItem($smarty, $language, $cache)); + require_once ROOT_PATH . '/modules/Core/collections/panel/RecentRegistrations.php'; + CollectionManager::addItemToCollection('dashboard_main_items', new RecentRegistrationsItem($template->getEngine(), $language, $cache)); } } diff --git a/modules/Core/pages/authme_connector.php b/modules/Core/pages/authme_connector.php index 31ff47561d..b90fc773f3 100644 --- a/modules/Core/pages/authme_connector.php +++ b/modules/Core/pages/authme_connector.php @@ -1,17 +1,26 @@ get('general', 'register'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); -require_once(ROOT_PATH . '/modules/Core/includes/emails/register.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; +require_once ROOT_PATH . '/modules/Core/includes/emails/register.php'; // Use recaptcha? $captcha = CaptchaBase::isCaptchaEnabled(); @@ -348,13 +357,13 @@ } if (count($errors)) { - $smarty->assign('ERRORS', $errors); + $template->getEngine()->addVariable('ERRORS', $errors); } -$smarty->assign('ERROR', $language->get('general', 'error')); +$template->getEngine()->addVariable('ERROR', $language->get('general', 'error')); if (!isset($_GET['step'])) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'AUTHME_SETUP' => Config::get('authme'), 'AUTHME_NOT_SETUP' => $language->get('user', 'authme_not_setup'), 'CONNECT_WITH_AUTHME' => $language->get('user', 'connect_with_authme'), @@ -373,7 +382,7 @@ // Recaptcha if ($captcha) { - $smarty->assign('CAPTCHA', CaptchaBase::getActiveProvider()->getHtml()); + $template->getEngine()->addVariable('CAPTCHA', CaptchaBase::getActiveProvider()->getHtml()); $template->addJSFiles([CaptchaBase::getActiveProvider()->getJavascriptSource() => []]); $submitScript = CaptchaBase::getActiveProvider()->getJavascriptSubmit('form-contact'); @@ -387,7 +396,7 @@ } } - $template_file = ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme.tpl'; + $template_file = ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme'; } else { $fields = new Fields(); // Step 2 @@ -418,7 +427,7 @@ ); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CONNECT_WITH_AUTHME' => $language->get('user', 'connect_with_authme'), 'AUTHME_SYNC_PASSWORD' => $language->get('user', 'authme_sync_password'), 'AUTHME_SYNC_PASSWORD_HELP' => $language->get('user', 'authme_sync_password_help'), @@ -430,7 +439,7 @@ 'SUBMIT' => $language->get('general', 'submit'), ]); - $template_file = ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme_email.tpl'; + $template_file = ROOT_PATH . '/custom/templates/' . TEMPLATE . '/authme_email'; } // Load modules + template @@ -438,7 +447,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/complete_signup.php b/modules/Core/pages/complete_signup.php index eec7b35baa..2d2f9d5514 100644 --- a/modules/Core/pages/complete_signup.php +++ b/modules/Core/pages/complete_signup.php @@ -1,19 +1,28 @@ get('general', 'register'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -90,15 +99,15 @@ Redirect::to(URL::build('/')); } -// Smarty variables +// Template variables if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS_TITLE' => $language->get('general', 'error'), 'ERRORS' => $errors ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'REGISTER' => $language->get('general', 'register'), 'PASSWORD' => $language->get('user', 'password'), 'CONFIRM_PASSWORD' => $language->get('user', 'confirm_password'), @@ -113,7 +122,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; -$template->displayTemplate('complete_signup.tpl', $smarty); +$template->displayTemplate('complete_signup'); diff --git a/modules/Core/pages/custom.php b/modules/Core/pages/custom.php index a527e3b33d..1b6cd25f4a 100644 --- a/modules/Core/pages/custom.php +++ b/modules/Core/pages/custom.php @@ -1,18 +1,28 @@ get('custom_pages', ['url', rtrim($route, '/')]); if (!$custom_page->count()) { - require(ROOT_PATH . '/404.php'); + require ROOT_PATH . '/404.php'; die(); } @@ -47,7 +57,7 @@ } if (!isset($can_view)) { - require(ROOT_PATH . '/403.php'); + require ROOT_PATH . '/403.php'; die(); } @@ -60,7 +70,7 @@ define('PAGE', $custom_page->id); define('CUSTOM_PAGE', $custom_page->title); $page_title = Output::getClean($custom_page->title); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $template->assets()->include([ DARK_MODE @@ -77,7 +87,7 @@ 'skip_purify' => $custom_page->all_html ?? false ])['content']; -$smarty->assign([ +$template->getEngine()->addVariables([ 'WIDGETS_LEFT' => $widgets->getWidgets('left'), 'WIDGETS_RIGHT' => $widgets->getWidgets('right'), 'CONTENT' => $content, @@ -85,11 +95,11 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; if ($custom_page->basic) { - $template->displayTemplate('custom_basic.tpl', $smarty); + $template->displayTemplate('custom_basic'); } else { - $template->displayTemplate('custom.tpl', $smarty); + $template->displayTemplate('custom'); } diff --git a/modules/Core/pages/forgot_password.php b/modules/Core/pages/forgot_password.php index f12f448519..887daca090 100644 --- a/modules/Core/pages/forgot_password.php +++ b/modules/Core/pages/forgot_password.php @@ -1,18 +1,28 @@ get('user', 'forgot_password')); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Ensure user is not logged in if ($user->isLoggedIn()) { @@ -80,20 +90,20 @@ } if (isset($error)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR_TITLE' => $language->get('general', 'error'), 'ERROR' => $error ]); } else { if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS_TITLE' => $language->get('general', 'success'), 'SUCCESS' => $success ]); } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'FORGOT_PASSWORD' => str_replace('?', '', $language->get('user', 'forgot_password')), 'FORGOT_PASSWORD_INSTRUCTIONS' => $language->get('user', 'forgot_password_instructions'), 'EMAIL_ADDRESS' => $language->get('user', 'email_address'), @@ -105,11 +115,11 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('forgot_password.tpl', $smarty); + $template->displayTemplate('forgot_password'); } else { // Check code exists $target_user = new User($_GET['c'], 'reset_code'); @@ -165,13 +175,13 @@ } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR_TITLE' => $language->get('general', 'error'), 'ERROR' => $errors ]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'FORGOT_PASSWORD' => str_replace('?', '', $language->get('user', 'forgot_password')), 'ENTER_NEW_PASSWORD' => $language->get('user', 'enter_new_password'), 'EMAIL_ADDRESS' => $language->get('user', 'email_address'), @@ -186,9 +196,9 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('change_password.tpl', $smarty); + $template->displayTemplate('change_password'); } diff --git a/modules/Core/pages/home.php b/modules/Core/pages/home.php index 9e310399fb..d74f1f3133 100644 --- a/modules/Core/pages/home.php +++ b/modules/Core/pages/home.php @@ -1,12 +1,22 @@ assign('HOME_SESSION_FLASH', Session::flash('home')); - $smarty->assign('SUCCESS_TITLE', $language->get('general', 'success')); + $template->getEngine()->addVariables([ + 'HOME_SESSION_FLASH' => Session::flash('home'), + 'SUCCESS_TITLE' => $language->get('general', 'success'), + ]); } if (Session::exists('home_error')) { - $smarty->assign('HOME_SESSION_ERROR_FLASH', Session::flash('home_error')); - $smarty->assign('ERROR_TITLE', $language->get('general', 'error')); + $template->getEngine()->addVariables([ + 'HOME_SESSION_ERROR_FLASH' => Session::flash('home_error'), + 'ERROR_TITLE' => $language->get('general', 'error'), + ]); } $home_type = Settings::get('home_type'); -$smarty->assign('HOME_TYPE', $home_type); - if ($home_type === 'news') { foreach ($front_page_modules as $module) { require(ROOT_PATH . '/' . $module); } } else if ($home_type === 'custom') { - $smarty->assign('CUSTOM_HOME_CONTENT', Settings::get('home_custom_content')); + $template->getEngine()->addVariable('CUSTOM_HOME_CONTENT', Settings::get('home_custom_content')); } // Assign to Smarty variables -$smarty->assign('SOCIAL', $language->get('general', 'social')); +$template->getEngine()->addVariables([ + 'HOME_TYPE' => $home_type, + 'SOCIAL' => $language->get('general', 'social'), +]); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -54,8 +69,8 @@ $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('index.tpl', $smarty); +$template->displayTemplate('index'); diff --git a/modules/Core/pages/leaderboards.php b/modules/Core/pages/leaderboards.php index 43cdba603e..cffec55477 100644 --- a/modules/Core/pages/leaderboards.php +++ b/modules/Core/pages/leaderboards.php @@ -1,35 +1,45 @@ getLeaderboardPlaceholders(); if (!count($leaderboard_placeholders)) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } const PAGE = 'leaderboards'; $page_title = $language->get('general', 'leaderboards'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $leaderboard_placeholders_data = []; $leaderboard_users = []; -$timeago = new TimeAgo(TIMEZONE); +$timeAgo = new TimeAgo(TIMEZONE); foreach ($leaderboard_placeholders as $leaderboard_placeholder) { // Get all rows from user placeholder table with this placeholders server id + name @@ -58,13 +68,13 @@ $row_data->username = Output::getClean($leaderboard_users[$uuid]->data()->username); $row_data->avatar = AvatarSource::getAvatarFromUUID($uuid, 24); $row_data->value = $row->value; - $row_data->last_updated = ucfirst($timeago->inWords($row->last_updated, $language)); + $row_data->last_updated = ucfirst($timeAgo->inWords($row->last_updated, $language)); $leaderboard_placeholders_data[] = $row_data; } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PLAYER' => $language->get('admin', 'placeholders_player'), 'SCORE' => $language->get('admin', 'placeholders_score'), 'LAST_UPDATED' => $language->get('admin', 'placeholders_last_updated'), @@ -110,8 +120,8 @@ function hideTables() { $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('leaderboards.tpl', $smarty); +$template->displayTemplate('leaderboards'); diff --git a/modules/Core/pages/login.php b/modules/Core/pages/login.php index edc0613ed9..d16f5500ab 100644 --- a/modules/Core/pages/login.php +++ b/modules/Core/pages/login.php @@ -1,12 +1,21 @@ assign('EMAIL', $language->get('user', 'email')); + $template->getEngine()->addVariable('EMAIL', $language->get('user', 'email')); } else if ($login_method == 'email_or_username') { - $smarty->assign('USERNAME', $language->get('user', 'email_or_username')); + $template->getEngine()->addVariable('USERNAME', $language->get('user', 'email_or_username')); } else if (Settings::get('mc_integration')) { - $smarty->assign('USERNAME', $language->get('user', 'minecraft_username')); + $template->getEngine()->addVariable('USERNAME', $language->get('user', 'minecraft_username')); } else { - $smarty->assign('USERNAME', $language->get('user', 'username')); + $template->getEngine()->addVariable('USERNAME', $language->get('user', 'username')); } // Add "login with..." message to provider array @@ -265,7 +274,7 @@ ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'USERNAME_INPUT' => ($login_method == 'email' ? Output::getClean(Input::get('email')) : Output::getClean(Input::get('username'))), 'PASSWORD' => $language->get('user', 'password'), 'REMEMBER_ME' => $language->get('user', 'remember_me'), @@ -284,17 +293,17 @@ ]); if (Session::exists('oauth_error')) { - $smarty->assign('ERROR', [Session::flash('oauth_error')]); + $template->getEngine()->addVariable('ERROR', [Session::flash('oauth_error')]); } else if (isset($return_error)) { - $smarty->assign('ERROR', $return_error); + $template->getEngine()->addVariable('ERROR', $return_error); } if (Session::exists('login_success')) { - $smarty->assign('SUCCESS', Session::flash('login_success')); + $template->getEngine()->addVariable('SUCCESS', Session::flash('login_success')); } if ($captcha) { - $smarty->assign('CAPTCHA', CaptchaBase::getActiveProvider()->getHtml()); + $template->getEngine()->addVariable('CAPTCHA', CaptchaBase::getActiveProvider()->getHtml()); $template->addJSFiles([CaptchaBase::getActiveProvider()->getJavascriptSource() => []]); $submitScript = CaptchaBase::getActiveProvider()->getJavascriptSubmit('form-login'); @@ -313,8 +322,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('login.tpl', $smarty); +$template->displayTemplate('login'); diff --git a/modules/Core/pages/panel/announcements.php b/modules/Core/pages/panel/announcements.php index 46706f9413..77a766a032 100644 --- a/modules/Core/pages/panel/announcements.php +++ b/modules/Core/pages/panel/announcements.php @@ -1,16 +1,26 @@ handlePanelPageLoad('admincp.core.announcements')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +28,7 @@ const PARENT_PAGE = 'announcements'; const PANEL_PAGE = 'announcements'; $page_title = $language->get('admin', 'announcements'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['action'])) { // View all announcements @@ -32,15 +42,13 @@ } if (count($announcements_list) >= 1) { - $smarty->assign([ - 'ALL_ANNOUNCEMENTS' => $announcements_list - ]); + $template->getEngine()->addVariable('ALL_ANNOUNCEMENTS', $announcements_list); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'NONE' => $language->get('general', 'none'), 'NO_ANNOUNCEMENTS' => $language->get('admin', 'no_announcements'), - 'ANNOUCEMENTS_INFO' => $language->get('admin', 'announcement_info'), + 'ANNOUNCEMENTS_INFO' => $language->get('admin', 'announcement_info'), 'NEW_LINK' => URL::build('/panel/core/announcements', 'action=new'), 'NEW' => $language->get('admin', 'new_announcement'), 'ACTIONS' => $language->get('general', 'actions'), @@ -49,7 +57,7 @@ 'REORDER_DRAG_URL' => URL::build('/panel/core/announcements') ]); - $template_file = 'core/announcements.tpl'; + $template_file = 'core/announcements'; } else { switch ($_GET['action']) { case 'new': @@ -120,7 +128,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'ANNOUNCEMENT_TITLE' => $language->get('admin', 'creating_announcement'), 'HEADER_VALUE' => ((isset($_POST['header']) && $_POST['header']) ? Output::getClean(Input::get('header')) : ''), 'MESSAGE_VALUE' => ((isset($_POST['message']) && $_POST['message']) ? Output::getClean(Input::get('message')) : ''), @@ -134,7 +142,7 @@ 'GUEST_PERMISSIONS' => (isset($_POST['perm-view-0']) && $_POST['perm-view-0'] == 1) ]); - $template_file = 'core/announcements_form.tpl'; + $template_file = 'core/announcements_form'; break; case 'edit': // Edit hook @@ -219,7 +227,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'ANNOUNCEMENT_TITLE' => $language->get('admin', 'editing_announcement'), 'HEADER_VALUE' => Output::getClean($announcement->header), 'MESSAGE_VALUE' => Output::getClean($announcement->message), @@ -281,25 +289,25 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('announcement_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('announcement_success'), 'SUCCESS_TITLE' => $language->get('general', 'success') ]); } if (Session::exists('announcement_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => [Session::flash('announcement_error')], 'ERRORS_TITLE' => $language->get('general', 'error') ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, 'ERRORS_TITLE' => $language->get('general', 'error') ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PAGE' => PANEL_PAGE, 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), @@ -336,7 +344,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/api.php b/modules/Core/pages/panel/api.php index 28ba2b71e5..7c576ddfb5 100644 --- a/modules/Core/pages/panel/api.php +++ b/modules/Core/pages/panel/api.php @@ -1,16 +1,27 @@ handlePanelPageLoad('admincp.core.api')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +29,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'api'; $page_title = $language->get('admin', 'api'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['view'])) { if (Input::exists()) { @@ -153,69 +164,63 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('api_success')) { - $smarty->assign( - [ - 'SUCCESS' => Session::flash('api_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') - ] - ); + $template->getEngine()->addVariables([ + 'SUCCESS' => Session::flash('api_success'), + 'SUCCESS_TITLE' => $language->get('general', 'success'), + ]); } if (isset($errors) && count($errors)) { - $smarty->assign( - [ - 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') - ] - ); + $template->getEngine()->addVariables([ + 'ERRORS' => $errors, + 'ERRORS_TITLE' => $language->get('general', 'error'), + ]); } if (!isset($_GET['view'])) { // Is the API enabled? $api_enabled = Settings::get('use_api'); - $smarty->assign( - [ - 'PARENT_PAGE' => PARENT_PAGE, - 'DASHBOARD' => $language->get('admin', 'dashboard'), - 'CONFIGURATION' => $language->get('admin', 'configuration'), - 'API' => $language->get('admin', 'api'), - 'PAGE' => PANEL_PAGE, - 'API_INFO' => $language->get('admin', 'api_info', [ - 'pluginLinkStart' => '', - 'pluginLinkEnd' => '', - 'botLinkStart' => '', - 'botLinkEnd' => '', - ]), - 'INFO' => $language->get('general', 'info'), - 'ENABLE_API' => $language->get('admin', 'enable_api'), - 'API_ENABLED' => $api_enabled, - 'API_KEY' => $language->get('admin', 'api_key'), - 'API_KEY_VALUE' => Settings::get('mc_api_key'), - 'API_KEY_REGEN_URL' => URL::build('/panel/core/api/', 'action=api_regen'), - 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), - 'CONFIRM_API_REGEN' => $language->get('admin', 'confirm_api_regen'), - 'YES' => $language->get('general', 'yes'), - 'NO' => $language->get('general', 'no'), - 'CHANGE' => $language->get('general', 'change'), - 'API_URL' => $language->get('admin', 'api_url'), - 'API_URL_VALUE' => rtrim(URL::getSelfURL(), '/') . rtrim(URL::build('/api/v2/', '', 'non-friendly'), '/'), - 'ENABLE_API_FOR_URL' => $language->get('admin', 'api_disabled'), - 'COPY' => $language->get('admin', 'copy'), - 'USERNAME_SYNC' => $language->get('admin', 'enable_username_sync'), - 'USERNAME_SYNC_INFO' => $language->get('admin', 'enable_username_sync_info'), - 'USERNAME_SYNC_VALUE' => Settings::get('username_sync') === '1', - 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit'), - 'COPIED' => $language->get('general', 'copied'), - 'GROUP_SYNC' => $language->get('admin', 'group_sync'), - 'GROUP_SYNC_LINK' => URL::build('/panel/core/api/', 'view=group_sync'), - 'API_ENDPOINTS' => $language->get('admin', 'api_endpoints'), - 'API_ENDPOINTS_LINK' => URL::build('/panel/core/api/', 'view=api_endpoints') - ] - ); - - $template_file = 'core/api.tpl'; + $template->getEngine()->addVariables([ + 'PARENT_PAGE' => PARENT_PAGE, + 'DASHBOARD' => $language->get('admin', 'dashboard'), + 'CONFIGURATION' => $language->get('admin', 'configuration'), + 'API' => $language->get('admin', 'api'), + 'PAGE' => PANEL_PAGE, + 'API_INFO' => $language->get('admin', 'api_info', [ + 'pluginLinkStart' => '', + 'pluginLinkEnd' => '', + 'botLinkStart' => '', + 'botLinkEnd' => '', + ]), + 'INFO' => $language->get('general', 'info'), + 'ENABLE_API' => $language->get('admin', 'enable_api'), + 'API_ENABLED' => $api_enabled, + 'API_KEY' => $language->get('admin', 'api_key'), + 'API_KEY_VALUE' => Settings::get('mc_api_key'), + 'API_KEY_REGEN_URL' => URL::build('/panel/core/api/', 'action=api_regen'), + 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), + 'CONFIRM_API_REGEN' => $language->get('admin', 'confirm_api_regen'), + 'YES' => $language->get('general', 'yes'), + 'NO' => $language->get('general', 'no'), + 'CHANGE' => $language->get('general', 'change'), + 'API_URL' => $language->get('admin', 'api_url'), + 'API_URL_VALUE' => rtrim(URL::getSelfURL(), '/') . rtrim(URL::build('/api/v2/', '', 'non-friendly'), '/'), + 'ENABLE_API_FOR_URL' => $language->get('admin', 'api_disabled'), + 'COPY' => $language->get('admin', 'copy'), + 'USERNAME_SYNC' => $language->get('admin', 'enable_username_sync'), + 'USERNAME_SYNC_INFO' => $language->get('admin', 'enable_username_sync_info'), + 'USERNAME_SYNC_VALUE' => Settings::get('username_sync') === '1', + 'TOKEN' => Token::get(), + 'SUBMIT' => $language->get('general', 'submit'), + 'COPIED' => $language->get('general', 'copied'), + 'GROUP_SYNC' => $language->get('admin', 'group_sync'), + 'GROUP_SYNC_LINK' => URL::build('/panel/core/api/', 'view=group_sync'), + 'API_ENDPOINTS' => $language->get('admin', 'api_endpoints'), + 'API_ENDPOINTS_LINK' => URL::build('/panel/core/api/', 'view=api_endpoints'), + ]); + + $template_file = 'core/api'; } else { if ($_GET['view'] == 'group_sync') { @@ -229,34 +234,32 @@ $group_sync_values[] = $rule_values; } - $smarty->assign( - [ - 'PARENT_PAGE' => PARENT_PAGE, - 'DASHBOARD' => $language->get('admin', 'dashboard'), - 'CONFIGURATION' => $language->get('admin', 'configuration'), - 'API' => $language->get('admin', 'api'), - 'PAGE' => PANEL_PAGE, - 'INFO' => $language->get('general', 'info'), - 'GROUP_SYNC_INFO' => $language->get('admin', 'group_sync_info'), - 'BACK' => $language->get('general', 'back'), - 'BACK_LINK' => URL::build('/panel/core/api'), - 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit'), - 'GROUP_SYNC_VALUES' => $group_sync_values, - 'GROUP_SYNC_INJECTORS' => GroupSyncManager::getInstance()->getInjectors(), - 'ENABLED_GROUP_SYNC_INJECTORS' => GroupSyncManager::getInstance()->getEnabledInjectors(), - 'NAMELESS_INJECTOR_COLUMN' => GroupSyncManager::getInstance()->getInjectorByClass(NamelessMCGroupSyncInjector::class)->getColumnName(), - 'LANGUAGE' => $language, - 'DELETE' => $language->get('general', 'delete'), - 'NEW_RULE' => $language->get('admin', 'new_rule'), - 'EXISTING_RULES' => $language->get('admin', 'existing_rules'), - 'DELETE_LINK' => URL::build('/panel/core/api/', 'view=group_sync'), - 'NONE' => $language->get('general', 'none'), - 'DISABLED' => $language->get('admin', 'disabled') - ] - ); - - $template_file = 'core/api_group_sync.tpl'; + $template->getEngine()->addVariables([ + 'PARENT_PAGE' => PARENT_PAGE, + 'DASHBOARD' => $language->get('admin', 'dashboard'), + 'CONFIGURATION' => $language->get('admin', 'configuration'), + 'API' => $language->get('admin', 'api'), + 'PAGE' => PANEL_PAGE, + 'INFO' => $language->get('general', 'info'), + 'GROUP_SYNC_INFO' => $language->get('admin', 'group_sync_info'), + 'BACK' => $language->get('general', 'back'), + 'BACK_LINK' => URL::build('/panel/core/api'), + 'TOKEN' => Token::get(), + 'SUBMIT' => $language->get('general', 'submit'), + 'GROUP_SYNC_VALUES' => $group_sync_values, + 'GROUP_SYNC_INJECTORS' => GroupSyncManager::getInstance()->getInjectors(), + 'ENABLED_GROUP_SYNC_INJECTORS' => GroupSyncManager::getInstance()->getEnabledInjectors(), + 'NAMELESS_INJECTOR_COLUMN' => GroupSyncManager::getInstance()->getInjectorByClass(NamelessMCGroupSyncInjector::class)->getColumnName(), + 'LANGUAGE' => $language, + 'DELETE' => $language->get('general', 'delete'), + 'NEW_RULE' => $language->get('admin', 'new_rule'), + 'EXISTING_RULES' => $language->get('admin', 'existing_rules'), + 'DELETE_LINK' => URL::build('/panel/core/api/', 'view=group_sync'), + 'NONE' => $language->get('general', 'none'), + 'DISABLED' => $language->get('admin', 'disabled'), + ]); + + $template_file = 'core/api_group_sync'; } else { if ($_GET['view'] == 'api_endpoints') { @@ -272,38 +275,36 @@ ]; } - $smarty->assign( - [ - 'PARENT_PAGE' => PARENT_PAGE, - 'DASHBOARD' => $language->get('admin', 'dashboard'), - 'CONFIGURATION' => $language->get('admin', 'configuration'), - 'API_ENDPOINTS' => $language->get('admin', 'api_endpoints'), - 'PAGE' => PANEL_PAGE, - 'BACK' => $language->get('general', 'back'), - 'BACK_LINK' => URL::build('/panel/core/api'), - 'ROUTE' => $language->get('admin', 'route'), - 'DESCRIPTION' => $language->get('admin', 'description'), - 'MODULE' => $language->get('admin', 'module'), - 'METHOD' => $language->get('admin', 'method'), - 'ENDPOINTS_INFO' => $language->get('admin', 'api_endpoints_info', [ - 'docLinkStart' => '', - 'docLinkEnd' => '' - ]), - 'ENDPOINTS_ARRAY' => $endpoints_array, - 'TYPE' => $language->get('admin', 'type'), - 'TRANSFORMERS' => $language->get('admin', 'transformers'), - 'TRANSFORMERS_ARRAY' => Endpoints::getAllTransformers(), - ] - ); - - $template_file = 'core/api_endpoints.tpl'; + $template->getEngine()->addVariables([ + 'PARENT_PAGE' => PARENT_PAGE, + 'DASHBOARD' => $language->get('admin', 'dashboard'), + 'CONFIGURATION' => $language->get('admin', 'configuration'), + 'API_ENDPOINTS' => $language->get('admin', 'api_endpoints'), + 'PAGE' => PANEL_PAGE, + 'BACK' => $language->get('general', 'back'), + 'BACK_LINK' => URL::build('/panel/core/api'), + 'ROUTE' => $language->get('admin', 'route'), + 'DESCRIPTION' => $language->get('admin', 'description'), + 'MODULE' => $language->get('admin', 'module'), + 'METHOD' => $language->get('admin', 'method'), + 'ENDPOINTS_INFO' => $language->get('admin', 'api_endpoints_info', [ + 'docLinkStart' => '', + 'docLinkEnd' => '' + ]), + 'ENDPOINTS_ARRAY' => $endpoints_array, + 'TYPE' => $language->get('admin', 'type'), + 'TRANSFORMERS' => $language->get('admin', 'transformers'), + 'TRANSFORMERS_ARRAY' => Endpoints::getAllTransformers(), + ]); + + $template_file = 'core/api_endpoints'; } } } $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/auth.php b/modules/Core/pages/panel/auth.php index 00656ef3a2..cb7e70a1a1 100644 --- a/modules/Core/pages/panel/auth.php +++ b/modules/Core/pages/panel/auth.php @@ -1,12 +1,21 @@ isLoggedIn()) { @@ -26,7 +35,7 @@ const PAGE = 'panel'; const PANEL_PAGE = 'auth'; $page_title = $language->get('admin', 're-authenticate'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Deal with any input if (Input::exists()) { @@ -34,10 +43,9 @@ // Validate input $validation = Validate::check($_POST, [ 'password' => [ - Validate::REQUIRED => true - ] + Validate::REQUIRED => true ] - ); + ]); if ($validation->passed()) { $user = new User(); @@ -68,7 +76,7 @@ } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PLEASE_REAUTHENTICATE' => $language->get('admin', 're-authenticate'), 'PASSWORD' => $language->get('user', 'password'), 'TOKEN' => Token::get(), @@ -77,7 +85,7 @@ ]); if (Session::exists('adm_auth_error')) { - $smarty->assign('ERROR', Session::flash('adm_auth_error')); + $template->getEngine()->addVariable('ERROR', Session::flash('adm_auth_error')); } // Load modules + template @@ -85,7 +93,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('auth.tpl', $smarty); +$template->displayTemplate('auth'); diff --git a/modules/Core/pages/panel/avatars.php b/modules/Core/pages/panel/avatars.php index 73afcfb58c..034f2abc9a 100644 --- a/modules/Core/pages/panel/avatars.php +++ b/modules/Core/pages/panel/avatars.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.avatars')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'avatars'; $page_title = $language->get('admin', 'avatars'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Input if (Input::exists()) { @@ -65,23 +74,23 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (Session::exists('avatar_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('avatar_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -103,7 +112,7 @@ } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -138,7 +147,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/avatars.tpl', $smarty); +$template->displayTemplate('core/avatars'); diff --git a/modules/Core/pages/panel/debugging_and_maintenance.php b/modules/Core/pages/panel/debugging_and_maintenance.php index df95e28f76..ad8e384eaa 100644 --- a/modules/Core/pages/panel/debugging_and_maintenance.php +++ b/modules/Core/pages/panel/debugging_and_maintenance.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.debugging')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'debugging_and_maintenance'; $page_title = $language->get('admin', 'debugging_and_maintenance'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Input if (Input::exists()) { @@ -63,27 +72,27 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('debugging_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('debugging_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } if ($user->hasPermission('admincp.errors')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR_LOGS' => $language->get('admin', 'error_logs'), - 'ERROR_LOGS_LINK' => URL::build('/panel/core/errors') + 'ERROR_LOGS_LINK' => URL::build('/panel/core/errors'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -108,7 +117,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/debugging_and_maintenance.tpl', $smarty); +$template->displayTemplate('core/debugging_and_maintenance'); diff --git a/modules/Core/pages/panel/emails.php b/modules/Core/pages/panel/emails.php index 275b8dcc97..6a736f128f 100644 --- a/modules/Core/pages/panel/emails.php +++ b/modules/Core/pages/panel/emails.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.emails')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'emails'; $page_title = $language->get('admin', 'emails'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Since emails are sent in the user's language, they need to be able to pick which language's messages to edit if (Session::exists('editing_language')) { @@ -37,7 +46,7 @@ if (isset($_GET['action'])) { if ($_GET['action'] == 'test') { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SEND_TEST_EMAIL' => $language->get('admin', 'send_test_email'), 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/emails') @@ -60,7 +69,7 @@ $success = $language->get('admin', 'test_email_success'); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'TEST_EMAIL_QUERY' => $language->get('admin', 'test_email_query'), 'TEST_EMAIL_SUGGEST_1' => $language->get('admin', 'test_email_suggest_1'), 'TEST_EMAIL_SUGGEST_2' => $language->get('admin', 'test_email_suggest_2'), @@ -70,7 +79,7 @@ ]) ]); } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SEND_TEST_EMAIL_INFO' => $language->get('admin', 'send_test_email_info', [ 'email' => Text::bold(Output::getClean($user->data()->email)) ]), @@ -80,7 +89,7 @@ ]); } - $template_file = 'core/emails_test.tpl'; + $template_file = 'core/emails_test'; } else { if ($_GET['action'] == 'edit_messages') { @@ -95,7 +104,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/emails'), 'EMAILS_MESSAGES' => $language->get('admin', 'edit_email_messages'), @@ -119,16 +128,14 @@ 'TOKEN' => Token::get() ]); - $template_file = 'core/emails_edit_messages.tpl'; + $template_file = 'core/emails_edit_messages'; } else { if ($_GET['action'] == 'preview') { $viewing_language = new Language('core', Session::get('editing_language')); - $smarty->assign([ - 'MESSAGE' => Email::formatEmail($_GET['email'], $viewing_language) - ]); + $template->getEngine()->addVariable('MESSAGE', Email::formatEmail($_GET['email'], $viewing_language)); - $template_file = 'core/emails_edit_messages_preview.tpl'; + $template_file = 'core/emails_edit_messages_preview'; } } } @@ -186,13 +193,13 @@ } if ($user->hasPermission('admincp.core.emails_mass_message')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'MASS_MESSAGE' => $language->get('admin', 'emails_mass_message'), 'MASS_MESSAGE_LINK' => URL::build('/panel/core/emails/mass_message'), ]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'MASS_MESSAGE' => $language->get('admin', 'emails_mass_message'), 'MASS_MESSAGE_LINK' => URL::build('/panel/core/emails/mass_message'), 'EDIT_EMAIL_MESSAGES' => $language->get('admin', 'edit_email_messages'), @@ -225,7 +232,7 @@ 'TOKEN' => Token::get() ]); - $template_file = 'core/emails.tpl'; + $template_file = 'core/emails'; } // Load modules + template @@ -236,20 +243,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -261,7 +268,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/emails_errors.php b/modules/Core/pages/panel/emails_errors.php index 21b3cf4883..13b70d2520 100644 --- a/modules/Core/pages/panel/emails_errors.php +++ b/modules/Core/pages/panel/emails_errors.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.emails')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'emails'; $page_title = $language->get('admin', 'email_errors'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (isset($_GET['do'])) { if (in_array($_GET['do'], ['delete', 'purge'])) { @@ -74,7 +83,7 @@ break; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK_LINK' => URL::build('/panel/core/emails/errors'), 'VIEWING_ERROR' => $language->get('admin', 'viewing_email_error'), 'USERNAME' => $language->get('user', 'username'), @@ -101,7 +110,7 @@ if (count($user_validated)) { $user_validated = $user_validated[0]; if ($user_validated->active == 0) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'VALIDATE_USER_LINK' => URL::build('/panel/users/edit/', 'id=' . urlencode($error->user_id) . '&action=validate'), 'VALIDATE_USER_TEXT' => $language->get('admin', 'validate_user') ]); @@ -112,7 +121,7 @@ if (count($user_error)) { $user_error = $user_error[0]; if ($user_error->active == 0 && !is_null($user_error->reset_code)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'REGISTRATION_LINK' => $language->get('admin', 'registration_link'), 'SHOW_REGISTRATION_LINK' => $language->get('admin', 'show_registration_link'), 'REGISTRATION_LINK_VALUE' => rtrim(URL::getSelfURL(), '/') . URL::build('/complete_signup/', 'c=' . urlencode($user_error->reset_code)) @@ -121,7 +130,7 @@ } } - $template_file = 'core/emails_errors_view.tpl'; + $template_file = 'core/emails_errors_view'; } else { Redirect::to(URL::build('/panel/core/emails/errors')); } @@ -150,7 +159,7 @@ $results = $paginator->getLimited($email_errors, 10, $p, count($email_errors)); $pagination = $paginator->generate(7, URL::build('/panel/core/emails/errors')); - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK_LINK' => URL::build('/panel/core/emails'), 'TYPE' => $language->get('admin', 'type'), 'DATE' => $language->get('general', 'date'), @@ -192,7 +201,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EMAIL_ERRORS_ARRAY' => $template_errors, 'DELETE_LINK' => URL::build('/panel/core/emails/errors/', 'do=delete&id={x}'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -205,21 +214,19 @@ 'PAGINATION' => $pagination ]); } else { - $smarty->assign([ - 'NO_ERRORS' => $language->get('admin', 'no_email_errors') - ]); + $template->getEngine()->addVariable('NO_ERRORS', $language->get('admin', 'no_email_errors')); } - $template_file = 'core/emails_errors.tpl'; + $template_file = 'core/emails_errors'; } // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('emails_errors_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('emails_errors_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } @@ -228,13 +235,13 @@ } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -248,7 +255,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/emails_mass_message.php b/modules/Core/pages/panel/emails_mass_message.php index d1e29fac65..61d14fbd36 100644 --- a/modules/Core/pages/panel/emails_mass_message.php +++ b/modules/Core/pages/panel/emails_mass_message.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.emails_mass_message')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'emails'; $page_title = $language->get('admin', 'emails_mass_message'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Handle input if (Input::exists()) { @@ -75,7 +84,7 @@ $php_mailer = Settings::get('phpmailer'); $outgoing_email = Settings::get('outgoing_email'); -$smarty->assign([ +$template->getEngine()->addVariables([ 'SENDING_MASS_MESSAGE' => $language->get('admin', 'sending_mass_message'), 'EMAILS_MASS_MESSAGE' => $language->get('admin', 'emails_mass_message'), 'SUBJECT' => $language->get('admin', 'email_message_subject'), @@ -87,7 +96,7 @@ 'BACK_LINK' => URL::build('/panel/core/emails') ]); -$template_file = 'core/emails_mass_message.tpl'; +$template_file = 'core/emails_mass_message'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -103,20 +112,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -128,7 +137,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/errors.php b/modules/Core/pages/panel/errors.php index 500edddff0..ff64170891 100644 --- a/modules/Core/pages/panel/errors.php +++ b/modules/Core/pages/panel/errors.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.errors')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'debugging_and_maintenance'; $page_title = $language->get('admin', 'error_logs'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (isset($_GET['log'], $_GET['do']) && $_GET['do'] == 'purge') { if (Token::check()) { @@ -34,9 +43,9 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('error_log_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('error_log_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } @@ -68,19 +77,19 @@ } if (file_exists(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $_GET['log'] . '-log.log']))) { - $smarty->assign('LOG', nl2br(Output::getClean(Util::readFileEnd(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $type . '-log.log']))))); + $template->getEngine()->addVariable('LOG', nl2br(Output::getClean(Util::readFileEnd(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'cache', 'logs', $type . '-log.log']))))); } else { - $smarty->assign('NO_LOG_FOUND', $language->get('admin', 'log_file_not_found')); + $template->getEngine()->addVariable('NO_LOG_FOUND', $language->get('admin', 'log_file_not_found')); } if (Session::exists('error_log_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => [Session::flash('error_log_error')], 'ERRORS_TITLE' => $language->get('general', 'error') ]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK_LINK' => URL::build('/panel/core/errors'), 'LOG_NAME' => $title, 'ACTIONS' => $language->get('general', 'actions'), @@ -92,7 +101,7 @@ 'PURGE_LOG_LINK' => URL::build('/panel/core/errors/', 'log=' . urlencode($type) . '&do=purge') ]); } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK_LINK' => URL::build('/panel/core/debugging_and_maintenance'), 'FATAL_LOG' => $language->get('admin', 'fatal_log'), 'FATAL_LOG_LINK' => URL::build('/panel/core/errors/', 'log=fatal'), @@ -105,7 +114,7 @@ ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -118,11 +127,11 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template if (!isset($_GET['log'])) { - $template->displayTemplate('core/errors.tpl', $smarty); + $template->displayTemplate('core/errors'); } else { - $template->displayTemplate('core/errors_view.tpl', $smarty); + $template->displayTemplate('core/errors_view'); } diff --git a/modules/Core/pages/panel/general_settings.php b/modules/Core/pages/panel/general_settings.php index bebd0a7afb..0212b594f5 100644 --- a/modules/Core/pages/panel/general_settings.php +++ b/modules/Core/pages/panel/general_settings.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.general')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'general_settings'; $page_title = $language->get('admin', 'general_settings'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Handle input if (isset($_GET['do'])) { @@ -195,16 +204,16 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS_TITLE' => $language->get('general', 'success'), - 'SUCCESS' => $success + 'SUCCESS' => $success, ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS_TITLE' => $language->get('general', 'error'), - 'ERRORS' => $errors + 'ERRORS' => $errors, ]); } @@ -225,7 +234,7 @@ $displaynames = Settings::get('displaynames'); $method = Settings::get('login_method'); -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -298,7 +307,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/general_settings.tpl', $smarty); +$template->displayTemplate('core/general_settings'); diff --git a/modules/Core/pages/panel/groups.php b/modules/Core/pages/panel/groups.php index dc63dbab2f..51a418fe6a 100644 --- a/modules/Core/pages/panel/groups.php +++ b/modules/Core/pages/panel/groups.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.groups')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'groups'; const PANEL_PAGE = 'groups'; $page_title = $language->get('admin', 'groups'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -120,7 +129,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CREATING_NEW_GROUP' => $language->get('admin', 'creating_group'), 'CANCEL' => $language->get('general', 'cancel'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -139,7 +148,7 @@ 'FORCE_TFA' => $language->get('admin', 'force_tfa') ]); - $template_file = 'core/groups_new.tpl'; + $template_file = 'core/groups_new'; break; @@ -154,12 +163,12 @@ } if ($group->id == 2 || ((in_array($group->id, $user->getAllGroupIds())) && !$user->hasPermission('admincp.groups.self'))) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'OWN_GROUP' => $language->get('admin', 'cant_edit_this_group'), 'INFO' => $language->get('general', 'info') ]); } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'PERMISSIONS' => $language->get('admin', 'permissions'), 'PERMISSIONS_LINK' => URL::build('/panel/core/groups/', 'action=permissions&group=' . urlencode($group->id)), 'DELETE' => $language->get('general', 'delete'), @@ -268,7 +277,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'GROUP_TITLE' => Output::getClean($group->name), 'GROUP_ID' => Output::getClean($group->id), 'NAME' => $language->get('admin', 'name'), @@ -297,7 +306,7 @@ 'FORCE_TFA_VALUE' => $group->force_tfa ]); - $template_file = 'core/groups_form.tpl'; + $template_file = 'core/groups_form'; break; @@ -392,7 +401,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'GROUP_TITLE' => $language->get('admin', 'cloning_group', [ 'group' => Output::getClean($group->name) ]), @@ -423,7 +432,7 @@ 'FORCE_TFA_VALUE' => $group->force_tfa ]); - $template_file = 'core/groups_form.tpl'; + $template_file = 'core/groups_form'; break; @@ -468,7 +477,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'PERMISSIONS' => $language->get('admin', 'permissions'), 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/groups/', 'action=edit&group=' . urlencode($group->id)), @@ -478,7 +487,7 @@ 'DESELECT_ALL' => $language->get('admin', 'deselect_all') ]); - $template_file = 'core/groups_permissions.tpl'; + $template_file = 'core/groups_permissions'; break; @@ -513,7 +522,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'GROUP_ID' => $language->get('admin', 'group_id'), 'NAME' => $language->get('admin', 'name'), 'USERS' => $language->get('admin', 'users'), @@ -528,24 +537,24 @@ 'REORDER_DRAG_URL' => URL::build('/panel/core/groups', 'action=order') ]); - $template_file = 'core/groups.tpl'; + $template_file = 'core/groups'; } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'GROUPS' => $language->get('admin', 'groups'), @@ -561,7 +570,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/hooks.php b/modules/Core/pages/panel/hooks.php index 64b8939713..afa28f0918 100644 --- a/modules/Core/pages/panel/hooks.php +++ b/modules/Core/pages/panel/hooks.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.hooks')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'hooks'; $page_title = $language->get('admin', 'hooks'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['action'])) { // View all hooks @@ -36,7 +45,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'HOOKS_INFO' => $language->get('admin', 'hooks_info'), 'NEW_HOOK' => $language->get('admin', 'new_hook'), 'NEW_HOOK_LINK' => URL::build('/panel/core/hooks/', 'action=new'), @@ -47,7 +56,7 @@ 'NO' => $language->get('general', 'no') ]); - $template_file = 'core/hooks.tpl'; + $template_file = 'core/hooks'; } else { switch ($_GET['action']) { case 'new': @@ -106,7 +115,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CREATING_NEW_HOOK' => $language->get('admin', 'creating_new_hook'), 'HOOK_NAME' => $language->get('admin', 'hook_name'), 'HOOK_URL' => $language->get('admin', 'hook_url'), @@ -121,7 +130,7 @@ 'SUPPORTS_NORMAL' => $language->get('admin', 'event_supports_normal'), ]); - $template_file = 'core/hooks_new.tpl'; + $template_file = 'core/hooks_new'; break; case 'edit': @@ -192,7 +201,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_HOOK' => $language->get('admin', 'editing_hook'), 'HOOK_NAME' => $language->get('admin', 'hook_name'), 'HOOK_NAME_VALUE' => Output::getClean($hook->name), @@ -211,7 +220,7 @@ 'SUPPORTS_NORMAL' => $language->get('admin', 'event_supports_normal'), ]); - $template_file = 'core/hooks_edit.tpl'; + $template_file = 'core/hooks_edit'; break; case 'delete': @@ -252,20 +261,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'NO_HOOKS' => $language->get('admin', 'no_hooks_yet'), 'NAME' => $language->get('admin', 'name'), 'LINK' => $language->get('general', 'url'), @@ -281,7 +290,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/images.php b/modules/Core/pages/panel/images.php index c8b3a18125..0e5da3047e 100644 --- a/modules/Core/pages/panel/images.php +++ b/modules/Core/pages/panel/images.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.styles.images')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'images'; $page_title = $language->get('admin', 'images'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Reset background if (isset($_GET['action'])) { @@ -100,16 +109,14 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ - 'ERRORS' => $errors - ]); + $template->getEngine()->addVariable('ERRORS', $errors); } // Get banner from cache @@ -238,36 +245,36 @@ } if (!is_writable(ROOT_PATH . '/uploads/backgrounds')) { - $smarty->assign('BACKGROUNDS_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ + $template->getEngine()->addVariable('BACKGROUNDS_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/backgrounds') ])); } if (!is_writable(ROOT_PATH . '/uploads/template_banners')) { - $smarty->assign('TEMPLATE_BANNERS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ + $template->getEngine()->addVariable('TEMPLATE_BANNERS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/template_banners') ])); } if (!is_writable(ROOT_PATH . '/uploads/logos')) { - $smarty->assign('LOGOS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ + $template->getEngine()->addVariable('LOGOS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/logos') ])); } if (!is_writable(ROOT_PATH . '/uploads/favicons')) { - $smarty->assign('FAVICONS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ + $template->getEngine()->addVariable('FAVICONS_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/favicons') ])); } if (!is_writable(ROOT_PATH . '/uploads/og_images')) { - $smarty->assign('OG_IMAGES_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ + $template->getEngine()->addVariable('OG_IMAGES_DIRECTORY_NOT_WRITABLE', $language->get('admin', 'x_directory_not_writable', [ 'directory' => Text::bold('uploads/og_images') ])); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'LAYOUT' => $language->get('admin', 'layout'), @@ -310,7 +317,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/images.tpl', $smarty); +$template->displayTemplate('core/images'); diff --git a/modules/Core/pages/panel/index.php b/modules/Core/pages/panel/index.php index 33fc8c7d82..0fc80ab933 100644 --- a/modules/Core/pages/panel/index.php +++ b/modules/Core/pages/panel/index.php @@ -1,23 +1,32 @@ handlePanelPageLoad()) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } const PAGE = 'panel'; const PANEL_PAGE = 'dashboard'; $page_title = $language->get('admin', 'dashboard'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -105,9 +114,9 @@ } if (!count($news)) { - $smarty->assign('NO_NEWS', $language->get('admin', 'unable_to_retrieve_nameless_news')); + $template->getEngine()->addVariable('NO_NEWS', $language->get('admin', 'unable_to_retrieve_nameless_news')); } else { - $smarty->assign('NEWS', $news); + $template->getEngine()->addVariable('NEWS', $news); } // Compatibility @@ -209,7 +218,7 @@ ]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SERVER_COMPATIBILITY' => $language->get('admin', 'server_compatibility'), 'COMPAT_SUCCESS' => $compat_success, 'COMPAT_WARNINGS' => $compat_warnings, @@ -218,18 +227,14 @@ } if (is_dir(ROOT_PATH . '/modules/Core/pages/admin')) { - $smarty->assign([ - 'DIRECTORY_WARNING' => $language->get('admin', 'admin_dir_still_exists') - ]); + $template->getEngine()->addVariable('DIRECTORY_WARNING', $language->get('admin', 'admin_dir_still_exists')); } else { if (is_dir(ROOT_PATH . '/modules/Core/pages/mod')) { - $smarty->assign([ - 'DIRECTORY_WARNING' => $language->get('admin', 'mod_dir_still_exists') - ]); + $template->getEngine()->addVariable('DIRECTORY_WARNING', $language->get('admin', 'mod_dir_still_exists')); } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'DASHBOARD' => $language->get('admin', 'dashboard'), 'DASHBOARD_STATS' => CollectionManager::getEnabledCollection('dashboard_stats'), 'PAGE' => PANEL_PAGE, @@ -252,7 +257,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('index.tpl', $smarty); +$template->displayTemplate('index'); diff --git a/modules/Core/pages/panel/integrations.php b/modules/Core/pages/panel/integrations.php index 18a9bba97e..7d87d80219 100644 --- a/modules/Core/pages/panel/integrations.php +++ b/modules/Core/pages/panel/integrations.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.integrations.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +28,7 @@ const PANEL_PAGE = 'integrations'; const EDITING_USER = true; $page_title = $language->get('admin', 'integrations'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; $integrations = Integrations::getInstance(); @@ -37,14 +46,14 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'INTEGRATIONS_LIST' => $integrations_list, 'ENABLED' => $language->get('admin', 'enabled'), 'CAN_UNLINK' => $language->get('admin', 'can_unlink'), 'REQUIRED' => $language->get('admin', 'required') ]); - $template_file = 'core/integrations.tpl'; + $template_file = 'core/integrations'; } else { // View integration settings $integration = $integrations->getIntegration($_GET['integration']); @@ -81,7 +90,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_INTEGRATION' => $language->get('admin', 'editing_integration_x', ['integration' => Output::getClean($integration->getName())]), 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/integrations'), @@ -93,10 +102,10 @@ 'REQUIRED_VALUE' => $integration->data()->required, ]); - $template_file = 'core/integrations_edit.tpl'; + $template_file = 'core/integrations_edit'; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), @@ -116,16 +125,16 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -134,7 +143,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/minecraft.php b/modules/Core/pages/panel/minecraft.php index 656a530536..b3def811d6 100644 --- a/modules/Core/pages/panel/minecraft.php +++ b/modules/Core/pages/panel/minecraft.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.minecraft')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'integrations'; const PANEL_PAGE = 'minecraft'; $page_title = $language->get('admin', 'minecraft'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (Input::exists()) { // Check token @@ -41,16 +50,16 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -58,7 +67,7 @@ $minecraft_enabled = Settings::get(Settings::MINECRAFT_INTEGRATION); $uuid_linking = Settings::get('uuid_linking'); -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), @@ -74,44 +83,44 @@ if ($minecraft_enabled == 1) { if ($user->hasPermission('admincp.minecraft.authme')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'AUTHME' => $language->get('admin', 'authme_integration'), - 'AUTHME_LINK' => URL::build('/panel/minecraft/authme') + 'AUTHME_LINK' => URL::build('/panel/minecraft/authme'), ]); } if ($user->hasPermission('admincp.minecraft.servers')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SERVERS' => $language->get('admin', 'minecraft_servers'), - 'SERVERS_LINK' => URL::build('/panel/minecraft/servers') + 'SERVERS_LINK' => URL::build('/panel/minecraft/servers'), ]); } if ($user->hasPermission('admincp.minecraft.query_errors')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'QUERY_ERRORS' => $language->get('admin', 'query_errors'), - 'QUERY_ERRORS_LINK' => URL::build('/panel/minecraft/query_errors') + 'QUERY_ERRORS_LINK' => URL::build('/panel/minecraft/query_errors'), ]); } if ($user->hasPermission('admincp.minecraft.banners') && function_exists('exif_imagetype')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'BANNERS' => $language->get('admin', 'server_banners'), - 'BANNERS_LINK' => URL::build('/panel/minecraft/banners') + 'BANNERS_LINK' => URL::build('/panel/minecraft/banners'), ]); } if ($user->hasPermission('admincp.core.placeholders')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'PLACEHOLDERS' => $language->get('admin', 'placeholders'), - 'PLACEHOLDERS_LINK' => URL::build('/panel/minecraft/placeholders') + 'PLACEHOLDERS_LINK' => URL::build('/panel/minecraft/placeholders'), ]); } } $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('integrations/minecraft/minecraft.tpl', $smarty); +$template->displayTemplate('integrations/minecraft/minecraft'); diff --git a/modules/Core/pages/panel/minecraft_authme.php b/modules/Core/pages/panel/minecraft_authme.php index 9306db059d..aa0c48e8ce 100644 --- a/modules/Core/pages/panel/minecraft_authme.php +++ b/modules/Core/pages/panel/minecraft_authme.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.minecraft.authme')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +28,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'authme'; $page_title = $language->get('admin', 'authme_integration'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Handle input if (Input::exists()) { @@ -91,16 +100,16 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -109,7 +118,7 @@ // Retrieve AuthMe database details $authme_db = Config::get('authme', []); - $smarty->assign([ + $template->getEngine()->addVariables([ 'AUTHME_DB_DETAILS' => $authme_db, 'AUTHME_HASH_ALGORITHM' => $language->get('admin', 'authme_hash_algorithm'), 'AUTHME_DB_ADDRESS' => $language->get('admin', 'authme_db_address'), @@ -126,7 +135,7 @@ ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), @@ -139,12 +148,12 @@ 'ENABLE_AUTHME' => $language->get('admin', 'enable_authme'), 'ENABLE_AUTHME_VALUE' => (Settings::get('authme') == '1'), 'AUTHME' => $language->get('admin', 'authme_integration'), - 'MINECRAFT_LINK' => URL::build('/panel/minecraft') + 'MINECRAFT_LINK' => URL::build('/panel/minecraft'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('integrations/minecraft/minecraft_authme.tpl', $smarty); +$template->displayTemplate('integrations/minecraft/minecraft_authme'); diff --git a/modules/Core/pages/panel/minecraft_query_errors.php b/modules/Core/pages/panel/minecraft_query_errors.php index 5a67691198..485eabcd3c 100644 --- a/modules/Core/pages/panel/minecraft_query_errors.php +++ b/modules/Core/pages/panel/minecraft_query_errors.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.minecraft.query_errors')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +28,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'query_errors'; $page_title = $language->get('admin', 'query_errors'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['id'])) { if (isset($_GET['action']) && $_GET['action'] == 'purge') { @@ -64,17 +73,17 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGINATION' => $pagination, 'QUERY_ERRORS_ARRAY' => $template_array, 'SERVER_ADDRESS' => $language->get('admin', 'server_address'), 'SERVER_PORT' => $language->get('admin', 'server_port'), 'DATE' => $language->get('general', 'date'), - 'ACTIONS' => $language->get('general', 'actions') + 'ACTIONS' => $language->get('general', 'actions'), ]); } - $template_file = 'integrations/minecraft/minecraft_query_errors.tpl'; + $template_file = 'integrations/minecraft/minecraft_query_errors'; } else { // View an error @@ -94,7 +103,7 @@ Redirect::to(URL::build('/panel/minecraft/query_errors')); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'VIEWING_ERROR' => $language->get('admin', 'viewing_query_error'), 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/minecraft/query_errors'), @@ -110,10 +119,10 @@ 'SERVER_ADDRESS_VALUE' => Output::getClean($query_error->ip), 'SERVER_PORT_VALUE' => Output::getClean($query_error->port), 'DATE_VALUE' => date(DATE_FORMAT, $query_error->date), - 'ERROR_MESSAGE' => Output::getClean($query_error->error) + 'ERROR_MESSAGE' => Output::getClean($query_error->error), ]); - $template_file = 'integrations/minecraft/minecraft_query_errors_view.tpl'; + $template_file = 'integrations/minecraft/minecraft_query_errors_view'; } @@ -129,20 +138,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), @@ -161,12 +170,12 @@ 'PURGE_QUERY_ERRORS' => $language->get('admin', 'purge_errors'), 'PURGE_QUERY_ERRORS_LINK' => URL::build('/panel/minecraft/query_errors/', 'action=purge'), 'CONFIRM_PURGE_ERRORS' => $language->get('admin', 'confirm_purge_errors'), - 'NO_QUERY_ERRORS' => $language->get('admin', 'no_query_errors') + 'NO_QUERY_ERRORS' => $language->get('admin', 'no_query_errors'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/minecraft_server_banners.php b/modules/Core/pages/panel/minecraft_server_banners.php index 4464a439c6..6924dc51c2 100644 --- a/modules/Core/pages/panel/minecraft_server_banners.php +++ b/modules/Core/pages/panel/minecraft_server_banners.php @@ -1,21 +1,30 @@ handlePanelPageLoad('admincp.minecraft.banners')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } if (!function_exists('exif_imagetype')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -24,7 +33,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'server_banners'; $page_title = $language->get('admin', 'server_banners'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['server']) && !isset($_GET['edit'])) { $servers = DB::getInstance()->get('mc_servers', ['id', '<>', 0])->results(); @@ -39,17 +48,17 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SERVERS' => $template_array, 'EDIT' => $language->get('general', 'edit'), - 'VIEW' => $language->get('general', 'view') + 'VIEW' => $language->get('general', 'view'), ]); } else { - $smarty->assign('NO_SERVERS', $language->get('admin', 'no_servers_defined')); + $template->getEngine()->addVariable('NO_SERVERS', $language->get('admin', 'no_servers_defined')); } - $template_file = 'integrations/minecraft/minecraft_server_banners.tpl'; + $template_file = 'integrations/minecraft/minecraft_server_banners'; } else { if (isset($_GET['server'])) { @@ -61,15 +70,15 @@ } $server = $server[0]; - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/minecraft/banners'), 'SERVER_NAME' => Output::getClean($server->name), 'BANNER_URL' => URL::getSelfURL() . ltrim(rtrim(URL::build('/banner/' . urlencode($server->name) . '.png'), '/'), '/'), - 'BANNER_PATH' => rtrim(URL::build('/banner/' . urlencode($server->name) . '.png'), '/') + 'BANNER_PATH' => rtrim(URL::build('/banner/' . urlencode($server->name) . '.png'), '/'), ]); - $template_file = 'integrations/minecraft/minecraft_server_banners_view.tpl'; + $template_file = 'integrations/minecraft/minecraft_server_banners_view'; } else { // Edit @@ -129,16 +138,16 @@ $n++; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/minecraft/banners'), 'SERVER_NAME' => Output::getClean($server->name), 'BANNER_BACKGROUND' => $language->get('admin', 'banner_background'), 'BANNER_BACKGROUND_VALUE' => Output::getClean($server->banner_background), - 'IMAGES' => $template_images + 'IMAGES' => $template_images, ]); - $template_file = 'integrations/minecraft/minecraft_server_banners_edit.tpl'; + $template_file = 'integrations/minecraft/minecraft_server_banners_edit'; } } @@ -146,20 +155,20 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), @@ -168,12 +177,12 @@ 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), 'SUBMIT' => $language->get('general', 'submit'), - 'SERVER_BANNERS' => $language->get('admin', 'server_banners') + 'SERVER_BANNERS' => $language->get('admin', 'server_banners'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/minecraft_servers.php b/modules/Core/pages/panel/minecraft_servers.php index 3b506afb89..211576174f 100644 --- a/modules/Core/pages/panel/minecraft_servers.php +++ b/modules/Core/pages/panel/minecraft_servers.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.minecraft.servers')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +28,7 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'servers'; $page_title = $language->get('admin', 'minecraft_servers'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (isset($_GET['action'])) { switch ($_GET['action']) { @@ -184,10 +193,10 @@ // Display query information alert only if external query is selected $query_type = Settings::get('query_type', 'internal'); if ($query_type === 'external') { - $smarty->assign('SERVER_QUERY_INFORMATION', $language->get('admin', 'server_query_information')); + $template->getEngine()->addVariable('SERVER_QUERY_INFORMATION', $language->get('admin', 'server_query_information')); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/minecraft/servers'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -223,10 +232,10 @@ 'ENABLE_PLAYER_LIST_INFO' => $language->get('admin', 'player_list_help'), 'SERVER_QUERY_PORT' => $language->get('admin', 'server_query_port'), 'SERVER_QUERY_PORT_INFO' => $language->get('admin', 'server_query_port_help'), - 'SERVER_QUERY_PORT_VALUE' => Output::getClean(Input::get('query_port')) + 'SERVER_QUERY_PORT_VALUE' => Output::getClean(Input::get('query_port')), ]); - $template_file = 'integrations/minecraft/minecraft_servers_new.tpl'; + $template_file = 'integrations/minecraft/minecraft_servers_new'; break; @@ -393,10 +402,10 @@ $query_type = Settings::get('query_type', 'internal'); if ($query_type == 'external') { - $smarty->assign('SERVER_QUERY_INFORMATION', $language->get('admin', 'server_query_information')); + $template->getEngine()->addVariable('SERVER_QUERY_INFORMATION', $language->get('admin', 'server_query_information')); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_SERVER' => $language->get('admin', 'editing_server'), 'SERVER_ID' => $server_editing->id, 'CANCEL' => $language->get('general', 'cancel'), @@ -440,10 +449,10 @@ 'ENABLE_PLAYER_LIST_VALUE' => ($server_editing->player_list == 1), 'SERVER_QUERY_PORT' => $language->get('admin', 'server_query_port'), 'SERVER_QUERY_PORT_INFO' => $language->get('admin', 'server_query_port_help'), - 'SERVER_QUERY_PORT_VALUE' => Output::getClean($server_editing->query_port) + 'SERVER_QUERY_PORT_VALUE' => Output::getClean($server_editing->query_port), ]); - $template_file = 'integrations/minecraft/minecraft_servers_edit.tpl'; + $template_file = 'integrations/minecraft/minecraft_servers_edit'; break; @@ -584,7 +593,7 @@ } } else { - $smarty->assign('NO_SERVERS', $language->get('admin', 'no_servers_defined')); + $template->getEngine()->addVariable('NO_SERVERS', $language->get('admin', 'no_servers_defined')); } // Settings @@ -593,7 +602,7 @@ $group_sync_server = Settings::get('group_sync_mc_server'); $player_list_limit = Settings::get('player_list_limit', '20'); - $smarty->assign([ + $template->getEngine()->addVariables([ 'NEW_SERVER' => $language->get('admin', 'add_server'), 'NEW_SERVER_LINK' => URL::build('/panel/minecraft/servers/', 'action=new'), 'CONFIRM_DELETE_SERVER' => $language->get('admin', 'confirm_delete_server'), @@ -624,10 +633,10 @@ 'STATUS_PAGE' => $language->get('admin', 'status_page'), 'STATUS_PAGE_VALUE' => ($status_page == '1'), 'REORDER_DRAG_URL' => URL::build('/panel/minecraft/servers', 'action=order'), - 'SERVERS' => $template_array + 'SERVERS' => $template_array, ]); - $template_file = 'integrations/minecraft/minecraft_servers.tpl'; + $template_file = 'integrations/minecraft/minecraft_servers'; } @@ -643,20 +652,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), @@ -665,12 +674,12 @@ 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), 'SUBMIT' => $language->get('general', 'submit'), - 'MINECRAFT_SERVERS' => $language->get('admin', 'minecraft_servers') + 'MINECRAFT_SERVERS' => $language->get('admin', 'minecraft_servers'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/modules.php b/modules/Core/pages/panel/modules.php index f8d2681f56..77cf544402 100644 --- a/modules/Core/pages/panel/modules.php +++ b/modules/Core/pages/panel/modules.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.modules')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'modules'; const PANEL_PAGE = 'modules'; $page_title = $language->get('admin', 'modules'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -127,7 +136,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'INSTALL_MODULE' => $language->get('admin', 'install'), 'INSTALL_MODULE_LINK' => URL::build('/panel/core/modules/', 'action=install'), 'AUTHOR' => $language->get('admin', 'author'), @@ -348,31 +357,31 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'MODULES' => $language->get('admin', 'modules'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/modules.tpl', $smarty); +$template->displayTemplate('core/modules'); diff --git a/modules/Core/pages/panel/navigation.php b/modules/Core/pages/panel/navigation.php index 5bbe3b8a45..05a966ab9f 100644 --- a/modules/Core/pages/panel/navigation.php +++ b/modules/Core/pages/panel/navigation.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.navigation')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'navigation'; $page_title = $language->get('admin', 'navigation'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Deal with input if (Input::exists()) { @@ -68,20 +77,20 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('navigation_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('navigation_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -100,12 +109,12 @@ 'NAVBAR_ICON' => $language->get('admin', 'navbar_icon'), 'DROPDOWN_ITEMS' => $language->get('admin', 'dropdown_items'), 'DROPDOWN_NAME' => $language->get('admin', 'dropdown_name'), - 'DROPDOWN_NAME_VALUE' => $language->get('general', 'more') + 'DROPDOWN_NAME_VALUE' => $language->get('general', 'more'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/navigation.tpl', $smarty); +$template->displayTemplate('core/navigation'); diff --git a/modules/Core/pages/panel/pages.php b/modules/Core/pages/panel/pages.php index a52b39e50f..380ff8fa73 100644 --- a/modules/Core/pages/panel/pages.php +++ b/modules/Core/pages/panel/pages.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.pages')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'pages'; const PANEL_PAGE = 'custom_pages'; $page_title = $language->get('admin', 'custom_pages'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -37,7 +46,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'NEW_PAGE' => $language->get('admin', 'new_page'), 'NEW_PAGE_LINK' => URL::build('/panel/core/pages/', 'action=new'), 'EDIT' => $language->get('general', 'edit'), @@ -51,7 +60,7 @@ 'DELETE_LINK' => URL::build('/panel/core/pages', 'action=delete'), ]); - $template_file = 'core/pages.tpl'; + $template_file = 'core/pages'; } else { switch ($_GET['action']) { case 'new': @@ -198,7 +207,7 @@ $content = EventHandler::executeEvent('renderCustomPageEdit', ['content' => $content])['content']; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/core/pages'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -228,7 +237,7 @@ 'GROUP' => $language->get('admin', 'group'), 'VIEW_PAGE' => $language->get('admin', 'view_page'), 'GUESTS' => $language->get('user', 'guests'), - 'GROUPS' => $template_array + 'GROUPS' => $template_array, ]); $template->assets()->include([ @@ -237,7 +246,7 @@ $template->addJSScript(Input::createTinyEditor($language, 'inputContent', $content, true, true)); - $template_file = 'core/pages_new.tpl'; + $template_file = 'core/pages_new'; break; @@ -494,7 +503,7 @@ $content = EventHandler::executeEvent('renderCustomPageEdit', ['content' => ($_POST['content'] ?: $page->content)])['content']; - $smarty->assign([ + $template->getEngine()->addVariables([ 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/core/pages'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -533,7 +542,7 @@ 'VIEW_PAGE' => $language->get('admin', 'view_page'), 'GUESTS' => $language->get('user', 'guests'), 'GROUPS' => $template_array, - 'GUEST_PERMS' => $guest_can_view + 'GUEST_PERMS' => $guest_can_view, ]); $template->assets()->include([ @@ -542,7 +551,7 @@ $template->addJSScript(Input::createTinyEditor($language, 'inputContent', $content, true, true)); - $template_file = 'core/pages_edit.tpl'; + $template_file = 'core/pages_edit'; break; @@ -576,32 +585,32 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'PAGES' => $language->get('admin', 'pages'), 'CUSTOM_PAGES' => $language->get('admin', 'custom_pages'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/panel_templates.php b/modules/Core/pages/panel/panel_templates.php index 69c3ffa6fb..ec6036b5f8 100644 --- a/modules/Core/pages/panel/panel_templates.php +++ b/modules/Core/pages/panel/panel_templates.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.styles.panel_templates')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'panel_templates'; $page_title = $language->get('admin', 'panel_templates'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['action'])) { // Get all templates @@ -64,7 +73,7 @@ $template = $current_template; - $smarty->assign([ + $template->getEngine()->addVariables([ 'WARNING' => $language->get('admin', 'warning'), 'ACTIVATE' => $language->get('admin', 'activate'), 'DEACTIVATE' => $language->get('admin', 'deactivate'), @@ -87,7 +96,7 @@ 'ACTIONS' => $language->get('general', 'actions') ]); - $template_file = 'core/panel_templates.tpl'; + $template_file = 'core/panel_templates'; } else { switch ($_GET['action']) { @@ -266,7 +275,7 @@ case 'clear_cache': if (Token::check()) { - $smarty->clearAllCache(); + $template->getEngine()->clearCache(); Session::flash('admin_templates', $language->get('admin', 'cache_cleared')); } else { Session::flash('admin_templates_error', $language->get('general', 'invalid_token')); @@ -291,32 +300,32 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'LAYOUT' => $language->get('admin', 'layout'), 'PANEL_TEMPLATES' => $language->get('admin', 'panel_templates'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/placeholders.php b/modules/Core/pages/panel/placeholders.php index 49d4cae809..0e0a1c6d6c 100644 --- a/modules/Core/pages/panel/placeholders.php +++ b/modules/Core/pages/panel/placeholders.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.placeholders')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,11 +28,11 @@ const PANEL_PAGE = 'minecraft'; const MINECRAFT_PAGE = 'placeholders'; $page_title = $language->get('admin', 'placeholders'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; $all_placeholders = Placeholders::getInstance()->getAllPlaceholders(); -$template_file = 'integrations/minecraft/placeholders.tpl'; +$template_file = 'integrations/minecraft/placeholders'; if (isset($_GET['leaderboard'])) { @@ -33,7 +42,7 @@ if ($placeholder != null) { - $template_file = 'integrations/minecraft/placeholders_leaderboard.tpl'; + $template_file = 'integrations/minecraft/placeholders_leaderboard'; if (Input::exists()) { @@ -59,7 +68,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGE' => PANEL_PAGE, 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), @@ -79,7 +88,7 @@ 'LEADERBOARD_SORT' => $language->get('admin', 'placeholder_leaderboard_sort'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), 'MINECRAFT' => $language->get('admin', 'minecraft'), - 'MINECRAFT_LINK' => URL::build('/panel/minecraft') + 'MINECRAFT_LINK' => URL::build('/panel/minecraft'), ]); } else { Redirect::to(URL::build('/panel/minecraft/placeholders')); @@ -135,7 +144,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGE' => PANEL_PAGE, 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), @@ -175,22 +184,22 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('placeholders_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('placeholders_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/privacy_and_terms.php b/modules/Core/pages/panel/privacy_and_terms.php index 372beff36c..6ad9641be5 100644 --- a/modules/Core/pages/panel/privacy_and_terms.php +++ b/modules/Core/pages/panel/privacy_and_terms.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.terms')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'privacy_and_terms'; $page_title = $language->get('admin', 'privacy_and_terms'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (Input::exists()) { $errors = []; @@ -84,16 +93,16 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -112,7 +121,7 @@ $site_privacy = $site_privacy[0]->value; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -123,12 +132,12 @@ 'PRIVACY_POLICY' => $language->get('general', 'privacy_policy'), 'PRIVACY_POLICY_VALUE' => Output::getPurified($site_privacy), 'TERMS_AND_CONDITIONS' => $language->get('user', 'terms_and_conditions'), - 'TERMS_AND_CONDITIONS_VALUE' => Output::getPurified($site_terms) + 'TERMS_AND_CONDITIONS_VALUE' => Output::getPurified($site_terms), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/privacy_and_terms.tpl', $smarty); +$template->displayTemplate('core/privacy_and_terms'); diff --git a/modules/Core/pages/panel/profile_fields.php b/modules/Core/pages/panel/profile_fields.php index 39df867ba6..89bb579af0 100644 --- a/modules/Core/pages/panel/profile_fields.php +++ b/modules/Core/pages/panel/profile_fields.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.fields')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'custom_profile_fields'; $page_title = $language->get('admin', 'custom_fields'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -99,7 +108,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CREATING_PROFILE_FIELD' => $language->get('admin', 'creating_profile_field'), 'CANCEL' => $language->get('general', 'cancel'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -121,10 +130,10 @@ 'EDITABLE_HELP' => $language->get('admin', 'profile_field_editable_help'), 'REQUIRED_HELP' => $language->get('admin', 'profile_field_required_help'), 'PUBLIC_HELP' => $language->get('admin', 'profile_field_public_help'), - 'DISPLAY_FIELD_ON_FORUM_HELP' => $language->get('admin', 'profile_field_forum_help') + 'DISPLAY_FIELD_ON_FORUM_HELP' => $language->get('admin', 'profile_field_forum_help'), ]); - $template_file = 'core/profile_fields_create.tpl'; + $template_file = 'core/profile_fields_create'; } else { if ($_GET['action'] == 'edit') { @@ -222,7 +231,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_PROFILE_FIELD' => $language->get('admin', 'editing_profile_field'), 'CANCEL' => $language->get('general', 'cancel'), 'DELETE' => $language->get('general', 'delete'), @@ -255,10 +264,10 @@ 'EDITABLE_HELP' => $language->get('admin', 'profile_field_editable_help'), 'REQUIRED_HELP' => $language->get('admin', 'profile_field_required_help'), 'PUBLIC_HELP' => $language->get('admin', 'profile_field_public_help'), - 'DISPLAY_FIELD_ON_FORUM_HELP' => $language->get('admin', 'profile_field_forum_help') + 'DISPLAY_FIELD_ON_FORUM_HELP' => $language->get('admin', 'profile_field_forum_help'), ]); - $template_file = 'core/profile_fields_edit.tpl'; + $template_file = 'core/profile_fields_edit'; } else { Redirect::to(URL::build('/panel/core/profile_fields')); } @@ -292,7 +301,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'FIELDS' => $template_fields, 'NO_FIELDS' => $language->get('admin', 'no_custom_fields'), 'NEW_FIELD' => $language->get('admin', 'new_field'), @@ -305,7 +314,7 @@ 'FORUM_POSTS' => $language->get('admin', 'forum_posts') ]); - $template_file = 'core/profile_fields.tpl'; + $template_file = 'core/profile_fields'; } if (Session::exists('profile_field_success')) { @@ -313,30 +322,30 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), 'PROFILE_FIELDS' => $language->get('admin', 'custom_fields'), - 'PAGE' => PANEL_PAGE + 'PAGE' => PANEL_PAGE, ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/queue.php b/modules/Core/pages/panel/queue.php index f6df3e122e..d896e91166 100644 --- a/modules/Core/pages/panel/queue.php +++ b/modules/Core/pages/panel/queue.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.queue')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,22 +27,22 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'queue'; $page_title = $language->get('admin', 'queue'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('queue_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('queue_success'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (Session::exists('queue_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => Session::flash('queue_error'), - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -42,7 +51,7 @@ case 'status': // List queue tasks - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/queue'), 'CANCEL' => $language->get('admin', 'queue_cancel_task'), @@ -104,7 +113,7 @@ }); '); - $template_file = 'core/queue_status.tpl'; + $template_file = 'core/queue_status'; break; case 'task': @@ -156,14 +165,14 @@ } if (in_array($task->status, [Task::STATUS_READY, Task::STATUS_ERROR, Task::STATUS_IN_PROGRESS])) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CANCEL_TASK' => $language->get('admin', 'queue_cancel_task'), 'CONFIRM_CANCEL_TASK' => $language->get('admin', 'queue_cancel_task_confirm'), ]); } if (in_array($task->status, [Task::STATUS_FAILED, Task::STATUS_CANCELLED, Task::STATUS_IN_PROGRESS])) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CONFIRM_REQUEUE_TASK' => $language->get('admin', 'queue_requeue_task_confirm'), 'REQUEUE_TASK' => $language->get('admin', 'queue_requeue_task'), ]); @@ -173,7 +182,7 @@ $taskUser = new User($task->user_id); if ($taskUser->exists()) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'TASK_TRIGGERED_BY' => $language->get('admin', 'queue_task_triggered_by'), 'TASK_USERNAME' => $taskUser->getDisplayname(), 'TASK_USERNAME_STYLE' => $taskUser->getGroupStyle(), @@ -184,7 +193,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'ACTIONS' => $language->get('general', 'actions'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), 'BACK' => $language->get('general', 'back'), @@ -224,7 +233,7 @@ 'YES' => $language->get('general', 'yes'), ]); - $template_file = 'core/queue_task.tpl'; + $template_file = 'core/queue_task'; break; default: @@ -294,7 +303,7 @@ Settings::set('cron_key', $cron_key); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUBMIT' => $language->get('general', 'submit'), 'INFO' => $language->get('general', 'info'), 'QUEUE_INFO' => $language->get('admin', 'queue_info'), @@ -306,10 +315,10 @@ 'QUEUE_STATUS_LINK' => URL::build('/panel/core/queue', 'view=status'), ]); - $template_file = 'core/queue.tpl'; + $template_file = 'core/queue'; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -324,4 +333,4 @@ require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/reactions.php b/modules/Core/pages/panel/reactions.php index d159bfbdd0..be2e8fa87e 100644 --- a/modules/Core/pages/panel/reactions.php +++ b/modules/Core/pages/panel/reactions.php @@ -1,16 +1,26 @@ handlePanelPageLoad('admincp.core.reactions')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +28,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'reactions'; $page_title = $language->get('user', 'reactions'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; $template->assets()->include( AssetTree::JQUERY_UI, @@ -28,16 +38,16 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('api_reactions')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('api_reactions'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (Session::exists('api_reactions_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => [Session::flash('api_reactions_error')], - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -80,7 +90,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'NEW_REACTION' => $language->get('admin', 'new_reaction'), 'NEW_REACTION_LINK' => URL::build('/panel/core/reactions/', 'action=new'), 'NAME' => $language->get('admin', 'name'), @@ -92,7 +102,7 @@ 'REORDER_DRAG_URL' => URL::build('/panel/core/reactions', 'action=order'), ]); - $template_file = 'core/reactions.tpl'; + $template_file = 'core/reactions'; } else { if (isset($_GET['action'])) { switch ($_GET['action']) { @@ -162,7 +172,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/core/reactions'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -185,7 +195,7 @@ 'EDITING' => false, ]); - $template_file = 'core/reactions_form.tpl'; + $template_file = 'core/reactions_form'; break; @@ -307,7 +317,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/core/reactions'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -335,30 +345,30 @@ 'EDITING' => true, ]); - $template_file = 'core/reactions_form.tpl'; + $template_file = 'core/reactions_form'; } } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), 'REACTIONS' => $language->get('user', 'reactions'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/registration.php b/modules/Core/pages/panel/registration.php index 91bbda8baa..4f9f59f43a 100644 --- a/modules/Core/pages/panel/registration.php +++ b/modules/Core/pages/panel/registration.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.registration')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'registration'; $page_title = $language->get('admin', 'registration'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Deal with input if (Input::exists()) { @@ -114,23 +123,23 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($captcha_warning)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CAPTCHA_WARNINGS' => [$captcha_warning, $language->get('admin', 'invalid_recaptcha_settings_info')], - 'WARNING' => $language->get('general', 'warning') + 'WARNING' => $language->get('general', 'warning'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -167,7 +176,7 @@ ]; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'EMAIL_VERIFICATION' => $language->get('admin', 'email_verification'), 'EMAIL_VERIFICATION_VALUE' => Settings::get('email_verification') === '1', 'CAPTCHA_GENERAL' => $language->get('admin', 'captcha_general'), @@ -211,7 +220,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/registration.tpl', $smarty); +$template->displayTemplate('core/registration'); diff --git a/modules/Core/pages/panel/security.php b/modules/Core/pages/panel/security.php index 838bb91a12..3fb34b50bf 100644 --- a/modules/Core/pages/panel/security.php +++ b/modules/Core/pages/panel/security.php @@ -1,26 +1,35 @@ handlePanelPageLoad('admincp.security')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } const PAGE = 'panel'; const PARENT_PAGE = 'security'; const PANEL_PAGE = 'security'; -// Define the sort column #, as for group_sync we dont show IP (since its from MC server or Discord bot) +// Define the sort column #, as for group_sync we don't show IP (since its from MC server or Discord bot) define('SORT', (isset($_GET['view']) && $_GET['view'] == 'group_sync') ? 1 : 2); $page_title = $language->get('admin', 'security'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['view'])) { $links = []; @@ -60,12 +69,12 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'PLEASE_SELECT_LOGS' => $language->get('admin', 'please_select_logs'), - 'LINKS' => $links + 'LINKS' => $links, ]); - $template_file = 'core/security.tpl'; + $template_file = 'core/security'; } else { switch ($_GET['view']) { case 'acp_logins': @@ -292,47 +301,47 @@ Redirect::to(URL::build('/panel/security')); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/security'), 'LOG_TITLE' => $log_title, 'COLS' => $cols, 'COL_TITLES' => $col_titles, - 'ROWS' => $rows + 'ROWS' => $rows, ]); - $template_file = 'core/security_view.tpl'; + $template_file = 'core/security_view'; } // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'SECURITY' => $language->get('admin', 'security'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/seo.php b/modules/Core/pages/panel/seo.php index dd7ddd0b2d..ee863a8508 100644 --- a/modules/Core/pages/panel/seo.php +++ b/modules/Core/pages/panel/seo.php @@ -1,16 +1,26 @@ handlePanelPageLoad('admincp.core.seo')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,9 +28,9 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'seo'; $page_title = $language->get('admin', 'seo'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; -$timeago = new TimeAgo(TIMEZONE); +$timeAgo = new TimeAgo(TIMEZONE); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -82,34 +92,34 @@ $cache->setCache('sitemap_cache'); if ($cache->isCached('updated')) { $updated = $cache->retrieve('updated'); - $updated = $timeago->inWords($updated, $language); + $updated = $timeAgo->inWords($updated, $language); } else { $updated = $language->get('admin', 'unknown'); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SITEMAP_LAST_GENERATED' => $language->get('admin', 'sitemap_last_generated_x', [ 'generatedAt' => Text::bold($updated) ]), 'SITEMAP_LINK' => (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/cache/sitemaps/sitemap-index.xml', 'SITEMAP_FULL_LINK' => rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/cache/sitemaps/sitemap-index.xml', 'DOWNLOAD_SITEMAP' => $language->get('admin', 'download_sitemap'), - 'LINK' => $language->get('admin', 'sitemap_link') + 'LINK' => $language->get('admin', 'sitemap_link'), ]); } else { - $smarty->assign('SITEMAP_NOT_GENERATED', $language->get('admin', 'sitemap_not_generated_yet')); + $template->getEngine()->addVariable('SITEMAP_NOT_GENERATED', $language->get('admin', 'sitemap_not_generated_yet')); } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'DEFAULT_DESCRIPTION' => $language->get('admin', 'default_description'), 'DEFAULT_DESCRIPTION_VALUE' => Settings::get('default_meta_description'), 'DEFAULT_KEYWORDS' => $language->get('admin', 'default_keywords'), 'DEFAULT_KEYWORDS_VALUE' => Settings::get('default_meta_keywords'), ]); - $template_file = 'core/seo.tpl'; + $template_file = 'core/seo'; } else { $page = $pages->getPageById($_GET['metadata']); if (is_null($page)) { @@ -198,7 +208,7 @@ $n++; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/seo'), 'EDITING_PAGE' => $language->get('admin', 'editing_page_x', [ @@ -212,24 +222,24 @@ 'OG_IMAGES_ARRAY' => $og_images, ]); - $template_file = 'core/seo_metadata_edit.tpl'; + $template_file = 'core/seo_metadata_edit'; } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -250,7 +260,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/social_media.php b/modules/Core/pages/panel/social_media.php index 3cd34b5b54..4f95a9a4c3 100644 --- a/modules/Core/pages/panel/social_media.php +++ b/modules/Core/pages/panel/social_media.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.core.social_media')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'core_configuration'; const PANEL_PAGE = 'social_media'; $page_title = $language->get('admin', 'social_media'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Deal with input if (Input::exists()) { @@ -60,16 +69,16 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -79,7 +88,7 @@ $twitter_style = Settings::get('twitter_style'); $fb_url = Settings::get('fb_url'); -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -99,7 +108,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/social_media.tpl', $smarty); +$template->displayTemplate('core/social_media'); diff --git a/modules/Core/pages/panel/templates.php b/modules/Core/pages/panel/templates.php index 36c0265c0e..b2f4baa135 100644 --- a/modules/Core/pages/panel/templates.php +++ b/modules/Core/pages/panel/templates.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.styles.templates')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'template'; $page_title = $language->get('admin', 'templates'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['action'])) { // Get all templates @@ -88,10 +97,9 @@ } if (isset($all_templates_error)) { - $smarty->assign('WEBSITE_TEMPLATES_ERROR', $all_templates_error); + $template->getEngine()->addVariable('WEBSITE_TEMPLATES_ERROR', $all_templates_error); } else { $all_templates_query = $all_templates_query->json(); - $timeago = new TimeAgo(TIMEZONE); foreach ($all_templates_query as $item) { $all_templates[] = [ @@ -123,7 +131,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'WARNING' => $language->get('admin', 'warning'), 'ACTIVATE' => $language->get('admin', 'activate'), 'DEACTIVATE' => $language->get('admin', 'deactivate'), @@ -148,10 +156,10 @@ 'VIEW' => $language->get('general', 'view'), 'TEMPLATE' => $language->get('admin', 'template'), 'STATS' => $language->get('admin', 'stats'), - 'ACTIONS' => $language->get('general', 'actions') + 'ACTIONS' => $language->get('general', 'actions'), ]); - $template_file = 'core/templates.tpl'; + $template_file = 'core/templates'; } else { switch ($_GET['action']) { case 'install': @@ -347,7 +355,7 @@ if ($template->getSettings()) { require_once($template->getSettings()); - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_TEMPLATE' => $language->get('admin', 'editing_template_x', [ 'template' => Text::bold(Output::getClean($template_query->name)) ]), @@ -357,7 +365,7 @@ 'PERMISSIONS_LINK' => $user->hasPermission('admincp.groups') ? URL::build('/panel/core/templates/', 'template=' . urlencode($template_query->id) . '&action=permissions') : null, ]); - $template_file = 'core/template_settings.tpl'; + $template_file = 'core/template_settings'; } else { Redirect::to(URL::build('/panel/core/templates')); } @@ -471,7 +479,7 @@ $guest_query = DB::getInstance()->query('SELECT 0 AS id, can_use_template FROM nl2_groups_templates WHERE group_id = 0 AND template_id = ?', [$template_query->id])->results(); $group_query = DB::getInstance()->query('SELECT id, `name`, can_use_template FROM nl2_groups A LEFT JOIN (SELECT group_id, can_use_template FROM nl2_groups_templates WHERE template_id = ?) B ON A.id = B.group_id ORDER BY `order` ASC', [$template_query->id])->results(); - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_TEMPLATE' => $language->get('admin', 'editing_template_x', [ 'template' => Text::bold(Output::getClean($template_query->name)) ]), @@ -484,10 +492,10 @@ 'GROUP' => $language->get('admin', 'group'), 'CAN_USE_TEMPLATE' => $language->get('admin', 'can_use_template'), 'SELECT_ALL' => $language->get('admin', 'select_all'), - 'DESELECT_ALL' => $language->get('admin', 'deselect_all') + 'DESELECT_ALL' => $language->get('admin', 'deselect_all'), ]); - $template_file = 'core/template_permissions.tpl'; + $template_file = 'core/template_permissions'; break; @@ -505,7 +513,7 @@ } if ($_GET['template'] == 1) { - $smarty->assign('DEFAULT_TEMPLATE_WARNING', $language->get('admin', 'warning_editing_default_template')); + $template->getEngine()->addVariable('DEFAULT_TEMPLATE_WARNING', $language->get('admin', 'warning_editing_default_template')); } if (!isset($_GET['file']) && !isset($_GET['dir'])) { @@ -533,7 +541,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/templates/'), 'TEMPLATE_FILES' => $template_files, @@ -544,7 +552,7 @@ 'PERMISSIONS_LINK' => $user->hasPermission('admincp.groups') ? URL::build('/panel/core/templates/', 'template=' . urlencode($template_query->id) . '&action=permissions') : null, ]); - $template_file = 'core/templates_list_files.tpl'; + $template_file = 'core/templates_list_files'; } else { if (isset($_GET['dir']) && !isset($_GET['file'])) { // List files in dir @@ -587,7 +595,7 @@ $back_link = URL::build('/panel/core/templates/', 'action=edit&template=' . urlencode($template_query->id)); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => $back_link, 'TEMPLATE_FILES' => $template_files, @@ -598,7 +606,7 @@ 'PERMISSIONS_LINK' => $user->hasPermission('admincp.groups') ? '/panel/core/templates/?template=' . Output::getClean($template_query->id) . '&action=permissions' : null, ]); - $template_file = 'core/templates_list_files.tpl'; + $template_file = 'core/templates_list_files'; } else { if (isset($_GET['file'])) { $file = basename(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'custom', 'templates', Output::getClean($template_query->name), Output::getClean($_GET['file'])])); @@ -621,6 +629,7 @@ $raw_type = pathinfo($file, PATHINFO_EXTENSION); $type_map = [ 'tpl' => 'smarty', + 'twig' => 'twig', 'css' => 'css', 'js' => 'javascript', 'conf' => 'properties' @@ -678,7 +687,7 @@ $template_path = Output::getClean($_GET['file']); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_FILE' => $language->get('admin', 'editing_template_file_in_template', [ 'file' => Text::bold($template_path), 'template' => Text::bold(Output::getClean($template_query->name)), @@ -690,19 +699,20 @@ 'NO' => $language->get('general', 'no'), 'CANCEL_LINK' => $cancel_link, 'FILE_CONTENTS' => Output::getClean(file_get_contents($file_path)), - 'FILE_TYPE' => $file_type + 'FILE_TYPE' => $file_type, ]); - $template_file = 'core/templates_edit.tpl'; + $template_file = 'core/templates_edit'; } } } - $smarty->assign([ - 'EDITING_TEMPLATE' => $language->get('admin', 'editing_template_x', [ + $template->getEngine()->addVariable( + 'EDITING_TEMPLATE', + $language->get('admin', 'editing_template_x', [ 'template' => Text::bold(Output::getClean($template_query->name)) - ]), - ]); + ]) + ); break; @@ -723,32 +733,32 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'LAYOUT' => $language->get('admin', 'layout'), 'TEMPLATES' => $language->get('admin', 'templates'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/update.php b/modules/Core/pages/panel/update.php index c32bd5e2cd..9b4fdefd40 100644 --- a/modules/Core/pages/panel/update.php +++ b/modules/Core/pages/panel/update.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.update')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -27,22 +36,22 @@ const PARENT_PAGE = 'update'; const PANEL_PAGE = 'update'; $page_title = $language->get('admin', 'update'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -56,7 +65,7 @@ if (!is_string($update_check)) { if ($update_check->updateAvailable()) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'NEW_UPDATE' => $update_check->isUrgent() ? $language->get('admin', 'new_urgent_update_available') : $language->get('admin', 'new_update_available'), @@ -72,16 +81,14 @@ 'UPGRADE_LINK' => URL::build('/panel/upgrade'), 'DOWNLOAD_LINK' => $update_check->upgradeZipLink(), 'DOWNLOAD' => $language->get('admin', 'download'), - 'INSTALL_CONFIRM' => $language->get('admin', 'install_confirm') + 'INSTALL_CONFIRM' => $language->get('admin', 'install_confirm'), ]); } } else { - $smarty->assign([ - 'UPDATE_CHECK_ERROR' => $update_check, - ]); + $template->getEngine()->addVariable('UPDATE_CHECK_ERROR', $update_check); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'UPDATE' => $language->get('admin', 'update'), @@ -97,7 +104,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/update.tpl', $smarty); +$template->displayTemplate('core/update'); diff --git a/modules/Core/pages/panel/user.php b/modules/Core/pages/panel/user.php index 567c2a510b..242c9d9db0 100644 --- a/modules/Core/pages/panel/user.php +++ b/modules/Core/pages/panel/user.php @@ -1,16 +1,26 @@ handlePanelPageLoad()) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -39,22 +49,22 @@ const PANEL_PAGE = 'users'; const PARENT_PAGE = 'users'; $page_title = Output::getClean($user_query->username); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -63,21 +73,21 @@ if ($user->hasPermission('admincp.users.edit')) { // Email address - $smarty->assign([ + $template->getEngine()->addVariables([ 'EMAIL_ADDRESS' => Output::getClean($user_query->email), - 'EMAIL_ADDRESS_LABEL' => $language->get('user', 'email_address') + 'EMAIL_ADDRESS_LABEL' => $language->get('user', 'email_address'), ]); } if ($user->hasPermission('modcp.ip_lookup')) { // Last IP - $smarty->assign([ + $template->getEngine()->addVariables([ 'LAST_IP' => Output::getClean($user_query->lastip), - 'LAST_IP_LABEL' => $language->get('admin', 'ip_address') + 'LAST_IP_LABEL' => $language->get('admin', 'ip_address'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'PAGE' => PANEL_PAGE, @@ -119,7 +129,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/user.tpl', $smarty); +$template->displayTemplate('core/user'); diff --git a/modules/Core/pages/panel/users.php b/modules/Core/pages/panel/users.php index 50e79883c0..8a373cbd6b 100644 --- a/modules/Core/pages/panel/users.php +++ b/modules/Core/pages/panel/users.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.users')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'users'; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -28,44 +37,38 @@ } if (isset($success)) { - $smarty->assign( - [ - 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') - ] - ); + $template->getEngine()->addVariables([ + 'SUCCESS' => $success, + 'SUCCESS_TITLE' => $language->get('general', 'success'), + ]); } if (isset($errors) && count($errors)) { - $smarty->assign( - [ - 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') - ] - ); + $template->getEngine()->addVariables([ + 'ERRORS' => $errors, + 'ERRORS_TITLE' => $language->get('general', 'error'), + ]); } -$smarty->assign( - [ - 'PARENT_PAGE' => PARENT_PAGE, - 'DASHBOARD' => $language->get('admin', 'dashboard'), - 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), - 'USERS' => $language->get('admin', 'users'), - 'PAGE' => PANEL_PAGE, - 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit'), - 'USER' => $language->get('admin', 'user'), - 'GROUP' => $language->get('admin', 'group'), - 'GROUPS' => $language->get('admin', 'groups'), - 'REGISTERED' => $language->get('admin', 'registered'), - 'ACTIONS' => $language->get('general', 'actions'), - 'ACTIONS_LIST' => Core_Module::getUserActions() - ] -); +$template->getEngine()->addVariables([ + 'PARENT_PAGE' => PARENT_PAGE, + 'DASHBOARD' => $language->get('admin', 'dashboard'), + 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), + 'USERS' => $language->get('admin', 'users'), + 'PAGE' => PANEL_PAGE, + 'TOKEN' => Token::get(), + 'SUBMIT' => $language->get('general', 'submit'), + 'USER' => $language->get('admin', 'user'), + 'GROUP' => $language->get('admin', 'group'), + 'GROUPS' => $language->get('admin', 'groups'), + 'REGISTERED' => $language->get('admin', 'registered'), + 'ACTIONS' => $language->get('general', 'actions'), + 'ACTIONS_LIST' => Core_Module::getUserActions(), +]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/users.tpl', $smarty); +$template->displayTemplate('core/users'); diff --git a/modules/Core/pages/panel/users_edit.php b/modules/Core/pages/panel/users_edit.php index 107d88172b..ae8ce7c82f 100644 --- a/modules/Core/pages/panel/users_edit.php +++ b/modules/Core/pages/panel/users_edit.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.users.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -29,7 +38,7 @@ const PANEL_PAGE = 'users'; const EDITING_USER = true; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -271,43 +280,42 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } if (isset($warnings) && count($warnings)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'WARNINGS' => $warnings, - 'WARNINGS_TITLE' => $language->get('admin', 'warning') + 'WARNINGS_TITLE' => $language->get('admin', 'warning'), ]); } if ($user_query->active == 0) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'VALIDATE_USER' => $language->get('admin', 'validate_user'), 'VALIDATE_USER_LINK' => URL::build('/panel/users/edit/', 'id=' . urlencode($user_query->id) . '&action=validate'), 'RESEND_ACTIVATION_EMAIL' => $language->get('admin', 'resend_activation_email'), - 'RESEND_ACTIVATION_EMAIL_LINK' => URL::build('/panel/users/edit/', 'id=' . urlencode($user_query->id) . '&action=resend_email') + 'RESEND_ACTIVATION_EMAIL_LINK' => URL::build('/panel/users/edit/', 'id=' . urlencode($user_query->id) . '&action=resend_email'), ]); } if ($user_query->id != 1 && !$view_user->canViewStaffCP()) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'DELETE_USER' => $language->get('admin', 'delete_user'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), 'CONFIRM_DELETE_USER' => $language->get('admin', 'confirm_user_deletion', ['user' => Output::getClean($user_query->username)]), 'YES' => $language->get('general', 'yes'), 'NO' => $language->get('general', 'no'), - 'NEW_PASSWORD' => $language->get('user', 'new_password'), 'CONFIRM_NEW_PASSWORD' => $language->get('user', 'confirm_new_password'), 'CHANGE_PASSWORD' => $language->get('user', 'change_password'), @@ -316,9 +324,7 @@ $limit_groups = false; if ($user_query->id == 1 || ($user_query->id == $user->data()->id && !$user->hasPermission('admincp.groups.self'))) { - $smarty->assign([ - 'CANT_EDIT_GROUP' => $language->get('admin', 'cant_modify_root_user') - ]); + $template->getEngine()->addVariable('CANT_EDIT_GROUP', $language->get('admin', 'cant_modify_root_user')); $limit_groups = true; } @@ -369,7 +375,7 @@ ]; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), @@ -426,7 +432,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/users_edit.tpl', $smarty); +$template->displayTemplate('core/users_edit'); diff --git a/modules/Core/pages/panel/users_integrations.php b/modules/Core/pages/panel/users_integrations.php index 506fba600d..7ede513530 100644 --- a/modules/Core/pages/panel/users_integrations.php +++ b/modules/Core/pages/panel/users_integrations.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.users.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +28,7 @@ const PANEL_PAGE = 'users'; const EDITING_USER = true; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { Redirect::to(URL::build('/panel/users')); @@ -54,7 +63,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'VIEWING_USER_INTEGRATIONS' => $language->get('admin', 'viewing_integrations_for_x', [ 'user' => Output::getClean($view_user->data()->username), ]), @@ -73,10 +82,10 @@ 'UNLINK_LINK' => URL::build('/panel/users/integrations/', 'id=' . $view_user->data()->id . '&action=unlink&integration='), 'USERNAME' => $language->get('user', 'username'), 'IDENTIFIER' => $language->get('admin', 'identifier'), - 'VERIFIED' => $language->get('admin', 'verified') + 'VERIFIED' => $language->get('admin', 'verified'), ]); - $template_file = 'core/users_integrations.tpl'; + $template_file = 'core/users_integrations'; } else if (isset($_GET['integration'])) { switch ($_GET['action']) { case 'link': @@ -128,7 +137,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'INTEGRATION_TITLE' => $language->get('admin', 'linking_integration_for_x', [ 'integration' => Output::getClean($integration->getName()), 'user' => Output::getClean($view_user->data()->username), @@ -142,7 +151,7 @@ 'IDENTIFIER' => $language->get('admin', 'integration_identifier', ['integration' => Output::getClean($integration->getName())]), ]); - $template_file = 'core/users_integrations_form.tpl'; + $template_file = 'core/users_integrations_form'; break; @@ -187,7 +196,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'INTEGRATION_TITLE' => $language->get('admin', 'editing_integration_for_x', [ 'integration' => Output::getClean($integration->getName()), 'user' => Output::getClean($view_user->data()->username), @@ -202,7 +211,7 @@ 'SYNC_INTEGRATION' => $language->get('admin', 'sync_integration'), ]); - $template_file = 'core/users_integrations_form.tpl'; + $template_file = 'core/users_integrations_form'; break; @@ -231,7 +240,7 @@ } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), @@ -240,7 +249,7 @@ 'TOKEN' => Token::get(), 'SUBMIT' => $language->get('general', 'submit'), 'USER_ID' => $view_user->data()->id, - 'BACK' => $language->get('general', 'back') + 'BACK' => $language->get('general', 'back'), ]); if (Session::exists('integrations_success')) { @@ -252,16 +261,16 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } @@ -270,7 +279,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/users_ip_lookup.php b/modules/Core/pages/panel/users_ip_lookup.php index be7d5963d4..9428f8e331 100644 --- a/modules/Core/pages/panel/users_ip_lookup.php +++ b/modules/Core/pages/panel/users_ip_lookup.php @@ -1,16 +1,25 @@ handlePanelPageLoad('modcp.ip_lookup')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'ip_lookup'; $page_title = $language->get('moderator', 'ip_lookup'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -56,18 +65,18 @@ ]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'ACCOUNTS' => $accounts, 'COUNT_ACCOUNTS' => $count_accounts, 'BACK' => $language->get('general', 'back'), - 'BACK_LINK' => URL::build('/panel/users/ip_lookup') + 'BACK_LINK' => URL::build('/panel/users/ip_lookup'), ]); - $template_file = 'core/users_ip_lookup_results.tpl'; + $template_file = 'core/users_ip_lookup_results'; } else { $errors = [$language->get('moderator', 'no_ips_with_username')]; - $template_file = 'core/users_ip_lookup.tpl'; + $template_file = 'core/users_ip_lookup'; } } else { if (isset($_GET['ip'])) { @@ -78,7 +87,7 @@ if (!count($ip_accounts)) { $errors = [$language->get('moderator', 'no_accounts_with_that_ip')]; - $template_file = 'core/users_ip_lookup.tpl'; + $template_file = 'core/users_ip_lookup'; } else { $accounts = []; @@ -102,7 +111,7 @@ $count_accounts = $language->get('moderator', 'count_accounts_with_ip', ['count' => count($ip_accounts), 'address' => Output::getClean($_GET['ip'])]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'IP_SEARCH' => true, 'ACCOUNTS' => $accounts, 'COUNT_ACCOUNTS' => $count_accounts, @@ -110,7 +119,7 @@ 'BACK_LINK' => URL::build('/panel/users/ip_lookup') ]); - $template_file = 'core/users_ip_lookup_results.tpl'; + $template_file = 'core/users_ip_lookup_results'; } } else { if (Input::exists()) { @@ -141,25 +150,25 @@ } } - $template_file = 'core/users_ip_lookup.tpl'; + $template_file = 'core/users_ip_lookup'; } } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), @@ -167,12 +176,12 @@ 'IP_LOOKUP' => $language->get('moderator', 'ip_lookup'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/users_oauth.php b/modules/Core/pages/panel/users_oauth.php index b50717083e..7f7f25d5c3 100644 --- a/modules/Core/pages/panel/users_oauth.php +++ b/modules/Core/pages/panel/users_oauth.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.users.edit')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +28,7 @@ const PANEL_PAGE = 'users'; const EDITING_USER = true; $page_title = $language->get('admin', 'users'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (isset($_GET['action']) && $_GET['action'] === 'delete') { if (Input::exists()) { @@ -54,13 +63,13 @@ } if (Session::exists('oauth_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS_TITLE' => $language->get('general', 'success'), 'SUCCESS' => Session::flash('oauth_success'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), @@ -93,7 +102,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('core/users_oauth.tpl', $smarty); +$template->displayTemplate('core/users_oauth'); diff --git a/modules/Core/pages/panel/users_punishments.php b/modules/Core/pages/panel/users_punishments.php index 392f387688..f3da901192 100644 --- a/modules/Core/pages/panel/users_punishments.php +++ b/modules/Core/pages/panel/users_punishments.php @@ -1,16 +1,25 @@ handlePanelPageLoad('modcp.punishments')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -20,7 +29,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'punishments'; $page_title = $language->get('moderator', 'punishments'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -327,26 +336,26 @@ } if ($user->hasPermission('modcp.punishments.reset_avatar')) { - $smarty->assign('RESET_AVATAR', $language->get('moderator', 'reset_avatar')); + $template->getEngine()->addVariable('RESET_AVATAR', $language->get('moderator', 'reset_avatar')); } if ($user->hasPermission('modcp.punishments.warn')) { - $smarty->assign('WARN', $language->get('moderator', 'warn')); + $template->getEngine()->addVariable('WARN', $language->get('moderator', 'warn')); } if ($user->hasPermission('modcp.punishments.ban')) { - $smarty->assign('BAN', $language->get('moderator', 'ban')); + $template->getEngine()->addVariable('BAN', $language->get('moderator', 'ban')); } if ($user->hasPermission('modcp.punishments.banip')) { - $smarty->assign('BAN_IP', $language->get('moderator', 'ban_ip')); + $template->getEngine()->addVariable('BAN_IP', $language->get('moderator', 'ban_ip')); } if ($user->hasPermission('modcp.punishments.revoke')) { - $smarty->assign('REVOKE_PERMISSION', true); + $template->getEngine()->addVariable('REVOKE_PERMISSION', true); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'HAS_AVATAR' => $query->has_avatar, 'BACK_LINK' => URL::build('/panel/user/' . urlencode($view_user->data()->id)), 'BACK' => $language->get('general', 'back'), @@ -367,10 +376,10 @@ 'AVATAR' => $view_user->getAvatar(), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), 'YES' => $language->get('general', 'yes'), - 'NO' => $language->get('general', 'no') + 'NO' => $language->get('general', 'no'), ]); - $template_file = 'core/users_punishments_user.tpl'; + $template_file = 'core/users_punishments_user'; } else { if (Input::exists() && isset($_POST['username'])) { if (Token::check()) { @@ -416,7 +425,7 @@ $results = $paginator->getLimited($punishments, 10, $p, count($punishments)); $pagination = $paginator->generate(7, URL::build('/panel/users/punishments/')); - $smarty_results = []; + $template_results = []; foreach ($results->data as $result) { switch ($result->type) { case 1: @@ -436,7 +445,7 @@ $target_user = new User($result->punished); $staff_user = new User($result->staff); - $smarty_results[] = [ + $template_results[] = [ 'username' => $target_user->getDisplayname(true), 'nickname' => $target_user->getDisplayname(), 'profile' => URL::build('/panel/user/' . urlencode($result->punished . '-' . $target_user->data()->username)), @@ -457,28 +466,28 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGINATION' => $pagination, 'STAFF' => $language->get('moderator', 'staff'), 'ACTIONS' => $language->get('moderator', 'actions'), 'WHEN' => $language->get('moderator', 'when'), 'VIEW_USER' => $language->get('moderator', 'view_user'), 'TYPE' => $language->get('moderator', 'type'), - 'RESULTS' => $smarty_results, + 'RESULTS' => $template_results, 'ACKNOWLEDGED' => $language->get('moderator', 'acknowledged'), - 'REVOKED' => $language->get('moderator', 'revoked') + 'REVOKED' => $language->get('moderator', 'revoked'), ]); } else { - $smarty->assign('NO_PUNISHMENTS', $language->get('moderator', 'no_punishments_found')); + $template->getEngine()->addVariable('NO_PUNISHMENTS', $language->get('moderator', 'no_punishments_found')); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'USERNAME' => $language->get('user', 'username'), 'SEARCH' => $language->get('general', 'search'), - 'CANCEL' => $language->get('general', 'cancel') + 'CANCEL' => $language->get('general', 'cancel'), ]); - $template_file = 'core/users_punishments.tpl'; + $template_file = 'core/users_punishments'; } if (Session::exists('user_punishment_success')) { @@ -486,32 +495,32 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), 'PUNISHMENTS' => $language->get('moderator', 'punishments'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/users_reports.php b/modules/Core/pages/panel/users_reports.php index f52fe06513..1e34a97ed7 100644 --- a/modules/Core/pages/panel/users_reports.php +++ b/modules/Core/pages/panel/users_reports.php @@ -1,16 +1,25 @@ handlePanelPageLoad('modcp.reports')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'users'; const PANEL_PAGE = 'reports'; $page_title = $language->get('moderator', 'reports'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; $timeago = new TimeAgo(TIMEZONE); @@ -38,9 +47,9 @@ $change_view_link = URL::build('/panel/users/reports/', 'view=closed&uid=' . urlencode((int) $_GET['uid'])); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CHANGE_VIEW' => $language->get('moderator', 'view_closed'), - 'CHANGE_VIEW_LINK' => $change_view_link + 'CHANGE_VIEW_LINK' => $change_view_link, ]); } else { // Get closed reports @@ -54,9 +63,9 @@ $change_view_link = URL::build('/panel/users/reports/', 'uid=' . urlencode((int) $_GET['uid'])); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CHANGE_VIEW' => $language->get('moderator', 'view_open'), - 'CHANGE_VIEW_LINK' => $change_view_link + 'CHANGE_VIEW_LINK' => $change_view_link, ]); } @@ -132,21 +141,21 @@ ]; } - $smarty->assign('PAGINATION', $pagination); + $template->getEngine()->addVariable('PAGINATION', $pagination); } else { if (!isset($_GET['view'])) { - $smarty->assign('NO_REPORTS', $language->get('moderator', 'no_open_reports')); + $template->getEngine()->addVariable('NO_REPORTS', $language->get('moderator', 'no_open_reports')); } else { - $smarty->assign('NO_REPORTS', $language->get('moderator', 'no_closed_reports')); + $template->getEngine()->addVariable('NO_REPORTS', $language->get('moderator', 'no_closed_reports')); } } if (isset($_GET['uid'])) { - $smarty->assign('VIEWING_USER', Output::getClean($user->idToNickname((int)$_GET['uid']))); + $template->getEngine()->addVariable('VIEWING_USER', Output::getClean($user->idToNickname((int)$_GET['uid']))); } - // Smarty variables - $smarty->assign([ + // Template variables + $template->getEngine()->addVariables([ 'ALL_REPORTS' => $reports, 'VIEW' => $language->get('general', 'view'), 'USER_REPORTED' => $language->get('moderator', 'user_reported'), @@ -158,7 +167,7 @@ 'API' => $language->get('general', 'origin_api'), ]); - $template_file = 'core/users_reports.tpl'; + $template_file = 'core/users_reports'; } else { // Get report by ID if (!isset($_GET['action'])) { @@ -211,11 +220,11 @@ // Get comments $comments = DB::getInstance()->get('reports_comments', ['report_id', $report->id])->results(); - $smarty_comments = []; + $template_comments = []; foreach ($comments as $comment) { $comment_user = new User($comment->commenter_id); - $smarty_comments[] = [ + $template_comments[] = [ 'username' => $comment_user->getDisplayname(), 'profile' => URL::build('/panel/user/' . urlencode($comment->commenter_id . '-' . $comment_user->data()->username)), 'style' => $comment_user->getGroupStyle(), @@ -259,8 +268,8 @@ $reporter_user = new User($report->reporter_id); - // Smarty variables - $smarty->assign([ + // Template variables + $template->getEngine()->addVariables([ 'REPORTS_LINK' => URL::build('/panel/users/reports'), 'VIEWING_REPORT' => $language->get('moderator', 'viewing_report'), 'BACK' => $language->get('general', 'back'), @@ -277,7 +286,7 @@ 'REPORTER_USER_PROFILE' => URL::build('/panel/user/' . urlencode($report->reporter_id . '-' . $reporter_user->data()->username)), 'REPORTER_USER_STYLE' => $reporter_user->getGroupStyle(), 'REPORTER_USER_AVATAR' => $reporter_user->getAvatar(), - 'COMMENTS' => $smarty_comments, + 'COMMENTS' => $template_comments, 'COMMENTS_TEXT' => $language->get('moderator', 'comments'), 'NO_COMMENTS' => $language->get('moderator', 'no_comments'), 'NEW_COMMENT' => $language->get('moderator', 'new_comment'), @@ -289,18 +298,18 @@ // Close/reopen link if ($report->status == 0) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CLOSE_LINK' => URL::build('/panel/users/reports/', 'action=close&id=' . urlencode($report->id)), - 'CLOSE_REPORT' => $language->get('moderator', 'close_report') + 'CLOSE_REPORT' => $language->get('moderator', 'close_report'), ]); } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'REOPEN_LINK' => URL::build('/panel/users/reports/', 'action=open&id=' . urlencode($report->id)), - 'REOPEN_REPORT' => $language->get('moderator', 'reopen_report') + 'REOPEN_REPORT' => $language->get('moderator', 'reopen_report'), ]); } - $template_file = 'core/users_reports_view.tpl'; + $template_file = 'core/users_reports_view'; } else { if ($_GET['action'] == 'close') { // Close report @@ -390,32 +399,32 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), 'REPORTS' => $language->get('moderator', 'reports'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/panel/widgets.php b/modules/Core/pages/panel/widgets.php index 3fc554871f..e6f6e10099 100644 --- a/modules/Core/pages/panel/widgets.php +++ b/modules/Core/pages/panel/widgets.php @@ -1,16 +1,26 @@ handlePanelPageLoad('admincp.widgets')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +28,7 @@ const PARENT_PAGE = 'layout'; const PANEL_PAGE = 'widgets'; $page_title = $language->get('admin', 'widgets'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); @@ -58,7 +68,7 @@ return $a['order'] - $b['order']; }); - $smarty->assign([ + $template->getEngine()->addVariables([ 'ENABLE' => $language->get('admin', 'enable'), 'DISABLE' => $language->get('admin', 'disable'), 'EDIT' => $language->get('general', 'edit'), @@ -68,7 +78,7 @@ 'PROFILE_WIDGETS_LIST' => $profile_widgets_list, ]); - $template_file = 'core/widgets.tpl'; + $template_file = 'core/widgets'; } else { if ($_GET['action'] == 'enable') { // Enable a widget @@ -184,7 +194,7 @@ } if ($widget_instance->getSettings() !== null) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SETTINGS' => $language->get('admin', 'settings'), 'SETTINGS_LINK' => URL::build('/panel/core/widgets/', 'action=settings&w=' . urlencode($widget->id)), ]); @@ -195,7 +205,7 @@ $location = 'right'; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_WIDGET' => $language->get('admin', 'editing_widget_x', [ 'widget' => Text::bold(Output::getClean($widget->name)), ]), @@ -235,7 +245,7 @@ require_once($widget_instance->getSettings()); - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_WIDGET' => $language->get('admin', 'editing_widget_x', [ 'widget' => Text::bold(Output::getClean($widget->name)), ]), @@ -243,7 +253,7 @@ 'BACK_LINK' => URL::build('/panel/core/widgets/', 'action=edit&w=' . urlencode($widget->id)), ]); - $template_file = 'core/widget_settings.tpl'; + $template_file = 'core/widget_settings'; } else { Redirect::to('/panel/core/widgets'); } @@ -259,20 +269,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'LAYOUT' => $language->get('admin', 'layout'), @@ -284,7 +294,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Core/pages/portal.php b/modules/Core/pages/portal.php index f44ba2821b..84b5ff5c8b 100644 --- a/modules/Core/pages/portal.php +++ b/modules/Core/pages/portal.php @@ -1,30 +1,39 @@ get('general', 'home'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; -$smarty->assign([ +$template->getEngine()->addVariables([ 'GENERAL_SETTINGS_URL' => URL::build('/panel/core/general_settings'), ]); // Display template -$template->displayTemplate('portal.tpl', $smarty); +$template->displayTemplate('portal'); diff --git a/modules/Core/pages/privacy.php b/modules/Core/pages/privacy.php index 72e48f76bb..e60469bde5 100644 --- a/modules/Core/pages/privacy.php +++ b/modules/Core/pages/privacy.php @@ -1,28 +1,37 @@ get('general', 'privacy_policy'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Retrieve privacy policy from database -$policy = DB::getInstance()->get('privacy_terms', ['name', 'privacy'])->results(); -if (!count($policy)) { +$policy = DB::getInstance()->get('privacy_terms', ['name', 'privacy']); +if (!$policy->count()) { $policy = Output::getPurified(Settings::get('privacy_policy')); } else { - $policy = Output::getPurified($policy[0]->value); + $policy = Output::getPurified($policy->first()->value); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PRIVACY_POLICY' => $language->get('general', 'privacy_policy'), 'POLICY' => $policy ]); @@ -32,8 +41,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('privacy.tpl', $smarty); +$template->displayTemplate('privacy'); diff --git a/modules/Core/pages/profile.php b/modules/Core/pages/profile.php index 700b109839..4ef12b7a66 100644 --- a/modules/Core/pages/profile.php +++ b/modules/Core/pages/profile.php @@ -1,12 +1,21 @@ get('user', 'profile'); } -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $template->assets()->include([ DARK_MODE @@ -430,12 +439,12 @@ // Set Can view if ($profile_user->isPrivateProfile() && !$user->canBypassPrivateProfile()) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'PRIVATE_PROFILE' => $language->get('user', 'private_profile_page'), 'CAN_VIEW' => false ]); } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CAN_VIEW' => true ]); } @@ -443,7 +452,7 @@ // Generate Smarty variables to pass to template if ($user->isLoggedIn()) { // Form token - $smarty->assign([ + $template->getEngine()->addVariables([ 'TOKEN' => Token::get(), 'LOGGED_IN' => true, 'SUBMIT' => $language->get('general', 'submit'), @@ -452,7 +461,7 @@ ]); if ($user->hasPermission('profile.private.bypass')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CAN_VIEW' => true ]); } @@ -499,7 +508,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SELF' => true, 'SETTINGS_LINK' => URL::build('/user/settings'), 'CHANGE_BANNER' => $language->get('user', 'change_banner'), @@ -508,7 +517,7 @@ ]); if ($user->hasPermission('usercp.profile_banner')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'UPLOAD_PROFILE_BANNER' => $language->get('user', 'upload_profile_banner'), 'PROFILE_BANNER' => $language->get('user', 'profile_banner'), 'BROWSE' => $language->get('general', 'browse'), @@ -517,7 +526,7 @@ ]); } } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'MESSAGE_LINK' => URL::build('/user/messaging/', 'action=new&uid=' . urlencode($query->id)), 'FOLLOW_LINK' => URL::build('/user/follow/', 'user=' . urlencode($query->id)), 'CONFIRM' => $language->get('general', 'confirm'), @@ -526,19 +535,19 @@ // Is the user blocked? if ($user->isBlocked($user->data()->id, $query->id)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'UNBLOCK_USER' => $language->get('user', 'unblock_user'), 'CONFIRM_UNBLOCK_USER' => $language->get('user', 'confirm_unblock_user') ]); } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'BLOCK_USER' => $language->get('user', 'block_user'), 'CONFIRM_BLOCK_USER' => $language->get('user', 'confirm_block_user') ]); } if ($user->hasPermission('modcp.profile_banner_reset')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'RESET_PROFILE_BANNER' => $language->get('moderator', 'reset_profile_banner'), 'RESET_PROFILE_BANNER_LINK' => URL::build('/profile/' . urlencode($query->username) . '/', 'action=reset_banner') ]); @@ -546,10 +555,10 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'NICKNAME' => $profile_user->getDisplayname(true), 'USERNAME' => $profile_user->getDisplayname(), - 'GROUPS' => (isset($query) ? $profile_user->getAllGroupHtml() : [Output::getPurified($group)]), + 'GROUPS' => $profile_user->getAllGroupHtml(), 'USERNAME_COLOUR' => $profile_user->getGroupStyle(), 'USER_TITLE' => Output::getClean($query->user_title), 'FOLLOW' => $language->get('user', 'follow'), @@ -589,7 +598,7 @@ $results = $paginator->getLimited($wall_posts_query, 10, $p, count($wall_posts_query)); $pagination = $paginator->generate(7, URL::build('/profile/' . urlencode($query->username) . '/')); - $smarty->assign('PAGINATION', $pagination); + $template->getEngine()->addVariable('PAGINATION', $pagination); // Display the correct number of posts foreach ($results->data as $nValue) { @@ -678,17 +687,17 @@ ]; } } else { - $smarty->assign('NO_WALL_POSTS', $language->get('user', 'no_wall_posts')); + $template->getEngine()->addVariable('NO_WALL_POSTS', $language->get('user', 'no_wall_posts')); } - $smarty->assign('WALL_POSTS', $wall_posts); + $template->getEngine()->addVariable('WALL_POSTS', $wall_posts); if (isset($error)) { - $smarty->assign('ERROR', $error); + $template->getEngine()->addVariable('ERROR', $error); } if (isset($success)) { - $smarty->assign('SUCCESS', $success); + $template->getEngine()->addVariable('SUCCESS', $success); } // About tab @@ -736,10 +745,10 @@ ]; } } - $smarty->assign('INTEGRATIONS', $user_integrations); + $template->getEngine()->addVariable('INTEGRATIONS', $user_integrations); if (!count($fields)) { - $smarty->assign('NO_ABOUT_FIELDS', $language->get('user', 'no_about_fields')); + $template->getEngine()->addVariable('NO_ABOUT_FIELDS', $language->get('user', 'no_about_fields')); } $profile_placeholders = $profile_user->getProfilePlaceholders(); @@ -773,9 +782,9 @@ 'value' => $query->profile_views ]; - $smarty->assign('ABOUT_FIELDS', $fields); + $template->getEngine()->addVariable('ABOUT_FIELDS', $fields); - $smarty->assign([ + $template->getEngine()->addVariables([ 'REACTIONS' => $all_reactions, 'REACTIONS_BY_USER' => $reactions_by_user, 'REACTIONS_TEXT' => $language->get('user', 'reactions'), @@ -795,7 +804,7 @@ } // Assign profile tabs - $smarty->assign('TABS', $tabs); + $template->getEngine()->addVariable('TABS', $tabs); if (isset($directories[1]) && !empty($directories[1]) && !isset($_GET['error']) && $user->isLoggedIn() && $user->data()->username == $profile) { // Script for banner selector @@ -805,7 +814,7 @@ } if (Session::exists('profile_banner_error')) { - $smarty->assign('ERROR', Session::flash('profile_banner_error')); + $template->getEngine()->addVariable('ERROR', Session::flash('profile_banner_error')); } // Load modules + template @@ -813,35 +822,39 @@ $template->onPageLoad(); - $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left', $profile_user)); - $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right', $profile_user)); + $template->getEngine()->addVariables([ + 'WIDGETS_LEFT' => $widgets->getWidgets('left', $profile_user), + 'WIDGETS_RIGHT' => $widgets->getWidgets('right', $profile_user), + ]); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('profile.tpl', $smarty); + $template->displayTemplate('profile'); } else { if (isset($_GET['error'])) { - // User not exist - $smarty->assign([ + // User does not exist + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'HOME' => $language->get('general', 'home'), - 'NOT_FOUND' => $language->get('user', 'couldnt_find_that_user') + 'NOT_FOUND' => $language->get('user', 'couldnt_find_that_user'), ]); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); $template->onPageLoad(); - $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); - $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); + $template->getEngine()->addVariables([ + 'WIDGETS_LEFT' => $widgets->getWidgets('left'), + 'WIDGETS_RIGHT' => $widgets->getWidgets('right'), + ]); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user_not_exist.tpl', $smarty); + $template->displayTemplate('user_not_exist'); // Search for user // TODO diff --git a/modules/Core/pages/register.php b/modules/Core/pages/register.php index c159cad68d..7d8a5cc056 100644 --- a/modules/Core/pages/register.php +++ b/modules/Core/pages/register.php @@ -1,12 +1,21 @@ get('general', 'register'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); -require_once(ROOT_PATH . '/modules/Core/includes/emails/register.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; +require_once ROOT_PATH . '/modules/Core/includes/emails/register.php'; // Check if registration is enabled if (!Settings::get('registration_enabled')) { // Registration is disabled, display a message - // Get registration disabled message and assign to Smarty variable + // Get registration disabled message and assign to template variable $fallback_message = $language->get('general', 'registration_disabled_message_fallback'); $message = Output::getPurified(Settings::get('registration_disabled_message', $fallback_message)); - $smarty->assign([ + $template->getEngine()->addVariables([ 'REGISTRATION_DISABLED' => $message, 'CREATE_AN_ACCOUNT' => $language->get('user', 'create_an_account') ]); @@ -39,11 +48,11 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('registration_disabled.tpl', $smarty); + $template->displayTemplate('registration_disabled'); die(); } @@ -54,7 +63,7 @@ if ($authme_enabled == 1) { // Authme connector - require(implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', 'Core', 'pages', 'authme_connector.php'])); + require implode(DIRECTORY_SEPARATOR, [ROOT_PATH, 'modules', 'Core', 'pages', 'authme_connector.php']); die(); } } @@ -334,9 +343,9 @@ } if (isset($errors)) { - $smarty->assign('REGISTRATION_ERROR', $errors); + $template->getEngine()->addVariable('REGISTRATION_ERROR', $errors); } else if (Session::exists('oauth_error')) { - $smarty->assign('REGISTRATION_ERROR', Session::flash('oauth_error')); + $template->getEngine()->addVariable('REGISTRATION_ERROR', Session::flash('oauth_error')); } $fields = new Fields(); @@ -355,7 +364,7 @@ $email_value = json_decode(Session::get('oauth_register_data'), true)['email']; } -$smarty->assign('EMAIL_INPUT', $email_value); +$template->getEngine()->addVariable('EMAIL_INPUT', $email_value); $fields->add('username', Fields::TEXT, $language->get('user', 'username'), true, $username_value); $fields->add('email', Fields::EMAIL, $language->get('user', 'email_address'), true, $email_value); @@ -387,7 +396,7 @@ $oauth_flow = Session::exists('oauth_register_data'); if ($oauth_flow) { $data = json_decode(Session::get('oauth_register_data'), true); - $smarty->assign([ + $template->getEngine()->addVariables([ 'OAUTH_MESSAGE_CONTINUE' => $language->get('general', 'oauth_message_continue', [ 'provider' => ucfirst($data['provider']) ]), @@ -409,8 +418,8 @@ ]); } -// Assign Smarty variables -$smarty->assign([ +// Assign template variables +$template->getEngine()->addVariables([ 'FIELDS' => $fields->getAll(), 'I_AGREE' => $language->get('user', 'i_agree'), 'AGREE_TO_TERMS' => $language->get('user', 'agree_t_and_c', [ @@ -431,7 +440,7 @@ ]); if ($captcha) { - $smarty->assign('CAPTCHA', CaptchaBase::getActiveProvider()->getHtml()); + $template->getEngine()->addVariable('CAPTCHA', CaptchaBase::getActiveProvider()->getHtml()); $template->addJSFiles([CaptchaBase::getActiveProvider()->getJavascriptSource() => []]); $submitScript = CaptchaBase::getActiveProvider()->getJavascriptSubmit('form-register'); @@ -450,8 +459,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('register.tpl', $smarty); +$template->displayTemplate('register'); diff --git a/modules/Core/pages/status.php b/modules/Core/pages/status.php index d74d0425ce..25c042bf46 100644 --- a/modules/Core/pages/status.php +++ b/modules/Core/pages/status.php @@ -1,26 +1,35 @@ get('general', 'status'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $servers = DB::getInstance()->orderWhere('mc_servers', 'display = 1', '`order`', 'ASC')->results(); -$smarty->assign( +$template->getEngine()->addVariables( [ 'STATUS' => $language->get('general', 'status'), 'IP' => $language->get('general', 'ip'), @@ -38,8 +47,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('status.tpl', $smarty); +$template->displayTemplate('status'); diff --git a/modules/Core/pages/terms.php b/modules/Core/pages/terms.php index 26fae415b9..a10a881fe7 100644 --- a/modules/Core/pages/terms.php +++ b/modules/Core/pages/terms.php @@ -1,31 +1,40 @@ get('user', 'terms_and_conditions'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Retrieve terms from database -$site_terms = DB::getInstance()->get('privacy_terms', ['name', 'terms'])->results(); -if (!count($site_terms)) { +$site_terms = DB::getInstance()->get('privacy_terms', ['name', 'terms']); +if (!$site_terms->count()) { $site_terms = Settings::get('t_and_c_site'); } else { - $site_terms = $site_terms[0]->value; + $site_terms = $site_terms->first()->value; } $site_terms = Output::getPurified($site_terms); $nameless_terms = Output::getPurified(Settings::get('t_and_c')); -$smarty->assign([ +$template->getEngine()->addVariables([ 'TERMS' => $language->get('user', 'terms_and_conditions'), 'SITE_TERMS' => $site_terms, 'NAMELESS_TERMS' => $nameless_terms @@ -36,8 +45,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('terms.tpl', $smarty); +$template->displayTemplate('terms'); diff --git a/modules/Core/pages/user/alerts.php b/modules/Core/pages/user/alerts.php index 617263cbc6..83404c9436 100644 --- a/modules/Core/pages/user/alerts.php +++ b/modules/Core/pages/user/alerts.php @@ -1,12 +1,21 @@ get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $timeago = new TimeAgo(TIMEZONE); @@ -48,11 +57,11 @@ } if (Session::exists('alerts_error')) { - $smarty->assign('ERROR', Session::flash('alerts_error')); + $template->getEngine()->addVariable('ERROR', Session::flash('alerts_error')); } // Language values - $smarty->assign([ + $template->getEngine()->addVariables([ 'USER_CP' => $language->get('user', 'user_cp'), 'ALERTS' => $language->get('user', 'alerts'), 'ALERTS_LIST' => $alerts_limited, @@ -66,15 +75,15 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user/alerts.tpl', $smarty); + $template->displayTemplate('user/alerts'); } else { if ($_GET['action'] == 'purge') { @@ -94,7 +103,7 @@ Redirect::to(URL::build('/user/alerts')); } - // Check the alert belongs to the user.. + // Check the alert belongs to the user $alert = DB::getInstance()->get('alerts', ['id', $_GET['view']])->results(); if (!count($alert) || $alert[0]->user_id != $user->data()->id) { diff --git a/modules/Core/pages/user/connections.php b/modules/Core/pages/user/connections.php index 6af0b5d4d8..4222cbbe42 100644 --- a/modules/Core/pages/user/connections.php +++ b/modules/Core/pages/user/connections.php @@ -1,12 +1,21 @@ get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; if (Input::exists()) { if (Token::check()) { @@ -86,7 +95,7 @@ } // Language values -$smarty->assign([ +$template->getEngine()->addVariables([ 'TOKEN' => Token::get(), 'USER_CP' => $language->get('user', 'user_cp'), 'CONNECTIONS' => $language->get('user', 'connections'), @@ -108,14 +117,14 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, 'SUCCESS_TITLE' => $language->get('general', 'success') ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, 'ERRORS_TITLE' => $language->get('general', 'error') ]); @@ -124,12 +133,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('user/connections.tpl', $smarty); +$template->displayTemplate('user/connections'); diff --git a/modules/Core/pages/user/index.php b/modules/Core/pages/user/index.php index 398d20cab5..8104f7d317 100644 --- a/modules/Core/pages/user/index.php +++ b/modules/Core/pages/user/index.php @@ -1,12 +1,22 @@ get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $user_details = [ $language->get('user', 'username') => $user->getDisplayname(true), @@ -26,7 +36,7 @@ ]; // Language values -$smarty->assign([ +$template->getEngine()->addVariables([ 'USER_CP' => $language->get('user', 'user_cp'), 'USER_DETAILS' => $language->get('user', 'user_details'), 'USER_DETAILS_VALUES' => $user_details, @@ -94,7 +104,7 @@ $average_data = '[' . rtrim($average_data, ', ') . ']'; $total_data = '[' . rtrim($total_data, ', ') . ']'; - $smarty->assign('FORUM_GRAPH', $forum_language->get('forum', 'last_7_days_posts')); + $template->getEngine()->addVariable('FORUM_GRAPH', $forum_language->get('forum', 'last_7_days_posts')); } if ($forum_enabled) { @@ -186,4 +196,4 @@ require(ROOT_PATH . '/core/templates/footer.php'); // Display template -$template->displayTemplate('user/index.tpl', $smarty); +$template->displayTemplate('user/index'); diff --git a/modules/Core/pages/user/messaging.php b/modules/Core/pages/user/messaging.php index d5555e6d2c..5cad069775 100644 --- a/modules/Core/pages/user/messaging.php +++ b/modules/Core/pages/user/messaging.php @@ -1,12 +1,21 @@ get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $timeago = new TimeAgo(TIMEZONE); -$smarty->assign( - [ - 'ERROR_TITLE' => $language->get('general', 'error') - ] -); +$template->getEngine()->addVariable('ERROR_TITLE', $language->get('general', 'error')); // Get page if (isset($_GET['p'])) { @@ -59,7 +64,7 @@ $results = $paginator->getLimited($messages, 10, $p, count($messages)); $pagination = $paginator->generate(7, URL::build('/user/messaging/')); - $smarty->assign('PAGINATION', $pagination); + $template->getEngine()->addVariable('PAGINATION', $pagination); // Array to pass to template $template_array = []; @@ -90,41 +95,37 @@ ]; } - // Assign Smarty variables - $smarty->assign( - [ - 'USER_CP' => $language->get('user', 'user_cp'), - 'MESSAGING' => $language->get('user', 'messaging'), - 'MESSAGES' => $template_array, - 'NO_MESSAGES' => $language->get('user', 'no_messages_full'), - 'MESSAGE_TITLE' => $language->get('user', 'message_title'), - 'PARTICIPANTS' => $language->get('user', 'participants'), - 'LAST_MESSAGE' => $language->get('user', 'last_message'), - ] - ); + // Assign template variables + $template->getEngine()->addVariables([ + 'USER_CP' => $language->get('user', 'user_cp'), + 'MESSAGING' => $language->get('user', 'messaging'), + 'MESSAGES' => $template_array, + 'NO_MESSAGES' => $language->get('user', 'no_messages_full'), + 'MESSAGE_TITLE' => $language->get('user', 'message_title'), + 'PARTICIPANTS' => $language->get('user', 'participants'), + 'LAST_MESSAGE' => $language->get('user', 'last_message'), + ]); if ($user->hasPermission('usercp.messaging')) { // Can send messages - $smarty->assign( - [ - 'NEW_MESSAGE' => $language->get('user', 'new_message'), - 'NEW_MESSAGE_LINK' => URL::build('/user/messaging/', 'action=new') - ] - ); + $template->getEngine()->addVariables([ + 'NEW_MESSAGE' => $language->get('user', 'new_message'), + 'NEW_MESSAGE_LINK' => URL::build('/user/messaging/', 'action=new') + ]); } // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user/messaging.tpl', $smarty); + $template->displayTemplate('user/messaging'); } else { if ($_GET['action'] == 'new') { @@ -285,36 +286,34 @@ } if (isset($error)) { - $smarty->assign('ERROR', $error); + $template->getEngine()->addVariable('ERROR', $error); } if (isset($_GET['uid'])) { // Messaging a specific user - $user_messaging = DB::getInstance()->get('users', ['id', $_GET['uid']])->results(); + $user_messaging = DB::getInstance()->get('users', ['id', $_GET['uid']]); - if (count($user_messaging)) { - $smarty->assign('TO_USER', Output::getClean($user_messaging[0]->username)); + if ($user_messaging->count()) { + $template->getEngine()->addVariable('TO_USER', Output::getClean($user_messaging->first()->username)); } } $content = (isset($_POST['content'])) ? EventHandler::executeEvent('renderPrivateMessageEdit', ['content' => $_POST['content']])['content'] : null; - // Assign Smarty variables - $smarty->assign( - [ - 'NEW_MESSAGE' => $language->get('user', 'new_message'), - 'CANCEL' => $language->get('general', 'cancel'), - 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), - 'CANCEL_LINK' => URL::build('/user/messaging'), - 'SUBMIT' => $language->get('general', 'submit'), - 'TOKEN' => Token::get(), - 'MESSAGE_TITLE' => $language->get('user', 'message_title'), - 'MESSAGE_TITLE_VALUE' => (isset($_POST['title']) ? Output::getPurified($_POST['title']) : ''), - 'TO' => $language->get('user', 'to'), - 'SEPARATE_USERS_WITH_COMMAS' => $language->get('user', 'separate_users_with_commas'), - 'ALL_USERS' => $user->listAllOtherUsers() - ] - ); + // Assign template variables + $template->getEngine()->addVariables([ + 'NEW_MESSAGE' => $language->get('user', 'new_message'), + 'CANCEL' => $language->get('general', 'cancel'), + 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), + 'CANCEL_LINK' => URL::build('/user/messaging'), + 'SUBMIT' => $language->get('general', 'submit'), + 'TOKEN' => Token::get(), + 'MESSAGE_TITLE' => $language->get('user', 'message_title'), + 'MESSAGE_TITLE_VALUE' => (isset($_POST['title']) ? Output::getPurified($_POST['title']) : ''), + 'TO' => $language->get('user', 'to'), + 'SEPARATE_USERS_WITH_COMMAS' => $language->get('user', 'separate_users_with_commas'), + 'ALL_USERS' => $user->listAllOtherUsers() + ]); $template->assets()->include([ AssetTree::TINYMCE, @@ -325,15 +324,15 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user/new_message.tpl', $smarty); + $template->displayTemplate('user/new_message'); } else if ($_GET['action'] == 'view') { // Ensure message is specified @@ -404,7 +403,7 @@ } // Display success message - $smarty->assign('MESSAGE_SENT', $language->get('user', 'message_sent_successfully')); + $template->getEngine()->addVariable('MESSAGE_SENT', $language->get('user', 'message_sent_successfully')); unset($_POST['content']); } else { @@ -420,7 +419,7 @@ } if (isset($error)) { - $smarty->assign('ERROR', $error); + $template->getEngine()->addVariable('ERROR', $error); } // Get all PM replies @@ -435,7 +434,7 @@ $results = $paginator->getLimited($pm_replies, 10, $p, count($pm_replies)); $pagination = $paginator->generate(7, URL::build('/user/messaging/', 'action=view&message=' . urlencode($pm[0]->id) . '&')); - $smarty->assign('PAGINATION', $pagination); + $template->getEngine()->addVariable('PAGINATION', $pagination); // Array to pass to template $template_array = []; @@ -466,8 +465,8 @@ } $participants = rtrim($participants, ', '); - // Smarty variables - $smarty->assign([ + // Template variables + $template->getEngine()->addVariables([ 'MESSAGE_TITLE' => Output::getClean($pm[0]->title), 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/user/messaging'), @@ -496,15 +495,15 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user/view_message.tpl', $smarty); + $template->displayTemplate('user/view_message'); } else if ($_GET['action'] == 'leave') { // Try to remove the user from the conversation diff --git a/modules/Core/pages/user/oauth.php b/modules/Core/pages/user/oauth.php index 918b852691..f66e593612 100644 --- a/modules/Core/pages/user/oauth.php +++ b/modules/Core/pages/user/oauth.php @@ -1,13 +1,21 @@ get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; if (Input::exists()) { if (Token::check()) { @@ -53,20 +61,20 @@ } if (Session::exists('oauth_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $language->get('general', 'success'), 'SUCCESS_MESSAGE' => Session::flash('oauth_success'), ]); } if (Session::exists('oauth_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR' => $language->get('general', 'error'), 'ERROR_MESSAGE' => Session::flash('oauth_error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'TOKEN' => Token::get(), 'NO' => $language->get('general', 'no'), 'YES' => $language->get('general', 'yes'), @@ -84,12 +92,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('user/oauth.tpl', $smarty); +$template->displayTemplate('user/oauth'); diff --git a/modules/Core/pages/user/placeholders.php b/modules/Core/pages/user/placeholders.php index dd909c6a62..58f0883354 100644 --- a/modules/Core/pages/user/placeholders.php +++ b/modules/Core/pages/user/placeholders.php @@ -1,12 +1,21 @@ get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; -$timeago = new TimeAgo(TIMEZONE); +$timeAgo = new TimeAgo(TIMEZONE); $placeholders_list = []; @@ -34,13 +43,13 @@ 'name' => $placeholder->name, 'friendly_name' => $placeholder->friendly_name, 'value' => $placeholder->value, - 'last_updated' => ucfirst($timeago->inWords($placeholder->last_updated, $language)), + 'last_updated' => ucfirst($timeAgo->inWords($placeholder->last_updated, $language)), 'show_on_profile' => $placeholder->show_on_profile, 'show_on_forum' => $placeholder->show_on_forum ]; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'USER_CP' => $language->get('user', 'user_cp'), 'NO_PLACEHOLDERS' => $language->get('user', 'no_placeholders'), 'PLACEHOLDERS' => $language->get('user', 'placeholders'), @@ -56,12 +65,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('user/placeholders.tpl', $smarty); +$template->displayTemplate('user/placeholders'); diff --git a/modules/Core/pages/user/settings.php b/modules/Core/pages/user/settings.php index 9303882499..e98e7ca5bd 100644 --- a/modules/Core/pages/user/settings.php +++ b/modules/Core/pages/user/settings.php @@ -1,12 +1,21 @@ get('user', 'user_cp'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Forum enabled? $forum_enabled = Util::isModuleEnabled('Forum'); -// Two factor auth? +// Two-factor auth? if (isset($_GET['do'])) { if ($_GET['do'] == 'enable_tfa') { @@ -45,8 +54,8 @@ $errors[] = Session::get('force_tfa_alert'); } - // Assign Smarty variables - $smarty->assign([ + // Assign template variables + $template->getEngine()->addVariables([ 'TWO_FACTOR_AUTH' => $language->get('user', 'two_factor_auth'), 'TFA_SCAN_CODE_TEXT' => $language->get('user', 'tfa_scan_code'), 'IMG_SRC' => $tfa->getQRCodeImageAsDataUri(Output::getClean(SITE_NAME) . ':' . Output::getClean($user->data()->username), $secret), @@ -61,9 +70,7 @@ ]); if (isset($errors) && count($errors)) { - $smarty->assign([ - 'ERRORS' => $errors - ]); + $template->getEngine()->addVariable('ERRORS', $errors); } } else { // Validate code to see if it matches the secret @@ -92,10 +99,10 @@ } if (isset($error)) { - $smarty->assign('ERROR', $error); + $template->getEngine()->addVariable('ERROR', $error); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'TWO_FACTOR_AUTH' => $language->get('user', 'two_factor_auth'), 'TFA_ENTER_CODE' => $language->get('user', 'tfa_enter_code'), 'SUBMIT' => $language->get('general', 'submit'), @@ -106,11 +113,11 @@ ]); } Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); - $template->displayTemplate('user/tfa.tpl', $smarty); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; + $template->displayTemplate('user/tfa'); } else { if ($_GET['do'] == 'disable_tfa') { @@ -553,7 +560,7 @@ } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, 'ERRORS_TITLE' => $language->get('general', 'error') ]); @@ -562,34 +569,32 @@ if ($user->hasPermission('usercp.signature')) { $signature = Output::getPurified($user->data()->signature); - $smarty->assign([ + $template->getEngine()->addVariables([ 'SIGNATURE' => $language->get('user', 'signature'), 'SIGNATURE_VALUE' => $signature ]); } if ($forum_enabled) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'TOPIC_UPDATES' => $language->get('user', 'topic_updates'), 'TOPIC_UPDATES_ENABLED' => DB::getInstance()->get('users', ['id', $user->data()->id])->first()->topic_updates ]); } if ($user->canPrivateProfile()) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'PRIVATE_PROFILE' => $language->get('user', 'private_profile'), 'PRIVATE_PROFILE_ENABLED' => $user->isPrivateProfile() ]); } if (isset($error)) { - $smarty->assign([ - 'ERROR' => $error, - ]); + $template->getEngine()->addVariable('ERROR', $error); } // Language values - $smarty->assign([ + $template->getEngine()->addVariables([ 'SETTINGS' => $language->get('user', 'profile_settings'), 'ACTIVE_LANGUAGE' => $language->get('user', 'active_language'), 'LANGUAGES' => $languages, @@ -621,7 +626,7 @@ ]); if (defined('CUSTOM_AVATARS')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CUSTOM_AVATARS' => true, 'CUSTOM_AVATARS_SCRIPT' => ((defined('CONFIG_PATH')) ? CONFIG_PATH . '/' : '/') . 'core/includes/image_upload.php', 'BROWSE' => $language->get('general', 'browse'), @@ -633,7 +638,7 @@ } if ($user->data()->tfa_enabled == 1) { - $smarty->assign('DISABLE', $language->get('user', 'disable')); + $template->getEngine()->addVariable('DISABLE', $language->get('user', 'disable')); foreach ($user->getGroups() as $group) { if ($group->force_tfa) { $forced = true; @@ -642,18 +647,20 @@ } if (isset($forced) && $forced) { - $smarty->assign('FORCED', true); + $template->getEngine()->addVariable('FORCED', true); } else { - $smarty->assign('DISABLE_LINK', URL::build('/user/settings/', 'do=disable_tfa')); + $template->getEngine()->addVariable('DISABLE_LINK', URL::build('/user/settings/', 'do=disable_tfa')); } } else { // Enable - $smarty->assign('ENABLE', $language->get('user', 'enable')); - $smarty->assign('ENABLE_LINK', URL::build('/user/settings/', 'do=enable_tfa')); + $template->getEngine()->addVariables([ + 'ENABLE' => $language->get('user', 'enable'), + 'ENABLE_LINK' => URL::build('/user/settings/', 'do=enable_tfa'), + ]); } if ($user->data()->register_method && Settings::get('authme')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'AUTHME_SYNC_PASSWORD' => $language->get('user', 'authme_sync_password'), 'AUTHME_SYNC_PASSWORD_INFO' => $language->get('user', Settings::get('login_method') === 'username' ? 'authme_sync_password_setting' @@ -666,13 +673,13 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); - require(ROOT_PATH . '/core/templates/cc_navbar.php'); + require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user/settings.tpl', $smarty); + $template->displayTemplate('user/settings'); } diff --git a/modules/Core/queries/reactions.php b/modules/Core/queries/reactions.php index ed465bf28d..2ae13067a5 100644 --- a/modules/Core/queries/reactions.php +++ b/modules/Core/queries/reactions.php @@ -1,4 +1,19 @@ assign([ + $template->getEngine()->addVariables([ 'ACTIVE_TAB' => $_GET['tab'], 'REACTIONS' => $formatted_reactions, ]); // modal - die($template->getTemplate('reactions_modal.tpl', $smarty)); + die($template->getTemplate('reactions_modal')); } // add reaction diff --git a/modules/Core/queries/user.php b/modules/Core/queries/user.php index 2297450296..7d3a5d4cb7 100644 --- a/modules/Core/queries/user.php +++ b/modules/Core/queries/user.php @@ -1,4 +1,21 @@ 'Error: Invalid ID'])); @@ -41,7 +58,7 @@ } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PROFILE' => $profile, 'USERNAME' => $username, 'NICKNAME' => $nickname, @@ -64,5 +81,5 @@ 'avatar' => $avatar, 'style' => $style, 'groups' => $groups, - 'html' => $template->getTemplate('user_popover.tpl', $smarty) + 'html' => $template->getTemplate('user_popover') ], JSON_PRETTY_PRINT); diff --git a/modules/Core/widgets/FacebookWidget.php b/modules/Core/widgets/FacebookWidget.php index 0614e9e745..f4c3640dce 100644 --- a/modules/Core/widgets/FacebookWidget.php +++ b/modules/Core/widgets/FacebookWidget.php @@ -3,7 +3,7 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * * License: MIT * @@ -14,8 +14,8 @@ class FacebookWidget extends WidgetBase { private string $_fb_url; - public function __construct(Smarty $smarty, ?string $fb_url = '') { - $this->_smarty = $smarty; + public function __construct(TemplateEngine $engine, ?string $fb_url = '') { + $this->_engine = $engine; // Set widget variables $this->_module = 'Core'; diff --git a/modules/Core/widgets/MinecraftAccountProfileWidget.php b/modules/Core/widgets/MinecraftAccountProfileWidget.php index c8c783038f..7767324154 100644 --- a/modules/Core/widgets/MinecraftAccountProfileWidget.php +++ b/modules/Core/widgets/MinecraftAccountProfileWidget.php @@ -5,12 +5,12 @@ class MinecraftAccountProfileWidget extends ProfileWidgetBase { private Cache $_cache; private Language $_language; - public function __construct(Smarty $smarty, Cache $cache, Language $language) { + public function __construct(TemplateEngine $engine, Cache $cache, Language $language) { $this->_name = 'Minecraft Account'; $this->_description = 'Displays a users Minecraft account on their profile.'; $this->_module = 'Core'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_cache = $cache; $this->_language = $language; } @@ -26,7 +26,7 @@ public function initialise(User $user): void { ? CONFIG_PATH : ''; - $this->_smarty->assign([ + $this->_engine->addVariables([ 'USERNAME' => $integrationUser->data()->username, 'UUID' => $integrationUser->data()->identifier, 'UUID_FORMATTED' => ProfileUtils::formatUUID($integrationUser->data()->identifier), @@ -48,19 +48,19 @@ public function initialise(User $user): void { $server_name = $server->name; $server_ip = $server->ip; } else { - $this->_smarty->assign('SERVER_UNKNOWN', true); + $this->_engine->addVariable('SERVER_UNKNOWN', true); $server_name = $this->_language->get('admin', 'unknown'); $server_ip = $this->_language->get('admin', 'unknown'); } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'LAST_ONLINE' => date(DATE_FORMAT, $last_online), 'LAST_ONLINE_AGO' => (new TimeAgo(TIMEZONE))->inWords($last_online, $this->_language), 'LAST_ONLINE_SERVER' => $server_name, 'LAST_ONLINE_SERVER_IP' => $server_ip ]); } else { - $this->_smarty->assign([ + $this->_engine->addVariables([ 'ALL_UNKNOWN' => true, 'LAST_ONLINE' => $this->_language->get('admin', 'unknown'), 'LAST_ONLINE_AGO' => $this->_language->get('admin', 'unknown'), @@ -69,6 +69,6 @@ public function initialise(User $user): void { ]); } - $this->_content = $this->_smarty->fetch('widgets/minecraft_account.tpl'); + $this->_content = $this->_engine->fetch('widgets/minecraft_account'); } } diff --git a/modules/Core/widgets/OnlineStaffWidget.php b/modules/Core/widgets/OnlineStaffWidget.php index 4e0bb9aa1d..53eb350dde 100644 --- a/modules/Core/widgets/OnlineStaffWidget.php +++ b/modules/Core/widgets/OnlineStaffWidget.php @@ -3,9 +3,9 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Online staff widget */ @@ -15,11 +15,11 @@ class OnlineStaffWidget extends WidgetBase { private Cache $_cache; private Language $_language; - public function __construct(Smarty $smarty, Language $language, Cache $cache) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache) { $this->_module = 'Core'; $this->_name = 'Online Staff'; $this->_description = 'Displays a list of online staff members on your website.'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_cache = $cache; $this->_language = $language; @@ -59,20 +59,20 @@ public function initialise(): void { } } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'ONLINE_STAFF' => $this->_language->get('general', 'online_staff'), 'ONLINE_STAFF_LIST' => $staff_members, 'TOTAL_ONLINE_STAFF' => $this->_language->get('general', 'total_online_staff', ['count' => count($online)]), ]); } else { - $this->_smarty->assign([ + $this->_engine->addVariables([ 'ONLINE_STAFF' => $this->_language->get('general', 'online_staff'), 'NO_STAFF_ONLINE' => $this->_language->get('general', 'no_online_staff'), 'TOTAL_ONLINE_STAFF' => $this->_language->get('general', 'total_online_staff', ['count' => 0]), ]); } - $this->_content = $this->_smarty->fetch('widgets/online_staff.tpl'); + $this->_content = $this->_engine->fetch('widgets/online_staff'); } } diff --git a/modules/Core/widgets/OnlineUsersWidget.php b/modules/Core/widgets/OnlineUsersWidget.php index 44ca587346..29d2edaf39 100644 --- a/modules/Core/widgets/OnlineUsersWidget.php +++ b/modules/Core/widgets/OnlineUsersWidget.php @@ -1,11 +1,10 @@ _module = 'Core'; $this->_name = 'Online Users'; $this->_description = 'Displays a list of online users on your website.'; $this->_settings = ROOT_PATH . '/modules/Core/includes/admin_widgets/online_users.php'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_cache = $cache; $this->_language = $language; } @@ -79,7 +78,7 @@ public function initialise(): void { } } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'SHOW_NICKNAME_INSTEAD' => $use_nickname_show, 'ONLINE_USERS' => $this->_language->get('general', 'online_users'), 'ONLINE_USERS_LIST' => $users, @@ -87,13 +86,13 @@ public function initialise(): void { ]); } else { - $this->_smarty->assign([ + $this->_engine->addVariables([ 'ONLINE_USERS' => $this->_language->get('general', 'online_users'), 'NO_USERS_ONLINE' => $this->_language->get('general', 'no_online_users'), 'TOTAL_ONLINE_USERS' => $this->_language->get('general', 'total_online_users', ['count' => 0]) ]); } - $this->_content = $this->_smarty->fetch('widgets/online_users.tpl'); + $this->_content = $this->_engine->fetch('widgets/online_users'); } } diff --git a/modules/Core/widgets/ProfilePostsWidget.php b/modules/Core/widgets/ProfilePostsWidget.php index d346fe4332..dda4403364 100644 --- a/modules/Core/widgets/ProfilePostsWidget.php +++ b/modules/Core/widgets/ProfilePostsWidget.php @@ -2,7 +2,7 @@ /* * Made by Aberdeener * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.2 + * NamelessMC version 2.2.0 * * License: MIT * @@ -16,11 +16,11 @@ class ProfilePostsWidget extends WidgetBase { private User $_user; private TimeAgo $_timeago; - public function __construct(Smarty $smarty, Language $language, Cache $cache, User $user, TimeAgo $timeago) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache, User $user, TimeAgo $timeago) { $this->_module = 'Core'; $this->_name = 'Latest Profile Posts'; $this->_description = 'Display the latest profile posts on your site.'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; $this->_cache = $cache; @@ -91,14 +91,14 @@ public function initialise(): void { $this->_cache->store('profile_posts_' . $user_id, $posts_array, 120); } if (count($posts_array) >= 1) { - $this->_smarty->assign([ + $this->_engine->addVariables([ 'PROFILE_POSTS_ARRAY' => $posts_array ]); } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'LATEST_PROFILE_POSTS' => $this->_language->get('user', 'latest_profile_posts'), 'NO_PROFILE_POSTS' => $this->_language->get('user', 'no_profile_posts') ]); - $this->_content = $this->_smarty->fetch('widgets/profile_posts.tpl'); + $this->_content = $this->_engine->fetch('widgets/profile_posts'); } } diff --git a/modules/Core/widgets/ReactionsProfileWidget.php b/modules/Core/widgets/ReactionsProfileWidget.php index 2e2c19c8d5..72d71e7143 100644 --- a/modules/Core/widgets/ReactionsProfileWidget.php +++ b/modules/Core/widgets/ReactionsProfileWidget.php @@ -4,12 +4,12 @@ class ReactionsProfileWidget extends ProfileWidgetBase { private Language $_language; - public function __construct(Smarty $smarty, Language $language) { + public function __construct(TemplateEngine $engine, Language $language) { $this->_name = 'Reactions'; $this->_description = 'Displays a users received and given reactions on their profile.'; $this->_module = 'Core'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; } @@ -70,7 +70,7 @@ public function initialise(User $user): void { } } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'REACTIONS_TEXT' => $this->_language->get('user', 'reactions'), 'GIVEN' => $this->_language->get('user', 'given'), 'RECEIVED' => $this->_language->get('user', 'received'), @@ -79,7 +79,7 @@ public function initialise(User $user): void { 'REACTION_SCORE_AGGREGATE' => $reaction_score_aggregate, 'CONTEXT_REACTION_SCORES' => $context_reaction_scores, ]); - $this->_content = $this->_smarty->fetch('widgets/reactions.tpl'); + $this->_content = $this->_engine->fetch('widgets/reactions'); } private function calculateCounts(string $type, User $user, array &$reactions): void { diff --git a/modules/Core/widgets/ServerStatusWidget.php b/modules/Core/widgets/ServerStatusWidget.php index a6e8927f7a..e514ed4b57 100644 --- a/modules/Core/widgets/ServerStatusWidget.php +++ b/modules/Core/widgets/ServerStatusWidget.php @@ -1,11 +1,10 @@ _module = 'Core'; $this->_name = 'Server Status'; $this->_description = 'Display your Minecraft server status.'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; $this->_cache = $cache; @@ -58,7 +57,7 @@ public function initialise(): void { } if (count($server_array) >= 1) { - $this->_smarty->assign( + $this->_engine->addVariables( [ 'SERVER' => $server_array, 'ONLINE' => $this->_language->get('general', 'online'), @@ -68,12 +67,12 @@ public function initialise(): void { ] ); } - $this->_smarty->assign( + $this->_engine->addVariables( [ 'SERVER_STATUS' => $this->_language->get('general', 'server_status'), 'NO_SERVERS' => $this->_language->get('general', 'no_default_server') ] ); - $this->_content = $this->_smarty->fetch('widgets/server_status.tpl'); + $this->_content = $this->_engine->fetch('widgets/server_status'); } } diff --git a/modules/Core/widgets/StatsWidget.php b/modules/Core/widgets/StatsWidget.php index 7fb9472c54..cba0a69f98 100644 --- a/modules/Core/widgets/StatsWidget.php +++ b/modules/Core/widgets/StatsWidget.php @@ -2,9 +2,9 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.2 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Statistics Widget // By Xemah // https://xemah.me */ @@ -14,11 +14,11 @@ class StatsWidget extends WidgetBase { private Cache $_cache; private Language $_language; - public function __construct(Smarty $smarty, Language $language, Cache $cache) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache) { $this->_module = 'Core'; $this->_name = 'Statistics'; $this->_description = 'Displays the basic statistics of your website.'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_cache = $cache; $this->_language = $language; @@ -92,7 +92,7 @@ public function initialise(): void { $total_posts = $this->_cache->retrieve('total_posts'); } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'FORUM_STATISTICS' => $this->_language->get('general', 'forum_statistics'), 'TOTAL_THREADS' => $this->_language->get('general', 'total_threads'), 'TOTAL_THREADS_VALUE' => $total_topics, @@ -101,7 +101,7 @@ public function initialise(): void { ]); } - $this->_smarty->assign([ + $this->_engine->addVariables([ 'STATISTICS' => $this->_language->get('general', 'statistics'), 'USERS_REGISTERED' => $this->_language->get('general', 'users_registered'), 'USERS_REGISTERED_VALUE' => $users_registered, @@ -115,6 +115,6 @@ public function initialise(): void { 'TOTAL_ONLINE_VALUE' => $online_guests + $online_users, ]); - $this->_content = $this->_smarty->fetch('widgets/statistics.tpl'); + $this->_content = $this->_engine->fetch('widgets/statistics'); } } diff --git a/modules/Core/widgets/TwitterWidget.php b/modules/Core/widgets/TwitterWidget.php index aaa364e57b..9aff3f57e6 100644 --- a/modules/Core/widgets/TwitterWidget.php +++ b/modules/Core/widgets/TwitterWidget.php @@ -3,9 +3,9 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Twitter Widget */ @@ -15,11 +15,11 @@ class TwitterWidget extends WidgetBase { private string $_twitter_url; private string $_theme; - public function __construct(Smarty $smarty, ?string $twitter = '', ?string $theme = '') { + public function __construct(TemplateEngine $engine, ?string $twitter = '', ?string $theme = '') { $this->_module = 'Core'; $this->_name = 'Twitter'; $this->_description = 'Display your Twitter feed on your site. Make sure you have entered your Twitter URL in the StaffCP -> Core -> Social Media tab first!'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_twitter_url = $twitter; $this->_theme = $theme; diff --git a/modules/Discord Integration/module.php b/modules/Discord Integration/module.php index 31639b5dbb..3b64b58604 100644 --- a/modules/Discord Integration/module.php +++ b/modules/Discord Integration/module.php @@ -1,4 +1,11 @@ Aberdeener'; - $module_version = '2.1.2'; - $nameless_version = '2.1.2'; + $module_version = '2.2.0'; + $nameless_version = '2.2.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -50,13 +57,13 @@ public function onDisable() { public function onEnable() { } - public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smarty, $navs, Widgets $widgets, ?TemplateBase $template) { + public function onPageLoad(User $user, Pages $pages, Cache $cache, $smarty, $navs, Widgets $widgets, ?TemplateBase $template) { PermissionHandler::registerPermissions($this->getName(), [ 'admincp.discord' => $this->_language->get('admin', 'integrations') . ' » ' . Discord::getLanguageTerm('discord'), ]); if ($pages->getActivePage()['widgets'] || (defined('PANEL_PAGE') && str_contains(PANEL_PAGE, 'widget'))) { - $widgets->add(new DiscordWidget($cache, $smarty)); + $widgets->add(new DiscordWidget($cache)); } if (!defined('FRONT_END')) { diff --git a/modules/Discord Integration/pages/panel/discord.php b/modules/Discord Integration/pages/panel/discord.php index 28645e3b92..ab009ceaff 100644 --- a/modules/Discord Integration/pages/panel/discord.php +++ b/modules/Discord Integration/pages/panel/discord.php @@ -1,16 +1,25 @@ handlePanelPageLoad('admincp.discord')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -18,7 +27,7 @@ const PARENT_PAGE = 'integrations'; const PANEL_PAGE = 'discord'; $page_title = Discord::getLanguageTerm('discord'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (Input::exists()) { $errors = []; @@ -85,29 +94,29 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } if (Session::exists('discord_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => [Session::flash('discord_error')], - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } // TODO: Add a check to see if the bot is online using `/status` endpoint Discord::botRequest('/status'); -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'INTEGRATIONS' => $language->get('admin', 'integrations'), @@ -140,7 +149,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('integrations/discord/discord.tpl', $smarty); +$template->displayTemplate('integrations/discord/discord'); diff --git a/modules/Discord Integration/widgets/DiscordWidget.php b/modules/Discord Integration/widgets/DiscordWidget.php index 8c548d9b8c..755c0f575a 100644 --- a/modules/Discord Integration/widgets/DiscordWidget.php +++ b/modules/Discord Integration/widgets/DiscordWidget.php @@ -4,9 +4,9 @@ * Made by Partydragen * Updated by BrightSkyz * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Discord Widget */ @@ -16,12 +16,11 @@ class DiscordWidget extends WidgetBase { private Cache $_cache; private ?string $_guild_id; - public function __construct(Cache $cache, Smarty $smarty) { + public function __construct(Cache $cache) { $this->_module = 'Discord Integration'; $this->_name = 'Discord'; $this->_description = 'Display your Discord channel on your site. Make sure you have entered your Discord widget details in the StaffCP -> Integrations -> Discord tab first!'; $this->_settings = ROOT_PATH . '/modules/Discord Integration/includes/admin_widgets/discord.php'; - $this->_smarty = $smarty; $this->_cache = $cache; $this->_guild_id = Discord::getGuildId(); diff --git a/modules/Forum/collections/panel/RecentPosts.php b/modules/Forum/collections/panel/RecentPosts.php index e95e055d47..5a878c918f 100644 --- a/modules/Forum/collections/panel/RecentPosts.php +++ b/modules/Forum/collections/panel/RecentPosts.php @@ -2,20 +2,20 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Recent posts dashboard collection item */ class RecentPostsItem extends CollectionItemBase { - private Smarty $_smarty; + private TemplateEngine $_engine; private Language $_language; private int $_posts; - public function __construct(Smarty $smarty, Language $language, Cache $cache, int $posts) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache, int $posts) { $cache->setCache('dashboard_stats_collection'); if ($cache->isCached('recent_posts')) { $from_cache = $cache->retrieve('recent_posts'); @@ -29,17 +29,17 @@ public function __construct(Smarty $smarty, Language $language, Cache $cache, in parent::__construct($order, $enabled); - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; $this->_posts = $posts; } public function getContent(): string { - $this->_smarty->assign([ + $this->_engine->addVariables([ 'TITLE' => $this->_language->get('forum', 'recent_posts'), 'VALUE' => $this->_posts ]); - return $this->_smarty->fetch('collections/dashboard_stats/recent_posts.tpl'); + return $this->_engine->fetch('collections/dashboard_stats/recent_posts'); } } diff --git a/modules/Forum/collections/panel/RecentTopics.php b/modules/Forum/collections/panel/RecentTopics.php index 5ea1fb5e04..0e22b9d8f1 100644 --- a/modules/Forum/collections/panel/RecentTopics.php +++ b/modules/Forum/collections/panel/RecentTopics.php @@ -3,20 +3,20 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.0-pr8 + * NamelessMC version 2.2.0 * - * License: MIT + * Licence: MIT * * Recent topics dashboard collection item */ class RecentTopicsItem extends CollectionItemBase { - private Smarty $_smarty; + private TemplateEngine $_engine; private Language $_language; private int $_topics; - public function __construct(Smarty $smarty, Language $language, Cache $cache, int $topics) { + public function __construct(TemplateEngine $engine, Language $language, Cache $cache, int $topics) { $cache->setCache('dashboard_stats_collection'); if ($cache->isCached('recent_topics')) { $from_cache = $cache->retrieve('recent_topics'); @@ -30,17 +30,17 @@ public function __construct(Smarty $smarty, Language $language, Cache $cache, in parent::__construct($order, $enabled); - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_language = $language; $this->_topics = $topics; } public function getContent(): string { - $this->_smarty->assign([ + $this->_engine->addVariables([ 'TITLE' => $this->_language->get('forum', 'recent_topics'), 'VALUE' => $this->_topics ]); - return $this->_smarty->fetch('collections/dashboard_stats/recent_topics.tpl'); + return $this->_engine->fetch('collections/dashboard_stats/recent_topics'); } } diff --git a/modules/Forum/front_page.php b/modules/Forum/front_page.php index 6b96016105..5d0f6048da 100644 --- a/modules/Forum/front_page.php +++ b/modules/Forum/front_page.php @@ -1,12 +1,16 @@ getAllGroupIds()); @@ -51,12 +55,14 @@ $cache->store('news-' . $groups_key, $news, 60); } -$timeago = new TimeAgo(TIMEZONE); +$timeAgo = new TimeAgo(TIMEZONE); foreach ($news as $key => $item) { - $news[$key]['time_ago'] = $timeago->inWords($item['time_ago'], $language); + $news[$key]['time_ago'] = $timeAgo->inWords($item['time_ago'], $language); } -$smarty->assign('LATEST_ANNOUNCEMENTS', $forum_language->get('forum', 'latest_announcements')); -$smarty->assign('READ_FULL_POST', $forum_language->get('forum', 'read_full_post')); -$smarty->assign('NEWS', $news); -$smarty->assign('NO_NEWS', $forum_language->get('forum', 'no_news')); +$template->getEngine()->addVariables([ + 'LATEST_ANNOUNCEMENTS' => $forum_language->get('forum', 'latest_announcements'), + 'READ_FULL_POST' => $forum_language->get('forum', 'read_full_post'), + 'NEWS' => $news, + 'NO_NEWS' => $forum_language->get('forum', 'no_news'), +]); diff --git a/modules/Forum/module.php b/modules/Forum/module.php index 4ea279ffc6..a2b985dcfa 100644 --- a/modules/Forum/module.php +++ b/modules/Forum/module.php @@ -1,12 +1,10 @@ _forum_language = $forum_language; $name = 'Forum'; - $author = 'Samerton'; - $module_version = '2.1.2'; - $nameless_version = '2.1.2'; + $author = 'Samerton'; + $module_version = '2.2.0'; + $nameless_version = '2.2.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -185,7 +183,15 @@ public function onDisable() { // No actions necessary } - public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template) { + public function onPageLoad( + User $user, + Pages $pages, + Cache $cache, + $smarty, + iterable $navs, + Widgets $widgets, + ?TemplateBase $template + ) { // AdminCP PermissionHandler::registerPermissions('Forum', [ 'admincp.forums' => $this->_language->get('moderator', 'staff_cp') . ' » ' . $this->_forum_language->get('forum', 'forum') @@ -236,7 +242,7 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem // Widgets if ($pages->getActivePage()['widgets'] || (defined('PANEL_PAGE') && str_contains(PANEL_PAGE, 'widget'))) { // Latest posts - $widgets->add(new LatestPostsWidget($this->_forum_language, $smarty, $cache, $user, $this->_language)); + $widgets->add(new LatestPostsWidget($this->_forum_language, $template->getEngine(), $cache, $user, $this->_language)); } // Front end or back end? @@ -248,20 +254,22 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem $topic_count = count($topic_count); $post_count = DB::getInstance()->get('posts', ['post_creator', $user->data()->id])->results(); $post_count = count($post_count); - $smarty->assign('LOGGED_IN_USER_FORUM', [ + $template->getEngine()->addVariable('LOGGED_IN_USER_FORUM', [ 'topic_count' => $topic_count, 'post_count' => $post_count ]); } if (defined('PAGE') && PAGE == 'user_query') { - $user_id = $smarty->getTemplateVars('USER_ID'); + $user_id = $template->getEngine()->getVariable('USER_ID'); if ($user_id) { $forum = new Forum(); - $smarty->assign('TOPICS', $this->_forum_language->get('forum', 'x_topics', ['count' => $forum->getTopicCount($user_id)])); - $smarty->assign('POSTS', $this->_forum_language->get('forum', 'x_posts', ['count' => $forum->getPostCount($user_id)])); + $template->getEngine()->addVariables([ + 'TOPICS' => $this->_forum_language->get('forum', 'x_topics', ['count' => $forum->getTopicCount($user_id)]), + 'POSTS' => $this->_forum_language->get('forum', 'x_posts', ['count' => $forum->getPostCount($user_id)]) + ]); } } @@ -376,11 +384,11 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem Core_Module::addDataToDashboardGraph($this->_language->get('admin', 'overview'), $data); // Dashboard stats - require_once(ROOT_PATH . '/modules/Forum/collections/panel/RecentTopics.php'); - CollectionManager::addItemToCollection('dashboard_stats', new RecentTopicsItem($smarty, $this->_forum_language, $cache, $latest_topics_count)); + require_once ROOT_PATH . '/modules/Forum/collections/panel/RecentTopics.php'; + CollectionManager::addItemToCollection('dashboard_stats', new RecentTopicsItem($template->getEngine(), $this->_forum_language, $cache, $latest_topics_count)); - require_once(ROOT_PATH . '/modules/Forum/collections/panel/RecentPosts.php'); - CollectionManager::addItemToCollection('dashboard_stats', new RecentPostsItem($smarty, $this->_forum_language, $cache, $latest_posts_count)); + require_once ROOT_PATH . '/modules/Forum/collections/panel/RecentPosts.php'; + CollectionManager::addItemToCollection('dashboard_stats', new RecentPostsItem($template->getEngine(), $this->_forum_language, $cache, $latest_posts_count)); } } diff --git a/modules/Forum/pages/forum/edit.php b/modules/Forum/pages/forum/edit.php index 617247423d..7c9dddfc7f 100644 --- a/modules/Forum/pages/forum/edit.php +++ b/modules/Forum/pages/forum/edit.php @@ -1,18 +1,28 @@ get('forum', 'edit_post'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // User must be logged in to proceed if (!$user->isLoggedIn()) { @@ -181,21 +191,22 @@ } if (isset($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR_TITLE' => $language->get('general', 'error'), 'ERRORS' => $errors ]); } -$smarty->assign('EDITING_POST', $forum_language->get('forum', 'edit_post')); +$template->getEngine()->addVariable('EDITING_POST', $forum_language->get('forum', 'edit_post')); if (isset($edit_title, $post_labels)) { - $smarty->assign('EDITING_TOPIC', true); - - $smarty->assign('TOPIC_TITLE_VALUE', $post_title); + $template->getEngine()->addVariables([ + 'EDITING_TOPIC' => true, + 'TOPIC_TITLE_VALUE' => $post_title, + 'LABELS_TEXT' => $forum_language->get('forum', 'label'), + ]); // Topic labels - $smarty->assign('LABELS_TEXT', $forum_language->get('forum', 'label')); $labels = []; $forum_labels = DB::getInstance()->get('forums_topic_labels', ['id', '<>', 0])->results(); @@ -235,7 +246,7 @@ } } - $smarty->assign('LABELS', $labels); + $template->getEngine()->addVariable('LABELS', $labels); } // Purify post content @@ -244,7 +255,7 @@ 'user' => $user ])['content']; -$smarty->assign([ +$template->getEngine()->addVariables([ 'TOKEN' => Token::get(), 'SUBMIT' => $language->get('general', 'submit'), 'CANCEL' => $language->get('general', 'cancel'), @@ -265,8 +276,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('forum/forum_edit_post.tpl', $smarty); +$template->displayTemplate('forum/forum_edit_post'); diff --git a/modules/Forum/pages/forum/index.php b/modules/Forum/pages/forum/index.php index 5a20ad28c5..fd428070cb 100644 --- a/modules/Forum/pages/forum/index.php +++ b/modules/Forum/pages/forum/index.php @@ -1,59 +1,67 @@ get('forum', 'forum'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Initialise $forum = new Forum(); -$timeago = new TimeAgo(TIMEZONE); +$timeAgo = new TimeAgo(TIMEZONE); // Get user group IDs $groups = $user->getAllGroupIds(); // Breadcrumbs and search bar - same for latest discussions view + table view -$smarty->assign('BREADCRUMB_URL', URL::build('/forum')); -$smarty->assign('BREADCRUMB_TEXT', $forum_language->get('forum', 'forum_index')); -// Search bar -$smarty->assign([ +$template->getEngine()->addVariables([ + 'BREADCRUMB_URL' => URL::build('/forum'), + 'BREADCRUMB_TEXT' => $forum_language->get('forum', 'forum_index'), 'SEARCH_URL' => URL::build('/forum/search'), 'SEARCH' => $language->get('general', 'search'), - 'TOKEN' => Token::get() + 'TOKEN' => Token::get(), ]); -// Server status module -$smarty->assign('SERVER_STATUS', ''); - // Check session if (Session::exists('spam_info')) { - $smarty->assign('SPAM_INFO', Session::flash('spam_info')); + $template->getEngine()->addVariable('SPAM_INFO', Session::flash('spam_info')); } // Assign language variables -$smarty->assign('FORUMS_TITLE', $forum_language->get('forum', 'forums')); -$smarty->assign('DISCUSSION', $forum_language->get('forum', 'discussion')); -$smarty->assign('TOPIC', $forum_language->get('forum', 'topic')); -$smarty->assign('STATS', $forum_language->get('forum', 'stats')); -$smarty->assign('LAST_REPLY', $forum_language->get('forum', 'last_reply')); -$smarty->assign('BY', $forum_language->get('forum', 'by')); -$smarty->assign('IN', $forum_language->get('forum', 'in')); -$smarty->assign('VIEWS', $forum_language->get('forum', 'views')); -$smarty->assign('TOPICS', $forum_language->get('forum', 'topics')); -$smarty->assign('POSTS', $forum_language->get('forum', 'posts')); -$smarty->assign('STATISTICS', $forum_language->get('forum', 'statistics')); -$smarty->assign('OVERVIEW', $forum_language->get('forum', 'overview')); -$smarty->assign('LATEST_DISCUSSIONS_TITLE', $forum_language->get('forum', 'latest_discussions')); -$smarty->assign('NO_TOPICS', $forum_language->get('forum', 'no_topics_short')); +$template->getEngine()->addVariables([ + 'FORUMS_TITLE' => $forum_language->get('forum', 'forums'), + 'DISCUSSION' => $forum_language->get('forum', 'discussion'), + 'TOPIC' => $forum_language->get('forum', 'topic'), + 'STATS' => $forum_language->get('forum', 'stats'), + 'LAST_REPLY' => $forum_language->get('forum', 'last_reply'), + 'BY' => $forum_language->get('forum', 'by'), + 'IN' => $forum_language->get('forum', 'in'), + 'VIEWS' => $forum_language->get('forum', 'views'), + 'TOPICS' => $forum_language->get('forum', 'topics'), + 'POSTS' => $forum_language->get('forum', 'posts'), + 'STATISTICS' => $forum_language->get('forum', 'statistics'), + 'OVERVIEW' => $forum_language->get('forum', 'overview'), + 'LATEST_DISCUSSIONS_TITLE' => $forum_language->get('forum', 'latest_discussions'), + 'NO_TOPICS' => $forum_language->get('forum', 'no_topics_short'), +]); // Get forums $cache_name = 'forum_forums_' . rtrim(implode('-', $groups), '-'); @@ -79,10 +87,10 @@ $forums[$key]['subforums'][$subforum_id]->last_post->profile = $last_post_user->getProfileURL(); if (is_null($forums[$key]['subforums'][$subforum_id]->last_post->created)) { - $forums[$key]['subforums'][$subforum_id]->last_post->date_friendly = $timeago->inWords($forums[$key]['subforums'][$subforum_id]->last_post->post_date, $language); + $forums[$key]['subforums'][$subforum_id]->last_post->date_friendly = $timeAgo->inWords($forums[$key]['subforums'][$subforum_id]->last_post->post_date, $language); $forums[$key]['subforums'][$subforum_id]->last_post->post_date = date(DATE_FORMAT, strtotime($forums[$key]['subforums'][$subforum_id]->last_post->post_date)); } else { - $forums[$key]['subforums'][$subforum_id]->last_post->date_friendly = $timeago->inWords($forums[$key]['subforums'][$subforum_id]->last_post->created, $language); + $forums[$key]['subforums'][$subforum_id]->last_post->date_friendly = $timeAgo->inWords($forums[$key]['subforums'][$subforum_id]->last_post->created, $language); $forums[$key]['subforums'][$subforum_id]->last_post->post_date = date(DATE_FORMAT, $forums[$key]['subforums'][$subforum_id]->last_post->created); } } @@ -100,23 +108,27 @@ $cache->store('forums', $forums, 60); } -$smarty->assign('FORUMS', $forums); -$smarty->assign('YES', $language->get('general', 'yes')); -$smarty->assign('NO', $language->get('general', 'no')); -$smarty->assign('SUBFORUMS', $forum_language->get('forum', 'subforums')); - -$smarty->assign('FORUM_INDEX_LINK', URL::build('/forum')); +$template->getEngine()->addVariables([ + 'FORUMS' => $forums, + 'YES' => $language->get('general', 'yes'), + 'NO' => $language->get('general', 'no'), + 'SUBFORUMS' => $forum_language->get('forum', 'subforums'), + 'FORUM_INDEX_LINK' => URL::build('/forum'), + 'FORUM_SPAM_WARNING_TITLE' => $language->get('general', 'warning'), +]); // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); $template->onPageLoad(); -$smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); -$smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); +$template->getEngine()->addVariables([ + 'WIDGETS_LEFT' => $widgets->getWidgets('left'), + 'WIDGETS_RIGHT' => $widgets->getWidgets('right'), +]); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('forum/forum_index.tpl', $smarty); +$template->displayTemplate('forum/forum_index'); diff --git a/modules/Forum/pages/forum/merge.php b/modules/Forum/pages/forum/merge.php index dac900b926..67dbe532dc 100644 --- a/modules/Forum/pages/forum/merge.php +++ b/modules/Forum/pages/forum/merge.php @@ -1,17 +1,27 @@ get('forum', 'merge_topics'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $forum = new Forum(); @@ -73,8 +83,7 @@ // Get topics $topics = DB::getInstance()->query('SELECT * FROM nl2_topics WHERE forum_id = ? AND deleted = 0 AND id <> ? ORDER BY id ASC', [$forum_id, $topic_id])->results(); -// Smarty -$smarty->assign([ +$template->getEngine()->addVariables([ 'MERGE_TOPICS' => $forum_language->get('forum', 'merge_topics'), 'MERGE_INSTRUCTIONS' => $forum_language->get('forum', 'merge_instructions'), 'TOKEN' => Token::get(), @@ -90,8 +99,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('forum/merge.tpl', $smarty); +$template->displayTemplate('forum/merge'); diff --git a/modules/Forum/pages/forum/move.php b/modules/Forum/pages/forum/move.php index 30e901ff0e..9d53806cdc 100644 --- a/modules/Forum/pages/forum/move.php +++ b/modules/Forum/pages/forum/move.php @@ -1,17 +1,27 @@ get('forum', 'move_topic'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $forum = new Forum(); @@ -124,8 +134,8 @@ } } -// Assign Smarty variables -$smarty->assign([ +// Assign template variables +$template->getEngine()->addVariables([ 'MOVE_TOPIC' => $forum_language->get('forum', 'move_topic'), 'MOVE_TO' => $forum_language->get('forum', 'move_topic_to'), 'TOKEN' => Token::get(), @@ -133,7 +143,7 @@ 'CANCEL' => $language->get('general', 'cancel'), 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), 'CANCEL_LINK' => URL::build('/forum/topic/' . urlencode($topic->id)), - 'FORUMS' => $template_forums + 'FORUMS' => $template_forums, ]); // Load modules + template @@ -141,8 +151,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('forum/move.tpl', $smarty); +$template->displayTemplate('forum/move'); diff --git a/modules/Forum/pages/forum/new_topic.php b/modules/Forum/pages/forum/new_topic.php index 85d6733bf3..395a739abd 100644 --- a/modules/Forum/pages/forum/new_topic.php +++ b/modules/Forum/pages/forum/new_topic.php @@ -1,18 +1,28 @@ get('forum', 'new_topic'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // User must be logged in to proceed if (!$user->isLoggedIn()) { @@ -46,7 +56,7 @@ $forum_title = Output::getClean($current_forum->forum_title); // Topic labels -$smarty->assign('LABELS_TEXT', $forum_language->get('forum', 'label')); +$template->getEngine()->addVariable('LABELS_TEXT', $forum_language->get('forum', 'label')); $labels = []; $default_labels = $current_forum->default_labels ? explode(',', $current_forum->default_labels) : []; @@ -230,11 +240,11 @@ // Generate content for template if (isset($error)) { - $smarty->assign('ERROR', $error); + $template->getEngine()->addVariable('ERROR', $error); } $creating_topic_in = $forum_language->get('forum', 'creating_topic_in_x', ['forum' => $forum_title]); -$smarty->assign('CREATING_TOPIC_IN', $creating_topic_in); +$template->getEngine()->addVariable('CREATING_TOPIC_IN', $creating_topic_in); // Get info about forum $forum_query = DB::getInstance()->get('forums', ['id', $fid])->results(); @@ -245,8 +255,8 @@ $placeholder = Output::getPurified($forum_query->topic_placeholder); } -// Smarty variables -$smarty->assign([ +// Template variables +$template->getEngine()->addVariables([ 'LABELS' => $labels, 'TOPIC_TITLE' => $forum_language->get('forum', 'topic_title'), 'TOPIC_VALUE' => ((isset($_POST['title']) && $_POST['title']) ? Output::getClean(Input::get('title')) : ''), @@ -282,8 +292,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('forum/new_topic.tpl', $smarty); +$template->displayTemplate('forum/new_topic'); diff --git a/modules/Forum/pages/forum/search.php b/modules/Forum/pages/forum/search.php index 59bf7b78fe..f2545d9dee 100644 --- a/modules/Forum/pages/forum/search.php +++ b/modules/Forum/pages/forum/search.php @@ -1,12 +1,22 @@ getAllGroupIds(); @@ -160,7 +170,7 @@ $results = $paginator->getLimited($results, 10, $p, count($results)); $pagination = $paginator->generate(7, URL::build('/forum/search/', 's=' . urlencode($search) . '&')); - $smarty->assign('PAGINATION', $pagination); + $template->getEngine()->addVariable('PAGINATION', $pagination); // Posts to display on the page $posts = []; @@ -178,7 +188,7 @@ 'post_author_profile' => $post_user->getProfileURL(), 'post_author_style' => $post_user->getGroupStyle(), 'post_date_full' => date(DATE_FORMAT, strtotime($results->data[$n]['post_date'])), - 'post_date_friendly' => $timeago->inWords($results->data[$n]['post_date'], $language), + 'post_date_friendly' => $timeAgo->inWords($results->data[$n]['post_date'], $language), 'content' => $content, 'topic_title' => Output::getClean($results->data[$n]['topic_title']), 'post_url' => URL::build('/forum/topic/' . urlencode($results->data[$n]['topic_id']) . '-' . $forum->titleToURL($results->data[$n]['topic_title']), 'pid=' . $results->data[$n]['post_id']) @@ -188,19 +198,19 @@ $results = null; - $smarty->assign([ + $template->getEngine()->addVariables([ 'RESULTS' => $posts, 'READ_FULL_POST' => $forum_language->get('forum', 'read_full_post') ]); } else { - $smarty->assign('NO_RESULTS', $forum_language->get('forum', 'no_results_found')); + $template->getEngine()->addVariable('NO_RESULTS', $forum_language->get('forum', 'no_results_found')); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SEARCH_RESULTS' => $forum_language->get('forum', 'search_results'), 'NEW_SEARCH' => $forum_language->get('forum', 'new_search'), 'NEW_SEARCH_URL' => URL::build('/forum/search'), - 'SEARCH_TERM' => (isset($_GET['s']) ? Output::getClean($_GET['s']) : '') + 'SEARCH_TERM' => Output::getClean($_GET['s']), ]); // Load modules + template @@ -208,22 +218,22 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('forum/search_results.tpl', $smarty); + $template->displayTemplate('forum/search_results'); } else { // Search bar if (isset($error)) { - $smarty->assign('ERROR', $error); + $template->getEngine()->addVariable('ERROR', $error); } else { if (Session::exists('search_error')) { - $smarty->assign('ERROR', Session::flash('search_error')); + $template->getEngine()->addVariable('ERROR', Session::flash('search_error')); } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'FORUM_SEARCH' => $forum_language->get('forum', 'forum_search'), 'FORM_ACTION' => URL::build('/forum/search'), 'SEARCH' => $language->get('general', 'search'), @@ -237,9 +247,9 @@ $template->onPageLoad(); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('forum/search.tpl', $smarty); + $template->displayTemplate('forum/search'); } diff --git a/modules/Forum/pages/forum/view_forum.php b/modules/Forum/pages/forum/view_forum.php index 46017e34f8..e548d02e06 100644 --- a/modules/Forum/pages/forum/view_forum.php +++ b/modules/Forum/pages/forum/view_forum.php @@ -1,12 +1,23 @@ get('forum', 'forum'); $page_title .= ' - ' . $language->get('general', 'page_x', ['page' => $p]); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; // Redirect forum? if ($forum_query->redirect_forum == 1) { @@ -82,7 +93,7 @@ Redirect::to(Output::getClean($forum_query->redirect_url)); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CONFIRM_REDIRECT' => $forum_language->get('forum', 'forum_redirect_warning', ['url' => Output::getClean($forum_query->redirect_url)]), 'YES' => $language->get('general', 'yes'), 'NO' => $language->get('general', 'no'), @@ -95,14 +106,16 @@ $template->onPageLoad(); - $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); - $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); + $template->getEngine()->addVariables([ + 'WIDGETS_LEFT' => $widgets->getWidgets('left'), + 'WIDGETS_RIGHT' => $widgets->getWidgets('right'), + ]); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('forum/view_forum_confirm_redirect.tpl', $smarty); + $template->displayTemplate('forum/view_forum_confirm_redirect'); } else { // Get all topics if ($user->isLoggedIn()) { @@ -121,10 +134,10 @@ $stickies = DB::getInstance()->query('SELECT * FROM nl2_topics WHERE forum_id = ? AND sticky = 1 AND deleted = 0 ORDER BY topic_reply_date DESC', [$fid])->results(); // Search bar - $smarty->assign([ + $template->getEngine()->addVariables([ 'SEARCH_URL' => URL::build('/forum/search'), 'SEARCH' => $language->get('general', 'search'), - 'TOKEN' => Token::get() + 'TOKEN' => Token::get(), ]); // Breadcrumbs and search bar - same for latest discussions view + table view @@ -171,13 +184,10 @@ 'link' => URL::build('/forum') ]; - $smarty->assign('BREADCRUMBS', array_reverse($breadcrumbs)); - - // Server status module - $smarty->assign('SERVER_STATUS', ''); - - // Assignments - $smarty->assign('FORUM_INDEX_LINK', URL::build('/forum')); + $template->getEngine()->addVariables([ + 'BREADCRUMBS' => array_reverse($breadcrumbs), + 'FORUM_INDEX_LINK' => URL::build('/forum'), + ]); // Any subforums? $subforums = DB::getInstance()->query('SELECT * FROM nl2_forums WHERE parent = ? ORDER BY forum_order ASC', [$forum_query->id])->results(); @@ -245,44 +255,45 @@ } // Assign language variables - $smarty->assign('FORUMS', $forum_language->get('forum', 'forums')); - $smarty->assign('DISCUSSION', $forum_language->get('forum', 'discussion')); - $smarty->assign('TOPIC', $forum_language->get('forum', 'topic')); - $smarty->assign('STATS', $forum_language->get('forum', 'stats')); - $smarty->assign('LAST_REPLY', $forum_language->get('forum', 'last_reply')); - $smarty->assign('BY', $forum_language->get('forum', 'by')); - $smarty->assign('VIEWS', $forum_language->get('forum', 'views')); - $smarty->assign('POSTS', $forum_language->get('forum', 'posts')); - $smarty->assign('STATISTICS', $forum_language->get('forum', 'stats')); - $smarty->assign('OVERVIEW', $forum_language->get('forum', 'overview')); - $smarty->assign('LATEST_DISCUSSIONS_TITLE', $forum_language->get('forum', 'latest_discussions')); - $smarty->assign('TOPICS', $forum_language->get('forum', 'topics')); - $smarty->assign('NO_TOPICS', $forum_language->get('forum', 'no_topics_short')); - $smarty->assign('SUBFORUMS', $subforum_array); - $smarty->assign('SUBFORUM_LANGUAGE', $forum_language->get('forum', 'subforums')); - $smarty->assign('FORUM_TITLE', Output::getPurified($forum_query->forum_title)); - $smarty->assign('FORUM_DESCRIPTION', Output::getPurified($forum_query->forum_description)); - $smarty->assign('FORUM_ICON', Output::getPurified($forum_query->icon)); - $smarty->assign('STICKY_TOPICS', $forum_language->get('forum', 'sticky_topics')); + $template->getEngine()->addVariables([ + 'FORUMS' => $forum_language->get('forum', 'forums'), + 'DISCUSSION' => $forum_language->get('forum', 'discussion'), + 'TOPIC' => $forum_language->get('forum', 'topic'), + 'STATS' => $forum_language->get('forum', 'stats'), + 'LAST_REPLY' => $forum_language->get('forum', 'last_reply'), + 'BY' => $forum_language->get('forum', 'by'), + 'VIEWS' => $forum_language->get('forum', 'views'), + 'POSTS' => $forum_language->get('forum', 'posts'), + 'STATISTICS' => $forum_language->get('forum', 'stats'), + 'OVERVIEW' => $forum_language->get('forum', 'overview'), + 'LATEST_DISCUSSIONS_TITLE' => $forum_language->get('forum', 'latest_discussions'), + 'TOPICS' => $forum_language->get('forum', 'topics'), + 'NO_TOPICS' => $forum_language->get('forum', 'no_topics_short'), + 'SUBFORUMS' => $subforum_array, + 'SUBFORUM_LANGUAGE' => $forum_language->get('forum', 'subforums'), + 'FORUM_TITLE' => Output::getPurified($forum_query->forum_title), + 'FORUM_DESCRIPTION' => Output::getPurified($forum_query->forum_description), + 'FORUM_ICON' => Output::getPurified($forum_query->icon), + 'STICKY_TOPICS' => $forum_language->get('forum', 'sticky_topics'), + 'NEW_TOPIC' => $forum_language->get('forum', 'new_topic'), + ]); // Can the user post here? if ($user->isLoggedIn() && $forum->canPostTopic($fid, $user_groups)) { - $smarty->assign('NEW_TOPIC_BUTTON', URL::build('/forum/new/', 'fid=' . urlencode($fid))); + $template->getEngine()->addVariable('NEW_TOPIC_BUTTON', URL::build('/forum/new/', 'fid=' . urlencode($fid))); } else { - $smarty->assign('NEW_TOPIC_BUTTON', false); + $template->getEngine()->addVariable('NEW_TOPIC_BUTTON', false); } - $smarty->assign('NEW_TOPIC', $forum_language->get('forum', 'new_topic')); - // Topics if (!count($stickies) && !count($topics)) { // No topics yet - $smarty->assign('NO_TOPICS_FULL', $forum_language->get('forum', 'no_topics')); + $template->getEngine()->addVariable('NO_TOPICS_FULL', $forum_language->get('forum', 'no_topics')); if ($user->isLoggedIn() && $forum->canPostTopic($fid, $user_groups)) { - $smarty->assign('NEW_TOPIC_BUTTON', URL::build('/forum/new/', 'fid=' . urlencode($fid))); + $template->getEngine()->addVariable('NEW_TOPIC_BUTTON', URL::build('/forum/new/', 'fid=' . urlencode($fid))); } else { - $smarty->assign('NEW_TOPIC_BUTTON', false); + $template->getEngine()->addVariable('NEW_TOPIC_BUTTON', false); } $no_topics_exist = true; @@ -291,7 +302,7 @@ $labels_cache = []; $sticky_array = []; - // Assign sticky threads to smarty variable + // Assign sticky threads to template variable foreach ($stickies as $sticky) { // Get number of replies to a topic $replies = DB::getInstance()->get('posts', ['topic_id', $sticky->id])->results(); @@ -394,9 +405,9 @@ $pagination = $paginator->generate(7, URL::build('/forum/view/' . urlencode($fid) . '-' . $forum->titleToURL($forum_query->forum_title))); if (count($topics)) { - $smarty->assign('PAGINATION', $pagination); + $template->getEngine()->addVariable('PAGINATION', $pagination); } else { - $smarty->assign('PAGINATION', ''); + $template->getEngine()->addVariable('PAGINATION', ''); } $template_array = []; @@ -489,9 +500,11 @@ ]; } - // Assign to Smarty variable - $smarty->assign('STICKY_DISCUSSIONS', $sticky_array); - $smarty->assign('LATEST_DISCUSSIONS', $template_array); + // Assign to template variable + $template->getEngine()->addVariables([ + 'STICKY_DISCUSSIONS' => $sticky_array, + 'LATEST_DISCUSSIONS' => $template_array, + ]); } // Load modules + template @@ -499,16 +512,18 @@ $template->onPageLoad(); - $smarty->assign('WIDGETS_LEFT', $widgets->getWidgets('left')); - $smarty->assign('WIDGETS_RIGHT', $widgets->getWidgets('right')); + $template->getEngine()->addVariables([ + 'WIDGETS_LEFT' => $widgets->getWidgets('left'), + 'WIDGETS_RIGHT' => $widgets->getWidgets('right'), + ]); - require(ROOT_PATH . '/core/templates/navbar.php'); - require(ROOT_PATH . '/core/templates/footer.php'); + require ROOT_PATH . '/core/templates/navbar.php'; + require ROOT_PATH . '/core/templates/footer.php'; // Display template if (isset($no_topics_exist)) { - $template->displayTemplate('forum/view_forum_no_discussions.tpl', $smarty); + $template->displayTemplate('forum/view_forum_no_discussions'); } else { - $template->displayTemplate('forum/view_forum.tpl', $smarty); + $template->displayTemplate('forum/view_forum'); } } diff --git a/modules/Forum/pages/forum/view_topic.php b/modules/Forum/pages/forum/view_topic.php index 9a4c38a0d7..45461e003d 100644 --- a/modules/Forum/pages/forum/view_topic.php +++ b/modules/Forum/pages/forum/view_topic.php @@ -1,12 +1,23 @@ topicExist($tid); if (!$list) { - require_once(ROOT_PATH . '/404.php'); + require_once ROOT_PATH . '/404.php'; die(); } @@ -45,13 +56,13 @@ $topic = $topic[0]; if ($topic->deleted == 1) { - require_once(ROOT_PATH . '/404.php'); + require_once ROOT_PATH . '/404.php'; die(); } $list = $forum->canViewForum($topic->forum_id, $user_groups); if (!$list) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -64,7 +75,7 @@ if ($topic->topic_creator != $user_id && !$forum->canViewOtherTopics($topic->forum_id, $user_groups)) { // Only allow viewing stickied topics if ($topic->sticky == 0) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } } @@ -102,7 +113,7 @@ Redirect::to(URL::build('/forum/topic/' . urlencode($tid) . '-' . $forum->titleToURL($topic->topic_title)) . '#post-' . $_GET['pid']); } } else { - require_once(ROOT_PATH . '/404.php'); + require_once ROOT_PATH . '/404.php'; } die(); } @@ -161,15 +172,15 @@ } $page_title = ((strlen(Output::getClean($topic->topic_title)) > 20) ? Output::getClean(mb_substr($topic->topic_title, 0, 20)) . '...' : Output::getClean($topic->topic_title)) . ' - ' . $language->get('general', 'page_x', ['page' => $p]); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; -// Assign author + title to Smarty variables +// Assign author + title to template variables // Get first post $first_post = DB::getInstance()->query('SELECT * FROM nl2_posts WHERE topic_id = ? ORDER BY id ASC LIMIT 1', [$tid])->first(); $topic_user = new User($topic->topic_creator); -$smarty->assign([ +$template->getEngine()->addVariables([ 'TOPIC_TITLE' => Output::getClean($topic->topic_title), 'TOPIC_AUTHOR_USERNAME' => $topic_user->getDisplayname(), 'TOPIC_AUTHOR_MCNAME' => $topic_user->getDisplayname(true), @@ -221,7 +232,7 @@ } } -$smarty->assign(['TOPIC_LABEL' => $label, 'TOPIC_LABELS' => $labels]); +$template->getEngine()->addVariables(['TOPIC_LABEL' => $label, 'TOPIC_LABELS' => $labels]); // Get all posts in the topic $posts = $forum->getPosts($tid); @@ -394,9 +405,9 @@ // Are reactions enabled? $reactions_enabled = Settings::get('forum_reactions') === '1'; -$smarty->assign('REACTIONS_ENABLED', $reactions_enabled); +$template->getEngine()->addVariable('REACTIONS_ENABLED', $reactions_enabled); -// Assign Smarty variables to pass to template +// Assign template variables to pass to template $parent_category = DB::getInstance()->get('forums', ['id', $forum_parent[0]->parent])->results(); $breadcrumbs = [ @@ -448,17 +459,17 @@ 'link' => URL::build('/forum') ]; -$smarty->assign('BREADCRUMBS', array_reverse($breadcrumbs)); +$template->getEngine()->addVariable('BREADCRUMBS', array_reverse($breadcrumbs)); // Display session messages if (Session::exists('success_post')) { - $smarty->assign('SESSION_SUCCESS_POST', Session::flash('success_post')); + $template->getEngine()->addVariable('SESSION_SUCCESS_POST', Session::flash('success_post')); } if (Session::exists('failure_post')) { - $smarty->assign('SESSION_FAILURE_POST', Session::flash('failure_post')); + $template->getEngine()->addVariable('SESSION_FAILURE_POST', Session::flash('failure_post')); } if (isset($error) && count($error)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR_TITLE' => $language->get('general', 'error'), 'ERRORS' => $error ]); @@ -468,29 +479,29 @@ // Can the user post a reply? if ($user->isLoggedIn() && $can_reply) { - $smarty->assign('CAN_REPLY', true); + $template->getEngine()->addVariable('CAN_REPLY', true); // Is the topic locked? if ($topic->locked != 1) { // Not locked - $smarty->assign('NEW_REPLY', $forum_language->get('forum', 'new_reply')); + $template->getEngine()->addVariable('NEW_REPLY', $forum_language->get('forum', 'new_reply')); } else { // Locked if ($forum->canModerateForum($forum_parent[0]->id, $user_groups)) { // Can post anyway - $smarty->assign('NEW_REPLY', $forum_language->get('forum', 'new_reply')); + $template->getEngine()->addVariable('NEW_REPLY', $forum_language->get('forum', 'new_reply')); } else { // Can't post - $smarty->assign('NEW_REPLY', $forum_language->get('forum', 'topic_locked')); + $template->getEngine()->addVariable('NEW_REPLY', $forum_language->get('forum', 'topic_locked')); } } } if ($topic->locked == 1) { - $smarty->assign('LOCKED', true); + $template->getEngine()->addVariable('LOCKED', true); } // Is the user a moderator? if ($user->isLoggedIn() && $forum->canModerateForum($forum_parent[0]->id, $user_groups)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CAN_MODERATE' => true, 'MOD_ACTIONS' => $forum_language->get('forum', 'mod_actions'), 'LOCK_URL' => URL::build('/forum/lock/', 'tid=' . urlencode($tid)), @@ -512,7 +523,7 @@ } // Sharing -$smarty->assign([ +$template->getEngine()->addVariables([ 'SHARE' => $forum_language->get('forum', 'share'), 'SHARE_TWITTER' => $forum_language->get('forum', 'share_twitter'), 'SHARE_TWITTER_URL' => 'https://twitter.com/intent/tweet?text=' . urlencode(rtrim(URL::getSelfURL(), '/')) . URL::build('/forum/topic/' . urlencode($tid) . '-' . $forum->titleToURL($topic->topic_title)), @@ -529,7 +540,7 @@ $results = $paginator->getLimited($posts, 10, $p, count($posts)); $pagination = $paginator->generate(7, URL::build('/forum/topic/' . $tid . '-' . $forum->titleToURL($topic->topic_title))); -$smarty->assign('PAGINATION', $pagination); +$template->getEngine()->addVariable('PAGINATION', $pagination); // Replies $replies = []; @@ -561,7 +572,7 @@ if ($user->isLoggedIn()) { // Assign token - $smarty->assign('TOKEN', $token); + $template->getEngine()->addVariable('TOKEN', $token); // Edit button if ($forum->canModerateForum($forum_parent[0]->id, $user_groups)) { @@ -719,11 +730,11 @@ ]; } -$smarty->assign('REPLIES', $replies); +$template->getEngine()->addVariable('REPLIES', $replies); // Reactions if ($reactions_enabled) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'REACTIONS_URL' => URL::build('/queries/reactions'), 'REACTIONS_TEXT' => $language->get('user', 'reactions'), ]); @@ -732,7 +743,7 @@ if ($user->isLoggedIn()) { // Reactions if ($reactions_enabled) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'REACTIONS' => $all_reactions, 'REACTIONS_BY_USER' => $reactions_by_user, ]); @@ -750,12 +761,12 @@ ]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'UNFOLLOW' => $forum_language->get('forum', 'unfollow'), 'UNFOLLOW_URL' => URL::build('/forum/topic/' . $tid . '/', 'action=unfollow') ]); } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'FOLLOW' => $forum_language->get('forum', 'follow'), 'FOLLOW_URL' => URL::build('/forum/topic/' . $tid . '/', 'action=follow') ]); @@ -769,7 +780,7 @@ if ($user->isLoggedIn() && $can_reply) { if ($forum->canModerateForum($forum_parent[0]->id, $user_groups) || $topic->locked != 1) { if ($topic->locked == 1) { - $smarty->assign('TOPIC_LOCKED_NOTICE', $forum_language->get('forum', 'topic_locked_notice')); + $template->getEngine()->addVariable('TOPIC_LOCKED_NOTICE', $forum_language->get('forum', 'topic_locked_notice')); } if (isset($_POST['content'])) { @@ -777,18 +788,16 @@ $content = EventHandler::executeEvent('renderPostEdit', ['content' => $_POST['content']])['content']; } - $smarty->assign([ - 'SUBMIT' => $language->get('general', 'submit') - ]); + $template->getEngine()->addVariable('SUBMIT', $language->get('general', 'submit')); } } else { if ($topic->locked == 1) { - $smarty->assign('TOPIC_LOCKED', $forum_language->get('forum', 'topic_locked')); + $template->getEngine()->addVariable('TOPIC_LOCKED', $forum_language->get('forum', 'topic_locked')); } } -// Assign Smarty language variables -$smarty->assign([ +// Assign template language variables +$template->getEngine()->addVariables([ 'POSTS' => $forum_language->get('forum', 'posts'), 'BY' => ucfirst($forum_language->get('forum', 'by')), 'CANCEL' => $language->get('general', 'cancel'), @@ -854,8 +863,8 @@ class: \'info\', $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('forum/view_topic.tpl', $smarty); +$template->displayTemplate('forum/view_topic'); diff --git a/modules/Forum/pages/panel/forums.php b/modules/Forum/pages/panel/forums.php index 401f30d357..1989cc11da 100644 --- a/modules/Forum/pages/panel/forums.php +++ b/modules/Forum/pages/panel/forums.php @@ -1,17 +1,27 @@ handlePanelPageLoad('admincp.forums')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +29,7 @@ const PARENT_PAGE = 'forum'; const PANEL_PAGE = 'forums'; $page_title = $forum_language->get('forum', 'forums'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['action']) && !isset($_GET['forum'])) { $forums = DB::getInstance()->orderAll('forums', 'forum_order', 'ASC')->results(); @@ -66,15 +76,15 @@ $forum_reactions = Settings::get('forum_reactions'); - $smarty->assign([ + $template->getEngine()->addVariables([ 'NEW_FORUM' => $forum_language->get('forum', 'new_forum'), 'NEW_FORUM_LINK' => URL::build('/panel/forums/', 'action=new'), 'FORUMS_ARRAY' => $template_array, 'NO_FORUMS' => $forum_language->get('forum', 'no_forums'), - 'REORDER_DRAG_URL' => URL::build('/panel/forums') + 'REORDER_DRAG_URL' => URL::build('/panel/forums'), ]); - $template_file = 'forum/forums.tpl'; + $template_file = 'forum/forums'; } else { if (isset($_GET['action'])) { switch ($_GET['action']) { @@ -143,7 +153,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'FORUM_TYPE' => $forum_language->get('forum', 'forum_type'), 'FORUM_TYPE_FORUM' => $forum_language->get('forum', 'forum_type_forum'), 'FORUM_TYPE_CATEGORY' => $forum_language->get('forum', 'forum_type_category'), @@ -152,10 +162,10 @@ 'FORUM_DESCRIPTION' => $forum_language->get('forum', 'forum_description'), 'FORUM_DESCRIPTION_VALUE' => Output::getClean(Input::get('forumdesc')), 'FORUM_ICON' => $forum_language->get('forum', 'forum_icon'), - 'FORUM_ICON_VALUE' => Output::getClean(Input::get('forum_icon')) + 'FORUM_ICON_VALUE' => Output::getClean(Input::get('forum_icon')), ]); - $template_file = 'forum/forums_new_step_1.tpl'; + $template_file = 'forum/forums_new_step_1'; } else { // Parent category, for type forum only if (!isset($_GET['forum']) || !is_numeric($_GET['forum'])) { @@ -246,7 +256,7 @@ } } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SELECT_PARENT_FORUM' => $forum_language->get('forum', 'select_a_parent_forum'), 'PARENT_FORUMS' => $template_array, 'DISPLAY_TOPICS_AS_NEWS' => $forum_language->get('forum', 'display_topics_as_news'), @@ -256,20 +266,20 @@ 'INCLUDE_IN_HOOK' => $forum_language->get('forum', 'include_in_hook'), 'HOOKS_ARRAY' => $hooks_array, 'INFO' => $language->get('general', 'info'), - 'HOOK_SELECT_INFO' => $language->get('admin', 'hook_select_info') + 'HOOK_SELECT_INFO' => $language->get('admin', 'hook_select_info'), ]); - $template_file = 'forum/forums_new_step_2.tpl'; + $template_file = 'forum/forums_new_step_2'; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CREATING_FORUM' => $forum_language->get('forum', 'creating_forum'), 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/forums'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), 'YES' => $language->get('general', 'yes'), 'NO' => $language->get('general', 'no'), - 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel') + 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), ]); break; @@ -449,14 +459,14 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'DELETE_FORUM' => $forum_language->get('forum', 'delete_forum'), 'MOVE_TOPICS_AND_POSTS_TO' => $forum_language->get('forum', 'move_topics_and_posts_to'), 'DELETE_TOPICS_AND_POSTS' => $forum_language->get('forum', 'delete_topics_and_posts'), - 'OTHER_FORUMS' => $template_array + 'OTHER_FORUMS' => $template_array, ]); - $template_file = 'forum/forums_delete.tpl'; + $template_file = 'forum/forums_delete'; break; @@ -739,7 +749,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/forums'), 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), @@ -786,10 +796,10 @@ 'TOPIC_PLACEHOLDER_VALUE' => Output::getPurified($forum[0]->topic_placeholder), 'DEFAULT_LABELS' => $forum_language->get('forum', 'default_labels'), 'DEFAULT_LABELS_INFO' => $forum_language->get('forum', 'default_labels_info'), - 'AVAILABLE_DEFAULT_LABELS' => $available_labels + 'AVAILABLE_DEFAULT_LABELS' => $available_labels, ]); - $template_file = 'forum/forums_edit.tpl'; + $template_file = 'forum/forums_edit'; } } } @@ -806,20 +816,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'FORUM' => $forum_language->get('forum', 'forum'), @@ -832,7 +842,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Forum/pages/panel/labels.php b/modules/Forum/pages/panel/labels.php index f5ae60204e..179c03f133 100644 --- a/modules/Forum/pages/panel/labels.php +++ b/modules/Forum/pages/panel/labels.php @@ -1,17 +1,27 @@ handlePanelPageLoad('admincp.forums')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +29,7 @@ const PARENT_PAGE = 'forum'; const PANEL_PAGE = 'forum_labels'; $page_title = $forum_language->get('forum', 'labels'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (!isset($_GET['action'])) { $db = DB::getInstance(); @@ -58,7 +68,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'LABEL_TYPES' => $forum_language->get('forum', 'label_types'), 'LABEL_TYPES_LINK' => URL::build('/panel/forums/labels/', 'action=types'), 'NEW_LABEL' => $forum_language->get('forum', 'new_label'), @@ -70,10 +80,10 @@ 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), 'YES' => $language->get('general', 'yes'), 'NO' => $language->get('general', 'no'), - 'NO_LABELS' => $forum_language->get('forum', 'no_labels_defined') + 'NO_LABELS' => $forum_language->get('forum', 'no_labels_defined'), ]); - $template_file = 'forum/labels.tpl'; + $template_file = 'forum/labels'; } else { switch ($_GET['action']) { @@ -177,7 +187,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'CREATING_LABEL' => $forum_language->get('forum', 'creating_label'), 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/forums/labels'), @@ -192,10 +202,10 @@ 'LABEL_FORUMS' => $forum_language->get('forum', 'label_forums'), 'ALL_FORUMS' => $template_forums, 'LABEL_GROUPS' => $forum_language->get('forum', 'label_groups'), - 'ALL_GROUPS' => $template_groups + 'ALL_GROUPS' => $template_groups, ]); - $template_file = 'forum/labels_new.tpl'; + $template_file = 'forum/labels_new'; break; @@ -323,7 +333,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'EDITING_LABEL' => $forum_language->get('forum', 'editing_label'), 'CANCEL' => $language->get('general', 'cancel'), 'CANCEL_LINK' => URL::build('/panel/forums/labels'), @@ -338,10 +348,10 @@ 'LABEL_FORUMS' => $forum_language->get('forum', 'label_forums'), 'ALL_FORUMS' => $template_forums, 'LABEL_GROUPS' => $forum_language->get('forum', 'label_groups'), - 'ALL_GROUPS' => $template_groups + 'ALL_GROUPS' => $template_groups, ]); - $template_file = 'forum/labels_edit.tpl'; + $template_file = 'forum/labels_edit'; break; @@ -382,7 +392,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'LABEL_TYPES' => $forum_language->get('forum', 'label_types'), 'LABELS_LINK' => URL::build('/panel/forums/labels'), 'NEW_LABEL_TYPE' => $forum_language->get('forum', 'new_label_type'), @@ -394,10 +404,10 @@ 'ARE_YOU_SURE' => $language->get('general', 'are_you_sure'), 'YES' => $language->get('general', 'yes'), 'NO' => $language->get('general', 'no'), - 'NO_LABEL_TYPES' => $forum_language->get('forum', 'no_label_types_defined') + 'NO_LABEL_TYPES' => $forum_language->get('forum', 'no_label_types_defined'), ]); - $template_file = 'forum/labels_types.tpl'; + $template_file = 'forum/labels_types'; break; @@ -448,7 +458,7 @@ } - $smarty->assign([ + $template->getEngine()->addVariables([ 'LABEL_TYPES' => $forum_language->get('forum', 'label_types'), 'CREATING_LABEL_TYPE' => $forum_language->get('forum', 'creating_label_type'), 'CANCEL' => $language->get('general', 'cancel'), @@ -462,10 +472,10 @@ 'LABEL_TYPE_HTML' => $forum_language->get('forum', 'label_type_html'), 'INFO' => $language->get('general', 'info'), 'LABEL_TYPE_HTML_INFO' => $forum_language->get('forum', 'label_type_html_help'), - 'LABEL_TYPE_HTML_VALUE' => Output::getClean(Input::get('label_type_html')) + 'LABEL_TYPE_HTML_VALUE' => Output::getClean(Input::get('label_type_html')), ]); - $template_file = 'forum/labels_types_new.tpl'; + $template_file = 'forum/labels_types_new'; break; @@ -527,7 +537,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'LABEL_TYPES' => $forum_language->get('forum', 'label_types'), 'EDITING_LABEL_TYPE' => $forum_language->get('forum', 'editing_label_type'), 'CANCEL' => $language->get('general', 'cancel'), @@ -541,10 +551,10 @@ 'LABEL_TYPE_HTML' => $forum_language->get('forum', 'label_type_html'), 'INFO' => $language->get('general', 'info'), 'LABEL_TYPE_HTML_INFO' => $forum_language->get('forum', 'label_type_html_help'), - 'LABEL_TYPE_HTML_VALUE' => Output::getClean($label->html) + 'LABEL_TYPE_HTML_VALUE' => Output::getClean($label->html), ]); - $template_file = 'forum/labels_types_edit.tpl'; + $template_file = 'forum/labels_types_edit'; break; @@ -591,32 +601,32 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'FORUM' => $forum_language->get('forum', 'forum'), 'LABELS' => $forum_language->get('forum', 'labels'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate($template_file, $smarty); +$template->displayTemplate($template_file); diff --git a/modules/Forum/pages/panel/settings.php b/modules/Forum/pages/panel/settings.php index da82c018c5..3e0093754e 100644 --- a/modules/Forum/pages/panel/settings.php +++ b/modules/Forum/pages/panel/settings.php @@ -1,17 +1,27 @@ handlePanelPageLoad('admincp.forums')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -19,7 +29,7 @@ const PARENT_PAGE = 'forum'; const PANEL_PAGE = 'forum_settings'; $page_title = $forum_language->get('forum', 'forums'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (Input::exists()) { if (Token::check()) { @@ -86,20 +96,20 @@ } if (isset($success)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $success, - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, - 'ERRORS_TITLE' => $language->get('general', 'error') + 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'FORUM' => $forum_language->get('forum', 'forum'), @@ -116,12 +126,12 @@ 'NEWS_ITEMS_ON_FRONT_PAGE_VALUE' => Settings::get('news_items_front_page', 5, 'forum'), 'PAGE' => PANEL_PAGE, 'TOKEN' => Token::get(), - 'SUBMIT' => $language->get('general', 'submit') + 'SUBMIT' => $language->get('general', 'submit'), ]); $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('forum/forums_settings.tpl', $smarty); +$template->displayTemplate('forum/forums_settings'); diff --git a/modules/Forum/pages/user/following_topics.php b/modules/Forum/pages/user/following_topics.php index 4602e9ace0..7733e4c92d 100644 --- a/modules/Forum/pages/user/following_topics.php +++ b/modules/Forum/pages/user/following_topics.php @@ -1,12 +1,22 @@ get('forum', 'following_topics'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $forum = new Forum(); -$timeago = new TimeAgo(TIMEZONE); +$timeAgo = new TimeAgo(TIMEZONE); if (Input::exists() && Input::get('action') == 'purge') { if (Token::check(Input::get('token'))) { @@ -47,9 +57,9 @@ $pagination = $paginator->generate(7, URL::build('/user/following_topics/')); if (count($topics)) { - $smarty->assign('PAGINATION', $pagination); + $template->getEngine()->addVariable('PAGINATION', $pagination); } else { - $smarty->assign('PAGINATION', ''); + $template->getEngine()->addVariable('PAGINATION', ''); } $template_array = []; @@ -70,7 +80,7 @@ $template_array[] = [ 'topic_title' => Output::getClean($topic->topic_title), - 'topic_date' => $timeago->inWords($topic->topic_date, $language), + 'topic_date' => $timeAgo->inWords($topic->topic_date, $language), 'topic_date_full' => date(DATE_FORMAT, $topic->topic_date), 'topic_author_id' => Output::getClean($authors[$topic->topic_creator]->data()->id), 'topic_author_nickname' => $authors[$topic->topic_creator]->getDisplayname(), @@ -84,7 +94,7 @@ 'reply_author_avatar' => $authors[$topic->topic_last_user]->getAvatar(), 'reply_author_style' => $authors[$topic->topic_last_user]->getGroupStyle(), 'reply_author_link' => URL::build('/profile/' . Output::getClean($authors[$topic->topic_last_user]->getDisplayname(true))), - 'reply_date' => $timeago->inWords($topic->topic_reply_date, $language), + 'reply_date' => $timeAgo->inWords($topic->topic_reply_date, $language), 'reply_date_full' => date(DATE_FORMAT, $topic->topic_reply_date), 'topic_link' => URL::build('/forum/topic/' . $topic->id . '-' . $forum->titleToURL($topic->topic_title)), 'last_post_link' => URL::build('/forum/topic/' . $topic->id . '-' . $forum->titleToURL($topic->topic_title), 'pid=' . $last_post->id), @@ -94,11 +104,11 @@ } if (Session::exists('success_post')) { - $smarty->assign('SUCCESS_MESSAGE', Session::flash('success_post')); + $template->getEngine()->addVariable('SUCCESS_MESSAGE', Session::flash('success_post')); } // Language values -$smarty->assign([ +$template->getEngine()->addVariables([ 'USER_CP' => $language->get('user', 'user_cp'), 'FOLLOWING_TOPICS' => $forum_language->get('forum', 'following_topics'), 'TOPICS_LIST' => $template_array, @@ -116,12 +126,12 @@ // Load modules + template Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); -require(ROOT_PATH . '/core/templates/cc_navbar.php'); +require ROOT_PATH . '/core/templates/cc_navbar.php'; $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('forum/following_topics.tpl', $smarty); +$template->displayTemplate('forum/following_topics'); diff --git a/modules/Forum/widgets/LatestPostsWidget.php b/modules/Forum/widgets/LatestPostsWidget.php index d74ec79b05..bbf6a52f9e 100644 --- a/modules/Forum/widgets/LatestPostsWidget.php +++ b/modules/Forum/widgets/LatestPostsWidget.php @@ -16,17 +16,17 @@ class LatestPostsWidget extends WidgetBase { private Cache $_cache; private User $_user; - public function __construct(Language $forum_language, Smarty $smarty, Cache $cache, User $user, Language $language) { + public function __construct(Language $forum_language, TemplateEngine $engine, Cache $cache, User $user, Language $language) { $this->_module = 'Forum'; $this->_name = 'Latest Posts'; $this->_description = 'Display latest posts from your forum.'; $this->_settings = ROOT_PATH . '/modules/Forum/widgets/admin/latest_posts.php'; - $this->_smarty = $smarty; + $this->_engine = $engine; $this->_cache = $cache; $this->_user = $user; $this->_language = $language; - $this->_smarty->assign([ + $this->_engine->addVariables([ 'LATEST_POSTS' => $forum_language->get('forum', 'latest_posts'), 'NO_POSTS_FOUND' => $forum_language->get('forum', 'no_posts_found'), 'BY' => $forum_language->get('forum', 'by'), @@ -119,8 +119,8 @@ public function initialise(): void { } // Generate HTML code for widget - $this->_smarty->assign('LATEST_POSTS_ARRAY', $template_array); + $this->_engine->addVariable('LATEST_POSTS_ARRAY', $template_array); - $this->_content = $this->_smarty->fetch('widgets/forum/latest_posts.tpl'); + $this->_content = $this->_engine->fetch('widgets/forum/latest_posts'); } } diff --git a/modules/Members/module.php b/modules/Members/module.php index 4ccfbe36a7..81848ee2b9 100644 --- a/modules/Members/module.php +++ b/modules/Members/module.php @@ -1,12 +1,10 @@ Aberdeener'; - $module_version = '2.1.2'; - $nameless_version = '2.1.2'; + $module_version = '2.2.0'; + $nameless_version = '2.2.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -48,7 +46,7 @@ public function onDisable() { // Not necessary for CookieConsent } - public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smarty, $navs, Widgets $widgets, ?TemplateBase $template) { + public function onPageLoad(User $user, Pages $pages, Cache $cache, $smarty, $navs, Widgets $widgets, ?TemplateBase $template) { $language = $this->_language; // AdminCP diff --git a/modules/Members/pages/members.php b/modules/Members/pages/members.php index 91a6142a48..4496bdbc16 100644 --- a/modules/Members/pages/members.php +++ b/modules/Members/pages/members.php @@ -1,17 +1,28 @@ get('members', 'members'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; if (isset($_GET['group'])) { if (!in_array($_GET['group'], json_decode(Settings::get('member_list_viewable_groups', '{}', 'Members'), true))) { @@ -20,7 +31,7 @@ $viewing_list = 'group'; $viewing_group = Group::find($_GET['group']); - $smarty->assign([ + $template->getEngine()->addVariables([ 'VIEWING_GROUP' => [ 'id' => $viewing_group->id, 'name' => Output::getClean($viewing_group->name), @@ -53,7 +64,7 @@ } if (isset($error)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR_TITLE' => $language->get('general', 'error'), 'ERROR' => $error, ]); @@ -86,9 +97,7 @@ $template_pagination_right ?? null ); $paginator->setValues($member_count, 20, $_GET['p'] ?? 1); - $smarty->assign([ - 'PAGINATION' => $paginator->generate(6, URL::build('/members/', $url_param)), - ]); + $template->getEngine()->addVariable('PAGINATION', $paginator->generate(6, URL::build('/members/', $url_param))); } // Sort sidebar lists to have displayOnOverview lists first @@ -97,7 +106,7 @@ return $b->displayOnOverview() - $a->displayOnOverview(); }); -$smarty->assign([ +$template->getEngine()->addVariables([ 'MEMBERS' => $members_language->get('members', 'members'), 'SIDEBAR_MEMBER_LISTS' => $sidebar_lists, 'MEMBER_LISTS_VIEWING' => $lists_viewing, @@ -126,8 +135,8 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('members/members.tpl', $smarty); +$template->displayTemplate('members/members'); diff --git a/modules/Members/pages/panel/member_lists.php b/modules/Members/pages/panel/member_lists.php index e3e04fad2e..a120b27910 100644 --- a/modules/Members/pages/panel/member_lists.php +++ b/modules/Members/pages/panel/member_lists.php @@ -1,7 +1,26 @@ handlePanelPageLoad('admincp.members')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -10,7 +29,7 @@ const PANEL_PAGE = 'member_lists_settings'; $page_title = $members_language->get('members', 'member_lists'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (Input::exists()) { if (Token::check()) { @@ -31,20 +50,20 @@ } if (Session::exists('admin_member_lists_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => [Session::flash('admin_member_lists_error')], 'ERRORS_TITLE' => $language->get('general', 'error'), ]); } if (Session::exists('admin_member_lists_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('admin_member_lists_success'), 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'MEMBERS' => $members_language->get('members', 'members'), @@ -65,7 +84,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('members/member_lists.tpl', $smarty); +$template->displayTemplate('members/member_lists'); diff --git a/modules/Members/pages/panel/settings.php b/modules/Members/pages/panel/settings.php index df01617cca..8ff59767d9 100644 --- a/modules/Members/pages/panel/settings.php +++ b/modules/Members/pages/panel/settings.php @@ -1,7 +1,26 @@ handlePanelPageLoad('admincp.members')) { - require_once(ROOT_PATH . '/403.php'); + require_once ROOT_PATH . '/403.php'; die(); } @@ -10,7 +29,7 @@ const PANEL_PAGE = 'members_settings'; $page_title = $members_language->get('members', 'members'); -require_once(ROOT_PATH . '/core/templates/backend_init.php'); +require_once ROOT_PATH . '/core/templates/backend_init.php'; if (Input::exists()) { if (Token::check()) { @@ -53,16 +72,16 @@ Module::loadPage($user, $pages, $cache, $smarty, [$navigation, $cc_nav, $staffcp_nav], $widgets, $template); if (Session::exists('admin_members_settings')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('admin_members_settings'), - 'SUCCESS_TITLE' => $language->get('general', 'success') + 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (Session::exists('admin_members_settings_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR' => Session::flash('admin_members_settings_error'), - 'ERRORS_TITLE' => $language->get('general', 'success') + 'ERRORS_TITLE' => $language->get('general', 'success'), ]); } @@ -74,7 +93,7 @@ ]; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'MEMBERS' => $members_language->get('members', 'members'), @@ -98,7 +117,7 @@ $template->onPageLoad(); -require(ROOT_PATH . '/core/templates/panel_navbar.php'); +require ROOT_PATH . '/core/templates/panel_navbar.php'; // Display template -$template->displayTemplate('members/members_settings.tpl', $smarty); +$template->displayTemplate('members/members_settings'); From 9b4a38fca1e3fd4a9f77b9fe3b9dd98ff3b28357 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Oct 2023 17:22:03 +0100 Subject: [PATCH 2/8] Update composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3318a8e695..8f4d7c447c 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ "robmorgan/phinx": "^0.13.4", "symfony/http-foundation": "^5.4.17", "joypixels/emoji-toolkit": "^7.0", - "php-di/php-di": "^6.4" + "php-di/php-di": "^6.4", + "twig/twig": "^3.0" }, "require-dev": { "phpstan/phpstan": "1.6.9", From 2f5c34a4bf74d2af52dab01a8c924e5bee927cfc Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Oct 2023 17:42:43 +0100 Subject: [PATCH 3/8] Convert Widgets class to template engine and PHPStan fixes --- core/classes/Widgets/Widgets.php | 18 ++++++++++++------ modules/Core/pages/panel/templates.php | 2 ++ modules/Members/pages/members.php | 8 ++++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/core/classes/Widgets/Widgets.php b/core/classes/Widgets/Widgets.php index 0e817f6d0b..c7fb840cb6 100644 --- a/core/classes/Widgets/Widgets.php +++ b/core/classes/Widgets/Widgets.php @@ -4,7 +4,7 @@ * * @package NamelessMC\Misc * @author Samerton - * @version 2.0.0-pr8 + * @version 2.2.0 * @license MIT */ class Widgets { @@ -12,17 +12,23 @@ class Widgets { private DB $_db; private Cache $_cache; private Language $_language; - private Smarty $_smarty; + private TemplateBase $_template; /** @var AbstractWidget[] */ private array $_widgets = []; private array $_enabled = []; private string $_name; + /** + * @param Cache $cache + * @param Language $language + * @param TemplateBase $template + * @param string $name + */ public function __construct( Cache $cache, Language $language, - Smarty $smarty, + TemplateBase $template, string $name = 'core' ) { // Assign name to use in cache file @@ -32,7 +38,7 @@ public function __construct( $this->_db = DB::getInstance(); $this->_language = $language; - $this->_smarty = $smarty; + $this->_template = $template; $enabled = $this->_cache->retrieve('enabled'); if ($enabled !== null && count($enabled)) { @@ -136,7 +142,7 @@ public function getWidgets(string $location, User $profile_user = null): array { } } catch (Exception $e) { ErrorHandler::logWarning('Unable to load widget ' . $item->getName() . ': ' . $e->getMessage()); - $this->_smarty->assign([ + $this->_template->getEngine()->addVariables([ 'WIDGET_ERROR_TITLE' => $this->_language->get('general', 'unable_to_load_widget'), 'WIDGET_ERROR_CONTENT' => $this->_language->get('general', 'problem_loading_widget', [ 'widget' => Output::getClean($item->getName()) @@ -144,7 +150,7 @@ public function getWidgets(string $location, User $profile_user = null): array { 'WIDGET_ERROR_MESSAGE' => $e->getMessage(), 'WIDGET_NAME' => Output::getClean($item->getName()), ]); - $ret[] = $this->_smarty->fetch('widgets/widget_error.tpl'); + $ret[] = $this->_template->getEngine()->fetch('widgets/widget_error'); } } diff --git a/modules/Core/pages/panel/templates.php b/modules/Core/pages/panel/templates.php index b2f4baa135..df59ced46b 100644 --- a/modules/Core/pages/panel/templates.php +++ b/modules/Core/pages/panel/templates.php @@ -349,6 +349,7 @@ Redirect::to(URL::build('/panel/core/templates')); } + /** @var mixed $template */ require_once(ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . str_replace(['../', '/', '..'], '', $template_query->name) . DIRECTORY_SEPARATOR . 'template.php'); if ($template instanceof TemplateBase) { @@ -373,6 +374,7 @@ Redirect::to(URL::build('/panel/core/templates')); } + /** @var TemplateBase $template */ $template = $current_template; break; diff --git a/modules/Members/pages/members.php b/modules/Members/pages/members.php index 4496bdbc16..f447045a02 100644 --- a/modules/Members/pages/members.php +++ b/modules/Members/pages/members.php @@ -6,7 +6,7 @@ * @license MIT * @version 2.2.0 * - * @var array $template_pagination + * @var ?array $template_pagination * @var Cache $cache * @var FakeSmarty $smarty * @var Language $language @@ -90,9 +90,13 @@ ? 'group=' . $_GET['group'] : 'list=' . $viewing_list; + if (!isset($template_pagination)) { + $template_pagination = []; + } + $template_pagination['div'] = $template_pagination['div'] .= ' centered'; $paginator = new Paginator( - $template_pagination ?? null, + $template_pagination, $template_pagination_left ?? null, $template_pagination_right ?? null ); From de13af21c1d5ee8b44509fc80ead2be9ae23e318 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Oct 2023 17:52:13 +0100 Subject: [PATCH 4/8] Fix widget initialisation --- core/init.php | 2 -- core/templates/frontend_init.php | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/init.php b/core/init.php index b342d69e61..9eade87898 100644 --- a/core/init.php +++ b/core/init.php @@ -326,8 +326,6 @@ define('DEFAULT_AVATAR_PERSPECTIVE', 'face'); } - $widgets = $container->get(Widgets::class); - // Navbar links $navigation = new Navigation(); $cc_nav = new Navigation(); diff --git a/core/templates/frontend_init.php b/core/templates/frontend_init.php index bea3baf368..d6a5457d34 100644 --- a/core/templates/frontend_init.php +++ b/core/templates/frontend_init.php @@ -224,5 +224,8 @@ } } +// Initialise widgets +$widgets = new Widgets($cache, $language, $template); + // TODO: remove in 2.3.0 $smarty = new FakeSmarty($template->getEngine()); From 16e5da26f184dfae6fcd95d9f37716f5e263dfa4 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Oct 2023 17:53:58 +0100 Subject: [PATCH 5/8] Fix panel widget initialisation --- core/templates/backend_init.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/templates/backend_init.php b/core/templates/backend_init.php index 4375bed412..690f39145b 100644 --- a/core/templates/backend_init.php +++ b/core/templates/backend_init.php @@ -7,6 +7,7 @@ * @version 2.2.0 * * @var Cache $cache + * @var Language $language * @var Navigation $cc_nav * @var string $page_title * @var TemplateBase $template @@ -36,3 +37,6 @@ } $template->getEngine()->addVariable('TITLE', $page_title); + +// Initialise widgets +$widgets = new Widgets($cache, $language, $template); From 681bf1305947aa22914fe55c3158677ea6975242 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 8 Jun 2024 14:26:11 +0100 Subject: [PATCH 6/8] chore: remove debug return --- core/classes/Database/PhinxAdapter.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/classes/Database/PhinxAdapter.php b/core/classes/Database/PhinxAdapter.php index 6e03e2e56e..fea7a6f2a6 100644 --- a/core/classes/Database/PhinxAdapter.php +++ b/core/classes/Database/PhinxAdapter.php @@ -19,8 +19,6 @@ public static function ensureUpToDate( ?string $migrationDir = null, bool $returnResults = false ) { - return; - $module = strtolower($module); if ($module === 'core') { From de7b06050e619ff00bd664742f9dd209553ae7b5 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 8 Jun 2024 15:05:53 +0100 Subject: [PATCH 7/8] feat: convert 403/404 pages to new template system and general tidy --- 403.php | 33 ++++++++----- 404.php | 33 ++++++++----- core/classes/Core/Module.php | 3 +- core/classes/Misc/DebugBarHelper.php | 9 ++-- core/classes/Templates/FakeSmarty.php | 11 +++-- core/classes/Templates/SmartyTemplateBase.php | 11 +++-- .../Templates/SmartyTemplateEngine.php | 26 +++++++---- core/classes/Templates/TemplateBase.php | 9 ++-- core/classes/Templates/TemplateEngine.php | 46 +++++++++++-------- core/classes/Templates/TwigTemplateBase.php | 11 +++-- core/classes/Templates/TwigTemplateEngine.php | 19 +++++--- core/classes/Widgets/AbstractWidget.php | 9 ++-- core/classes/Widgets/Widgets.php | 6 +-- core/includes/maintenance.php | 20 ++++---- core/includes/tfa_signin.php | 20 ++++---- core/init.php | 3 +- core/templates/backend_init.php | 10 ++-- core/templates/cc_navbar.php | 4 +- core/templates/footer.php | 6 +-- core/templates/frontend_init.php | 12 ++--- core/templates/navbar.php | 10 ++-- core/templates/panel_navbar.php | 20 ++++++-- custom/panel_templates/Default/template.php | 2 +- custom/templates/DefaultRevamp/template.php | 6 +-- .../template_settings/settings.php | 20 ++++---- modules/Core/pages/home.php | 4 +- modules/Core/pages/panel/templates.php | 22 ++++----- 27 files changed, 224 insertions(+), 161 deletions(-) diff --git a/403.php b/403.php index 251528e72d..2d2342c0ca 100644 --- a/403.php +++ b/403.php @@ -1,30 +1,39 @@ onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; -// Assign Smarty variables -$smarty->assign( +// Assign template variables +$template->getEngine()->addVariables( [ '403_TITLE' => $language->get('errors', '403_title'), 'CONTENT' => $language->get('errors', '403_content'), @@ -38,4 +47,4 @@ ); // Display template -$template->displayTemplate('403.tpl', $smarty); +$template->displayTemplate('403.tpl'); diff --git a/404.php b/404.php index eed1f38baa..d839ac2807 100644 --- a/404.php +++ b/404.php @@ -1,30 +1,39 @@ onPageLoad(); -require(ROOT_PATH . '/core/templates/navbar.php'); -require(ROOT_PATH . '/core/templates/footer.php'); +require ROOT_PATH . '/core/templates/navbar.php'; +require ROOT_PATH . '/core/templates/footer.php'; -// Assign Smarty variables -$smarty->assign( +// Assign template variables +$template->getEngine()->addVariables( [ '404_TITLE' => $language->get('errors', '404_title'), 'CONTENT' => $language->get('errors', '404_content'), @@ -36,4 +45,4 @@ ); // Display template -$template->displayTemplate('404.tpl', $smarty); +$template->displayTemplate('404.tpl'); diff --git a/core/classes/Core/Module.php b/core/classes/Core/Module.php index 71000dcbec..53b5621999 100644 --- a/core/classes/Core/Module.php +++ b/core/classes/Core/Module.php @@ -56,7 +56,8 @@ public function __construct( * @param Widgets $widgets Instance of widget class to pass. * @param TemplateBase $template Template to pass. */ - public static function loadPage(User $user, Pages $pages, Cache $cache, $smarty, iterable $navs, Widgets $widgets, TemplateBase $template): void { + public static function loadPage(User $user, Pages $pages, Cache $cache, $smarty, iterable $navs, Widgets $widgets, TemplateBase $template): void + { foreach (self::getModules() as $module) { $module->onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $template); } diff --git a/core/classes/Misc/DebugBarHelper.php b/core/classes/Misc/DebugBarHelper.php index 9e78277f40..6b02e9459d 100644 --- a/core/classes/Misc/DebugBarHelper.php +++ b/core/classes/Misc/DebugBarHelper.php @@ -58,17 +58,20 @@ public function enable(): void $this->_debugBar = $debugbar; } - public function addCollector(DataCollector $collector): void { + public function addCollector(DataCollector $collector): void + { $this->_debugBar->addCollector($collector); } - public function addSmartyCollector(Smarty $smarty): void { + public function addSmartyCollector(Smarty $smarty): void + { $smartyCollector = new SmartyCollector($smarty); $smartyCollector->useHtmlVarDumper(); $this->addCollector($smartyCollector); } - public function addTwigCollector(Environment $twig, Profile $profile): void { + public function addTwigCollector(Environment $twig, Profile $profile): void + { $twig->addExtension(new ProfilerExtension($profile)); $this->addCollector(new NamespacedTwigProfileCollector($profile)); } diff --git a/core/classes/Templates/FakeSmarty.php b/core/classes/Templates/FakeSmarty.php index 811e9abdc0..c61d8340be 100644 --- a/core/classes/Templates/FakeSmarty.php +++ b/core/classes/Templates/FakeSmarty.php @@ -1,7 +1,7 @@ assign still works until 2.3.0, when this will be removed + * It aims to wrap around TemplateBase to ensure $smarty->assign still works until 2.3.0, when this will be removed. * * @author Samerton * @license MIT @@ -9,14 +9,17 @@ * @deprecated */ -class FakeSmarty { +class FakeSmarty +{ private TemplateEngine $_engine; - public function __construct(TemplateEngine $engine) { + public function __construct(TemplateEngine $engine) + { $this->_engine = $engine; } - public function assign($key, $value = null) { + public function assign($key, $value = null) + { if (is_string($key)) { $this->_engine->addVariable($key, $value); } diff --git a/core/classes/Templates/SmartyTemplateBase.php b/core/classes/Templates/SmartyTemplateBase.php index 2cb82ebe07..ad7e999586 100644 --- a/core/classes/Templates/SmartyTemplateBase.php +++ b/core/classes/Templates/SmartyTemplateBase.php @@ -1,15 +1,15 @@ _engine = new SmartyTemplateEngine($name, $panelTemplate); diff --git a/core/classes/Templates/SmartyTemplateEngine.php b/core/classes/Templates/SmartyTemplateEngine.php index 223c1d4fb0..77f481d0e5 100644 --- a/core/classes/Templates/SmartyTemplateEngine.php +++ b/core/classes/Templates/SmartyTemplateEngine.php @@ -1,20 +1,23 @@ php_functions = [ 'isset', @@ -42,7 +45,7 @@ public function __construct(string $template, bool $panelTemplate = false) { 'nl2br', 'is_numeric', 'file_exists', - 'array_key_exists' + 'array_key_exists', ]; $securityPolicy->secure_dir = [ROOT_PATH . '/custom/templates', ROOT_PATH . '/custom/panel_templates']; $smarty->enableSecurity($securityPolicy); @@ -64,18 +67,21 @@ public function __construct(string $template, bool $panelTemplate = false) { parent::__construct(); } - public function render(string $templateFile): void { + public function render(string $templateFile): void + { echo $this->fetch($templateFile); } - public function fetch(string $templateFile): string { + public function fetch(string $templateFile): string + { $templateFile = str_replace('.tpl', '', $templateFile); $this->_smarty->assign($this->getVariables()); return $this->_smarty->fetch("$templateFile.tpl"); } - public function clearCache(): void { + public function clearCache(): void + { $this->_smarty->clearAllCache(); } } diff --git a/core/classes/Templates/TemplateBase.php b/core/classes/Templates/TemplateBase.php index a1007feec9..fd06b41cd0 100644 --- a/core/classes/Templates/TemplateBase.php +++ b/core/classes/Templates/TemplateBase.php @@ -233,9 +233,9 @@ public function getJS(): array } /** - * Fetches template HTML instead of rendering it + * Fetches template HTML instead of rendering it. * - * @param string $template + * @param string $template * @return string Generated HTML */ public function getTemplate(string $template): string @@ -249,11 +249,12 @@ public function getTemplate(string $template): string } /** - * Get template engine + * Get template engine. * * @return TemplateEngine */ - public function getEngine(): TemplateEngine { + public function getEngine(): TemplateEngine + { return $this->_engine; } } diff --git a/core/classes/Templates/TemplateEngine.php b/core/classes/Templates/TemplateEngine.php index ed72a23855..d0f77e5f49 100644 --- a/core/classes/Templates/TemplateEngine.php +++ b/core/classes/Templates/TemplateEngine.php @@ -1,78 +1,84 @@ _variables = []; } /** - * Register a template variable + * Register a template variable. * * TODO: mixed type for $value * - * @param string $key - * @param mixed $value + * @param string $key + * @param mixed $value * @return void */ - public function addVariable(string $key, $value): void { + public function addVariable(string $key, $value): void + { $this->_variables[$key] = $value; } /** - * Get a template variable + * Get a template variable. * - * @param string $key + * @param string $key * @return mixed */ - public function getVariable(string $key) { + public function getVariable(string $key) + { return $this->_variables[$key]; } /** - * Register several template variables + * Register several template variables. * - * @param array $variables + * @param array $variables * @return void */ - public function addVariables(array $variables): void { + public function addVariables(array $variables): void + { $this->_variables = array_merge($this->_variables, $variables); } /** - * Get all template variables + * Get all template variables. * * @return array */ - public function getVariables(): array { + public function getVariables(): array + { return $this->_variables; } /** - * Render a template file using the set template engine + * Render a template file using the set template engine. * - * @param string $templateFile Path to template file to render + * @param string $templateFile Path to template file to render. */ public abstract function render(string $templateFile): void; /** - * Fetch a generated template file using the set template engine + * Fetch a generated template file using the set template engine. * - * @param string $templateFile Path to template file to render + * @param string $templateFile Path to template file to render. * @return string HTML to render */ public abstract function fetch(string $templateFile): string; /** - * Clear template cache directory + * Clear template cache directory. */ public abstract function clearCache(): void; } diff --git a/core/classes/Templates/TwigTemplateBase.php b/core/classes/Templates/TwigTemplateBase.php index af7fb91442..e7b9b23cf2 100644 --- a/core/classes/Templates/TwigTemplateBase.php +++ b/core/classes/Templates/TwigTemplateBase.php @@ -1,17 +1,18 @@ _engine = new TwigTemplateEngine($name); diff --git a/core/classes/Templates/TwigTemplateEngine.php b/core/classes/Templates/TwigTemplateEngine.php index fa728332a3..efb7b96697 100644 --- a/core/classes/Templates/TwigTemplateEngine.php +++ b/core/classes/Templates/TwigTemplateEngine.php @@ -1,6 +1,6 @@ ROOT_PATH . '/cache/twig', @@ -39,17 +41,20 @@ public function __construct(string $template) { parent::__construct(); } - public function render(string $templateFile): void { + public function render(string $templateFile): void + { echo $this->fetch($templateFile); } - public function fetch(string $templateFile): string { + public function fetch(string $templateFile): string + { $templateFile = str_replace('.tpl', '', $templateFile); return $this->_twig->render("$templateFile.twig", $this->getVariables()); } - public function clearCache(): void { + public function clearCache(): void + { $dir = ROOT_PATH . '/cache/twig'; foreach (glob($dir . '/*') as $file) { diff --git a/core/classes/Widgets/AbstractWidget.php b/core/classes/Widgets/AbstractWidget.php index 1f9c366879..4e15a7879e 100644 --- a/core/classes/Widgets/AbstractWidget.php +++ b/core/classes/Widgets/AbstractWidget.php @@ -9,7 +9,7 @@ abstract class AbstractWidget protected ?string $_settings = null; protected bool $_requires_cookies = false; /** - * Will be removed in 2.3.0 + * Will be removed in 2.3.0. * @var ?Smarty * @deprecated */ @@ -80,7 +80,7 @@ public function getOrder(): int } /** - * Get Smarty instance in use by this widget. Removed in 2.3.0 + * Get Smarty instance in use by this widget. Removed in 2.3.0. * * @return Smarty Instance in use. * @deprecated @@ -93,9 +93,10 @@ public function getSmarty(): ?Smarty /** * Get template engine in use by this widget. * - * @return TemplateEngine Engine in use + * @return TemplateEngine Engine in use. */ - public function getTemplateEngine(): ?TemplateEngine { + public function getTemplateEngine(): ?TemplateEngine + { return $this->_engine; } diff --git a/core/classes/Widgets/Widgets.php b/core/classes/Widgets/Widgets.php index eed6278fbc..62dbefd486 100644 --- a/core/classes/Widgets/Widgets.php +++ b/core/classes/Widgets/Widgets.php @@ -20,10 +20,10 @@ class Widgets private string $_name; /** - * @param Cache $cache - * @param Language $language + * @param Cache $cache + * @param Language $language * @param TemplateBase $template - * @param string $name + * @param string $name */ public function __construct( Cache $cache, diff --git a/core/includes/maintenance.php b/core/includes/maintenance.php index 91d54415cf..20ae030938 100644 --- a/core/includes/maintenance.php +++ b/core/includes/maintenance.php @@ -1,6 +1,6 @@ Output::getClean($integrationUser->data()->identifier), ]; } - } else { // Perform tasks for guests if (!$_SESSION['checked'] || (isset($_SESSION['checked']) && $_SESSION['checked'] <= strtotime('-5 minutes'))) { diff --git a/core/templates/backend_init.php b/core/templates/backend_init.php index 690f39145b..a660034a1e 100644 --- a/core/templates/backend_init.php +++ b/core/templates/backend_init.php @@ -1,15 +1,15 @@ Output::getClean(SITE_NAME), 'SITE_HOME' => URL::build('/'), 'USER_INFO_URL' => URL::build('/queries/user/', 'id='), - 'GUEST' => $language->get('user', 'guest') + 'GUEST' => $language->get('user', 'guest'), ]); $cache->setCache('backgroundcache'); @@ -217,7 +217,7 @@ if ($user->canViewStaffCP()) { $template->getEngine()->addVariables([ 'PANEL_LINK' => URL::build('/panel'), - 'PANEL' => $language->get('moderator', 'staff_cp') + 'PANEL' => $language->get('moderator', 'staff_cp'), ]); } } diff --git a/core/templates/navbar.php b/core/templates/navbar.php index 4f36750570..26c24c9140 100644 --- a/core/templates/navbar.php +++ b/core/templates/navbar.php @@ -1,16 +1,16 @@ getEngine()->addVariables([ 'SITE_NAME' => Output::getClean(SITE_NAME), + 'SITE_HOME' => URL::build('/'), + 'CONFIG_PATH' => defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/', + 'OG_URL' => Output::getClean(rtrim(URL::getSelfURL(), '/') . $_SERVER['REQUEST_URI']), 'PANEL_INDEX' => URL::build('/panel'), 'NAV_LINKS' => $staffcp_nav->returnNav('top'), 'VIEW_SITE' => $language->get('admin', 'view_site'), @@ -23,4 +27,14 @@ 'NOTICES' => Core_Module::getNotices(), 'NO_NOTICES' => $language->get('admin', 'no_notices'), 'MODE_TOGGLE' => $language->get('admin', 'mode_toggle'), + 'LOGGED_IN_USER' => [ + 'username' => $user->getDisplayname(true), + 'nickname' => $user->getDisplayname(), + 'profile' => $user->getProfileURL(), + 'panel_profile' => URL::build('/panel/user/' . urlencode($user->data()->id) . '-' . urlencode($user->data()->username)), + 'username_style' => $user->getGroupStyle(), + 'user_title' => Output::getClean($user->data()->user_title), + 'avatar' => $user->getAvatar(), + 'integrations' => $user_integrations ?? [], + ] ]); diff --git a/custom/panel_templates/Default/template.php b/custom/panel_templates/Default/template.php index b95c552670..8bbc1b7cc7 100644 --- a/custom/panel_templates/Default/template.php +++ b/custom/panel_templates/Default/template.php @@ -136,7 +136,7 @@ public function __construct(Language $language) '); - $this->getEngine()->addVariable('NAMELESS_LOGO', (URL::buildAssetPath('/core/assets/img/namelessmc_logo.png'))); + $this->getEngine()->addVariable('NAMELESS_LOGO', URL::buildAssetPath('/core/assets/img/namelessmc_logo.png')); } public function onPageLoad() diff --git a/custom/templates/DefaultRevamp/template.php b/custom/templates/DefaultRevamp/template.php index cf872da650..d8df4d667d 100755 --- a/custom/templates/DefaultRevamp/template.php +++ b/custom/templates/DefaultRevamp/template.php @@ -154,10 +154,10 @@ public function onPageLoad() } /** - * @var Cache $cache + * @var Cache $cache * @var Language $language - * @var User $user - * @var Pages $pages + * @var User $user + * @var Pages $pages */ $template = new DefaultRevamp_Template($cache, $language, $user, $pages); $template_pagination = ['div' => 'ui mini pagination menu', 'a' => '{x}item']; diff --git a/custom/templates/DefaultRevamp/template_settings/settings.php b/custom/templates/DefaultRevamp/template_settings/settings.php index 3a72f7b234..38d0e63563 100644 --- a/custom/templates/DefaultRevamp/template_settings/settings.php +++ b/custom/templates/DefaultRevamp/template_settings/settings.php @@ -1,12 +1,16 @@ addJSScript(Input::createTinyEditor($language, 'inputHomeCustomContent', Settings::get('home_custom_content'))); -$smarty->assign([ +$current_template->getEngine()->addVariables([ 'SUBMIT' => $language->get('general', 'submit'), 'ENABLED' => $language->get('admin', 'enabled'), 'DISABLED' => $language->get('admin', 'disabled'), diff --git a/modules/Core/pages/home.php b/modules/Core/pages/home.php index d74f1f3133..d968e81b0f 100644 --- a/modules/Core/pages/home.php +++ b/modules/Core/pages/home.php @@ -22,7 +22,7 @@ // Always define page name const PAGE = 'index'; $page_title = $language->get('general', 'home'); -require_once(ROOT_PATH . '/core/templates/frontend_init.php'); +require_once ROOT_PATH . '/core/templates/frontend_init.php'; $template->assets()->include([ DARK_MODE @@ -51,7 +51,7 @@ foreach ($front_page_modules as $module) { require(ROOT_PATH . '/' . $module); } -} else if ($home_type === 'custom') { +} elseif ($home_type === 'custom') { $template->getEngine()->addVariable('CUSTOM_HOME_CONTENT', Settings::get('home_custom_content')); } diff --git a/modules/Core/pages/panel/templates.php b/modules/Core/pages/panel/templates.php index df59ced46b..19ae485597 100644 --- a/modules/Core/pages/panel/templates.php +++ b/modules/Core/pages/panel/templates.php @@ -1,21 +1,21 @@ handlePanelPageLoad('admincp.styles.templates')) { @@ -356,7 +356,7 @@ if ($template->getSettings()) { require_once($template->getSettings()); - $template->getEngine()->addVariables([ + $current_template->getEngine()->addVariables([ 'EDITING_TEMPLATE' => $language->get('admin', 'editing_template_x', [ 'template' => Text::bold(Output::getClean($template_query->name)) ]), From 9a1a437689350a32a253c1bed56456199b64e6a3 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 8 Jun 2024 15:10:26 +0100 Subject: [PATCH 8/8] chore: style fixes --- 403.php | 1 - 404.php | 1 - core/classes/Templates/FakeSmarty.php | 1 - core/classes/Templates/SmartyTemplateBase.php | 2 +- core/classes/Templates/SmartyTemplateEngine.php | 6 +++--- core/classes/Templates/TemplateEngine.php | 9 ++++----- core/includes/maintenance.php | 1 - core/includes/tfa_signin.php | 1 - core/templates/backend_init.php | 1 - core/templates/cc_navbar.php | 1 - core/templates/frontend_init.php | 1 - core/templates/panel_navbar.php | 2 +- custom/panel_templates/Default/template.php | 1 - .../DefaultRevamp/template_settings/settings.php | 11 ++++------- 14 files changed, 13 insertions(+), 26 deletions(-) diff --git a/403.php b/403.php index 2d2342c0ca..3208189dc6 100644 --- a/403.php +++ b/403.php @@ -17,7 +17,6 @@ * @var User $user * @var Widgets $widgets */ - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'); const PAGE = 403; diff --git a/404.php b/404.php index d839ac2807..d09a4b517b 100644 --- a/404.php +++ b/404.php @@ -17,7 +17,6 @@ * @var User $user * @var Widgets $widgets */ - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); const PAGE = 404; diff --git a/core/classes/Templates/FakeSmarty.php b/core/classes/Templates/FakeSmarty.php index c61d8340be..289c935476 100644 --- a/core/classes/Templates/FakeSmarty.php +++ b/core/classes/Templates/FakeSmarty.php @@ -8,7 +8,6 @@ * @version 2.2.0 * @deprecated */ - class FakeSmarty { private TemplateEngine $_engine; diff --git a/core/classes/Templates/SmartyTemplateBase.php b/core/classes/Templates/SmartyTemplateBase.php index ad7e999586..ac6071ee6a 100644 --- a/core/classes/Templates/SmartyTemplateBase.php +++ b/core/classes/Templates/SmartyTemplateBase.php @@ -15,7 +15,7 @@ abstract class SmartyTemplateBase extends TemplateBase * @param string $version * @param string $nameless_version * @param string $author - * @param bool $panelTemplate + * @param bool $panelTemplate */ public function __construct(string $name, string $version, string $nameless_version, string $author, bool $panelTemplate = false) { diff --git a/core/classes/Templates/SmartyTemplateEngine.php b/core/classes/Templates/SmartyTemplateEngine.php index 77f481d0e5..342bfbf690 100644 --- a/core/classes/Templates/SmartyTemplateEngine.php +++ b/core/classes/Templates/SmartyTemplateEngine.php @@ -6,14 +6,13 @@ * @license MIT * @version 2.2.0 */ - class SmartyTemplateEngine extends TemplateEngine { private Smarty $_smarty; /** - * @param string $template Template name to load - * @param bool $panelTemplate Whether this is a panel template or not + * @param string $template Template name to load + * @param bool $panelTemplate Whether this is a panel template or not * @throws SmartyException */ public function __construct(string $template, bool $panelTemplate = false) @@ -77,6 +76,7 @@ public function fetch(string $templateFile): string $templateFile = str_replace('.tpl', '', $templateFile); $this->_smarty->assign($this->getVariables()); + return $this->_smarty->fetch("$templateFile.tpl"); } diff --git a/core/classes/Templates/TemplateEngine.php b/core/classes/Templates/TemplateEngine.php index d0f77e5f49..efad07237f 100644 --- a/core/classes/Templates/TemplateEngine.php +++ b/core/classes/Templates/TemplateEngine.php @@ -6,7 +6,6 @@ * @license MIT * @version 2.2.0 */ - abstract class TemplateEngine { private array $_variables; @@ -22,7 +21,7 @@ public function __construct() * TODO: mixed type for $value * * @param string $key - * @param mixed $value + * @param mixed $value * @return void */ public function addVariable(string $key, $value): void @@ -67,7 +66,7 @@ public function getVariables(): array * * @param string $templateFile Path to template file to render. */ - public abstract function render(string $templateFile): void; + abstract public function render(string $templateFile): void; /** * Fetch a generated template file using the set template engine. @@ -75,10 +74,10 @@ public abstract function render(string $templateFile): void; * @param string $templateFile Path to template file to render. * @return string HTML to render */ - public abstract function fetch(string $templateFile): string; + abstract public function fetch(string $templateFile): string; /** * Clear template cache directory. */ - public abstract function clearCache(): void; + abstract public function clearCache(): void; } diff --git a/core/includes/maintenance.php b/core/includes/maintenance.php index 20ae030938..26791dec5a 100644 --- a/core/includes/maintenance.php +++ b/core/includes/maintenance.php @@ -19,7 +19,6 @@ * @var User $user * @var Widgets $widgets */ - $pages = new Pages(); const PAGE = 'maintenance'; diff --git a/core/includes/tfa_signin.php b/core/includes/tfa_signin.php index d04c084ebd..62a91cf356 100644 --- a/core/includes/tfa_signin.php +++ b/core/includes/tfa_signin.php @@ -19,7 +19,6 @@ * @var User $user * @var Widgets $widgets */ - if (isset($_POST['username'])) { $_SESSION['username'] = $_POST['username']; } else { diff --git a/core/templates/backend_init.php b/core/templates/backend_init.php index a660034a1e..9720bf170d 100644 --- a/core/templates/backend_init.php +++ b/core/templates/backend_init.php @@ -12,7 +12,6 @@ * @var string $page_title * @var TemplateBase $template */ - const BACK_END = true; if (file_exists(ROOT_PATH . '/custom/panel_templates/' . PANEL_TEMPLATE . '/template.php')) { diff --git a/core/templates/cc_navbar.php b/core/templates/cc_navbar.php index 7efed1335e..58d0e44e25 100644 --- a/core/templates/cc_navbar.php +++ b/core/templates/cc_navbar.php @@ -9,5 +9,4 @@ * @var Navigation $cc_nav * @var TemplateBase $template */ - $template->getEngine()->addVariable('CC_NAV_LINKS', $cc_nav->returnNav()); diff --git a/core/templates/frontend_init.php b/core/templates/frontend_init.php index 0bf5dce7cc..f2f2de2a25 100644 --- a/core/templates/frontend_init.php +++ b/core/templates/frontend_init.php @@ -11,7 +11,6 @@ * @var string $page_title * @var User $user */ - const FRONT_END = true; // Set current page URL in session, provided it's not the login page diff --git a/core/templates/panel_navbar.php b/core/templates/panel_navbar.php index f0744f24f7..2a8a03db13 100644 --- a/core/templates/panel_navbar.php +++ b/core/templates/panel_navbar.php @@ -36,5 +36,5 @@ 'user_title' => Output::getClean($user->data()->user_title), 'avatar' => $user->getAvatar(), 'integrations' => $user_integrations ?? [], - ] + ], ]); diff --git a/custom/panel_templates/Default/template.php b/custom/panel_templates/Default/template.php index 8bbc1b7cc7..c7732bce90 100644 --- a/custom/panel_templates/Default/template.php +++ b/custom/panel_templates/Default/template.php @@ -16,7 +16,6 @@ if (!class_exists('Default_Panel_Template')) { class Default_Panel_Template extends SmartyTemplateBase { - private Language $_language; // Constructor - set template name, version, Nameless version and author here diff --git a/custom/templates/DefaultRevamp/template_settings/settings.php b/custom/templates/DefaultRevamp/template_settings/settings.php index 38d0e63563..fddf81a4a2 100644 --- a/custom/templates/DefaultRevamp/template_settings/settings.php +++ b/custom/templates/DefaultRevamp/template_settings/settings.php @@ -1,18 +1,15 @@ setCache('template_settings');