Skip to content

Commit

Permalink
add AdminResponse and check. refs #2112 and refs #2500
Browse files Browse the repository at this point in the history
  • Loading branch information
craigh committed Jun 23, 2015
1 parent 504bdb2 commit f60791d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/lib/Zikula/Bundle/CoreBundle/EventListener/ThemeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
use Symfony\Component\HttpFoundation\JsonResponse;
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
{
Expand All @@ -43,7 +45,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()
Expand Down
25 changes: 25 additions & 0 deletions src/lib/Zikula/Core/Response/AdminResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Copyright Zikula Foundation 2015 - Zikula Application Framework
*
* This work is contributed to the Zikula Foundation under one or more
* Contributor Agreements and licensed to You under the following license:
*
* @license GNU/LGPLv3 (or at your option, any later version).
* @package Zikula
* @subpackage Response
*
* Please see the NOTICE file distributed with this source code for further
* information regarding copyright and licensing.
*/

namespace Zikula\Core\Response;

use Symfony\Component\HttpFoundation\Response;

/**
* Admin response will override theme.
*/
class AdminResponse extends Response
{
}

0 comments on commit f60791d

Please sign in to comment.