From: Matthias Schmidt Date: Thu, 5 Jan 2012 10:19:52 +0000 (+0100) Subject: Adds possibility to disable I18nHandles's assignment of value variables X-Git-Tag: 2.0.0_Beta_1~1445^2~5^2^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=038c032a071b9bca91ba7ca6322d119b02a12a88;p=GitHub%2FWoltLab%2FWCF.git Adds possibility to disable I18nHandles's assignment of value variables --- 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; + } }