-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from typo3-themes/analysis-227P9A
Apply fixes from StyleCI
- Loading branch information
Showing
3 changed files
with
69 additions
and
69 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -205,4 +205,3 @@ public function addTypoScriptForFe(&$params, TemplateService &$pObj, $extensions | |
} | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -76,4 +76,3 @@ public function init(&$params, $pObj) | |
} | ||
} | ||
} | ||
|
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,18 +1,20 @@ | ||
<?php | ||
|
||
namespace KayStrobach\Themes\ViewHelpers; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* Access constants | ||
* | ||
* @author Thomas Deuling <[email protected]> | ||
* @package themes | ||
* | ||
* | ||
* @deprecated readd constantsviewhelper to ensure compatibility to old themes | ||
* | ||
* | ||
*/ | ||
class ConstantViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper { | ||
class ConstantViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper | ||
{ | ||
|
||
/** | ||
* Initialize arguments. | ||
|
@@ -24,76 +26,76 @@ public function initializeArguments() | |
$this->registerArgument('constant', 'string', 'the constant path', false, ''); | ||
} | ||
|
||
/** | ||
* Gets a constant | ||
* | ||
* @param string $constant The name of the constant | ||
* @return string Constant-Value | ||
* | ||
* = Examples = | ||
* | ||
* <code title="Example"> | ||
* <theme:constant constant="themes.configuration.baseurl" /> | ||
* </code> | ||
* <output> | ||
* http://yourdomain.tld/ | ||
* (depending on your domain) | ||
* </output> | ||
*/ | ||
public function render() | ||
/** | ||
* Gets a constant | ||
* | ||
* @param string $constant The name of the constant | ||
* @return string Constant-Value | ||
* | ||
* = Examples = | ||
* | ||
* <code title="Example"> | ||
* <theme:constant constant="themes.configuration.baseurl" /> | ||
* </code> | ||
* <output> | ||
* http://yourdomain.tld/ | ||
* (depending on your domain) | ||
* </output> | ||
*/ | ||
public function render() | ||
{ | ||
$constant = $this->arguments['constant']; | ||
|
||
$pageWithTheme = \KayStrobach\Themes\Utilities\FindParentPageWithThemeUtility::find($this->getFrontendController()->id); | ||
$pageLanguage = (int)GeneralUtility::_GP('L'); | ||
// instantiate the cache | ||
/** @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache */ | ||
$cache = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('themes_cache'); | ||
$cacheLifeTime = 60 * 60 * 24 * 7 * 365 * 20; | ||
$cacheIdentifierString = 'theme-of-page-' . $pageWithTheme . '-of-language-' . $pageLanguage; | ||
$cacheIdentifier = sha1($cacheIdentifierString); | ||
$pageWithTheme = \KayStrobach\Themes\Utilities\FindParentPageWithThemeUtility::find($this->getFrontendController()->id); | ||
$pageLanguage = (int)GeneralUtility::_GP('L'); | ||
// instantiate the cache | ||
/** @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache */ | ||
$cache = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('themes_cache'); | ||
$cacheLifeTime = 60 * 60 * 24 * 7 * 365 * 20; | ||
$cacheIdentifierString = 'theme-of-page-' . $pageWithTheme . '-of-language-' . $pageLanguage; | ||
$cacheIdentifier = sha1($cacheIdentifierString); | ||
|
||
// If flatSetup is available, cache it | ||
$flatSetup = $this->getFrontendController()->tmpl->flatSetup; | ||
if ((isset($flatSetup) && (is_array($flatSetup)) && (count($flatSetup) > 0))) { | ||
$cache->set( | ||
$cacheIdentifier, | ||
$flatSetup, | ||
array( | ||
'page-' . $this->getFrontendController()->id | ||
), | ||
$cacheLifeTime | ||
); | ||
} else { | ||
$flatSetup = $cache->get($cacheIdentifier); | ||
} | ||
// If flatSetup is available, cache it | ||
$flatSetup = $this->getFrontendController()->tmpl->flatSetup; | ||
if ((isset($flatSetup) && (is_array($flatSetup)) && (count($flatSetup) > 0))) { | ||
$cache->set( | ||
$cacheIdentifier, | ||
$flatSetup, | ||
array( | ||
'page-' . $this->getFrontendController()->id | ||
), | ||
$cacheLifeTime | ||
); | ||
} else { | ||
$flatSetup = $cache->get($cacheIdentifier); | ||
} | ||
|
||
// If flatSetup not available and not cached, generate it! | ||
if (!isset($flatSetup) || !is_array($flatSetup)) { | ||
$this->getFrontendController()->tmpl->generateConfig(); | ||
$flatSetup = $this->getFrontendController()->tmpl->flatSetup; | ||
$cache->set( | ||
$cacheIdentifier, | ||
$flatSetup, | ||
array( | ||
'page-' . $this->getFrontendController()->id | ||
), | ||
$cacheLifeTime | ||
); | ||
} | ||
// If flatSetup not available and not cached, generate it! | ||
if (!isset($flatSetup) || !is_array($flatSetup)) { | ||
$this->getFrontendController()->tmpl->generateConfig(); | ||
$flatSetup = $this->getFrontendController()->tmpl->flatSetup; | ||
$cache->set( | ||
$cacheIdentifier, | ||
$flatSetup, | ||
array( | ||
'page-' . $this->getFrontendController()->id | ||
), | ||
$cacheLifeTime | ||
); | ||
} | ||
|
||
// check if there is a value and return it | ||
if ((is_array($flatSetup)) && (array_key_exists($constant, $flatSetup))) { | ||
return $this->getFrontendController()->tmpl->substituteConstants($flatSetup[$constant]); | ||
} | ||
return NULL; | ||
} | ||
// check if there is a value and return it | ||
if ((is_array($flatSetup)) && (array_key_exists($constant, $flatSetup))) { | ||
return $this->getFrontendController()->tmpl->substituteConstants($flatSetup[$constant]); | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController | ||
*/ | ||
public function getFrontendController() | ||
/** | ||
* @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController | ||
*/ | ||
public function getFrontendController() | ||
{ | ||
return $GLOBALS['TSFE']; | ||
} | ||
return $GLOBALS['TSFE']; | ||
} | ||
} |