[BUGFIX] Fix JS errors in configuration wizard of backend layout 36/38336/5
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 29 Mar 2015 15:12:35 +0000 (17:12 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 29 Mar 2015 16:54:16 +0000 (18:54 +0200)
Loading of the ExtJS stuff was missing.

And also do some cleanup stuff
(getLanguageService, getDatabaseConnection).

Add fix for another JavaScript error
 TypeError: top.TYPO3.settings.ContextHelp is undefined

Resolves: #66120
Releases: master
Change-Id: I32f1b2e170267c250f296b2bb27ea3c48095cb68
Reviewed-on: http://review.typo3.org/38336
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Controller/BackendLayoutWizardController.php

index e591388..3127f61 100644 (file)
@@ -16,6 +16,11 @@ namespace TYPO3\CMS\Backend\Controller;
 
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
+use TYPO3\CMS\Backend\Template\DocumentTemplate;
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+
 
 /**
  * Script Class for grid wizard
@@ -45,13 +50,24 @@ class BackendLayoutWizardController {
        public $content;
 
        /**
+        * @var string
+        */
+       public $formName;
+
+       /**
+        * @var string
+        */
+       public $fieldName;
+
+       /**
         * Initialises the Class
         *
         * @return void
         * @throws \InvalidArgumentException
         */
        public function init() {
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
+               $lang = $this->getLanguageService();
+               $lang->includeLLFile('EXT:lang/locallang_wizards.xlf');
 
                // Setting GET vars (used in frameset script):
                $this->P = GeneralUtility::_GP('P');
@@ -64,10 +80,12 @@ class BackendLayoutWizardController {
                $this->md5ID = $this->P['md5ID'];
                $uid = (int)$this->P['uid'];
                // Initialize document object:
-               $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
+               $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
                $pageRenderer = $this->doc->getPageRenderer();
-               $pageRenderer->addJsFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/JavaScript/grideditor.js');
+               $pageRenderer->loadExtJS();
+               $pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/JavaScript/grideditor.js');
+               $pageRenderer->addInlineSetting('ContextHelp', 'moduleUrl', BackendUtility::getModuleUrl('help_cshmanual'));
                $pageRenderer->addJsInlineCode('storeData', '
                        function storeData(data) {
                                if (parent.opener && parent.opener.document && parent.opener.document.' . $this->formName . ' && parent.opener.document.' . $this->formName . '[' . GeneralUtility::quoteJSvalue($this->fieldName) . ']) {
@@ -77,27 +95,27 @@ class BackendLayoutWizardController {
                        }
                        ', FALSE);
                $languageLabels = array(
-                       'save' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_labelSave', TRUE),
-                       'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_windowTitle', TRUE),
-                       'editCell' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_editCell', TRUE),
-                       'mergeCell' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_mergeCell', TRUE),
-                       'splitCell' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_splitCell', TRUE),
-                       'name' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_name', TRUE),
-                       'column' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_column', TRUE),
-                       'notSet' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_notSet', TRUE),
-                       'nameHelp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_nameHelp', TRUE),
-                       'columnHelp' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_columnHelp', TRUE)
+                       'save' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_labelSave', TRUE),
+                       'title' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_windowTitle', TRUE),
+                       'editCell' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_editCell', TRUE),
+                       'mergeCell' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_mergeCell', TRUE),
+                       'splitCell' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_splitCell', TRUE),
+                       'name' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_name', TRUE),
+                       'column' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_column', TRUE),
+                       'notSet' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_notSet', TRUE),
+                       'nameHelp' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_nameHelp', TRUE),
+                       'columnHelp' => $lang->sL('LLL:EXT:lang/locallang_wizards.xlf:grid_columnHelp', TRUE)
                );
                $pageRenderer->addInlineLanguageLabelArray($languageLabels);
                // Select record
-               $record = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($this->P['field'], $this->P['table'], 'uid=' . (int)$this->P['uid']);
+               $record = $this->getDatabaseConnection()->exec_SELECTgetRows($this->P['field'], $this->P['table'], 'uid=' . (int)$this->P['uid']);
                if (trim($record[0][$this->P['field']]) == '') {
                        $rows = array(array(array('colspan' => 1, 'rowspan' => 1, 'spanned' => FALSE, 'name' => '')));
                        $colCount = 1;
                        $rowCount = 1;
                } else {
                        // load TS parser
-                       $parser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
+                       $parser = GeneralUtility::makeInstance(TypoScriptParser::class);
                        $parser->parse($record[0][$this->P['field']]);
                        $data = $parser->setup['backend_layout.'];
                        $rows = array();
@@ -171,7 +189,7 @@ class BackendLayoutWizardController {
                        });
                        t3Grid.drawTable();
                        ');
-               $this->doc->styleSheetFile_post = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/Css/grideditor.css';
+               $this->doc->styleSheetFile_post = ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/Css/grideditor.css';
        }
 
        /**
@@ -180,10 +198,11 @@ class BackendLayoutWizardController {
         * @return void
         */
        public function main() {
-               $resourcePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/Images/BackendLayoutWizard/';
-               $content = '<a href="#" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" onclick="storeData(t3Grid.export2LayoutRecord());return true;">' . IconUtility::getSpriteIcon('actions-document-save') . '</a>';
-               $content .= '<a href="#" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" onclick="storeData(t3Grid.export2LayoutRecord());window.close();return true;">' . IconUtility::getSpriteIcon('actions-document-save-close') . '</a>';
-               $content .= '<a href="#" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '" onclick="window.close();return true;">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
+               $lang = $this->getLanguageService();
+               $resourcePath = ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/Images/BackendLayoutWizard/';
+               $content = '<a href="#" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" onclick="storeData(t3Grid.export2LayoutRecord());return true;">' . IconUtility::getSpriteIcon('actions-document-save') . '</a>';
+               $content .= '<a href="#" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" onclick="storeData(t3Grid.export2LayoutRecord());window.close();return true;">' . IconUtility::getSpriteIcon('actions-document-save-close') . '</a>';
+               $content .= '<a href="#" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '" onclick="window.close();return true;">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
                $content .= $this->doc->spacer(10);
                $content .= '
                <table border="0" width="90%" height="90%" id="outer_container">
@@ -193,20 +212,20 @@ class BackendLayoutWizardController {
                                        </div>
                                </td>
                                <td width="20" valign="center">
-                                       <a class="addCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_addColumn') . '" onclick="t3Grid.addColumn(); t3Grid.drawTable(\'editor\');">
+                                       <a class="addCol" href="#" title="' . $lang->getLL('grid_addColumn') . '" onclick="t3Grid.addColumn(); t3Grid.drawTable(\'editor\');">
                                                <img src="' . $resourcePath . 't3grid-tableright.png" border="0" />
                                        </a><br />
-                                       <a class="removeCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_removeColumn') . '" onclick="t3Grid.removeColumn(); t3Grid.drawTable(\'editor\');">
+                                       <a class="removeCol" href="#" title="' . $lang->getLL('grid_removeColumn') . '" onclick="t3Grid.removeColumn(); t3Grid.drawTable(\'editor\');">
                                                <img src="' . $resourcePath . 't3grid-tableleft.png" border="0" />
                                        </a>
                                </td>
                        </tr>
                        <tr>
                                <td colspan="2" height="20" align="center">
-                                       <a class="addCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_addRow') . '" onclick="t3Grid.addRow(); t3Grid.drawTable(\'editor\');">
+                                       <a class="addCol" href="#" title="' . $lang->getLL('grid_addRow') . '" onclick="t3Grid.addRow(); t3Grid.drawTable(\'editor\');">
                                                <img src="' . $resourcePath . 't3grid-tabledown.png" border="0" />
                                        </a>
-                                       <a class="removeCol" href="#" title="' . $GLOBALS['LANG']->getLL('grid_removeRow') . '" onclick="t3Grid.removeRow(); t3Grid.drawTable(\'editor\');">
+                                       <a class="removeCol" href="#" title="' . $lang->getLL('grid_removeRow') . '" onclick="t3Grid.removeRow(); t3Grid.drawTable(\'editor\');">
                                                <img src="' . $resourcePath . 't3grid-tableup.png" border="0" />
                                        </a>
                                </td>
@@ -225,4 +244,23 @@ class BackendLayoutWizardController {
                echo $this->doc->render('Grid wizard', $this->content);
        }
 
+
+       /**
+        * Returns LanguageService
+        *
+        * @return \TYPO3\CMS\Lang\LanguageService
+        */
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
+       }
+
+       /**
+        * Returns the database connection
+        *
+        * @return \TYPO3\CMS\Core\Database\DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
+
 }