From 038c032a071b9bca91ba7ca6322d119b02a12a88 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 5 Jan 2012 11:19:52 +0100 Subject: [PATCH] Adds possibility to disable I18nHandles's assignment of value variables --- .../lib/system/language/I18nHandler.class.php | 80 ++++++++++++------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php index 77de974916..48e5626ead 100644 --- a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php +++ b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php @@ -17,6 +17,12 @@ use wcf\system\WCF; * @category Community Framework */ class I18nHandler extends SingletonFactory { + /** + * indicates if value variables are assigned in assignVariables() + * @var boolean + */ + protected $assignValueVariablesDisabled = false; + /** * list of element ids * @var array @@ -278,50 +284,66 @@ class I18nHandler extends SingletonFactory { $value = ''; $i18nValues = array(); - // use POST values instead of querying database - if ($useRequestData) { - if ($this->isPlainValue($elementID)) { - $value = $this->getValue($elementID); - } - else { - if ($this->hasI18nValues($elementID)) { - $i18nValues = $this->i18nValues[$elementID]; + if (!$this->assignValueVariablesDisabled) { + // use POST values instead of querying database + if ($useRequestData) { + if ($this->isPlainValue($elementID)) { + $value = $this->getValue($elementID); } else { - $i18nValues = array(); - } - } - } - else { - if (preg_match('~^'.$this->elementOptions[$elementID]['pattern'].'$~', $this->elementOptions[$elementID]['value'])) { - // use i18n values from language items - $sql = "SELECT languageID, languageItemValue - FROM wcf".WCF_N."_language_item - WHERE languageItem = ? - AND packageID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - $this->elementOptions[$elementID]['value'], - $this->elementOptions[$elementID]['packageID'] - )); - while ($row = $statement->fetchArray()) { - $i18nValues[$row['languageID']] = $row['languageItemValue']; + if ($this->hasI18nValues($elementID)) { + $i18nValues = $this->i18nValues[$elementID]; + } + else { + $i18nValues = array(); + } } } else { - // use data provided by setOptions() - $value = $this->elementOptions[$elementID]['value']; + if (preg_match('~^'.$this->elementOptions[$elementID]['pattern'].'$~', $this->elementOptions[$elementID]['value'])) { + // use i18n values from language items + $sql = "SELECT languageID, languageItemValue + FROM wcf".WCF_N."_language_item + WHERE languageItem = ? + AND packageID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + $this->elementOptions[$elementID]['value'], + $this->elementOptions[$elementID]['packageID'] + )); + while ($row = $statement->fetchArray()) { + $i18nValues[$row['languageID']] = $row['languageItemValue']; + } + } + else { + // use data provided by setOptions() + $value = $this->elementOptions[$elementID]['value']; + } } } $elementValues[$elementID] = $value; $elementValuesI18n[$elementID] = $i18nValues; } - + WCF::getTPL()->assign(array( 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(), 'i18nPlainValues' => $elementValues, 'i18nValues' => $elementValuesI18n )); } + + /** + * Disables assignment of value variables in assignVariables(). + */ + public function disableAssignValueVariables() { + $this->assignValueVariablesDisabled = true; + } + + /** + * Enables assignment of value variables in assignVariables(). + */ + public function enableAssignValueVariables() { + $this->assignValueVariablesDisabled = false; + } } -- 2.20.1