From db647d9b4e20f753ceadf493237a48cba7ca7627 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Feb 2025 18:44:29 +0000 Subject: [PATCH] Add Smarty and Twig template engines (#3452) * Add Smarty and Twig template engines * Update composer.json * Convert Widgets class to template engine and PHPStan fixes * Fix widget initialisation * Fix panel widget initialisation * chore: remove debug return * feat: convert 403/404 pages to new template system and general tidy * chore: style fixes * feat: update latest pages to new template engine * feat: template base should not be nullable in onPageLoad * feat: set template base directory upon initialisation and allow custom smarty security directories * chore: fix style --- 403.php | 34 ++-- 404.php | 34 ++-- composer.json | 3 +- core/classes/Core/Module.php | 24 +-- core/classes/Misc/DebugBarHelper.php | 31 +++- core/classes/Templates/FakeSmarty.php | 30 ++++ core/classes/Templates/SmartyTemplateBase.php | 26 +++ .../Templates/SmartyTemplateEngine.php | 95 +++++++++++ core/classes/Templates/TemplateBase.php | 47 +++++- core/classes/Templates/TemplateEngine.php | 83 +++++++++ core/classes/Templates/TwigTemplateBase.php | 20 +++ core/classes/Templates/TwigTemplateEngine.php | 68 ++++++++ core/classes/Widgets/AbstractWidget.php | 26 ++- core/classes/Widgets/Widgets.php | 18 +- core/includes/maintenance.php | 34 ++-- core/includes/tfa_signin.php | 37 ++-- core/init.php | 77 +-------- core/templates/backend_init.php | 36 ++-- core/templates/cc_navbar.php | 18 +- core/templates/footer.php | 31 ++-- core/templates/frontend_init.php | 113 ++++++++++--- core/templates/navbar.php | 23 ++- core/templates/panel_navbar.php | 32 +++- .../Default/core/announcements.tpl | 2 +- custom/panel_templates/Default/template.php | 22 +-- custom/templates/DefaultRevamp/template.php | 32 ++-- .../template_settings/settings.php | 17 +- modules/Cookie Consent/module.php | 76 ++++----- 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 | 53 +++--- 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 | 159 +++++++++--------- 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 | 67 ++++---- modules/Core/pages/panel/emails_errors.php | 57 ++++--- 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 | 49 +++--- modules/Core/pages/panel/mass_message.php | 12 +- 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 | 41 +++-- 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 | 45 +++-- .../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 | 88 +++++----- 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 ++++--- .../Core/pages/panel/users_punishments.php | 75 +++++---- modules/Core/pages/panel/users_reports.php | 83 +++++---- modules/Core/pages/panel/users_sessions.php | 13 +- 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 | 18 +- modules/Core/pages/user/connections.php | 37 ++-- modules/Core/pages/user/index.php | 30 ++-- modules/Core/pages/user/messaging.php | 135 ++++++++------- .../Core/pages/user/notification_settings.php | 10 +- modules/Core/pages/user/placeholders.php | 39 +++-- modules/Core/pages/user/sessions.php | 10 +- 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 | 47 ++++-- modules/Members/pages/panel/member_lists.php | 33 +++- modules/Members/pages/panel/settings.php | 37 +++- 136 files changed, 3579 insertions(+), 2351 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/403.php b/403.php index 251528e72d..3208189dc6 100644 --- a/403.php +++ b/403.php @@ -1,30 +1,38 @@ 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 +46,4 @@ ); // Display template -$template->displayTemplate('403.tpl', $smarty); +$template->displayTemplate('403.tpl'); diff --git a/404.php b/404.php index eed1f38baa..d09a4b517b 100644 --- a/404.php +++ b/404.php @@ -1,30 +1,38 @@ 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 +44,4 @@ ); // Display template -$template->displayTemplate('404.tpl', $smarty); +$template->displayTemplate('404.tpl'); diff --git a/composer.json b/composer.json index 465a7f960a..27ffa19e20 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "joypixels/emoji-toolkit": "^7.0", "geoip2/geoip2": "^2.13", "jenssegers/agent": "^2.6", - "php-di/php-di": "^6.4" + "php-di/php-di": "^6.4", + "twig/twig": "^3.0" }, "require-dev": { "phpstan/phpstan": "1.6.9", diff --git a/core/classes/Core/Module.php b/core/classes/Core/Module.php index e53da64187..ceb75958b3 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 @@ -48,15 +48,15 @@ public function __construct( /** * Call `onPageLoad()` function for all registered modules. * - * @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 Navigation[] $navs Array of loaded navigation menus. - * @param Widgets $widgets Instance of widget class to pass. - * @param TemplateBase $template Template to pass. + * @param User $user User viewing the page. + * @param Pages $pages Instance of pages class. + * @param Cache $cache Instance of cache 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); @@ -76,12 +76,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. + * @param TemplateBase $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/Misc/DebugBarHelper.php b/core/classes/Misc/DebugBarHelper.php index 1a8d4eea06..6b02e9459d 100644 --- a/core/classes/Misc/DebugBarHelper.php +++ b/core/classes/Misc/DebugBarHelper.php @@ -1,6 +1,8 @@ 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..289c935476 --- /dev/null +++ b/core/classes/Templates/FakeSmarty.php @@ -0,0 +1,30 @@ +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..0a01f17b30 --- /dev/null +++ b/core/classes/Templates/SmartyTemplateBase.php @@ -0,0 +1,26 @@ +_engine = new SmartyTemplateEngine($dir); + + parent::__construct($name, $version, $nameless_version, $author); + } +} diff --git a/core/classes/Templates/SmartyTemplateEngine.php b/core/classes/Templates/SmartyTemplateEngine.php new file mode 100644 index 0000000000..e141462daf --- /dev/null +++ b/core/classes/Templates/SmartyTemplateEngine.php @@ -0,0 +1,95 @@ +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'); + $smarty->setTemplateDir($dir); + + if (defined('PHPDEBUGBAR')) { + DebugBarHelper::getInstance()->addSmartyCollector($smarty); + } + + $this->_securityPolicy = $securityPolicy; + $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(); + } + + /** + * Add an extra directory to the Smarty security policy. + * + * @param string $dir Directory to add to policy + * @return void + */ + public function addSecurityPolicyDirectory(string $dir): void + { + $this->_securityPolicy->secure_dir = [...$this->_securityPolicy->secure_dir, $dir]; + $this->_smarty->enableSecurity($this->_securityPolicy); + } +} diff --git a/core/classes/Templates/TemplateBase.php b/core/classes/Templates/TemplateBase.php index 1b4c004ddb..7fc919efa1 100644 --- a/core/classes/Templates/TemplateBase.php +++ b/core/classes/Templates/TemplateBase.php @@ -4,7 +4,7 @@ * * @package NamelessMC\Templates * @author Samerton - * @version 2.0.0-pr13 + * @version 2.2.0 * @license MIT */ abstract class TemplateBase @@ -46,12 +46,23 @@ 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; $this->_nameless_version = $nameless_version; $this->_author = $author; + + /* + * Temporary assignment to Smarty template engine for backwards compatibility for templates which extend TemplateBase + * This will be removed in 2.3.0 - breaking change! + */ + if (!isset($this->_engine)) { + $this->_engine = new SmartyTemplateEngine(ROOT_PATH . '/custom/templates/' . $name); + } } /** @@ -181,9 +192,11 @@ 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(); @@ -191,20 +204,20 @@ public function displayTemplate(string $template, Smarty $smarty): void array_unshift($this->_css, ...$css); array_unshift($this->_js, ...$js); - $smarty->assign([ + $this->_engine->addVariables([ 'TEMPLATE_CSS' => $this->getCSS(), '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(), ]); } - $smarty->display($template); + $this->_engine->render($template); } /** @@ -227,13 +240,29 @@ public function getJS(): array return $this->_js; } - public function getTemplate(string $template, Smarty $smarty): string + /** + * Fetches template HTML instead of rendering it. + * + * @param string $template + * @return string Generated HTML + */ + public function getTemplate(string $template): string { - $smarty->assign([ + $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..efad07237f --- /dev/null +++ b/core/classes/Templates/TemplateEngine.php @@ -0,0 +1,83 @@ +_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. + */ + abstract public 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 + */ + abstract public function fetch(string $templateFile): string; + + /** + * Clear template cache directory. + */ + abstract public function clearCache(): void; +} diff --git a/core/classes/Templates/TwigTemplateBase.php b/core/classes/Templates/TwigTemplateBase.php new file mode 100644 index 0000000000..63614179ad --- /dev/null +++ b/core/classes/Templates/TwigTemplateBase.php @@ -0,0 +1,20 @@ +_engine = new TwigTemplateEngine($dir); + } +} diff --git a/core/classes/Templates/TwigTemplateEngine.php b/core/classes/Templates/TwigTemplateEngine.php new file mode 100644 index 0000000000..e52d9bbbeb --- /dev/null +++ b/core/classes/Templates/TwigTemplateEngine.php @@ -0,0 +1,68 @@ + 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 9c963bab41..4e15a7879e 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; @@ -74,15 +80,26 @@ 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. @@ -95,7 +112,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/classes/Widgets/Widgets.php b/core/classes/Widgets/Widgets.php index b6c6965a15..62dbefd486 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)) { @@ -141,7 +147,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()), @@ -149,7 +155,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/core/includes/maintenance.php b/core/includes/maintenance.php index 4577acdf0c..26791dec5a 100644 --- a/core/includes/maintenance.php +++ b/core/includes/maintenance.php @@ -1,22 +1,32 @@ 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( + $template->getEngine()->addVariables( [ 'LOGIN' => $language->get('general', 'sign_in'), 'LOGIN_LINK' => URL::build('/login'), @@ -24,8 +34,8 @@ ); } -// Assign Smarty variables -$smarty->assign( +// 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.')), @@ -39,4 +49,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 1215f47d9c..62a91cf356 100644 --- a/core/includes/tfa_signin.php +++ b/core/includes/tfa_signin.php @@ -1,15 +1,24 @@ assign([ + $template->getEngine()->addVariables([ 'ERROR_TITLE' => $language->get('general', 'error'), '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 +51,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 2e367c500b..3741a6d151 100644 --- a/core/init.php +++ b/core/init.php @@ -134,11 +134,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 @@ -217,7 +214,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]; } } @@ -312,52 +309,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) { @@ -387,8 +338,6 @@ define('DEFAULT_AVATAR_PERSPECTIVE', 'face'); } - $widgets = $container->get(Widgets::class); - // Navbar links $navigation = new Navigation(); $cc_nav = new Navigation(); @@ -497,7 +446,7 @@ } } else { // Display notice to admin stating maintenance mode is enabled - $smarty->assign('MAINTENANCE_ENABLED', $language->get('admin', 'maintenance_enabled')); + define('BYPASS_MAINTENANCE', true); } } @@ -632,26 +581,6 @@ 'identifier' => Output::getClean($integrationUser->data()->identifier), ]; } - - // 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'))) { @@ -670,7 +599,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 0fc9f166e0..25e5917722 100644 --- a/core/templates/backend_init.php +++ b/core/templates/backend_init.php @@ -1,26 +1,25 @@ 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,18 +27,21 @@ $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([ +$template->getEngine()->addVariables([ 'DARK_MODE_ENABLED' => defined('DARK_MODE') && DARK_MODE ? DARK_MODE : '0', 'DARK_LIGHT_MODE_ACTION' => URL::build('/queries/dark_light_mode'), 'DARK_LIGHT_MODE_TOKEN' => $user->isLoggedIn() ? Token::get() : null, 'TITLE' => $page_title, ]); + +// Initialise widgets +$widgets = new Widgets($cache, $language, $template); diff --git a/core/templates/cc_navbar.php b/core/templates/cc_navbar.php index 49885312d5..58d0e44e25 100644 --- a/core/templates/cc_navbar.php +++ b/core/templates/cc_navbar.php @@ -1,14 +1,12 @@ assign([ - 'CC_NAV_LINKS' => $cc_nav->returnNav('top'), -]); +$template->getEngine()->addVariable('CC_NAV_LINKS', $cc_nav->returnNav()); diff --git a/core/templates/footer.php b/core/templates/footer.php index a3f6a57b3e..4500fa57b0 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'), + '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 1ae8f24c9c..f2f2de2a25 100644 --- a/core/templates/frontend_init.php +++ b/core/templates/frontend_init.php @@ -1,18 +1,27 @@ 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 @@ -69,7 +94,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'), @@ -107,56 +132,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), addslashes(strip_tags($page_metadata->description))), 'PAGE_KEYWORDS' => addslashes(strip_tags($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), addslashes(strip_tags(Settings::get('default_meta_description', '')))), 'PAGE_KEYWORDS' => addslashes(strip_tags(Settings::get('default_meta_keywords', ''))), ]); } } else { - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGE_DESCRIPTION' => str_replace('{site}', Output::getClean(SITE_NAME), addslashes(strip_tags(PAGE_DESCRIPTION))), 'PAGE_KEYWORDS' => (defined('PAGE_KEYWORDS') ? addslashes(strip_tags(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'), @@ -165,3 +190,39 @@ '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'), + ]); + } +} + +// Initialise widgets +$widgets = new Widgets($cache, $language, $template); + +// TODO: remove in 2.3.0 +$smarty = new FakeSmarty($template->getEngine()); diff --git a/core/templates/navbar.php b/core/templates/navbar.php index ceae531cc7..3b580d06bf 100644 --- a/core/templates/navbar.php +++ b/core/templates/navbar.php @@ -1,12 +1,17 @@ assign([ +// Assign to template variables +$template->getEngine()->addVariables([ 'NAVBAR_INVERSE' => '', 'SITE_NAME' => Output::getClean(SITE_NAME), 'NAV_LINKS' => $navigation->returnNav('top'), @@ -196,7 +201,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 960eaac869..2a8a03db13 100644 --- a/core/templates/panel_navbar.php +++ b/core/templates/panel_navbar.php @@ -1,17 +1,23 @@ assign([ +// Assign to template variables +$template->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'), @@ -21,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/core/announcements.tpl b/custom/panel_templates/Default/core/announcements.tpl index cec036b01a..e54117fe1e 100644 --- a/custom/panel_templates/Default/core/announcements.tpl +++ b/custom/panel_templates/Default/core/announcements.tpl @@ -37,7 +37,7 @@
-

{$ANNOUCEMENTS_INFO}

+

{$ANNOUNCEMENTS_INFO}

_language = $language; parent::__construct( 'Default', // Template name - '2.1.3', // Template version - '2.1.3', // 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 + __DIR__, // Specify the path to the template ); $this->assets()->include([ @@ -118,7 +119,7 @@ public function __construct(Smarty $smarty, Language $language) JS ); - $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() @@ -523,4 +524,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 b6e1f26560..03b26a8fb4 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,18 +22,18 @@ 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.3', - 'nl_version' => '2.1.3', + 'version' => '2.2.0', + 'nl_version' => '2.2.0', 'author' => 'Xemah', ]; $template['path'] = (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/custom/templates/' . $template['name'] . '/'; - parent::__construct($template['name'], $template['version'], $template['nl_version'], $template['author']); + parent::__construct($template['name'], $template['version'], $template['nl_version'], $template['author'], __DIR__); $this->_settings = ROOT_PATH . '/custom/templates/DefaultRevamp/template_settings/settings.php'; @@ -44,10 +44,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; @@ -65,11 +65,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; @@ -149,5 +153,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/custom/templates/DefaultRevamp/template_settings/settings.php b/custom/templates/DefaultRevamp/template_settings/settings.php index 3a72f7b234..fddf81a4a2 100644 --- a/custom/templates/DefaultRevamp/template_settings/settings.php +++ b/custom/templates/DefaultRevamp/template_settings/settings.php @@ -1,14 +1,15 @@ setCache('template_settings'); @@ -119,7 +120,7 @@ $current_template->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/Cookie Consent/module.php b/modules/Cookie Consent/module.php index 104aabd602..a4b2548cf3 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.3'; - $nameless_version = '2.1.3'; + $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 @@ -76,38 +74,36 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart $cookie_url = URL::build('/cookies'); // Add JS script - if ($template) { - $template->addCSSFiles([ - (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/modules/Cookie Consent/assets/css/cookieconsent.min.css' => [], - ]); - $template->addJSFiles([ - (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/modules/Cookie Consent/assets/js/cookieconsent.min.js' => [], - ]); - $template->addJSScript( - CookieConsent::generateScript( - array_merge($options, [ - 'cookies' => $this->_cookie_language->get('cookie', 'cookies'), - 'message' => $this->_cookie_language->get('cookie', 'cookie_popup'), - 'dismiss' => $this->_cookie_language->get('cookie', 'cookie_popup_disallow'), - 'allow' => $this->_cookie_language->get('cookie', 'cookie_popup_allow'), - 'link' => $this->_cookie_language->get('cookie', 'cookie_popup_more_info'), - 'href' => $cookie_url, - ]) - ) - ); - } - - $smarty->assign([ - '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'), - 'COOKIE_NOTICE_CONFIGURE' => $this->_cookie_language->get('cookie', 'configure_cookies'), - 'COOKIE_DECISION_MADE' => (bool)Cookie::get('cookieconsent_status'), + $template->addCSSFiles([ + (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/modules/Cookie Consent/assets/css/cookieconsent.min.css' => [], ]); - - $navs[0]->add('cookies', $this->_cookie_language->get('cookie', 'cookie_notice'), $cookie_url, 'footer'); + $template->addJSFiles([ + (defined('CONFIG_PATH') ? CONFIG_PATH : '') . '/modules/Cookie Consent/assets/js/cookieconsent.min.js' => [], + ]); + $template->addJSScript( + CookieConsent::generateScript( + array_merge($options, [ + 'cookies' => $this->_cookie_language->get('cookie', 'cookies'), + 'message' => $this->_cookie_language->get('cookie', 'cookie_popup'), + 'dismiss' => $this->_cookie_language->get('cookie', 'cookie_popup_disallow'), + 'allow' => $this->_cookie_language->get('cookie', 'cookie_popup_allow'), + 'link' => $this->_cookie_language->get('cookie', 'cookie_popup_more_info'), + 'href' => $cookie_url, + ]) + ) + ); } + $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'), + 'COOKIE_NOTICE_CONFIGURE' => $this->_cookie_language->get('cookie', 'configure_cookies'), + 'COOKIE_DECISION_MADE' => (bool)Cookie::get('cookieconsent_status'), + ]); + + $navs[0]->add('cookies', $this->_cookie_language->get('cookie', 'cookie_notice'), $cookie_url, 'footer'); + if (defined('BACK_END')) { $cache->setCache('panel_sidebar'); 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 6fb1532550..04e96620ec 100644 --- a/modules/Core/module.php +++ b/modules/Core/module.php @@ -1,12 +1,10 @@ Samerton'; - $module_version = '2.1.3'; - $nameless_version = '2.1.3'; + $module_version = '2.2.0'; + $nameless_version = '2.2.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -601,7 +599,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 @@ -693,7 +699,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 @@ -701,30 +707,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)); } } @@ -763,7 +769,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'), @@ -926,49 +932,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) ]); @@ -1513,26 +1523,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 586d32bd47..637d303f84 100644 --- a/modules/Core/pages/custom.php +++ b/modules/Core/pages/custom.php @@ -1,12 +1,22 @@ get('custom_pages', ['url', $page_route]); if (!$custom_page->count()) { - require(ROOT_PATH . '/404.php'); + require ROOT_PATH . '/404.php'; die(); } @@ -50,7 +60,7 @@ } if (!isset($can_view)) { - require(ROOT_PATH . '/403.php'); + require ROOT_PATH . '/403.php'; die(); } @@ -63,7 +73,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 @@ -80,7 +90,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, @@ -88,11 +98,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 30e8f3dc71..386a238ce6 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 e7de346c00..c2f162c85a 100644 --- a/modules/Core/pages/home.php +++ b/modules/Core/pages/home.php @@ -1,18 +1,28 @@ 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 @@ -22,13 +32,17 @@ ]); if (Session::exists('home')) { - $smarty->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'); @@ -36,18 +50,19 @@ $home_type = 'news'; } -$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')); +} elseif ($home_type === 'custom') { + $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); @@ -57,8 +72,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 ffaed11bf5..28b085946a 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 @@ -53,7 +63,7 @@ $leaderboard_users[$uuid] = $integration_user; } - $last_updated = $timeago->inWords($row->last_updated, $language); + $last_updated = $timeAgo->inWords($row->last_updated, $language); $row_data->server_id = $leaderboard_placeholder->server_id; $row_data->name = $leaderboard_placeholder->name; @@ -72,7 +82,7 @@ } } -$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'), @@ -118,8 +128,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 9caf2f0b07..9535645d10 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 @@ -274,7 +283,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'), @@ -293,17 +302,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'); @@ -322,8 +331,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 452898603d..70dc15b561 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 880cf74236..eb5781cb97 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()) { @@ -149,28 +160,24 @@ 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( + $template->getEngine()->addVariables( [ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), @@ -204,11 +211,11 @@ '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') + 'API_ENDPOINTS_LINK' => URL::build('/panel/core/api/', 'view=api_endpoints'), ] ); - $template_file = 'core/api.tpl'; + $template_file = 'core/api'; } else { if ($_GET['view'] == 'group_sync') { @@ -222,34 +229,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') { @@ -265,38 +270,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 4eda3c571b..453f3df2d8 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(); @@ -88,7 +96,7 @@ } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PLEASE_REAUTHENTICATE' => $language->get('admin', 're-authenticate'), 'PASSWORD' => $language->get('user', 'password'), 'TOKEN' => Token::get(), @@ -108,7 +116,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 @@ -116,7 +124,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 2cc8773945..4406068b5f 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,15 +193,13 @@ } if ($user->hasPermission('admincp.core.emails_mass_message')) { - $smarty->assign([ - 'MASS_MESSAGE' => $language->get('admin', 'mass_message'), + $template->getEngine()->addVariables([ + 'MASS_MESSAGE' => $language->get('admin', 'emails_mass_message'), 'MASS_MESSAGE_LINK' => URL::build('/panel/core/mass_message'), ]); } - $smarty->assign([ - 'MASS_MESSAGE' => $language->get('admin', 'mass_message'), - 'MASS_MESSAGE_LINK' => URL::build('/panel/core/mass_message'), + $template->getEngine()->addVariables([ 'EDIT_EMAIL_MESSAGES' => $language->get('admin', 'edit_email_messages'), 'EDIT_EMAIL_MESSAGES_LINK' => URL::build('/panel/core/emails/', 'action=edit_messages'), 'SEND_TEST_EMAIL' => $language->get('admin', 'send_test_email'), @@ -225,7 +230,7 @@ 'TOKEN' => Token::get() ]); - $template_file = 'core/emails.tpl'; + $template_file = 'core/emails'; } // Load modules + template @@ -236,20 +241,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 +266,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 292eac337d..6ba709f15a 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/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 30bece4539..6de5bb79a0 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'])) { @@ -189,16 +198,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, ]); } @@ -245,7 +254,7 @@ ]; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -318,7 +327,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 04cc0f9a3d..0ee5060420 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; @@ -514,7 +523,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'GROUP_ID' => $language->get('admin', 'group_id'), 'NAME' => $language->get('admin', 'name'), 'USERS' => $language->get('admin', 'users'), @@ -529,24 +538,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'), @@ -562,7 +571,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 75dc660413..b3f46de2d9 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 @@ -219,7 +228,7 @@ $compat_warnings_help[] = null; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SERVER_COMPATIBILITY' => $language->get('admin', 'server_compatibility'), 'COMPAT_SUCCESS' => $compat_success, 'COMPAT_WARNINGS' => $compat_warnings, @@ -229,18 +238,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, @@ -264,7 +269,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 b751a64624..d403e401b5 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(); @@ -51,7 +60,7 @@ ]; } - $smarty->assign([ + $template->getEngine()->addVariables([ 'INTEGRATIONS_LIST' => $integrations_list, 'ENABLED' => $language->get('admin', 'enabled'), 'CAN_UNLINK' => $language->get('admin', 'can_unlink'), @@ -62,7 +71,7 @@ 'SYNC_USERNAME_VALUE' => Settings::get('username_sync'), ]); - $template_file = 'core/integrations.tpl'; + $template_file = 'core/integrations'; } else { // View integration settings $integration = $integrations->getIntegration($_GET['integration']); @@ -133,7 +142,7 @@ 'client_url' => rtrim(URL::getSelfURL(), '/') . URL::build('/oauth', 'provider=' . $provider_name, 'non-friendly'), ]; - $smarty->assign([ + $template->getEngine()->addVariables([ 'OAUTH' => $language->get('admin', 'oauth'), 'OAUTH_INFO' => $language->get('admin', 'oauth_info', [ 'docLinkStart' => '', @@ -148,7 +157,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'), @@ -160,10 +169,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'), @@ -183,16 +192,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'), ]); } @@ -201,7 +210,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/mass_message.php b/modules/Core/pages/panel/mass_message.php index 067e485eff..dc5653b7a8 100644 --- a/modules/Core/pages/panel/mass_message.php +++ b/modules/Core/pages/panel/mass_message.php @@ -10,12 +10,12 @@ /** * @var Cache $cache + * @var FakeSmarty $smarty * @var Language $language * @var Navigation $cc_nav * @var Navigation $navigation * @var Navigation $staffcp_nav * @var Pages $pages - * @var Smarty $smarty * @var TemplateBase $template * @var User $user * @var Widgets $widgets @@ -184,7 +184,7 @@ $allGroups = DB::getInstance()->query('SELECT id, name FROM nl2_groups')->results(); -$smarty->assign([ +$template->getEngine()->addVariables([ 'SENDING_MASS_MESSAGE' => $language->get('admin', 'sending_mass_message'), 'COMMUNICATIONS' => $language->get('admin', 'communications'), 'MASS_MESSAGE' => $language->get('admin', 'mass_message'), @@ -225,20 +225,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'), 'CONFIGURATION' => $language->get('admin', 'configuration'), @@ -253,4 +253,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/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 a22ec654e2..e03ed770f0 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); @@ -130,7 +139,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'), @@ -409,20 +418,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'), 'MODULES' => $language->get('admin', 'modules'), @@ -434,7 +443,7 @@ $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 77c9c6f1b2..37bf7605ce 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'), @@ -154,7 +163,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'PAGE' => PANEL_PAGE, 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), @@ -195,22 +204,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 8f7136c137..2f961e217c 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()) { @@ -103,23 +112,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'), ]); } @@ -143,7 +152,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'), @@ -180,7 +189,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..19ae485597 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': @@ -341,13 +349,14 @@ 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) { if ($template->getSettings()) { require_once($template->getSettings()); - $smarty->assign([ + $current_template->getEngine()->addVariables([ 'EDITING_TEMPLATE' => $language->get('admin', 'editing_template_x', [ 'template' => Text::bold(Output::getClean($template_query->name)) ]), @@ -357,7 +366,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')); } @@ -365,6 +374,7 @@ Redirect::to(URL::build('/panel/core/templates')); } + /** @var TemplateBase $template */ $template = $current_template; break; @@ -471,7 +481,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 +494,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 +515,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 +543,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'BACK' => $language->get('general', 'back'), 'BACK_LINK' => URL::build('/panel/core/templates/'), 'TEMPLATE_FILES' => $template_files, @@ -544,7 +554,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 +597,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 +608,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 +631,7 @@ $raw_type = pathinfo($file, PATHINFO_EXTENSION); $type_map = [ 'tpl' => 'smarty', + 'twig' => 'twig', 'css' => 'css', 'js' => 'javascript', 'conf' => 'properties' @@ -678,7 +689,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 +701,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 +735,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 83146c21cc..763adb4eef 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); @@ -282,43 +291,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'), @@ -330,9 +338,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; } @@ -383,7 +389,7 @@ ]; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), @@ -440,7 +446,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_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 c225c8edd1..13a3669bc7 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, ]); } @@ -148,21 +157,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'), @@ -174,7 +183,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'])) { @@ -227,11 +236,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(), @@ -280,8 +289,8 @@ $smarty->assign('REPORT_SERVER', Output::getClean($server)); } - // 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'), @@ -298,7 +307,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'), @@ -310,18 +319,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 @@ -411,32 +420,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/users_sessions.php b/modules/Core/pages/panel/users_sessions.php index 6d6ed2bf7f..3641bcd53b 100644 --- a/modules/Core/pages/panel/users_sessions.php +++ b/modules/Core/pages/panel/users_sessions.php @@ -12,7 +12,7 @@ * @var Navigation $navigation * @var Navigation $staffcp_nav * @var Pages $pages - * @var Smarty $smarty + * @var FakeSmarty $smarty * @var TemplateBase $template * @var User $user * @var Widgets $widgets @@ -83,7 +83,7 @@ ]; } -$smarty->assign([ +$template->getEngine()->addVariables([ 'VIEWING_USER_SESSIONS' => $language->get('admin', 'viewing_sessions_for_x', [ 'user' => Output::getClean($view_user->data()->username), ]), @@ -94,9 +94,6 @@ 'LOGOUT' => $language->get('general', 'log_out'), 'IP_ADDRESS' => $language->get('admin', 'ip_address'), 'LAST_SEEN' => $language->get('admin', 'last_seen'), -]); - -$smarty->assign([ 'PARENT_PAGE' => PARENT_PAGE, 'DASHBOARD' => $language->get('admin', 'dashboard'), 'USER_MANAGEMENT' => $language->get('admin', 'user_management'), @@ -109,14 +106,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,4 +121,4 @@ $template->onPageLoad(); require ROOT_PATH . '/core/templates/panel_navbar.php'; -$template->displayTemplate('core/users_sessions.tpl', $smarty); +$template->displayTemplate('core/users_sessions.tpl'); diff --git a/modules/Core/pages/panel/widgets.php b/modules/Core/pages/panel/widgets.php index fe61daed7a..4ef548b571 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)), ]), @@ -237,7 +247,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)), ]), @@ -245,7 +255,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'); } @@ -261,20 +271,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'), @@ -286,7 +296,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 36fea91595..92c6881c1c 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 @@ -465,12 +474,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 ]); } @@ -478,7 +487,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'), @@ -487,7 +496,7 @@ ]); if ($user->hasPermission('profile.private.bypass')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'CAN_VIEW' => true ]); } @@ -534,7 +543,7 @@ } } - $smarty->assign([ + $template->getEngine()->addVariables([ 'SELF' => true, 'SETTINGS_LINK' => URL::build('/user/settings'), 'CHANGE_BANNER' => $language->get('user', 'change_banner'), @@ -543,7 +552,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'), @@ -552,7 +561,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'), @@ -561,19 +570,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') ]); @@ -581,10 +590,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'), @@ -624,7 +633,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) { @@ -713,17 +722,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 @@ -771,10 +780,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(); @@ -808,9 +817,9 @@ 'value' => $query->profile_views ]; - $smarty->assign('ABOUT_FIELDS', $fields); + $template->getEngine()->addVariable('ABOUT_FIELDS', $fields); - $smarty->assign([ + $template->getEngine()->addVariables([ 'CAN_PROFILE_POST' => $user->isLoggedIn() && $user->hasPermission('profile.post'), 'REACTIONS' => $all_reactions, 'REACTIONS_BY_USER' => $reactions_by_user, @@ -831,7 +840,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 @@ -841,7 +850,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 @@ -849,35 +858,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 b6ca3ad0a3..483c96123b 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(); } } @@ -329,9 +338,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(); @@ -350,7 +359,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); @@ -382,7 +391,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']) ]), @@ -408,8 +417,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', [ @@ -430,7 +439,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'); @@ -449,8 +458,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 438d533714..794725e600 100644 --- a/modules/Core/pages/user/alerts.php +++ b/modules/Core/pages/user/alerts.php @@ -9,12 +9,12 @@ /** * @var Cache $cache + * @var FakeSmarty $smarty * @var Language $language * @var Navigation $cc_nav * @var Navigation $navigation * @var Navigation $staffcp_nav * @var Pages $pages - * @var Smarty $smarty * @var TemplateBase $template * @var User $user * @var Widgets $widgets @@ -67,11 +67,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, @@ -91,7 +91,7 @@ require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user/alerts.tpl', $smarty); + $template->displayTemplate('user/alerts'); } elseif ($_GET['action'] == 'purge') { if (Token::check()) { @@ -109,7 +109,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']]); if (!$alert->count() || $alert->first()->user_id !== $user->data()->id) { @@ -139,17 +139,17 @@ } if (Session::exists('alerts_error')) { - $smarty->assign('ERROR', Session::flash('alerts_error')); + $template->getEngine()->addVariable('ERROR', Session::flash('alerts_error')); } if ($alert->url && $alert->url !== '#') { - $smarty->assign([ + $template->getEngine()->addVariables([ 'VIEW' => $language->get('user', 'alerts_follow_link'), 'VIEW_LINK' => urlencode($alert->url), ]); } - $smarty->assign([ + $template->getEngine()->addVariables([ 'USER_CP' => $language->get('user', 'user_cp'), 'ALERTS' => $language->get('user', 'alerts'), 'DELETE' => $language->get('general', 'delete'), @@ -175,5 +175,5 @@ require ROOT_PATH . '/core/templates/footer.php'; // Display template - $template->displayTemplate('user/alert.tpl', $smarty); + $template->displayTemplate('user/alert.tpl'); } 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/notification_settings.php b/modules/Core/pages/user/notification_settings.php index cc0f26643f..fa36c588d4 100644 --- a/modules/Core/pages/user/notification_settings.php +++ b/modules/Core/pages/user/notification_settings.php @@ -9,12 +9,12 @@ /** * @var Cache $cache + * @var FakeSmarty $smarty * @var Language $language * @var Navigation $cc_nav * @var Navigation $navigation * @var Navigation $staffcp_nav * @var Pages $pages - * @var Smarty $smarty * @var TemplateBase $template * @var User $user * @var Widgets $widgets @@ -104,19 +104,19 @@ } if (Session::exists('notification_settings_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => Session::flash('notification_settings_success'), 'SUCCESS_TITLE' => $language->get('general', 'success'), ]); } if (isset($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, ]); } -$smarty->assign([ +$template->getEngine()->addVariables([ 'USER_CP' => $language->get('user', 'user_cp'), 'NOTIFICATION_SETTINGS_TITLE' => $language->get('user', 'notification_settings'), 'NOTIFICATION_SETTINGS' => $mappedPreferences, @@ -138,4 +138,4 @@ require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('user/notification_settings.tpl', $smarty); +$template->displayTemplate('user/notification_settings.tpl'); 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/sessions.php b/modules/Core/pages/user/sessions.php index 9c2b3d0b4a..26e2b77b92 100644 --- a/modules/Core/pages/user/sessions.php +++ b/modules/Core/pages/user/sessions.php @@ -13,7 +13,7 @@ * @var Navigation $navigation * @var Navigation $staffcp_nav * @var Pages $pages - * @var Smarty $smarty + * @var FakeSmarty $smarty * @var TemplateBase $template * @var User $user * @var Widgets $widgets @@ -48,14 +48,14 @@ } if (Session::exists('user_sessions_success')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'SUCCESS' => $language->get('general', 'success'), 'SUCCESS_MESSAGE' => Session::flash('user_sessions_success'), ]); } if (Session::exists('user_sessions_error')) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERROR' => $language->get('general', 'error'), 'ERROR_MESSAGE' => Session::flash('user_sessions_error'), ]); @@ -96,7 +96,7 @@ } } -$smarty->assign([ +$template->getEngine()->addVariables([ 'TOKEN' => Token::get(), 'NO' => $language->get('general', 'no'), 'YES' => $language->get('general', 'yes'), @@ -124,4 +124,4 @@ require ROOT_PATH . '/core/templates/footer.php'; // Display template -$template->displayTemplate('user/sessions.tpl', $smarty); +$template->displayTemplate('user/sessions.tpl'); diff --git a/modules/Core/pages/user/settings.php b/modules/Core/pages/user/settings.php index 8205dbf18f..4916c870f4 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') { @@ -50,8 +59,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), @@ -66,9 +75,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 @@ -97,10 +104,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'), @@ -111,11 +118,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') { @@ -563,7 +570,7 @@ } if (isset($errors) && count($errors)) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'ERRORS' => $errors, 'ERRORS_TITLE' => $language->get('general', 'error') ]); @@ -572,34 +579,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, @@ -631,7 +636,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'), @@ -643,7 +648,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; @@ -652,18 +657,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' @@ -676,13 +683,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 6e6fac8a9a..3c6f72d2ae 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 5ab923e347..e5de046abb 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; @@ -66,7 +65,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'), @@ -76,12 +75,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 fc5ca8f420..4a2d8f5ce4 100644 --- a/modules/Discord Integration/module.php +++ b/modules/Discord Integration/module.php @@ -1,4 +1,11 @@ Aberdeener'; - $module_version = '2.1.3'; - $nameless_version = '2.1.3'; + $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 cd5baec76b..f64b7a1c39 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.3'; - $nameless_version = '2.1.3'; + $author = 'Samerton'; + $module_version = '2.2.0'; + $nameless_version = '2.2.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -187,7 +185,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') @@ -238,7 +244,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? @@ -250,20 +256,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)]) + ]); } } @@ -378,11 +386,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 55e5f4ffa9..f289f5a5c8 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()) { @@ -183,21 +193,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(); @@ -237,7 +248,7 @@ } } - $smarty->assign('LABELS', $labels); + $template->getEngine()->addVariable('LABELS', $labels); } // Purify post content @@ -246,7 +257,7 @@ 'user' => $user ])['content']; -$smarty->assign([ +$template->getEngine()->addVariables([ 'TOKEN' => Token::get(), 'SUBMIT' => $language->get('general', 'submit'), 'CANCEL' => $language->get('general', 'cancel'), @@ -267,8 +278,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 64253e809b..b09406eca8 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) : []; @@ -232,11 +242,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(); @@ -247,8 +257,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')) : ''), @@ -284,8 +294,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 5af0beca73..9f0c01e5fc 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); @@ -396,9 +407,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 = [ @@ -450,17 +461,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 ]); @@ -470,29 +481,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)), @@ -514,7 +525,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)), @@ -531,7 +542,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 = []; @@ -563,7 +574,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)) { @@ -724,11 +735,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'), ]); @@ -737,7 +748,7 @@ if ($user->isLoggedIn()) { // Reactions if ($reactions_enabled) { - $smarty->assign([ + $template->getEngine()->addVariables([ 'REACTIONS' => $all_reactions, 'REACTIONS_BY_USER' => $reactions_by_user, ]); @@ -755,12 +766,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') ]); @@ -774,7 +785,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'])) { @@ -782,18 +793,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'), @@ -859,8 +868,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 d2ec65f48f..c95be0f119 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'])) { @@ -247,7 +257,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'), @@ -257,20 +267,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; @@ -450,14 +460,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; @@ -741,7 +751,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'), @@ -788,10 +798,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'; } } } @@ -808,20 +818,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'), @@ -834,7 +844,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 679fb8578d..c6bc9b028c 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()) { @@ -87,20 +97,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'), @@ -121,12 +131,12 @@ 'INFO' => $language->get('general', 'info'), '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 65afd9010e..103a5a4c77 100644 --- a/modules/Members/module.php +++ b/modules/Members/module.php @@ -1,12 +1,10 @@ Aberdeener'; - $module_version = '2.1.3'; - $nameless_version = '2.1.3'; + $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..f447045a02 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, ]); @@ -79,16 +90,18 @@ ? '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 ); $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 +110,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 +139,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');