From a5f094480d67a9a1b9132a24d13db712e31440b3 Mon Sep 17 00:00:00 2001 From: Craig Heydenburg Date: Mon, 22 Jun 2015 09:46:21 -0400 Subject: [PATCH] add AdminResponse and check. refs #2112 and refs #2500 --- .../EventListener/ThemeListener.php | 22 +++++++++++++++- .../Zikula/Core/Response/AdminResponse.php | 25 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/lib/Zikula/Core/Response/AdminResponse.php diff --git a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ThemeListener.php b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ThemeListener.php index d3eb9ca7eb..8b61dc81c7 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ThemeListener.php +++ b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ThemeListener.php @@ -17,8 +17,10 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; +use Zikula\Core\Response\AdminResponse; use Zikula\Core\Response\PlainResponse; use Zikula_View_Theme; +use Zikula\Core\Event\GenericEvent; class ThemeListener implements EventSubscriberInterface { @@ -45,7 +47,25 @@ public function onKernelResponse(FilterResponseEvent $event) return; } - Zikula_View_Theme::getInstance()->themefooter($response); + $themeName = ''; + $smartyCaching = null; + + /** + * If Response is an AdminResponse, then change theme to the requested Admin theme (if set) + */ + if ($response instanceof AdminResponse) { + $adminTheme = \ModUtil::getVar('ZikulaAdminModule', 'admintheme'); + if (!empty($adminTheme)) { + $themeInfo = \ThemeUtil::getInfo(\ThemeUtil::getIDFromName($adminTheme)); + if ($themeInfo && $themeInfo['state'] == \ThemeUtil::STATE_ACTIVE && is_dir('themes/' . \DataUtil::formatForOS($themeInfo['directory']))) { + $event = new GenericEvent(null, array('type' => 'admin-theme'), $themeInfo['name']); + $themeName = \EventUtil::dispatch('user.gettheme', $event)->getData(); + $smartyCaching = false; + $_GET['type'] = 'admin'; // required for smarty and FormUtil::getPassedValue() to use the right pagetype from pageconfigurations.ini + } + } + } + Zikula_View_Theme::getInstance($themeName, $smartyCaching)->themefooter($response); } public static function getSubscribedEvents() diff --git a/src/lib/Zikula/Core/Response/AdminResponse.php b/src/lib/Zikula/Core/Response/AdminResponse.php new file mode 100644 index 0000000000..46768065ed --- /dev/null +++ b/src/lib/Zikula/Core/Response/AdminResponse.php @@ -0,0 +1,25 @@ +