-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to enable backend skin if themes is loaded.
- Loading branch information
1 parent
fdfa43a
commit 2ef1c55
Showing
5 changed files
with
221 additions
and
20 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
Classes/Utility/ExtensionManagerConfigurationUtility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
namespace BK2K\BootstrapPackage\Utility; | ||
|
||
/*************************************************************** | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2014 Benjamin Kott, http://www.bk2k.info | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
***************************************************************/ | ||
|
||
use TYPO3\CMS\Core\Messaging\FlashMessage; | ||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; | ||
|
||
/** | ||
* @author Benjamin Kott <[email protected]> | ||
*/ | ||
class ExtensionManagerConfigurationUtility { | ||
|
||
/** | ||
* @var integer | ||
*/ | ||
protected $errorType = FlashMessage::OK; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $header; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $preText; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $problems = array(); | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $extConf = array(); | ||
|
||
/** | ||
* Set the error level if no higher level | ||
* is set already | ||
* | ||
* @param string $level One out of error, ok, warning, info | ||
* @return void | ||
*/ | ||
private function setErrorLevel($level) { | ||
switch ($level){ | ||
case 'error': | ||
$this->errorType = FlashMessage::ERROR; | ||
$this->header = 'Errors found in your configuration'; | ||
$this->preText = 'Bootstrap Package will not work until these problems have been resolved:<br />'; | ||
break; | ||
case 'warning': | ||
if ($this->errorType < FlashMessage::ERROR) { | ||
$this->errorType = FlashMessage::WARNING; | ||
$this->header = 'Warnings about your configuration'; | ||
$this->preText = 'Bootstra pPackage might behave different than expected:<br />'; | ||
} | ||
break; | ||
case 'info': | ||
if ($this->errorType < FlashMessage::WARNING) { | ||
$this->errorType = FlashMessage::INFO; | ||
$this->header = 'Additional information'; | ||
$this->preText = '<br />'; | ||
} | ||
break; | ||
case 'ok': | ||
if ($this->errorType < FlashMessage::WARNING && $this->errorType != FlashMessage::INFO) { | ||
$this->errorType = FlashMessage::OK; | ||
$this->header = 'No errors were found'; | ||
$this->preText = 'Bootstrap Package has been configured correctly and works as expected.<br />'; | ||
} | ||
break; | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Checks if ext:themes is loaded and throws an additional Warning | ||
* | ||
* @return string | ||
*/ | ||
public function checkIfThemesIsLoaded(&$params, &$tsObj){ | ||
if(!ExtensionManagementUtility::isLoaded('themes')){ | ||
$this->setErrorLevel('ok'); | ||
}else{ | ||
$this->setErrorLevel('warning'); | ||
$this->problems[] = "The backend skin functionality from the Bootstrap Package is disabled by default if ext:themes is loaded."; | ||
} | ||
if (count($this->problems) > 0){ | ||
$message = '<ul>'; | ||
foreach($this->problems as $problem){ | ||
$message.= '<li>' . $problem . '</li>'; | ||
} | ||
$message.= '</ul>'; | ||
} | ||
$message = $this->preText . $message; | ||
$flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, $this->header, $this->errorType); | ||
$out = $flashMessage->render(); | ||
return $out; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> | ||
<xliff version="1.0"> | ||
<file source-language="en" datatype="plaintext" original="messages" date="2013-09-19T09:11:39Z" product-name="bootstrap_package"> | ||
<header/> | ||
<body> | ||
|
||
<trans-unit id="compat.extThemes"> | ||
<source>Themes</source> | ||
</trans-unit> | ||
|
||
<trans-unit id="backendSkin.alwaysEnableBackendSkin"> | ||
<source>Always enable the backend skin: The backend skin is disabled by default if ext:themes is installed, but you can force to load the backend_skin.</source> | ||
</trans-unit> | ||
<trans-unit id="backendSkin.logoTop"> | ||
<source>Logo Top: Default [../typo3conf/ext/bootstrap_package/Resources/Public/Images/Backend/[email protected]]</source> | ||
</trans-unit> | ||
<trans-unit id="backendSkin.logoLogin"> | ||
<source>Logo Login: Default [../typo3conf/ext/bootstrap_package/Resources/Public/Images/Backend/LoginLogo.png]</source> | ||
</trans-unit> | ||
|
||
<trans-unit id="realUrl.useRealUrlConfig"> | ||
<source>Use RealUrl Config from BootstrapPackage</source> | ||
</trans-unit> | ||
|
||
</body> | ||
</file> | ||
</xliff> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
# cat=Basic/Skin/10; type=string; label=Logo Top: Default [../typo3conf/ext/bootstrap_package/Resources/Public/Images/Backend/[email protected]] | ||
############################ | ||
### CUSTOM SUBCATEGORIES ### | ||
########################### | ||
# customsubcategory=100_compat=Compatibility | ||
# customsubcategory=110_skin=Backend Skin | ||
# customsubcategory=120_realurl=RealUrl | ||
|
||
# cat=General/120_realurl/10; type=boolean; label=LLL:EXT:bootstrap_package/Resources/Private/Language/ExtConfTemplate.xlf:realUrl.useRealUrlConfig | ||
UseRealUrlConfig = 1 | ||
|
||
# cat=General/110_skin/10; type=boolean; label=LLL:EXT:bootstrap_package/Resources/Private/Language/ExtConfTemplate.xlf:backendSkin.alwaysEnableBackendSkin | ||
AlwaysEnableBackendSkin = 0 | ||
|
||
# cat=General/110_skin/20; type=string; label=LLL:EXT:bootstrap_package/Resources/Private/Language/ExtConfTemplate.xlf:backendSkin.logoTop | ||
Logo = ../typo3conf/ext/bootstrap_package/Resources/Public/Images/Backend/[email protected] | ||
|
||
# cat=Basic/Skin/20; type=string; label=Logo Login: Default [../typo3conf/ext/bootstrap_package/Resources/Public/Images/Backend/LoginLogo.png] | ||
# cat=General/110_skin/30; type=string; label=LLL:EXT:bootstrap_package/Resources/Private/Language/ExtConfTemplate.xlf:backendSkin.logoLogin | ||
LoginLogo = ../typo3conf/ext/bootstrap_package/Resources/Public/Images/Backend/LoginLogo.png | ||
|
||
# cat=Basic/RealUrl/10; type=boolean; label=Use RealUrl Config from BootstrapPackage | ||
UseRealUrlConfig = 1 | ||
# cat=General/100_compat/10; type=user[\BK2K\BootstrapPackage\Utility\ExtensionManagerConfigurationUtility->checkIfThemesIsLoaded]; label=LLL:EXT:bootstrap_package/Resources/Private/Language/ExtConfTemplate.xlf:compat.extThemes | ||
checkIfThemesIsLoaded = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,15 @@ | |
|
||
|
||
/*************** | ||
* Load functions only if themes extension is not installed | ||
* | ||
* - let themes handle the includion of the needed static files | ||
* - enable backendskin only if themes is not installed | ||
* Make the extension configuration accessible | ||
*/ | ||
if(!is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY])){ | ||
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]); | ||
} | ||
|
||
|
||
/*************** | ||
* Let ext:themes the inclusion of the needed static files handle if loaded | ||
*/ | ||
if(!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('themes')) { | ||
|
||
|
@@ -17,21 +22,27 @@ | |
*/ | ||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Bootstrap Package'); | ||
|
||
} | ||
|
||
|
||
/*************** | ||
* Disable the backend skin if ext:themes is loaded and loading of the backend skin is not forced | ||
*/ | ||
if(!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('themes') || $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]['AlwaysEnableBackendSkin']) { | ||
|
||
/*************** | ||
* Backend Styling | ||
*/ | ||
if (TYPO3_MODE == 'BE') { | ||
$settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]); | ||
if(!isset($settings['Logo'])){ | ||
$settings['Logo'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Images/Backend/[email protected]'; | ||
if(!isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]['Logo'])){ | ||
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]['Logo'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Images/Backend/[email protected]'; | ||
} | ||
if(!isset($settings['LoginLogo'])){ | ||
$settings['LoginLogo'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Images/Backend/LoginLogo.png'; | ||
if(!isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]['LoginLogo'])){ | ||
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]['LoginLogo'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Images/Backend/LoginLogo.png'; | ||
} | ||
$GLOBALS['TBE_STYLES']['logo'] = $settings['Logo']; | ||
$GLOBALS['TBE_STYLES']['logo_login'] = $settings['LoginLogo']; | ||
$GLOBALS['TBE_STYLES']['logo'] = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]['Logo']; | ||
$GLOBALS['TBE_STYLES']['logo_login'] = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]['LoginLogo']; | ||
$GLOBALS['TBE_STYLES']['htmlTemplates']['EXT:backend/Resources/Private/Templates/login.html'] = 'EXT:bootstrap_package/Resources/Private/Templates/Backend/Login.html'; | ||
unset($settings); | ||
} | ||
|
||
} | ||
|
@@ -699,3 +710,11 @@ | |
); | ||
|
||
} | ||
|
||
|
||
/*************** | ||
* Reset extConf array to avoid errors | ||
*/ | ||
if(is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY])){ | ||
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY] = serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]); | ||
} |