I18nHandler now provides reset()
authorAlexander Ebert <ebert@woltlab.com>
Mon, 29 Apr 2013 23:43:43 +0000 (01:43 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 29 Apr 2013 23:43:43 +0000 (01:43 +0200)
disableAssignValueVariables() and enableAssignValueVariables() have been removed in favor of reset().

wcfsetup/install/files/lib/acp/form/AbstractCategoryAddForm.class.php
wcfsetup/install/files/lib/acp/form/CronjobAddForm.class.php
wcfsetup/install/files/lib/acp/form/PageMenuItemAddForm.class.php
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserOptionCategoryAddForm.class.php
wcfsetup/install/files/lib/system/language/I18nHandler.class.php

index 94ba45a2b31bd6dcd2ff200272441ac3c198d801..df99bc6aabc813b51cb37d6ee543376fb09e5be9 100644 (file)
@@ -286,8 +286,8 @@ abstract class AbstractCategoryAddForm extends AbstractForm {
                
                $this->saved();
                
-               // disable assignment of i18n values
-               I18nHandler::getInstance()->disableAssignValueVariables();
+               // reset i18n values
+               I18nHandler::getInstance()->reset();
                
                // show success message
                WCF::getTPL()->assign('success', true);
index 758a6d8081ac0ba59cedace3d5323c9b0e6f80d9..13139d6816b7968fa1a1e0b58c0b23939cbf8dae 100755 (executable)
@@ -182,6 +182,7 @@ class CronjobAddForm extends AbstractForm {
                // reset values
                $this->className = $this->description = '';
                $this->startMinute = $this->startHour = $this->startDom = $this->startMonth = $this->startDow = '*';
+               I18nHandler::getInstance()->reset();
                
                // show success.
                WCF::getTPL()->assign(array(
index 0c71259361926e6de7c9f23c52fa2e17c206519d..9a4d7cbf06d4126b248a82d8e0f2823725671157 100644 (file)
@@ -239,8 +239,7 @@ class PageMenuItemAddForm extends AbstractForm {
                $this->menuItemController = $this->menuItemLink = $this->pageMenuItem = $this->parentMenuItem = '';
                $this->showOrder = 0;
                
-               // disable assignment of value variables
-               I18nHandler::getInstance()->disableAssignValueVariables();
+               I18nHandler::getInstance()->reset();
                
                // reload parent menu items
                if ($menuItem->menuPosition == 'header' && $menuItem->parentMenuItem == '') {
index 9a14217efcb347d7fddd5dc1774a51d65febefca..658c8da97a45cb7e710c4cd29a574153863b292f 100644 (file)
@@ -505,6 +505,8 @@ class StyleAddForm extends AbstractForm {
                $this->imagePath = 'images/';
                $this->templateGroupID = 0;
                
+               I18nHandler::getInstance()->reset();
+               
                // reload variables
                $this->readStyleVariables();
                
index abb59a9eb48a3aba58c6ef3a13878a170b94bb9f..8d8db44aff011e785351f2e0547170c10833bd78 100755 (executable)
@@ -157,6 +157,8 @@ class UserGroupAddForm extends AbstractOptionListForm {
                // reset values
                $this->groupName = '';
                $this->optionValues = array();
+               
+               I18nHandler::getInstance()->reset();
        }
        
        /**
index 229c32543e8f7baceaac95018406e82a1e5a697d..db0ae7a381a6667c7da26a86050d342aabff776d 100644 (file)
@@ -255,6 +255,8 @@ class UserOptionAddForm extends AbstractForm {
                $this->editable = 3;
                $this->visible = 15;
                
+               I18nHandler::getInstance()->reset();
+               
                // show success
                WCF::getTPL()->assign('success', true);
        }
index a7163c443d563622b60b8e49bfdd35c6b0d901f2..67e81fbe157f13da6873f445cb1c7030833df717 100644 (file)
@@ -99,7 +99,8 @@ class UserOptionCategoryAddForm extends AbstractForm {
                // reset values
                $this->categoryName = '';
                $this->showOrder = 0;
-               I18nHandler::getInstance()->disableAssignValueVariables();
+               
+               I18nHandler::getInstance()->reset();
                
                // show success
                WCF::getTPL()->assign(array(
index 9a612c849dfb919df38167728b3a83970030330d..c17f80fe9f1bc0495888d0850046d6db0caec0b3 100644 (file)
@@ -19,12 +19,6 @@ use wcf\util\StringUtil;
  * @category   Community Framework
  */
 class I18nHandler extends SingletonFactory {
-       /**
-        * indicates if value variables are assigned in assignVariables()
-        * @var boolean
-        */
-       protected $assignValueVariablesDisabled = false;
-       
        /**
         * list of available languages
         * @var array<wcf\data\language\Language>
@@ -374,51 +368,49 @@ class I18nHandler extends SingletonFactory {
                        $value = '';
                        $i18nValues = array();
                        
-                       if (!$this->assignValueVariablesDisabled) {
-                               // 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];
-                                                       // encoding the entries for javascript
-                                                       foreach ($i18nValues as $languageID => $value) {
-                                                               $i18nValues[$languageID] = StringUtil::encodeJS(StringUtil::unifyNewlines($value));
-                                                       }
-                                               }
-                                               else {
-                                                       $i18nValues = array();
-                                               }
-                                       }
+                       // use POST values instead of querying database
+                       if ($useRequestData) {
+                               if ($this->isPlainValue($elementID)) {
+                                       $value = $this->getValue($elementID);
                                }
                                else {
-                                       $isI18n = Regex::compile('^'.$this->elementOptions[$elementID]['pattern'].'$')->match($this->elementOptions[$elementID]['value']);
-                                       if (!$isI18n) {
-                                               // check if it's a regular language variable
-                                               $isI18n = Regex::compile('^([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9-_]+$')->match($this->elementOptions[$elementID]['value']);
-                                       }
-                                       
-                                       if ($isI18n) {
-                                               // use i18n values from language items
-                                               $sql = "SELECT  languageID, languageItemValue
-                                                       FROM    wcf".WCF_N."_language_item
-                                                       WHERE   languageItem = ?";
-                                               $statement = WCF::getDB()->prepareStatement($sql);
-                                               $statement->execute(array(
-                                                       $this->elementOptions[$elementID]['value']
-                                               ));
-                                               while ($row = $statement->fetchArray()) {
-                                                       $i18nValues[$row['languageID']] = StringUtil::encodeJS(StringUtil::unifyNewlines($row['languageItemValue']));
+                                       if ($this->hasI18nValues($elementID)) {
+                                               $i18nValues = $this->i18nValues[$elementID];
+                                               // encoding the entries for javascript
+                                               foreach ($i18nValues as $languageID => $value) {
+                                                       $i18nValues[$languageID] = StringUtil::encodeJS(StringUtil::unifyNewlines($value));
                                                }
                                        }
                                        else {
-                                               // use data provided by setOptions()
-                                               $value = $this->elementOptions[$elementID]['value'];
+                                               $i18nValues = array();
                                        }
                                }
                        }
+                       else {
+                               $isI18n = Regex::compile('^'.$this->elementOptions[$elementID]['pattern'].'$')->match($this->elementOptions[$elementID]['value']);
+                               if (!$isI18n) {
+                                       // check if it's a regular language variable
+                                       $isI18n = Regex::compile('^([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9-_]+$')->match($this->elementOptions[$elementID]['value']);
+                               }
+                               
+                               if ($isI18n) {
+                                       // use i18n values from language items
+                                       $sql = "SELECT  languageID, languageItemValue
+                                               FROM    wcf".WCF_N."_language_item
+                                               WHERE   languageItem = ?";
+                                       $statement = WCF::getDB()->prepareStatement($sql);
+                                       $statement->execute(array(
+                                               $this->elementOptions[$elementID]['value']
+                                       ));
+                                       while ($row = $statement->fetchArray()) {
+                                               $i18nValues[$row['languageID']] = StringUtil::encodeJS(StringUtil::unifyNewlines($row['languageItemValue']));
+                                       }
+                               }
+                               else {
+                                       // use data provided by setOptions()
+                                       $value = $this->elementOptions[$elementID]['value'];
+                               }
+                       }
                        
                        $elementValues[$elementID] = $value;
                        $elementValuesI18n[$elementID] = $i18nValues;
@@ -432,17 +424,10 @@ class I18nHandler extends SingletonFactory {
        }
        
        /**
-        * Disables assignment of value variables in assignVariables().
-        */
-       public function disableAssignValueVariables() {
-               $this->assignValueVariablesDisabled = true;
-       }
-       
-       /**
-        * Enables assignment of value variables in assignVariables().
+        * Resets internally stored data after creating a new object through a form.
         */
-       public function enableAssignValueVariables() {
-               $this->assignValueVariablesDisabled = false;
+       public function reset() {
+               $this->i18nValues = $this->plainValues = array();
        }
        
        /**