[TASK] Code cleanup EXT:backend/Classes/Controller/ContentElement/*.php 12/37512/9
authorMichael Oehlhof <typo3@oehlhof.de>
Tue, 3 Mar 2015 22:19:19 +0000 (23:19 +0100)
committerFrank Nägler <typo3@naegler.net>
Wed, 3 Jun 2015 19:34:31 +0000 (21:34 +0200)
- add missing return values
- declare missing class variables
- remove unused variable assingments
- add getter for LanguageService
- add getter for BackendUser

Resolves: #65497
Releases: master
Change-Id: If6303319811e8c5c0979403c4399f8aa19459eb8
Reviewed-on: http://review.typo3.org/37512
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
typo3/sysext/backend/Classes/Controller/ContentElement/ElementHistoryController.php
typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
typo3/sysext/backend/Classes/Controller/ContentElement/MoveElementController.php
typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php

index 4036abc..557d82c 100644 (file)
@@ -37,10 +37,15 @@ class ElementHistoryController {
        public $doc;
 
        /**
+        * @var array
+        */
+       protected $pageInfo;
+
+       /**
         * Constructor
         */
        public function __construct() {
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_show_rechis.xlf');
+               $this->getLanguageService()->includeLLFile('EXT:lang/locallang_show_rechis.xlf');
                $GLOBALS['SOBE'] = $this;
 
                $this->init();
@@ -57,7 +62,7 @@ class ElementHistoryController {
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
                $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/show_rechis.html');
                // Start the page header
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('title'));
+               $this->content .= $this->doc->header($this->getLanguageService()->getLL('title'));
        }
 
        /**
@@ -75,8 +80,8 @@ class ElementHistoryController {
                $markers['CONTENT'] = $this->content;
                $markers['CSH'] = $docHeaderButtons['csh'];
                // Build the <body> for the module
-               $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
-               $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content = $this->doc->startPage($this->getLanguageService()->getLL('title'));
+               $this->content .= $this->doc->moduleBody($this->pageInfo, $docHeaderButtons, $markers);
        }
 
        /**
@@ -110,4 +115,13 @@ class ElementHistoryController {
                return $buttons;
        }
 
+       /**
+        * Returns LanguageService
+        *
+        * @return \TYPO3\CMS\Lang\LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
 }
index a59e47d..505ea6e 100644 (file)
@@ -77,7 +77,7 @@ class ElementInformationController {
         *
         * @var array
         */
-       public $pageinfo;
+       public $pageInfo;
 
        /**
         * Database records identified by table/uid
@@ -123,7 +123,7 @@ class ElementInformationController {
                $this->table = GeneralUtility::_GET('table');
                $this->uid = GeneralUtility::_GET('uid');
 
-               $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
+               $this->permsClause = $this->getBackendUser()->getPagePermsClause(1);
                $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
                $this->doc->divClass = 'container';
 
@@ -142,16 +142,16 @@ class ElementInformationController {
                $this->uid = (int)$this->uid;
 
                // Check permissions and uid value:
-               if ($this->uid && $GLOBALS['BE_USER']->check('tables_select', $this->table)) {
+               if ($this->uid && $this->getBackendUser()->check('tables_select', $this->table)) {
                        if ((string)$this->table == 'pages') {
-                               $this->pageinfo = BackendUtility::readPageAccess($this->uid, $this->perms_clause);
-                               $this->access = is_array($this->pageinfo) ? 1 : 0;
-                               $this->row = $this->pageinfo;
+                               $this->pageInfo = BackendUtility::readPageAccess($this->uid, $this->permsClause);
+                               $this->access = is_array($this->pageInfo) ? 1 : 0;
+                               $this->row = $this->pageInfo;
                        } else {
                                $this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
                                if ($this->row) {
-                                       $this->pageinfo = BackendUtility::readPageAccess($this->row['pid'], $this->perms_clause);
-                                       $this->access = is_array($this->pageinfo) ? 1 : 0;
+                                       $this->pageInfo = BackendUtility::readPageAccess($this->row['pid'], $this->permsClause);
+                                       $this->access = is_array($this->pageInfo) ? 1 : 0;
                                }
                        }
                        /** @var $treatData \TYPO3\CMS\Backend\Form\DataPreprocessor */
@@ -224,14 +224,14 @@ class ElementInformationController {
         */
        protected function renderPageTitle() {
                if ($this->type === 'folder') {
-                       $table = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder');
+                       $table = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:folder');
                        $title = $this->doc->getResourceHeader($this->folderObject, array(' ', ''), FALSE);
                } elseif ($this->type === 'file') {
-                       $table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
+                       $table = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
                        $title = $this->doc->getResourceHeader($this->fileObject, array(' ', ''), FALSE);
                } else {
-                       $table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
-                       $title = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1, array(' ', ''), FALSE);
+                       $table = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
+                       $title = $this->doc->getHeader($this->table, $this->row, $this->pageInfo['_thePath'], 1, array(' ', ''), FALSE);
                }
                // Set HTML title tag
                $this->titleTag = $table . ': ' . strip_tags(BackendUtility::getRecordTitle($this->table, $this->row));
@@ -249,7 +249,7 @@ class ElementInformationController {
        protected function renderPreview() {
                // Perhaps @todo in future: Also display preview for records - without fileObject
                if (!$this->fileObject) {
-                       return;
+                       return '';
                }
 
                $previewTag = '';
@@ -303,7 +303,7 @@ class ElementInformationController {
                                $downloadLink .= '
                                        <a class="btn btn-primary" href="' . htmlspecialchars($url) . '" target="_blank">
                                                ' . IconUtility::getSpriteIcon('actions-edit-download') . '
-                                               ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:download', TRUE) . '
+                                               ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:download', TRUE) . '
                                        </a>';
                        }
                }
@@ -321,17 +321,18 @@ class ElementInformationController {
                $tableRows = array();
                $extraFields = array();
 
+               $lang = $this->getLanguageService();
                if (in_array($this->type, array('folder', 'file'), TRUE)) {
                        if ($this->type === 'file') {
-                               $extraFields['creation_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
-                               $extraFields['modification_date'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
+                               $extraFields['creation_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
+                               $extraFields['modification_date'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
                        }
-                       $extraFields['storage'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', TRUE);
-                       $extraFields['folder'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder', TRUE);
+                       $extraFields['storage'] = $lang->sL('LLL:EXT:lang/locallang_tca.xlf:sys_file.storage', TRUE);
+                       $extraFields['folder'] = $lang->sL('LLL:EXT:lang/locallang_common.xlf:folder', TRUE);
                } else {
-                       $extraFields['crdate'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
-                       $extraFields['cruser_id'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
-                       $extraFields['tstamp'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
+                       $extraFields['crdate'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
+                       $extraFields['cruser_id'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
+                       $extraFields['tstamp'] = $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
 
                        // check if the special fields are defined in the TCA ctrl section of the table
                        foreach ($extraFields as $fieldName => $fieldLabel) {
@@ -359,7 +360,7 @@ class ElementInformationController {
                        }
                        // show the backend username who created the issue
                        if ($name === 'cruser_id' && $rowValue) {
-                               $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
+                               $userTemp = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
                                if ($userTemp[0]['username'] !== '') {
                                        $rowValue = $userTemp[0]['username'];
                                        if ($userTemp[0]['realName'] !== '') {
@@ -389,13 +390,13 @@ class ElementInformationController {
                                continue;
                        }
 
-                       $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
+                       $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
                        if ($isExcluded) {
                                continue;
                        }
 
                        $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
-                       $itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
+                       $itemLabel = $lang->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
                        $tableRows[] = '
                                <tr>
                                        <th>' . $itemLabel . '</th>
@@ -423,12 +424,12 @@ class ElementInformationController {
                        case 'db': {
                                $references = $this->makeRef($this->table, $this->row['uid']);
                                if (!empty($references)) {
-                                       $content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem'), $references);
+                                       $content .= $this->doc->section($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem'), $references);
                                }
 
                                $referencesFrom = $this->makeRefFrom($this->table, $this->row['uid']);
                                if (!empty($referencesFrom)) {
-                                       $content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem'), $referencesFrom);
+                                       $content .= $this->doc->section($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesFromThisItem'), $referencesFrom);
                                }
                                break;
                        }
@@ -438,7 +439,7 @@ class ElementInformationController {
                                        $references = $this->makeRef('_FILE', $this->fileObject);
 
                                        if (!empty($references)) {
-                                               $header = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem');
+                                               $header = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.referencesToThisItem');
                                                $content .= $this->doc->section($header, $references);
                                        }
                                }
@@ -461,7 +462,7 @@ class ElementInformationController {
                        $backLink .= '
                                <a class="btn btn-primary" href="' . htmlspecialchars($returnUrl) . '>
                                        ' . IconUtility::getSpriteIcon('actions-view-go-back') . '
-                                       ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:back', TRUE) . '
+                                       ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:back', TRUE) . '
                                </a>';
                }
                return $backLink;
@@ -479,13 +480,13 @@ class ElementInformationController {
                        if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
                                continue;
                        }
-                       $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table . ':' . $name));
+                       $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
                        if ($isExcluded) {
                                continue;
                        }
                        $uid = $this->row['uid'];
                        $itemValue = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, FALSE, $uid);
-                       $itemLabel = $GLOBALS['LANG']->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
+                       $itemLabel = $this->getLanguageService()->sL(BackendUtility::getItemLabel($this->table, $name), TRUE);
                        $tableRows[] = '
                                <tr>
                                        <th>' . $itemLabel . '</th>
@@ -512,8 +513,8 @@ class ElementInformationController {
         */
        public function printContent() {
                echo $this->doc->startPage($this->titleTag) .
-                               $this->doc->insertStylesAndJS($this->content) .
-                               $this->doc->endPage();
+                       $this->doc->insertStylesAndJS($this->content) .
+                       $this->doc->endPage();
        }
 
        /**
@@ -525,7 +526,7 @@ class ElementInformationController {
         */
        public function getLabelForTableColumn($tableName, $fieldName) {
                if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== NULL) {
-                       $field = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
+                       $field = $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
                        if (trim($field) === '') {
                                $field = $fieldName;
                        }
@@ -574,14 +575,14 @@ class ElementInformationController {
                        // Recordlist button
                        $url = BackendUtility::getModuleUrl('web_list', array('id' => $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')));
                        $pageActionIcons .= '
-                               <a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showList') . '">
+                               <a class="btn btn-default btn-sm" href="' . htmlspecialchars($url) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showList') . '">
                                        ' . IconUtility::getSpriteIcon('actions-system-list-open') . '
                                </a>';
 
                        // View page button
                        $viewOnClick = BackendUtility::viewOnClick($uid, '', BackendUtility::BEgetRootLine($uid));
                        $pageActionIcons .= '
-                               <a class="btn btn-default btn-sm" href="#" onclick="' . htmlspecialchars($viewOnClick) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">
+                               <a class="btn btn-default btn-sm" href="#" onclick="' . htmlspecialchars($viewOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">
                                        ' . IconUtility::getSpriteIcon('actions-document-view') . '
                                </a>';
                }
@@ -600,6 +601,7 @@ class ElementInformationController {
         * @return string HTML
         */
        protected function makeRef($table, $ref) {
+               $lang = $this->getLanguageService();
                // Files reside in sys_file table
                if ($table === '_FILE') {
                        $selectTable = 'sys_file';
@@ -608,10 +610,10 @@ class ElementInformationController {
                        $selectTable = $table;
                        $selectUid = $ref;
                }
-               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+               $rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
                        '*',
                        'sys_refindex',
-                       'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . (int)$selectUid . ' AND deleted=0'
+                       'ref_table=' . $this->getDatabaseConnection()->fullQuoteStr($selectTable, 'sys_refindex') . ' AND ref_uid=' . (int)$selectUid . ' AND deleted=0'
                );
 
                // Compile information for title tag:
@@ -621,13 +623,13 @@ class ElementInformationController {
                        $infoDataHeader = '
                                <tr>
                                        <th class="col-icon"></th>
-                                       <th class="col-title">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
+                                       <th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
                                        <th class="col-control"></th>
                                </tr>';
                }
@@ -659,9 +661,9 @@ class ElementInformationController {
                                                        ' . BackendUtility::getRecordTitle($row['tablename'], $record, TRUE) . '
                                                </a>
                                        </td>
-                                       <td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>
+                                       <td>' . $lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title'], TRUE) . '</td>
                                        <td>
-                                               <span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': '
+                                               <span title="' . $lang->sL('LLL:EXT:lang/locallang_common.xlf:page') . ': '
                                                        . htmlspecialchars($parentRecordTitle) . ' (uid=' . $record['pid'] . ')">
                                                        ' . $record['uid'] . '
                                                </span>
@@ -676,8 +678,8 @@ class ElementInformationController {
                                $infoData[] = '
                                <tr>
                                        <td class="col-icon"></td>
-                                       <td class="col-title">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . $row['recuid'] . ')</td>
-                                       <td>' . htmlspecialchars($GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename']) . '</td>
+                                       <td class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.missing_record') . ' (uid=' . $row['recuid'] . ')</td>
+                                       <td>' . htmlspecialchars($lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename']) . '</td>
                                        <td></td>
                                        <td>' . htmlspecialchars($this->getLabelForTableColumn($row['tablename'], $row['field'])) . '</td>
                                        <td>' . htmlspecialchars($row['flexpointer']) . '</td>
@@ -708,32 +710,33 @@ class ElementInformationController {
         * @return string HTML
         */
        protected function makeRefFrom($table, $ref) {
-               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+               $lang = $this->getLanguageService();
+               $rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
                        '*',
                        'sys_refindex',
-                       'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . (int)$ref
+                       'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($table, 'sys_refindex') . ' AND recuid=' . (int)$ref
                );
 
                // Compile information for title tag:
                $infoData = array();
+               $infoDataHeader = '';
                if (count($rows)) {
                        $infoDataHeader = '
                                <tr>
                                        <th class="col-icon"></th>
-                                       <th class="col-title">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
-                                       <th>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</th>
+                                       <th class="col-title">' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.title') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.table') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.uid') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.field') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.flexpointer') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.softrefKey') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.sorting') . '</th>
+                                       <th>' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:show_item.php.refString') . '</th>
                                        <th class="col-control"></th>
                                </tr>';
                }
                foreach ($rows as $row) {
                        $record = BackendUtility::getRecord($row['ref_table'], $row['ref_uid']);
-                       $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
                        $icon = IconUtility::getSpriteIconForRecord($row['tablename'], $record);
                        $actions = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
                        $editOnClick = BackendUtility::editOnClick('&edit[' . $row['ref_table'] . '][' . $row['ref_uid'] . ']=edit');
@@ -749,7 +752,7 @@ class ElementInformationController {
                                                        ' . BackendUtility::getRecordTitle($row['ref_table'], $record, TRUE) . '
                                                </a>
                                        </td>
-                                       <td>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], TRUE) . '</td>
+                                       <td>' . $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title'], TRUE) . '</td>
                                        <td>' . htmlspecialchars($row['ref_uid']) . '</td>
                                        <td>' . htmlspecialchars($this->getLabelForTableColumn($table, $row['field'])) . '</td>
                                        <td>' . htmlspecialchars($row['flexpointer']) . '</td>
@@ -761,7 +764,7 @@ class ElementInformationController {
                }
 
                if (empty($infoData)) {
-                       return;
+                       return '';
                }
 
                return '
@@ -780,7 +783,7 @@ class ElementInformationController {
         * @return array
         */
        protected function transformFileReferenceToRecordReference(array $referenceRecord) {
-               $fileReference = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+               $fileReference = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
                        '*',
                        'sys_file_reference',
                        'uid=' . (int)$referenceRecord['recuid']
@@ -795,4 +798,31 @@ class ElementInformationController {
                );
        }
 
+       /**
+        * Returns LanguageService
+        *
+        * @return \TYPO3\CMS\Lang\LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * Returns the current BE user.
+        *
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
+       /**
+        * Returns the database connection
+        *
+        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
+
 }
index 8671bb2..1643c6f 100644 (file)
@@ -85,7 +85,7 @@ class MoveElementController {
         * Constructor
         */
        public function __construct() {
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
+               $this->getLanguageService()->includeLLFile('EXT:lang/locallang_misc.xlf');
                $GLOBALS['SOBE'] = $this;
                $this->init();
        }
@@ -105,7 +105,7 @@ class MoveElementController {
                $this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id;
                $this->makeCopy = GeneralUtility::_GP('makeCopy');
                // Select-pages where clause for read-access:
-               $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
+               $this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
                // Starting the document template object:
                $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
@@ -113,7 +113,7 @@ class MoveElementController {
                $this->doc->JScode = '';
                // Starting document content (header):
                $this->content = '';
-               $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('movingElement'));
+               $this->content .= $this->doc->header($this->getLanguageService()->getLL('movingElement'));
        }
 
        /**
@@ -122,43 +122,45 @@ class MoveElementController {
         * @return void
         */
        public function main() {
+               $lang = $this->getLanguageService();
                if ($this->page_id) {
+                       $backendUser = $this->getBackendUser();
                        // Get record for element:
                        $elRow = BackendUtility::getRecordWSOL($this->table, $this->moveUid);
                        // Headerline: Icon, record title:
-                       $hline = IconUtility::getSpriteIconForRecord($this->table, $elRow, array('id' => 'c-recIcon', 'title' => htmlspecialchars(BackendUtility::getRecordIconAltText($elRow, $this->table))));
-                       $hline .= BackendUtility::getRecordTitle($this->table, $elRow, TRUE);
+                       $headerLine = IconUtility::getSpriteIconForRecord($this->table, $elRow, array('id' => 'c-recIcon', 'title' => htmlspecialchars(BackendUtility::getRecordIconAltText($elRow, $this->table))));
+                       $headerLine .= BackendUtility::getRecordTitle($this->table, $elRow, TRUE);
                        // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
-                       $hline .= $this->doc->spacer(5);
+                       $headerLine .= $this->doc->spacer(5);
                        $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript(array('makeCopy' => !$this->makeCopy))) . ';';
-                       $hline .= $this->doc->spacer(5);
-                       $hline .= '<input type="hidden" name="makeCopy" value="0" />' . '<input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy" class="t3-label-valign-top">' . $GLOBALS['LANG']->getLL('makeCopy', 1) . '</label>';
+                       $headerLine .= $this->doc->spacer(5);
+                       $headerLine .= '<input type="hidden" name="makeCopy" value="0" />' . '<input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy" class="t3-label-valign-top">' . $lang->getLL('makeCopy', 1) . '</label>';
                        // Add the header-content to the module content:
-                       $this->content .= $this->doc->section('', $hline, FALSE, TRUE);
+                       $this->content .= $this->doc->section('', $headerLine, FALSE, TRUE);
                        $this->content .= $this->doc->spacer(20);
                        // Reset variable to pick up the module content in:
                        $code = '';
                        // IF the table is "pages":
                        if ((string)$this->table == 'pages') {
                                // Get page record (if accessible):
-                               $pageinfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
-                               if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
+                               $pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
+                               if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) {
                                        // Initialize the position map:
                                        $posMap = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\PageMovingPagePositionMap::class);
                                        $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
                                        // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
-                                       if ($pageinfo['pid']) {
-                                               $pidPageInfo = BackendUtility::readPageAccess($pageinfo['pid'], $this->perms_clause);
+                                       if ($pageInfo['pid']) {
+                                               $pidPageInfo = BackendUtility::readPageAccess($pageInfo['pid'], $this->perms_clause);
                                                if (is_array($pidPageInfo)) {
-                                                       if ($GLOBALS['BE_USER']->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
-                                                               $code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int)$pageinfo['pid'], 'moveUid' => $this->moveUid))) . '">' . IconUtility::getSpriteIcon('actions-view-go-up') . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
+                                                       if ($backendUser->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
+                                                               $code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int)$pageInfo['pid'], 'moveUid' => $this->moveUid))) . '">' . IconUtility::getSpriteIcon('actions-view-go-up') . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
                                                        } else {
                                                                $code .= IconUtility::getSpriteIconForRecord('pages', $pidPageInfo) . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />';
                                                        }
                                                }
                                        }
                                        // Create the position tree:
-                                       $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
+                                       $code .= $posMap->positionTree($this->page_id, $pageInfo, $this->perms_clause, $this->R_URI);
                                }
                        }
                        // IF the table is "tt_content":
@@ -170,18 +172,18 @@ class MoveElementController {
                                        $this->page_id = $tt_content_rec['pid'];
                                }
                                // Checking if the parent page is readable:
-                               $pageinfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
-                               if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
+                               $pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
+                               if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) {
                                        // Initialize the position map:
                                        $posMap = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\ContentMovingPagePositionMap::class);
                                        $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
                                        $posMap->cur_sys_language = $this->sys_language;
                                        // Headerline for the parent page: Icon, record title:
-                                       $hline = IconUtility::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(BackendUtility::getRecordIconAltText($pageinfo, 'pages'))));
-                                       $hline .= BackendUtility::getRecordTitle('pages', $pageinfo, TRUE);
+                                       $headerLine = IconUtility::getSpriteIconForRecord('pages', $pageInfo, array('title' => htmlspecialchars(BackendUtility::getRecordIconAltText($pageInfo, 'pages'))));
+                                       $headerLine .= BackendUtility::getRecordTitle('pages', $pageInfo, TRUE);
                                        // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
                                        // SHARED page-TSconfig settings.
-                                       $modTSconfig_SHARED = BackendUtility::getModTSconfig($this->page_id, 'mod.SHARED');
+                                       // $modTSconfig_SHARED = BackendUtility::getModTSconfig($this->pageId, 'mod.SHARED');
                                        $colPosArray = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $this->page_id, $this);
                                        $colPosIds = array();
                                        foreach ($colPosArray as $colPos) {
@@ -190,16 +192,16 @@ class MoveElementController {
                                        // Removing duplicates, if any
                                        $colPosList = implode(',', array_unique($colPosIds));
                                        // Adding parent page-header and the content element columns from position-map:
-                                       $code = $hline . '<br />';
+                                       $code = $headerLine . '<br />';
                                        $code .= $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI);
                                        // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
                                        $code .= '<br /><br />';
-                                       if ($pageinfo['pid']) {
-                                               $pidPageInfo = BackendUtility::readPageAccess($pageinfo['pid'], $this->perms_clause);
+                                       if ($pageInfo['pid']) {
+                                               $pidPageInfo = BackendUtility::readPageAccess($pageInfo['pid'], $this->perms_clause);
                                                if (is_array($pidPageInfo)) {
-                                                       if ($GLOBALS['BE_USER']->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
+                                                       if ($backendUser->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
                                                                $code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array(
-                                                                       'uid' => (int)$pageinfo['pid'],
+                                                                       'uid' => (int)$pageInfo['pid'],
                                                                        'moveUid' => $this->moveUid
                                                                ))) . '">' . IconUtility::getSpriteIcon('actions-view-go-up') . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
                                                        } else {
@@ -208,19 +210,19 @@ class MoveElementController {
                                                }
                                        }
                                        // Create the position tree (for pages):
-                                       $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
+                                       $code .= $posMap->positionTree($this->page_id, $pageInfo, $this->perms_clause, $this->R_URI);
                                }
                        }
                        // Add the $code content as a new section to the module:
-                       $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('selectPositionOfElement'), $code, FALSE, TRUE);
+                       $this->content .= $this->doc->section($lang->getLL('selectPositionOfElement'), $code, FALSE, TRUE);
                }
                // Setting up the buttons and markers for docheader
                $docHeaderButtons = $this->getButtons();
                $markers['CSH'] = $docHeaderButtons['csh'];
                $markers['CONTENT'] = $this->content;
                // Build the <body> for the module
-               $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('movingElement'));
-               $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content = $this->doc->startPage($lang->getLL('movingElement'));
+               $this->content .= $this->doc->moduleBody($pageInfo, $docHeaderButtons, $markers);
                $this->content .= $this->doc->endPage();
                $this->content = $this->doc->insertStylesAndJS($this->content);
        }
@@ -251,10 +253,28 @@ class MoveElementController {
                                $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'move_el_cs');
                        }
                        if ($this->R_URI) {
-                               $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->getLL('goBack', TRUE) . '">' . IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
+                               $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $this->getLanguageService()->getLL('goBack', TRUE) . '">' . IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
                        }
                }
                return $buttons;
        }
 
+       /**
+        * Returns LanguageService
+        *
+        * @return \TYPO3\CMS\Lang\LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * Returns the current BE user.
+        *
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
 }
index 28f73fe..769be7b 100644 (file)
@@ -94,14 +94,40 @@ class NewContentElementController {
        public $config;
 
        /**
+        * @var array
+        */
+       protected $pageInfo;
+
+       /**
+        * @var array
+        */
+       protected $elementWrapper;
+
+       /**
+        * @var array
+        */
+       protected $elementWrapperForTabs;
+
+       /**
+        * @var string
+        */
+       protected $onClickEvent;
+
+       /**
+        * @var array
+        */
+       protected $MCONF;
+
+       /**
         * Constructor, initializing internal variables.
         *
         * @return void
         */
        public function init() {
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
+               $lang = $this->getLanguageService();
+               $lang->includeLLFile('EXT:lang/locallang_misc.xlf');
                $LOCAL_LANG_orig = $GLOBALS['LOCAL_LANG'];
-               $GLOBALS['LANG']->includeLLFile('EXT:cms/layout/locallang_db_new_content_el.xlf');
+               $lang->includeLLFile('EXT:cms/layout/locallang_db_new_content_el.xlf');
                \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($LOCAL_LANG_orig, $GLOBALS['LOCAL_LANG']);
                $GLOBALS['LOCAL_LANG'] = $LOCAL_LANG_orig;
 
@@ -124,9 +150,9 @@ class NewContentElementController {
                // Setting up the context sensitive menu:
                $this->doc->getContextMenuCode();
                // Getting the current page and receiving access information (used in main())
-               $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
-               $this->pageinfo = BackendUtility::readPageAccess($this->id, $perms_clause);
-               $this->access = is_array($this->pageinfo) ? 1 : 0;
+               $perms_clause = $this->getBackendUser()->getPagePermsClause(1);
+               $this->pageInfo = BackendUtility::readPageAccess($this->id, $perms_clause);
+               $this->access = is_array($this->pageInfo) ? 1 : 0;
        }
 
        /**
@@ -135,6 +161,7 @@ class NewContentElementController {
         * @return void
         */
        public function main() {
+               $lang = $this->getLanguageService();
                if ($this->id && $this->access) {
                        // Init position map object:
                        $posMap = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap::class);
@@ -155,9 +182,8 @@ class NewContentElementController {
                        // ***************************
                        // Creating content
                        // ***************************
-                       $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('newContentElement'));
+                       $this->content .= $this->doc->header($lang->getLL('newContentElement'));
                        // Wizard
-                       $code = '';
                        $wizardItems = $this->getWizardItems();
                        // Wrapper for wizards
                        $this->elementWrapper['section'] = array('', '');
@@ -237,20 +263,20 @@ class NewContentElementController {
                        }
                        // Add the wizard table to the content, wrapped in tabs:
                        if ($this->config['renderMode'] == 'tabs') {
-                               $code = '<p>' . $GLOBALS['LANG']->getLL('sel1', 1) . '</p>' . $this->doc->getDynamicTabMenu($menuItems, 'new-content-element-wizard');
+                               $code = '<p>' . $lang->getLL('sel1', 1) . '</p>' . $this->doc->getDynamicTabMenu($menuItems, 'new-content-element-wizard');
                        } else {
-                               $code = '<p>' . $GLOBALS['LANG']->getLL('sel1', 1) . '</p>';
+                               $code = '<p>' . $lang->getLL('sel1', 1) . '</p>';
                                foreach ($menuItems as $section) {
                                        $code .= '<h3 class="divider">' . $section['label'] . '</h3>' . $section['content'];
                                }
                        }
-                       $this->content .= $this->doc->section(!$this->onClickEvent ? $GLOBALS['LANG']->getLL('1_selectType') : '', $code, 0, 1);
+                       $this->content .= $this->doc->section(!$this->onClickEvent ? $lang->getLL('1_selectType') : '', $code, 0, 1);
                        // If the user must also select a column:
                        if (!$this->onClickEvent) {
                                // Add anchor "sel2"
                                $this->content .= $this->doc->section('', '<a name="sel2"></a>');
                                // Select position
-                               $code = '<p>' . $GLOBALS['LANG']->getLL('sel2', 1) . '</p>';
+                               $code = '<p>' . $lang->getLL('sel2', 1) . '</p>';
 
                                // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
                                $colPosArray = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $this->id, $this);
@@ -259,12 +285,12 @@ class NewContentElementController {
                                $colPosList = implode(',', array_unique(array_map('intval', $colPosIds)));
                                // Finally, add the content of the column selector to the content:
                                $code .= $posMap->printContentElementColumns($this->id, 0, $colPosList, 1, $this->R_URI);
-                               $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('2_selectPosition'), $code, 0, 1);
+                               $this->content .= $this->doc->section($lang->getLL('2_selectPosition'), $code, 0, 1);
                        }
                } else {
                        // In case of no access:
                        $this->content = '';
-                       $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('newContentElement'));
+                       $this->content .= $this->doc->header($lang->getLL('newContentElement'));
                        $this->content .= $this->doc->spacer(5);
                }
                // Setting up the buttons and markers for docheader
@@ -272,8 +298,8 @@ class NewContentElementController {
                $markers['CSH'] = $docHeaderButtons['csh'];
                $markers['CONTENT'] = $this->content;
                // Build the <body> for the module
-               $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('newContentElement'));
-               $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content = $this->doc->startPage($lang->getLL('newContentElement'));
+               $this->content .= $this->doc->moduleBody($this->pageInfo, $docHeaderButtons, $markers);
                $this->content .= $this->doc->sectionEnd();
                $this->content .= $this->doc->endPage();
                $this->content = $this->doc->insertStylesAndJS($this->content);
@@ -301,7 +327,7 @@ class NewContentElementController {
                if ($this->id && $this->access) {
                        $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'new_ce');
                        if ($this->R_URI) {
-                               $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->getLL('goBack', TRUE) . '">' . IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
+                               $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $this->getLanguageService()->getLL('goBack', TRUE) . '">' . IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
                        }
                }
                return $buttons;
@@ -328,36 +354,36 @@ class NewContentElementController {
         * @return array
         */
        public function wizardArray() {
+               $wizardItems = array();
                if (is_array($this->config)) {
                        $wizards = $this->config['wizardItems.'];
-               }
-               $appendWizards = $this->wizard_appendWizards($wizards['elements.']);
-               $wizardItems = array();
-               if (is_array($wizards)) {
-                       foreach ($wizards as $groupKey => $wizardGroup) {
-                               $groupKey = rtrim($groupKey, '.');
-                               $showItems = GeneralUtility::trimExplode(',', $wizardGroup['show'], TRUE);
-                               $showAll = $wizardGroup['show'] === '*';
-                               $groupItems = array();
-                               if (is_array($appendWizards[$groupKey . '.']['elements.'])) {
-                                       $wizardElements = array_merge((array)$wizardGroup['elements.'], $appendWizards[$groupKey . '.']['elements.']);
-                               } else {
-                                       $wizardElements = $wizardGroup['elements.'];
-                               }
-                               if (is_array($wizardElements)) {
-                                       foreach ($wizardElements as $itemKey => $itemConf) {
-                                               $itemKey = rtrim($itemKey, '.');
-                                               if ($showAll || in_array($itemKey, $showItems)) {
-                                                       $tmpItem = $this->wizard_getItem($groupKey, $itemKey, $itemConf);
-                                                       if ($tmpItem) {
-                                                               $groupItems[$groupKey . '_' . $itemKey] = $tmpItem;
+                       $appendWizards = $this->wizard_appendWizards($wizards['elements.']);
+                       if (is_array($wizards)) {
+                               foreach ($wizards as $groupKey => $wizardGroup) {
+                                       $groupKey = rtrim($groupKey, '.');
+                                       $showItems = GeneralUtility::trimExplode(',', $wizardGroup['show'], TRUE);
+                                       $showAll = $wizardGroup['show'] === '*';
+                                       $groupItems = array();
+                                       if (is_array($appendWizards[$groupKey . '.']['elements.'])) {
+                                               $wizardElements = array_merge((array)$wizardGroup['elements.'], $appendWizards[$groupKey . '.']['elements.']);
+                                       } else {
+                                               $wizardElements = $wizardGroup['elements.'];
+                                       }
+                                       if (is_array($wizardElements)) {
+                                               foreach ($wizardElements as $itemKey => $itemConf) {
+                                                       $itemKey = rtrim($itemKey, '.');
+                                                       if ($showAll || in_array($itemKey, $showItems)) {
+                                                               $tmpItem = $this->wizard_getItem($groupKey, $itemKey, $itemConf);
+                                                               if ($tmpItem) {
+                                                                       $groupItems[$groupKey . '_' . $itemKey] = $tmpItem;
+                                                               }
                                                        }
                                                }
                                        }
-                               }
-                               if (count($groupItems)) {
-                                       $wizardItems[$groupKey] = $this->wizard_getGroupHeader($groupKey, $wizardGroup);
-                                       $wizardItems = array_merge($wizardItems, $groupItems);
+                                       if (count($groupItems)) {
+                                               $wizardItems[$groupKey] = $this->wizard_getGroupHeader($groupKey, $wizardGroup);
+                                               $wizardItems = array_merge($wizardItems, $groupItems);
+                                       }
                                }
                        }
                }
@@ -391,33 +417,34 @@ class NewContentElementController {
        }
 
        /**
-        * @param string Not used
-        * @param string Not used
+        * @param string $groupKey Not used
+        * @param string $itemKey Not used
         * @param array $itemConf
         * @return array
         */
        public function wizard_getItem($groupKey, $itemKey, $itemConf) {
-               $itemConf['title'] = $GLOBALS['LANG']->sL($itemConf['title']);
-               $itemConf['description'] = $GLOBALS['LANG']->sL($itemConf['description']);
+               $itemConf['title'] = $this->getLanguageService()->sL($itemConf['title']);
+               $itemConf['description'] = $this->getLanguageService()->sL($itemConf['description']);
                $itemConf['tt_content_defValues'] = $itemConf['tt_content_defValues.'];
                unset($itemConf['tt_content_defValues.']);
                return $itemConf;
        }
 
        /**
-        * @param string Not used
+        * @param string $groupKey Not used
         * @param array $wizardGroup
         * @return array
         */
        public function wizard_getGroupHeader($groupKey, $wizardGroup) {
                return array(
-                       'header' => $GLOBALS['LANG']->sL($wizardGroup['header'])
+                       'header' => $this->getLanguageService()->sL($wizardGroup['header'])
                );
        }
 
        /**
         * Checks the array for elements which might contain unallowed default values and will unset them!
-        * Looks for the "tt_content_defValues" key in each element and if found it will traverse that array as fieldname / value pairs and check. The values will be added to the "params" key of the array (which should probably be unset or empty by default).
+        * Looks for the "tt_content_defValues" key in each element and if found it will traverse that array as fieldname / value pairs and check.
+        * The values will be added to the "params" key of the array (which should probably be unset or empty by default).
         *
         * @param array $wizardItems Wizard items, passed by reference
         * @return void
@@ -449,13 +476,14 @@ class NewContentElementController {
                        }
                        // If tt_content_defValues are defined...:
                        if (is_array($wizardItems[$key]['tt_content_defValues'])) {
+                               $backendUser = $this->getBackendUser();
                                // Traverse field values:
                                foreach ($wizardItems[$key]['tt_content_defValues'] as $fN => $fV) {
                                        if (is_array($GLOBALS['TCA']['tt_content']['columns'][$fN])) {
                                                // Get information about if the field value is OK:
                                                $config = &$GLOBALS['TCA']['tt_content']['columns'][$fN]['config'];
                                                $authModeDeny = $config['type'] == 'select' && $config['authMode']
-                                                       && !$GLOBALS['BE_USER']->checkAuthMode('tt_content', $fN, $fV, $config['authMode']);
+                                                       && !$backendUser->checkAuthMode('tt_content', $fN, $fV, $config['authMode']);
                                                // explode TSconfig keys only as needed
                                                if (!isset($removeItems[$fN])) {
                                                        $removeItems[$fN] = GeneralUtility::trimExplode(',', $TCEFORM_TSconfig[$fN]['removeItems'], TRUE);
@@ -487,4 +515,22 @@ class NewContentElementController {
                }
        }
 
+       /**
+        * Returns LanguageService
+        *
+        * @return \TYPO3\CMS\Lang\LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * Returns the current BE user.
+        *
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUser() {
+               return $GLOBALS['BE_USER'];
+       }
+
 }