X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FAdmin%2FThemes%2FEmbed.php;h=dabc9209e6be695ea27bcb04636babcc9265b481;hb=befc2af5043a3afde251721c0d27df695db1bb7e;hp=50ecff9322c42387794bed12dc44465e76f1eb3d;hpb=0406fe7adeb48775bd5a25638042f61c8d2b4fd1;p=friendica.git diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 50ecff9322..dabc9209e6 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Module\Admin\Themes; @@ -11,83 +30,59 @@ class Embed extends BaseAdmin { public static function init(array $parameters = []) { - $a = DI::app(); - - if ($a->argc > 2) { - // @TODO: Replace with parameter from router - $theme = $a->argv[2]; - $theme = Strings::sanitizeFilePathItem($theme); - if (is_file("view/theme/$theme/config.php")) { - $a->setCurrentTheme($theme); - } + $theme = Strings::sanitizeFilePathItem($parameters['theme']); + if (is_file("view/theme/$theme/config.php")) { + DI::app()->setCurrentTheme($theme); } } public static function post(array $parameters = []) { - parent::post($parameters); + self::checkAdminAccess(); - $a = DI::app(); - - if ($a->argc > 2) { - // @TODO: Replace with parameter from router - $theme = $a->argv[2]; - $theme = Strings::sanitizeFilePathItem($theme); - if (is_file("view/theme/$theme/config.php")) { + $theme = Strings::sanitizeFilePathItem($parameters['theme']); + if (is_file("view/theme/$theme/config.php")) { + require_once "view/theme/$theme/config.php"; + if (function_exists('theme_admin_post')) { self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings'); - - require_once "view/theme/$theme/config.php"; - - if (function_exists('theme_admin_post')) { - theme_admin_post($a); - } - } - - info(DI::l10n()->t('Theme settings updated.')); - - if (DI::mode()->isAjax()) { - return; + theme_admin_post(DI::app()); } + } - DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal'); + if (DI::mode()->isAjax()) { + return; } + + DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal'); } public static function content(array $parameters = []) { parent::content($parameters); - $a = DI::app(); - - if ($a->argc > 2) { - // @TODO: Replace with parameter from router - $theme = $a->argv[2]; - $theme = Strings::sanitizeFilePathItem($theme); - if (!is_dir("view/theme/$theme")) { - notice(DI::l10n()->t('Unknown theme.')); - return ''; - } + $theme = Strings::sanitizeFilePathItem($parameters['theme']); + if (!is_dir("view/theme/$theme")) { + notice(DI::l10n()->t('Unknown theme.')); + return ''; + } - $admin_form = ''; - if (is_file("view/theme/$theme/config.php")) { - require_once "view/theme/$theme/config.php"; + $admin_form = ''; + if (is_file("view/theme/$theme/config.php")) { + require_once "view/theme/$theme/config.php"; - if (function_exists('theme_admin')) { - $admin_form = theme_admin($a); - } + if (function_exists('theme_admin')) { + $admin_form = theme_admin(DI::app()); } - - // Overrides normal theme style include to strip user param to show embedded theme settings - Renderer::$theme['stylesheet'] = 'view/theme/' . $theme . '/style.pcss'; - - $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl'); - return Renderer::replaceMacros($t, [ - '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal', - '$form' => $admin_form, - '$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"), - ]); } - return ''; + // Overrides normal theme style include to strip user param to show embedded theme settings + Renderer::$theme['stylesheet'] = 'view/theme/' . $theme . '/style.pcss'; + + $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl'); + return Renderer::replaceMacros($t, [ + '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal', + '$form' => $admin_form, + '$form_security_token' => self::getFormSecurityToken("admin_theme_settings"), + ]); } }