diff --git a/typo3/sysext/lang/Classes/LanguageService.php b/typo3/sysext/lang/Classes/LanguageService.php index 3b4fd66d5c77d64b19fa1dc50b907800fa215350..7a22abd99f7ed0f0611e3a4272cf37b6d0f9b125 100644 --- a/typo3/sysext/lang/Classes/LanguageService.php +++ b/typo3/sysext/lang/Classes/LanguageService.php @@ -461,4 +461,27 @@ class LanguageService { } } + /** + * Gets labels with a specific fetched from the current locallang file. + * This is useful for e.g gathering javascript labels. + * + * @param string $prefix Prefix to select the correct labels + * @param string $strip Sub-prefix to be removed from label names in the result + * @return array Processed labels + */ + public function getLabelsWithPrefix($prefix, $strip = '') { + $extraction = array(); + $labels = array_merge((array)$GLOBALS['LOCAL_LANG']['default'], (array)$GLOBALS['LOCAL_LANG'][$GLOBALS['LANG']->lang]); + // Regular expression to strip the selection prefix and possibly something from the label name: + $labelPattern = '#^' . preg_quote($prefix, '#') . '(' . preg_quote($strip, '#') . ')?#'; + // Iterate through all locallang labels: + foreach ($labels as $label => $value) { + if (strpos($label, $prefix) === 0) { + $key = preg_replace($labelPattern, '', $label); + $extraction[$key] = $value; + } + } + return $extraction; + } + } diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php index 5a478202d98419c95cca0c381f931be17698e335..6c2cf346fb0446b2fe131aad22251b2fe274a8f5 100644 --- a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php +++ b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php @@ -226,34 +226,11 @@ class RecyclerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass 'depth_4' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_4'), 'depth_infi' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi') ); - $extensionLabels = $this->getJavaScriptLabelsFromLocallang('js.', 'label_'); + $extensionLabels = $this->languageService->getLabelsWithPrefix('js.', 'label_'); $javaScriptLabels = array_merge($coreLabels, $extensionLabels); return $javaScriptLabels; } - /** - * Gets labels to be used in JavaScript fetched from the current locallang file. - * - * @param string $selectionPrefix Prefix to select the correct labels (default: 'js.') - * @param string $stripFromSelectionName Sub-prefix to be removed from label names in the result (default: '') - * @return array Labels to be used in JavaScript of the current locallang file - * @todo Check, whether this method can be moved in a generic way to $GLOBALS['LANG'] - */ - protected function getJavaScriptLabelsFromLocallang($selectionPrefix = 'js.', $stripFromSelectionName = '') { - $extraction = array(); - $labels = array_merge((array)$GLOBALS['LOCAL_LANG']['default'], (array)$GLOBALS['LOCAL_LANG'][$this->languageService->lang]); - // Regular expression to strip the selection prefix and possibly something from the label name: - $labelPattern = '#^' . preg_quote($selectionPrefix, '#') . '(' . preg_quote($stripFromSelectionName, '#') . ')?#'; - // Iterate through all locallang labels: - foreach ($labels as $label => $value) { - if (strpos($label, $selectionPrefix) === 0) { - $key = preg_replace($labelPattern, '', $label); - $extraction[$key] = $value; - } - } - return $extraction; - } - /** * Gets the buttons that shall be rendered in the docHeader. * diff --git a/typo3/sysext/t3editor/Classes/T3editor.php b/typo3/sysext/t3editor/Classes/T3editor.php index ed6de26f00596b921081829a3a04506db8cf5c2b..690e9a7723e4400f766b9b9a8c097dc9b96e50fd 100644 --- a/typo3/sysext/t3editor/Classes/T3editor.php +++ b/typo3/sysext/t3editor/Classes/T3editor.php @@ -180,7 +180,7 @@ class T3editor implements \TYPO3\CMS\Core\SingletonInterface { $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS( 'T3editor = T3editor || {};' . - 'T3editor.lang = ' . json_encode($this->getJavaScriptLabels()) . ';' . LF . + 'T3editor.lang = ' . json_encode($GLOBALS['LANG']->getLabelsWithPrefix('js.', 'label_')) . ';' . LF . 'T3editor.PATH_t3e = "' . $GLOBALS['BACK_PATH'] . $path_t3e . '"; ' . LF . 'T3editor.PATH_codemirror = "' . $GLOBALS['BACK_PATH'] . $path_codemirror . '"; ' . LF . 'T3editor.URL_typo3 = "' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir) . '"; ' . LF . @@ -300,42 +300,6 @@ class T3editor implements \TYPO3\CMS\Core\SingletonInterface { return '[' . $stylesheet . 'T3editor.PATH_t3e + "res/css/t3editor_inner.css"]'; } - /** - * Gets the labels to be used in JavaScript in the Ext JS interface. - * @todo this method is copied from EXT:Recycler, maybe this should be refactored into a helper class - * - * @return array The labels to be used in JavaScript - */ - protected function getJavaScriptLabels() { - $coreLabels = array(); - $extensionLabels = $this->getJavaScriptLabelsFromLocallang('js.', 'label_'); - return array_merge($coreLabels, $extensionLabels); - } - - /** - * Gets labels to be used in JavaScript fetched from the current locallang file. - * @todo this method is copied from EXT:Recycler, maybe this should be refactored into a helper class - * - * @param string $selectionPrefix Prefix to select the correct labels (default: 'js.') - * @param string $stripFromSelectionName Sub-prefix to be removed from label names in the result (default: '') - * @return array Lables to be used in JavaScript of the current locallang file - * @todo Check, whether this method can be moved in a generic way to $GLOBALS['LANG'] - */ - protected function getJavaScriptLabelsFromLocallang($selectionPrefix = 'js.', $stripFromSelectionName = '') { - $extraction = array(); - $labels = array_merge((array)$GLOBALS['LOCAL_LANG']['default'], (array)$GLOBALS['LOCAL_LANG'][$GLOBALS['LANG']->lang]); - // Regular expression to strip the selection prefix and possibly something from the label name: - $labelPattern = '#^' . preg_quote($selectionPrefix, '#') . '(' . preg_quote($stripFromSelectionName, '#') . ')?#'; - // Iterate throuh all locallang lables: - foreach ($labels as $label => $value) { - if (strpos($label, $selectionPrefix) === 0) { - $key = preg_replace($labelPattern, '', $label); - $extraction[$key] = $value; - } - } - return $extraction; - } - /** * Generates HTML with code editor *