Fix language export
authorMatthias Schmidt <gravatronics@live.com>
Wed, 14 Jan 2015 18:02:58 +0000 (19:02 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Wed, 14 Jan 2015 18:02:58 +0000 (19:02 +0100)
wcfsetup/install/files/acp/templates/languageExport.tpl
wcfsetup/install/files/lib/acp/form/LanguageExportForm.class.php

index 4940d06e1134a3f553548ce6bdc096681dad50d4..b0f2b9757e5640fdf1eaec6c4fa18d2d4d6bd5ef 100644 (file)
        <nav>
                <ul>
                        <li><a href="{link controller='LanguageList'}{/link}" class="button"><span class="icon icon16 icon-list"></span> <span>{lang}wcf.acp.menu.link.language.list{/lang}</span></a></li>
-                               
+                       
                        {event name='contentNavigationButtons'}
                </ul>
        </nav>
 </div>
 
-<form enctype="multipart/form-data" method="post" action="{link controller='LanguageExport' id=$languageID}{/link}">
+<form enctype="multipart/form-data" method="post" action="{link controller='LanguageExport'}{/link}">
        <div class="container containerPadding marginTop">
                <fieldset>
                        <legend>{lang}wcf.acp.language.export{/lang}</legend>
                        
-                       <dl>
+                       <dl{if $errorField == 'languageID'} class="formError"{/if}>
                                <dt><label for="languageID">{lang}wcf.user.language{/lang}</label></dt>
                                <dd>
                                        {htmlOptions options=$languages selected=$languageID name='languageID' id='languageID'}
+                                       {if $errorField == 'languageID'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'noValidSelection'}
+                                                               {lang}wcf.global.form.error.noValidSelection{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.language.languageID.error.{@$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
                                </dd>
                        </dl>
                        
@@ -61,4 +70,4 @@
        </div>
 </form>
 
-{include file='footer'}
\ No newline at end of file
+{include file='footer'}
index 8503d1c12c7470a4e0d4ae51fe40543ac4a5fc40..8496570a43fd9de26ba6ccea5c1c451f14c02acf 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\language\LanguageEditor;
 use wcf\data\package\Package;
 use wcf\form\AbstractForm;
 use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\UserInputException;
 use wcf\system\language\LanguageFactory;
 use wcf\system\WCF;
 use wcf\util\ArrayUtil;
@@ -12,7 +13,7 @@ use wcf\util\ArrayUtil;
  * Shows the language export form.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage acp.form
@@ -71,13 +72,7 @@ class LanguageExportForm extends AbstractForm {
        public function readParameters() {
                parent::readParameters();
                
-               // get language editor object
                if (isset($_REQUEST['id'])) $this->languageID = intval($_REQUEST['id']);
-               $language = LanguageFactory::getInstance()->getLanguage($this->languageID);
-               if ($language === null) {
-                       throw new IllegalLinkException();
-               }
-               $this->language = new LanguageEditor($language);
        }
        
        /**
@@ -92,9 +87,21 @@ class LanguageExportForm extends AbstractForm {
                        if (isset($this->selectedPackages[0])) unset($this->selectedPackages[0]);
                }
                
-               if (isset($_POST['exportCustomValues'])) {
-                       $this->exportCustomValues = intval($_POST['exportCustomValues']);
+               if (isset($_POST['exportCustomValues'])) $this->exportCustomValues = intval($_POST['exportCustomValues']);
+               if (isset($_POST['languageID'])) $this->languageID = intval($_POST['languageID']);
+       }
+       
+       /**
+        * @see \wcf\form\IForm::validate()
+        */
+       public function validate() {
+               parent::validate();
+               
+               $language = LanguageFactory::getInstance()->getLanguage($this->languageID);
+               if ($language === null) {
+                       throw new UserInputException('languageID', 'noValidSelection');
                }
+               $this->language = new LanguageEditor($language);
        }
        
        /**
@@ -103,6 +110,14 @@ class LanguageExportForm extends AbstractForm {
        public function readData() {
                parent::readData();
                
+               if (empty($_POST) && $this->languageID) {
+                       $language = LanguageFactory::getInstance()->getLanguage($this->languageID);
+                       if ($language === null) {
+                               throw new IllegalLinkException();
+                       }
+                       $this->language = new LanguageEditor($language);
+               }
+               
                $this->readPackages();
        }