Project

General

Profile

Feature #23561 » rfc15741.diff

Administrator Admin, 2010-09-18 13:20

View differences:

t3lib/class.t3lib_pagerenderer.php
}
/**
* Gets labels to be used in JavaScript fetched from a locallang file.
*
* @param string Input is a file-reference (see t3lib_div::getFileAbsFileName). That file is expected to be a 'locallang.xml' file conataining a valid XML TYPO3 language structure.
* @param string Language key
* @param string Character set (option); if not set, determined by the language key
* @param integer Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
* @param string $selectionPrefix: Prefix to select the correct labels (default: '')
* @param string $stripFromSelectionName: Sub-prefix to be removed from label names in the result (default: '')
* @return void
*/
public function addInlineLanguageLabelFile($fileRef, $langKey, $charset = '', $errorMode = 0, $selectionPrefix = '', $stripFromSelectionName = '') {
$labelsFromFile = array();
$labels = t3lib_div::readLLfile($fileRef, $langKey, $charset, $errorMode);
// 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 labels:
foreach ((array)$labels as $label => $value) {
if ($selectionPrefix === '') {
$labelsFromFile[$label] = $value;
} elseif (strpos($label, $selectionPrefix) === 0) {
$key = preg_replace($labelPattern, '', $label);
$labelsFromFile[$key] = $value;
}
}
$this->inlineLanguageLabels = array_merge($this->inlineLanguageLabels, $labelsFromFile);
}
/**
* Adds Javascript Inline Setting. This will occur in TYPO3.settings - object
* The label can be used in scripts with TYPO3.setting.<key>
* Need extJs loaded
(1-1/3)