[TASK] Cleanup CssStyledContentController 51/19551/3
authorWouter Wolters <typo3@wouterwolters.nl>
Wed, 3 Apr 2013 22:15:01 +0000 (00:15 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 3 Apr 2013 22:58:13 +0000 (00:58 +0200)
* Make use of the "use" statement for GeneralUtility
* Long lines are spread over more lines for readability

Change-Id: Iea4bbfec9e672828fda5ad2d19f2d2a76268fa99
Resolves: #46902
Releases: 6.1
Reviewed-on: https://review.typo3.org/19551
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php

index 8e4d4ee..da4d173 100644 (file)
@@ -27,6 +27,8 @@ namespace TYPO3\CMS\CssStyledContent\Controller;
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Plugin class - instantiated from TypoScript.
  * Rendering some content elements from tt_content table.
@@ -84,7 +86,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                return '';
                        }
                        // Split into single lines:
-                       $lines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $content);
+                       $lines = GeneralUtility::trimExplode(LF, $content);
                        foreach ($lines as &$val) {
                                $val = '<li>' . $this->cObj->stdWrap($val, $conf['innerStdWrap.']) . '</li>';
                        }
@@ -146,10 +148,14 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                        $headerScope = $headerPos == 'top' ? 'col' : 'row';
                        $headerIdPrefix = $headerScope . $this->cObj->data['uid'] . '-';
                        // Split into single lines (will become table-rows):
-                       $rows = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $content);
+                       $rows = GeneralUtility::trimExplode(LF, $content);
                        reset($rows);
                        // Find number of columns to render:
-                       $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cObj->data['cols'] ? $this->cObj->data['cols'] : count(explode($delimiter, current($rows))), 0, 100);
+                       $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(
+                               $this->cObj->data['cols'] ? $this->cObj->data['cols'] : count(explode($delimiter, current($rows))),
+                               0,
+                               100
+                       );
                        // Traverse rows (rendering the table here)
                        $rCount = count($rows);
                        foreach ($rows as $k => $v) {
@@ -221,7 +227,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                        }
                        // Compile table output:
                        $out = '
-                               <table ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($tableTagParams) . '>' . $tableContents . '
+                               <table ' . GeneralUtility::implodeAttributes($tableTagParams) . '>' . $tableContents . '
                                </table>';
                        // Calling stdWrap:
                        if ($conf['stdWrap.']) {
@@ -259,22 +265,25 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                $field = trim($conf['field']) ? trim($conf['field']) : 'media';
                                $fileList = $this->cObj->data[$field];
                                $path = 'uploads/media/';
-                               if (is_array($GLOBALS['TCA']['tt_content']['columns'][$field]) && !empty($GLOBALS['TCA']['tt_content']['columns'][$field]['config']['uploadfolder'])) {
+                               if (
+                                       is_array($GLOBALS['TCA']['tt_content']['columns'][$field]) &&
+                                       !empty($GLOBALS['TCA']['tt_content']['columns'][$field]['config']['uploadfolder'])
+                               ) {
                                        // In TCA-Array folders are saved without trailing slash, so $path.$fileName won't work
                                        $path = $GLOBALS['TCA']['tt_content']['columns'][$field]['config']['uploadfolder'] . '/';
                                }
                        }
                        $path = trim($path);
                        // Explode into an array:
-                       $fileArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $fileList, 1);
+                       $fileArray = GeneralUtility::trimExplode(',', $fileList, 1);
                        // If there were files to list...:
                        if (count($fileArray)) {
                                // Get the descriptions for the files (if any):
-                               $descriptions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->cObj->data['imagecaption']);
+                               $descriptions = GeneralUtility::trimExplode(LF, $this->cObj->data['imagecaption']);
                                // Get the titles for the files (if any)
-                               $titles = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->cObj->data['titleText']);
+                               $titles = GeneralUtility::trimExplode(LF, $this->cObj->data['titleText']);
                                // Get the alternative text for icons/thumbnails
-                               $altTexts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->cObj->data['altText']);
+                               $altTexts = GeneralUtility::trimExplode(LF, $this->cObj->data['altText']);
                                // Add the target to linkProc when explicitly set
                                if ($this->cObj->data['target']) {
                                        $conf['linkProc.']['target'] = $this->cObj->data['target'];
@@ -303,12 +312,12 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                // Traverse the files found:
                                $filesData = array();
                                foreach ($fileArray as $key => $fileName) {
-                                       $absPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($path . $fileName));
+                                       $absPath = GeneralUtility::getFileAbsFileName(GeneralUtility::resolveBackPath($path . $fileName));
                                        if (@is_file($absPath)) {
                                                $fI = pathinfo($fileName);
                                                $filesData[$key] = array();
                                                $currentPath = $path;
-                                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($fileName, '../../')) {
+                                               if (GeneralUtility::isFirstPartOfStr($fileName, '../../')) {
                                                        $currentPath = '';
                                                        $fileName = substr($fileName, 6);
                                                }
@@ -331,7 +340,12 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                                $GLOBALS['TSFE']->register['fileSize'] = $filesData[$key]['filesize'];
                                                $GLOBALS['TSFE']->register['fileExtension'] = $filesData[$key]['fileextension'];
                                                $GLOBALS['TSFE']->register['description'] = $filesData[$key]['description'];
-                                               $filesData[$key]['linkedFilenameParts'] = $this->beautifyFileLink(explode('//**//', $this->cObj->filelink($fileName, $conf['linkProc.'])), $fileName, $conf['useSpacesInLinkText'], $conf['stripFileExtensionFromLinkText']);
+                                               $filesData[$key]['linkedFilenameParts'] = $this->beautifyFileLink(
+                                                       explode('//**//', $this->cObj->filelink($fileName, $conf['linkProc.'])),
+                                                       $fileName,
+                                                       $conf['useSpacesInLinkText'],
+                                                       $conf['stripFileExtensionFromLinkText']
+                                               );
                                        }
                                }
                                // optionSplit applied to conf to allow differnt settings per file
@@ -355,7 +369,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                        // Table tag params
                                        $tableTagParams = $this->getTableAttributes($conf, $type);
                                        $tableTagParams['class'] = 'csc-uploads csc-uploads-' . $type;
-                                       $outerWrap = '<table ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($tableTagParams) . '>|</table>';
+                                       $outerWrap = '<table ' . GeneralUtility::implodeAttributes($tableTagParams) . '>|</table>';
                                }
                                // Compile it all into table tags:
                                $out = $this->cObj->wrap(implode('', $outputEntries), $outerWrap);
@@ -394,7 +408,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                        if ($currentRelationValue >= 1) {
                                                $out[$a] = $currentRelationValue;
                                        } else {
-                                               \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('colRelations used with a value smaller than 1 therefore colRelations setting is ignored.', $this->extKey, 2);
+                                               GeneralUtility::devLog('colRelations used with a value smaller than 1 therefore colRelations setting is ignored.', $this->extKey, 2);
                                                unset($out);
                                                break;
                                        }
@@ -402,7 +416,12 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                if (max($out) / min($out) <= 10) {
                                        $relations = $out;
                                } else {
-                                       \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('The difference in size between the largest and smallest colRelation was not within a factor of ten therefore colRelations setting is ignored..', $this->extKey, 2);
+                                       GeneralUtility::devLog(
+                                               'The difference in size between the largest and smallest colRelation was not within' .
+                                               ' a factor of ten therefore colRelations setting is ignored..',
+                                               $this->extKey,
+                                               2
+                                       );
                                }
                        }
                }
@@ -476,7 +495,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                        }
                        return $content;
                }
-               $imgs = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $imgList);
+               $imgs = GeneralUtility::trimExplode(',', $imgList);
                $imgStart = intval($this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.']));
                $imgCount = count($imgs) - $imgStart;
                $imgMax = intval($this->cObj->stdWrap($conf['imgMax'], $conf['imgMax.']));
@@ -564,7 +583,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                $equalHeight = intval($this->cObj->stdWrap($conf['equalH'], $conf['equalH.']));
                if ($equalHeight) {
                        // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
-                       $gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Imaging\\GifBuilder');
+                       $gifCreator = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Imaging\\GifBuilder');
                        $gifCreator->init();
                        $relations_cols = array();
                        // contains the individual width of all images after scaling to $equalHeight
@@ -838,7 +857,9 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                }
                        }
                        // Set the margin for image + text, no wrap always to avoid multiple stylesheets
-                       $noWrapMargin = (int) (($maxWInText ? $maxWInText : $fiftyPercentWidthInText) + intval($this->cObj->stdWrap($conf['textMargin'], $conf['textMargin.'])));
+                       $noWrapMargin = (int) (($maxWInText ? $maxWInText : $fiftyPercentWidthInText) + intval(
+                               $this->cObj->stdWrap($conf['textMargin'], $conf['textMargin.'])
+                       ));
                        $this->addPageStyle('.csc-textpic-intext-right-nowrap .csc-textpic-text', 'margin-right: ' . $noWrapMargin . 'px;');
                        $this->addPageStyle('.csc-textpic-intext-left-nowrap .csc-textpic-text', 'margin-left: ' . $noWrapMargin . 'px;');
                        // Beside Text where the image block width is not equal to maxW
@@ -933,7 +954,10 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                        // Close this row at the end (colCount), or the last row at the final end
                                        if ($separateRows && $i + 1 == count($imgsTag)) {
                                                // Close the very last row with either normal configuration or lastRow stdWrap
-                                               $allRows .= $this->cObj->stdWrap($thisRow, is_array($conf['imageLastRowStdWrap.']) ? $conf['imageLastRowStdWrap.'] : $conf['imageRowStdWrap.']);
+                                               $allRows .= $this->cObj->stdWrap(
+                                                       $thisRow,
+                                                       is_array($conf['imageLastRowStdWrap.']) ? $conf['imageLastRowStdWrap.'] : $conf['imageRowStdWrap.']
+                                               );
                                        } elseif ($separateRows && $colPos == $colCount - 1) {
                                                $allRows .= $this->cObj->stdWrap($thisRow, $conf['imageRowStdWrap.']);
                                        }
@@ -1171,7 +1195,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                global $TYPO3_CONF_VARS;
                // Hook: menuConfig_preProcessModMenu
                if ($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]) {
-                       $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]);
+                       $hookObj = GeneralUtility::getUserObj($TYPO3_CONF_VARS['EXTCONF']['css_styled_content']['pi1_hooks'][$functionName]);
                        if (method_exists($hookObj, $functionName)) {
                                $hookObj->pObj = $this;
                                return $hookObj;