From 5cb83224a877e8b963750aee5032977ce6a86109 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Thu, 14 Mar 2013 21:11:14 +0100
Subject: [PATCH] [BUGFIX] Missing labels in backend modules

There seems to be some magic in SOBE that automatically includes
language files if they are located parallel to the module that is
loaded. The task from #46143 and #46144 registered new wizard classes
at a different location, so the magic doesn't hit anymore. As a
result, no labels are show in above extensions in the backend.
Fix is to include the locallang file in main() of the modules. The
direct access to $LANG is removed along the way by accessing
$GLOBALS['LANG'] directly.

Change-Id: Iecddb181141f5317b87e405ada925c61cfd9261c
Fixes: #46296
Related: #46143
Related: #46144
Releases: 6.1
Reviewed-on: https://review.typo3.org/18925
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
---
 ...mplateAnalyzerModuleFunctionController.php |  1 +
 .../class.tx_tstemplateanalyzer.php           |  2 +-
 ...ConstantEditorModuleFunctionController.php |  1 +
 .../class.tx_tstemplateceditor.php            |  2 +-
 ...ateInformationModuleFunctionController.php |  1 +
 .../class.tx_tstemplateinfo.php               |  2 +-
 ...eObjectBrowserModuleFunctionController.php |  1 +
 .../class.tx_tstemplateobjbrowser.php         |  2 +-
 ...atePagesWizardModuleFunctionController.php | 16 +++++------
 .../View/SortPagesWizardModuleFunction.php    | 28 +++++++++----------
 10 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/typo3/sysext/tstemplate_analyzer/Classes/Controller/TemplateAnalyzerModuleFunctionController.php b/typo3/sysext/tstemplate_analyzer/Classes/Controller/TemplateAnalyzerModuleFunctionController.php
index c5842ae6487f..66e52ab14fd3 100644
--- a/typo3/sysext/tstemplate_analyzer/Classes/Controller/TemplateAnalyzerModuleFunctionController.php
+++ b/typo3/sysext/tstemplate_analyzer/Classes/Controller/TemplateAnalyzerModuleFunctionController.php
@@ -44,6 +44,7 @@ class TemplateAnalyzerModuleFunctionController extends \TYPO3\CMS\Backend\Module
 	 */
 	public function init(&$pObj, $conf) {
 		parent::init($pObj, $conf);
+		$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_analyzer/locallang.xlf');
 		$this->pObj->modMenu_setDefaultList .= ',ts_analyzer_checkLinenum,ts_analyzer_checkSyntax';
 	}
 
diff --git a/typo3/sysext/tstemplate_analyzer/class.tx_tstemplateanalyzer.php b/typo3/sysext/tstemplate_analyzer/class.tx_tstemplateanalyzer.php
index 336cf2a479b6..fdd6e158e2f7 100644
--- a/typo3/sysext/tstemplate_analyzer/class.tx_tstemplateanalyzer.php
+++ b/typo3/sysext/tstemplate_analyzer/class.tx_tstemplateanalyzer.php
@@ -24,7 +24,7 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_analyzer/locallang.xlf');
+
 /*
  * @deprecated since 6.0, the classname tx_tstemplateanalyzer and this file is obsolete
  * and will be removed with 6.2. The class was renamed and is now located at:
diff --git a/typo3/sysext/tstemplate_ceditor/Classes/Controller/TypoScriptTemplateConstantEditorModuleFunctionController.php b/typo3/sysext/tstemplate_ceditor/Classes/Controller/TypoScriptTemplateConstantEditorModuleFunctionController.php
index 83f63cd68e13..f60b4d067ad4 100644
--- a/typo3/sysext/tstemplate_ceditor/Classes/Controller/TypoScriptTemplateConstantEditorModuleFunctionController.php
+++ b/typo3/sysext/tstemplate_ceditor/Classes/Controller/TypoScriptTemplateConstantEditorModuleFunctionController.php
@@ -101,6 +101,7 @@ class TypoScriptTemplateConstantEditorModuleFunctionController extends \TYPO3\CM
 	public function main() {
 		global $TYPO3_CONF_VARS;
 		global $tmpl, $tplRow, $theConstants;
+		$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_ceditor/locallang.xlf');
 		$theOutput = '';
 		// Create extension template
 		$this->pObj->createTemplate($this->pObj->id);
diff --git a/typo3/sysext/tstemplate_ceditor/class.tx_tstemplateceditor.php b/typo3/sysext/tstemplate_ceditor/class.tx_tstemplateceditor.php
index 0440d2c07dc7..3da97fe4650e 100644
--- a/typo3/sysext/tstemplate_ceditor/class.tx_tstemplateceditor.php
+++ b/typo3/sysext/tstemplate_ceditor/class.tx_tstemplateceditor.php
@@ -24,7 +24,7 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_ceditor/locallang.xlf');
+
 /*
  * @deprecated since 6.0, the classname tx_tstemplateceditor and this file is obsolete
  * and will be removed with 6.2. The class was renamed and is now located at:
diff --git a/typo3/sysext/tstemplate_info/Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php b/typo3/sysext/tstemplate_info/Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php
index d7ff8890ea34..8906fde8d05a 100644
--- a/typo3/sysext/tstemplate_info/Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php
+++ b/typo3/sysext/tstemplate_info/Classes/Controller/TypoScriptTemplateInformationModuleFunctionController.php
@@ -201,6 +201,7 @@ class TypoScriptTemplateInformationModuleFunctionController extends \TYPO3\CMS\B
 	public function main() {
 		global $BACK_PATH;
 		global $tmpl, $tplRow, $theConstants;
+		$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_info/locallang.xlf');
 		$this->pObj->MOD_MENU['includeTypoScriptFileContent'] = TRUE;
 		$edit = $this->pObj->edit;
 		$e = $this->pObj->e;
diff --git a/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php b/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php
index 95d3d315f1b9..73ed4f048a10 100644
--- a/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php
+++ b/typo3/sysext/tstemplate_info/class.tx_tstemplateinfo.php
@@ -24,7 +24,7 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_info/locallang.xlf');
+
 /*
  * @deprecated since 6.0, the classname tx_tstemplateinfo and this file is obsolete
  * and will be removed with 6.2. The class was renamed and is now located at:
diff --git a/typo3/sysext/tstemplate_objbrowser/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php b/typo3/sysext/tstemplate_objbrowser/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php
index 9380450d801a..45da96214696 100644
--- a/typo3/sysext/tstemplate_objbrowser/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php
+++ b/typo3/sysext/tstemplate_objbrowser/Classes/Controller/TypoScriptTemplateObjectBrowserModuleFunctionController.php
@@ -55,6 +55,7 @@ class TypoScriptTemplateObjectBrowserModuleFunctionController extends \TYPO3\CMS
 	 * @todo Define visibility
 	 */
 	public function modMenu() {
+		$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_objbrowser/locallang.xlf');
 		$modMenu = array(
 			'ts_browser_type' => array(
 				'const' => $GLOBALS['LANG']->getLL('constants'),
diff --git a/typo3/sysext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php b/typo3/sysext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php
index 437c481164dc..4bc415eb485a 100644
--- a/typo3/sysext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php
+++ b/typo3/sysext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php
@@ -24,7 +24,7 @@
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
-$GLOBALS['LANG']->includeLLFile('EXT:tstemplate_objbrowser/locallang.xlf');
+
 /*
  * @deprecated since 6.0, the classname tx_tstemplateobjbrowser and this file is obsolete
  * and will be removed with 6.2. The class was renamed and is now located at:
diff --git a/typo3/sysext/wizard_crpages/Classes/Controller/CreatePagesWizardModuleFunctionController.php b/typo3/sysext/wizard_crpages/Classes/Controller/CreatePagesWizardModuleFunctionController.php
index 80c7edb600b7..09bbc78b0e01 100644
--- a/typo3/sysext/wizard_crpages/Classes/Controller/CreatePagesWizardModuleFunctionController.php
+++ b/typo3/sysext/wizard_crpages/Classes/Controller/CreatePagesWizardModuleFunctionController.php
@@ -80,7 +80,7 @@ class CreatePagesWizardModuleFunctionController extends \TYPO3\CMS\Backend\Modul
 	 * @todo Define visibility
 	 */
 	public function main() {
-		global $SOBE, $LANG;
+		$GLOBALS['LANG']->includeLLFile('EXT:wizard_crpages/locallang.xlf');
 		$theCode = '';
 		$this->tsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($this->pObj->id);
 		$this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array();
@@ -147,17 +147,17 @@ class CreatePagesWizardModuleFunctionController extends \TYPO3\CMS\Backend\Modul
 						$lines[] = '<nobr>' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec, array('title' => \TYPO3\CMS\Backend\Utility\BackendUtility::titleAttribForPages($rec, '', FALSE))) . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</nobr>';
 					}
 				}
-				$theCode .= '<h4>' . $LANG->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines);
+				$theCode .= '<h4>' . $GLOBALS['LANG']->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines);
 			} else {
 				// Display create form
 				$lines = array();
 				for ($a = 0; $a < 9; $a++) {
 					$lines[] = $this->getFormLine($a);
 				}
-				$theCode .= '<h4>' . $LANG->getLL('wiz_newPages') . ':</h4>' . '<div id="formFieldContainer">' . implode('', $lines) . '</div>' . '<br class="clearLeft" />' . '<input type="button" id="createNewFormFields" value="' . $LANG->getLL('wiz_newPages_addMoreLines') . '" />' . '<br /><br />
-				<input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> <label for="createInListEnd">' . $LANG->getLL('wiz_newPages_listEnd') . '</label><br />
-				<input type="checkbox" name="hidePages" id="hidePages" value="1" /> <label for="hidePages">' . $LANG->getLL('wiz_newPages_hidePages') . '</label><br /><br />
-				<input type="submit" name="create" value="' . $LANG->getLL('wiz_newPages_lCreate') . '" />&nbsp;<input type="reset" value="' . $LANG->getLL('wiz_newPages_lReset') . '" /><br />';
+				$theCode .= '<h4>' . $GLOBALS['LANG']->getLL('wiz_newPages') . ':</h4>' . '<div id="formFieldContainer">' . implode('', $lines) . '</div>' . '<br class="clearLeft" />' . '<input type="button" id="createNewFormFields" value="' . $GLOBALS['LANG']->getLL('wiz_newPages_addMoreLines') . '" />' . '<br /><br />
+				<input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> <label for="createInListEnd">' . $GLOBALS['LANG']->getLL('wiz_newPages_listEnd') . '</label><br />
+				<input type="checkbox" name="hidePages" id="hidePages" value="1" /> <label for="hidePages">' . $GLOBALS['LANG']->getLL('wiz_newPages_hidePages') . '</label><br /><br />
+				<input type="submit" name="create" value="' . $GLOBALS['LANG']->getLL('wiz_newPages_lCreate') . '" />&nbsp;<input type="reset" value="' . $GLOBALS['LANG']->getLL('wiz_newPages_lReset') . '" /><br />';
 				// Add ExtJS inline code
 				$extCode = '
 					var tpl = "' . addslashes(str_replace(array(LF, TAB), array('', ''), $this->getFormLine('#'))) . '", i, line, div, bg, label;
@@ -186,11 +186,11 @@ class CreatePagesWizardModuleFunctionController extends \TYPO3\CMS\Backend\Modul
 				');
 			}
 		} else {
-			$theCode .= $GLOBALS['TBE_TEMPLATE']->rfw($LANG->getLL('wiz_newPages_errorMsg1'));
+			$theCode .= $GLOBALS['TBE_TEMPLATE']->rfw($GLOBALS['LANG']->getLL('wiz_newPages_errorMsg1'));
 		}
 		// CSH
 		$theCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_web_func', 'tx_wizardcrpages', $GLOBALS['BACK_PATH'], '<br />|');
-		$out = $this->pObj->doc->header($LANG->getLL('wiz_crMany'));
+		$out = $this->pObj->doc->header($GLOBALS['LANG']->getLL('wiz_crMany'));
 		$out .= $this->pObj->doc->section('', $theCode, 0, 1);
 		return $out;
 	}
diff --git a/typo3/sysext/wizard_sortpages/Classes/View/SortPagesWizardModuleFunction.php b/typo3/sysext/wizard_sortpages/Classes/View/SortPagesWizardModuleFunction.php
index 5069d6c466a1..3262f98fafcb 100644
--- a/typo3/sysext/wizard_sortpages/Classes/View/SortPagesWizardModuleFunction.php
+++ b/typo3/sysext/wizard_sortpages/Classes/View/SortPagesWizardModuleFunction.php
@@ -54,8 +54,8 @@ class SortPagesWizardModuleFunction extends \TYPO3\CMS\Backend\Module\AbstractFu
 	 * @todo Define visibility
 	 */
 	public function main() {
-		global $SOBE, $LANG;
-		$out = $this->pObj->doc->header($LANG->getLL('wiz_sort'));
+		$GLOBALS['LANG']->includeLLFile('EXT:wizard_sortpages/locallang.xlf');
+		$out = $this->pObj->doc->header($GLOBALS['LANG']->getLL('wiz_sort'));
 		if ($GLOBALS['BE_USER']->workspace === 0) {
 			$theCode = '';
 			// Check if user has modify permissions to
@@ -87,34 +87,34 @@ class SortPagesWizardModuleFunction extends \TYPO3\CMS\Backend\Module\AbstractFu
 			if (count($menuItems)) {
 				$lines = array();
 				$lines[] = '<tr class="t3-row-header">
-				<td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title') . '</td>
-				' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms') ? '<td> ' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle') . '</td>' : '') . '
-				<td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp') . '</td>
-				<td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate') . '</td>
+				<td>' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_title'), 'title') . '</td>
+				' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms') ? '<td> ' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_subtitle'), 'subtitle') . '</td>' : '') . '
+				<td>' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tChange'), 'tstamp') . '</td>
+				<td>' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tCreate'), 'crdate') . '</td>
 				</tr>';
 				foreach ($menuItems as $rec) {
 					$m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(2);
 					// edit permissions for that page!
 					$pRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause);
-					$lines[] = '<tr><td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec) . (!is_array($pRec) ? $GLOBALS['TBE_TEMPLATE']->rfw('<strong>' . $LANG->getLL('wiz_W', 1) . '</strong> ') : '') . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '&nbsp;</td>
+					$lines[] = '<tr><td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec) . (!is_array($pRec) ? $GLOBALS['TBE_TEMPLATE']->rfw('<strong>' . $GLOBALS['LANG']->getLL('wiz_W', 1) . '</strong> ') : '') . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '&nbsp;</td>
 					' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms') ? '<td nowrap="nowrap">' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['subtitle'], $GLOBALS['BE_USER']->uc['titleLen'])) . '&nbsp;</td>' : '') . '
 					<td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($rec['tstamp']) . '&nbsp;&nbsp;</td>
 					<td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($rec['crdate']) . '&nbsp;&nbsp;</td>
 					</tr>';
 				}
-				$theCode .= '<h4>' . $LANG->getLL('wiz_currentPageOrder', TRUE) . '</h4>
+				$theCode .= '<h4>' . $GLOBALS['LANG']->getLL('wiz_currentPageOrder', TRUE) . '</h4>
 			<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $lines) . '</table><br />';
 				// Menu:
 				$lines = array();
-				$lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title');
+				$lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_title'), 'title');
 				if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
-					$lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle');
+					$lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_subtitle'), 'subtitle');
 				}
-				$lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp');
-				$lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate');
+				$lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tChange'), 'tstamp');
+				$lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tCreate'), 'crdate');
 				$lines[] = '';
-				$lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'), 'REV');
-				$theCode .= '<h4>' . $LANG->getLL('wiz_changeOrder') . '</h4>' . implode('<br />', $lines);
+				$lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_REVERSE'), 'REV');
+				$theCode .= '<h4>' . $GLOBALS['LANG']->getLL('wiz_changeOrder') . '</h4>' . implode('<br />', $lines);
 			} else {
 				$flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('no_subpages'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE);
 				$theCode .= $flashMessage->render();
-- 
GitLab