Skip to content

Commit

Permalink
[TASK] Use stdWrapValue where possible (part 2)
Browse files Browse the repository at this point in the history
This is the second part to replace stdWrap calls where stdWrapValue
is possible instead.
The type int is now a possible return type for stdWrapValue.
In addition stdWrapValue can return now the string "0" if returned by
stdWrap operation.

Resolves: #91834
Related: #91657
Releases: master
Change-Id: I70749fdb9f9cd56b86ed602afc9b742c1ed0046c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65064
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
nhovratov authored and maddy2101 committed Sep 5, 2020
1 parent 5be7b80 commit d53f549
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function getConfiguration(?string $extensionName = null, ?string $pluginN
FrontendSimulatorUtility::simulateFrontendEnvironment($this->getContentObject());
}
$conf = $this->typoScriptService->convertPlainArrayToTypoScriptArray($frameworkConfiguration['persistence']);
$frameworkConfiguration['persistence']['storagePid'] = $GLOBALS['TSFE']->cObj->stdWrap($conf['storagePid'], $conf['storagePid.']);
$frameworkConfiguration['persistence']['storagePid'] = $GLOBALS['TSFE']->cObj->stdWrapValue('storagePid', $conf);
if (!$this->environmentService->isEnvironmentInFrontendMode()) {
FrontendSimulatorUtility::resetFrontendEnvironment();
}
Expand Down
227 changes: 82 additions & 145 deletions typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2583,17 +2583,10 @@ public function generatePage_postProcessing()
*/
public function generatePageTitle(): string
{
$pageTitleSeparator = '';

// Check for a custom pageTitleSeparator, and perform stdWrap on it
if (isset($this->config['config']['pageTitleSeparator']) && $this->config['config']['pageTitleSeparator'] !== '') {
$pageTitleSeparator = $this->config['config']['pageTitleSeparator'];

if (isset($this->config['config']['pageTitleSeparator.']) && is_array($this->config['config']['pageTitleSeparator.'])) {
$pageTitleSeparator = $this->cObj->stdWrap($pageTitleSeparator, $this->config['config']['pageTitleSeparator.']);
} else {
$pageTitleSeparator .= ' ';
}
$pageTitleSeparator = $this->cObj->stdWrapValue('pageTitleSeparator', $this->config['config'] ?? []);
if ($pageTitleSeparator !== '' && $pageTitleSeparator === ($this->config['config']['pageTitleSeparator'] ?? '')) {
$pageTitleSeparator .= ' ';
}

$titleProvider = GeneralUtility::makeInstance(PageTitleProviderManager::class);
Expand All @@ -2613,10 +2606,9 @@ public function generatePageTitle(): string
(bool)($this->config['config']['pageTitleFirst'] ?? false),
$pageTitleSeparator
);
$this->config['config']['pageTitle'] = $titleTagContent;
// stdWrap around the title tag
if (isset($this->config['config']['pageTitle.']) && is_array($this->config['config']['pageTitle.'])) {
$titleTagContent = $this->cObj->stdWrap($titleTagContent, $this->config['config']['pageTitle.']);
}
$titleTagContent = $this->cObj->stdWrapValue('pageTitle', $this->config['config']);

// config.noPageTitle = 2 - means do not render the page title
if (isset($this->config['config']['noPageTitle']) && (int)$this->config['config']['noPageTitle'] === 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,7 @@ protected function prepareConfiguration(): void
$this->menuConfig = array_merge($this->menuConfig, $this->processorConfiguration);

// Process languages
if (empty($this->menuConfig['languages']) && empty($this->menuConfig['languages.'])) {
$this->menuConfig['special.']['value'] = 'auto';
} elseif (!empty($this->menuConfig['languages.'])) {
$this->menuConfig['special.']['value'] = $this->cObj->stdWrap($this->menuConfig['languages'], $this->menuConfig['languages.']);
} else {
$this->menuConfig['special.']['value'] = $this->menuConfig['languages'];
}
$this->menuConfig['special.']['value'] = $this->cObj->stdWrapValue('languages', $this->menuConfig, 'auto');

// Filter configuration
foreach ($this->menuConfig as $key => $value) {
Expand Down Expand Up @@ -450,11 +444,11 @@ public function getFieldAsJson(string $content, array $conf): string
{
// Support of stdWrap for parameters
if (isset($conf['language.'])) {
$conf['language'] = $this->cObj->stdWrap($conf['language'], $conf['language.']);
$conf['language'] = $this->cObj->stdWrapValue('language', $conf);
unset($conf['language.']);
}
if (isset($conf['field.'])) {
$conf['field'] = $this->cObj->stdWrap($conf['field'], $conf['field.']);
$conf['field'] = $this->cObj->stdWrapValue('field', $conf);
unset($conf['field.']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public function prepareConfiguration()
}
// Process special value
if (isset($this->menuConfig['special.']['value.'])) {
$this->menuConfig['special.']['value'] = $this->cObj->stdWrap($this->menuConfig['special.']['value'], $this->menuConfig['special.']['value.']);
$this->menuConfig['special.']['value'] = $this->cObj->stdWrapValue('value', $this->menuConfig['special.']);
unset($this->menuConfig['special.']['value.']);
}
}
Expand Down
10 changes: 3 additions & 7 deletions typo3/sysext/frontend/Classes/Http/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,11 @@ protected function processHtmlBasedRenderingSettings(TypoScriptFrontendControlle
$stylesFromPlugins = '';
foreach ($controller->tmpl->setup['plugin.'] as $key => $iCSScode) {
if (is_array($iCSScode)) {
if ($iCSScode['_CSS_DEFAULT_STYLE'] && empty($controller->config['config']['removeDefaultCss'])) {
if (isset($iCSScode['_CSS_DEFAULT_STYLE.'])) {
$cssDefaultStyle = $controller->cObj->stdWrap($iCSScode['_CSS_DEFAULT_STYLE'], $iCSScode['_CSS_DEFAULT_STYLE.']);
} else {
$cssDefaultStyle = $iCSScode['_CSS_DEFAULT_STYLE'];
}
if ($iCSScode['_CSS_DEFAULT_STYLE'] ?? false && empty($controller->config['config']['removeDefaultCss'])) {
$cssDefaultStyle = $controller->cObj->stdWrapValue('_CSS_DEFAULT_STYLE', $iCSScode);
$stylesFromPlugins .= '/* default styles for extension "' . substr($key, 0, -1) . '" */' . LF . $cssDefaultStyle . LF;
}
if ($iCSScode['_CSS_PAGE_STYLE'] && empty($controller->config['config']['removePageCss'])) {
if ($iCSScode['_CSS_PAGE_STYLE'] ?? false && empty($controller->config['config']['removePageCss'])) {
$cssPageStyle = implode(LF, $iCSScode['_CSS_PAGE_STYLE']);
if (isset($iCSScode['_CSS_PAGE_STYLE.'])) {
$cssPageStyle = $controller->cObj->stdWrap($cssPageStyle, $iCSScode['_CSS_PAGE_STYLE.']);
Expand Down
56 changes: 21 additions & 35 deletions typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,15 @@ public function start($conf, $data)
// Getting sorted list of TypoScript keys from setup.
$sKeyArray = ArrayUtility::filterAndSortByNumericKeys($this->setup);
// Setting the background color, passing it through stdWrap
if ($conf['backColor.'] || $conf['backColor']) {
$this->setup['backColor'] = isset($this->setup['backColor.']) ? trim($this->cObj->stdWrap($this->setup['backColor'], $this->setup['backColor.'])) : $this->setup['backColor'];
}
$this->setup['backColor'] = $this->cObj->stdWrapValue('backColor', $this->setup);
if (!$this->setup['backColor']) {
$this->setup['backColor'] = 'white';
}
if ($conf['transparentColor.'] || $conf['transparentColor']) {
$this->setup['transparentColor_array'] = isset($this->setup['transparentColor.']) ? explode('|', trim($this->cObj->stdWrap($this->setup['transparentColor'], $this->setup['transparentColor.']))) : explode('|', trim($this->setup['transparentColor']));
}
if (isset($this->setup['transparentBackground.'])) {
$this->setup['transparentBackground'] = $this->cObj->stdWrap($this->setup['transparentBackground'], $this->setup['transparentBackground.']);
}
if (isset($this->setup['reduceColors.'])) {
$this->setup['reduceColors'] = $this->cObj->stdWrap($this->setup['reduceColors'], $this->setup['reduceColors.']);
}
$this->setup['transparentColor_array'] = explode('|', trim($this->cObj->stdWrapValue('transparentColor', $this->setup)));
$this->setup['transparentBackground'] = $this->cObj->stdWrapValue('transparentBackground', $this->setup);
$this->setup['reduceColors'] = $this->cObj->stdWrapValue('reduceColors', $this->setup);
// Set default dimensions
if (isset($this->setup['XY.'])) {
$this->setup['XY'] = $this->cObj->stdWrap($this->setup['XY'], $this->setup['XY.']);
}
$this->setup['XY'] = $this->cObj->stdWrapValue('XY', $this->setup);
if (!$this->setup['XY']) {
$this->setup['XY'] = '120,50';
}
Expand All @@ -180,7 +170,7 @@ public function start($conf, $data)
case 'TEXT':
if ($this->setup[$theKey . '.'] = $this->checkTextObj($conf)) {
// Adjust font width if max size is set:
$maxWidth = isset($this->setup[$theKey . '.']['maxWidth.']) ? $this->cObj->stdWrap($this->setup[$theKey . '.']['maxWidth'], $this->setup[$theKey . '.']['maxWidth.']) : $this->setup[$theKey . '.']['maxWidth'];
$maxWidth = $this->cObj->stdWrapValue('maxWidth', $this->setup[$theKey . '.'] ?? []);
if ($maxWidth) {
$this->setup[$theKey . '.']['fontSize'] = $this->fontResize($this->setup[$theKey . '.']);
}
Expand Down Expand Up @@ -252,13 +242,9 @@ public function start($conf, $data)
}
// Calculate offsets on elements
$this->setup['XY'] = $this->calcOffset($this->setup['XY']);
if (isset($this->setup['offset.'])) {
$this->setup['offset'] = $this->cObj->stdWrap($this->setup['offset'], $this->setup['offset.']);
}
$this->setup['offset'] = $this->cObj->stdWrapValue('offset', $this->setup);
$this->setup['offset'] = $this->calcOffset($this->setup['offset']);
if (isset($this->setup['workArea.'])) {
$this->setup['workArea'] = $this->cObj->stdWrap($this->setup['workArea'], $this->setup['workArea.']);
}
$this->setup['workArea'] = $this->cObj->stdWrapValue('workArea', $this->setup);
$this->setup['workArea'] = $this->calcOffset($this->setup['workArea']);
foreach ($sKeyArray as $theKey) {
$theValue = $this->setup[$theKey];
Expand All @@ -268,7 +254,7 @@ public function start($conf, $data)

case 'IMAGE':
if (isset($this->setup[$theKey . '.']['offset.'])) {
$this->setup[$theKey . '.']['offset'] = $this->cObj->stdWrap($this->setup[$theKey . '.']['offset'], $this->setup[$theKey . '.']['offset.']);
$this->setup[$theKey . '.']['offset'] = $this->cObj->stdWrapValue('offset', $this->setup[$theKey . '.']);
unset($this->setup[$theKey . '.']['offset.']);
}
if ($this->setup[$theKey . '.']['offset']) {
Expand All @@ -279,7 +265,7 @@ public function start($conf, $data)

case 'ELLIPSE':
if (isset($this->setup[$theKey . '.']['dimensions.'])) {
$this->setup[$theKey . '.']['dimensions'] = $this->cObj->stdWrap($this->setup[$theKey . '.']['dimensions'], $this->setup[$theKey . '.']['dimensions.']);
$this->setup[$theKey . '.']['dimensions'] = $this->cObj->stdWrapValue('dimensions', $this->setup[$theKey . '.']);
unset($this->setup[$theKey . '.']['dimensions.']);
}
if ($this->setup[$theKey . '.']['dimensions']) {
Expand All @@ -288,7 +274,7 @@ public function start($conf, $data)
break;
case 'WORKAREA':
if (isset($this->setup[$theKey . '.']['set.'])) {
$this->setup[$theKey . '.']['set'] = $this->cObj->stdWrap($this->setup[$theKey . '.']['set'], $this->setup[$theKey . '.']['set.']);
$this->setup[$theKey . '.']['set'] = $this->cObj->stdWrapValue('set', $this->setup[$theKey . '.']);
unset($this->setup[$theKey . '.']['set.']);
}
if ($this->setup[$theKey . '.']['set']) {
Expand All @@ -297,7 +283,7 @@ public function start($conf, $data)
break;
case 'CROP':
if (isset($this->setup[$theKey . '.']['crop.'])) {
$this->setup[$theKey . '.']['crop'] = $this->cObj->stdWrap($this->setup[$theKey . '.']['crop'], $this->setup[$theKey . '.']['crop.']);
$this->setup[$theKey . '.']['crop'] = $this->cObj->stdWrapValue('crop', $this->setup[$theKey . '.']);
unset($this->setup[$theKey . '.']['crop.']);
}
if ($this->setup[$theKey . '.']['crop']) {
Expand All @@ -306,14 +292,14 @@ public function start($conf, $data)
break;
case 'SCALE':
if (isset($this->setup[$theKey . '.']['width.'])) {
$this->setup[$theKey . '.']['width'] = $this->cObj->stdWrap($this->setup[$theKey . '.']['width'], $this->setup[$theKey . '.']['width.']);
$this->setup[$theKey . '.']['width'] = $this->cObj->stdWrapValue('width', $this->setup[$theKey . '.']);
unset($this->setup[$theKey . '.']['width.']);
}
if ($this->setup[$theKey . '.']['width']) {
$this->setup[$theKey . '.']['width'] = $this->calcOffset($this->setup[$theKey . '.']['width']);
}
if (isset($this->setup[$theKey . '.']['height.'])) {
$this->setup[$theKey . '.']['height'] = $this->cObj->stdWrap($this->setup[$theKey . '.']['height'], $this->setup[$theKey . '.']['height.']);
$this->setup[$theKey . '.']['height'] = $this->cObj->stdWrapValue('height', $this->setup[$theKey . '.']);
unset($this->setup[$theKey . '.']['height.']);
}
if ($this->setup[$theKey . '.']['height']) {
Expand All @@ -325,8 +311,8 @@ public function start($conf, $data)
}
// Get trivial data
$XY = GeneralUtility::intExplode(',', $this->setup['XY']);
$maxWidth = isset($this->setup['maxWidth.']) ? (int)$this->cObj->stdWrap($this->setup['maxWidth'], $this->setup['maxWidth.']) : (int)$this->setup['maxWidth'];
$maxHeight = isset($this->setup['maxHeight.']) ? (int)$this->cObj->stdWrap($this->setup['maxHeight'], $this->setup['maxHeight.']) : (int)$this->setup['maxHeight'];
$maxWidth = (int)$this->cObj->stdWrapValue('maxWidth', $this->setup);
$maxHeight = (int)$this->cObj->stdWrapValue('maxHeight', $this->setup);
$XY[0] = MathUtility::forceIntegerInRange($XY[0], 1, $maxWidth ?: 2000);
$XY[1] = MathUtility::forceIntegerInRange($XY[1], 1, $maxHeight ?: 2000);
$this->XY = $XY;
Expand Down Expand Up @@ -419,7 +405,7 @@ public function make()
foreach ($conf as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf[$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$conf[$parameter] = $this->cObj->stdWrapValue($parameter, $conf);
$isStdWrapped[$parameter] = 1;
}
}
Expand All @@ -440,7 +426,7 @@ public function make()
foreach ($conf['shadow.'] as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf['shadow.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$conf['shadow.'][$parameter] = $this->cObj->stdWrapValue($parameter, $conf);
$isStdWrapped[$parameter] = 1;
}
}
Expand All @@ -451,7 +437,7 @@ public function make()
foreach ($conf['emboss.'] as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf['emboss.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$conf['emboss.'][$parameter] = $this->cObj->stdWrapValue($parameter, $conf);
$isStdWrapped[$parameter] = 1;
}
}
Expand All @@ -462,7 +448,7 @@ public function make()
foreach ($conf['outline.'] as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf['outline.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$conf['outline.'][$parameter] = $this->cObj->stdWrapValue($parameter, $conf);
$isStdWrapped[$parameter] = 1;
}
}
Expand Down Expand Up @@ -561,7 +547,7 @@ public function checkTextObj($conf)
foreach ($conf as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf[$parameter] = $cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$conf[$parameter] = $cObj->stdWrap($parameter, $conf);
$isStdWrapped[$parameter] = 1;
}
}
Expand Down
Loading

0 comments on commit d53f549

Please sign in to comment.