Properly handling installations with only one language
authorAlexander Ebert <ebert@woltlab.com>
Fri, 8 Jul 2016 14:31:36 +0000 (16:31 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 8 Jul 2016 14:31:46 +0000 (16:31 +0200)
wcfsetup/install/files/acp/templates/pageAddDialog.tpl
wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Page/Add.js
wcfsetup/install/files/lib/acp/form/PageAddForm.class.php
wcfsetup/install/files/lib/acp/page/PageListPage.class.php

index 122034276bb1fbfd34aa2c706bf8dd1d9ec6a48d..2d5647eac9f99299e5587170a8160e3484dab749 100644 (file)
                        </dd>
                </dl>
                
-               <dl>
-                       <dt>{lang}wcf.acp.page.i18n{/lang}</dt>
-                       <dd>
-                               <label><input type="radio" name="isMultilingual" value="0" checked> {lang}wcf.acp.page.i18n.none{/lang}</label>
-                               <small>{lang}wcf.acp.page.i18n.none.description{/lang}</small>
-                               <label><input type="radio" name="isMultilingual" value="1"> {lang}wcf.acp.page.i18n.i18n{/lang}</label>
-                               <small>{lang}wcf.acp.page.i18n.i18n.description{/lang}</small>
-                       </dd>
-               </dl>
+               {if $availableLanguages|count > 1}
+                       <dl>
+                               <dt>{lang}wcf.acp.page.i18n{/lang}</dt>
+                               <dd>
+                                       <label><input type="radio" name="isMultilingual" value="0" checked> {lang}wcf.acp.page.i18n.none{/lang}</label>
+                                       <small>{lang}wcf.acp.page.i18n.none.description{/lang}</small>
+                                       <label><input type="radio" name="isMultilingual" value="1"> {lang}wcf.acp.page.i18n.i18n{/lang}</label>
+                                       <small>{lang}wcf.acp.page.i18n.i18n.description{/lang}</small>
+                               </dd>
+                       </dl>
+               {/if}
                
                <div class="formSubmit">
                        <button class="buttonPrimary">{lang}wcf.global.button.next{/lang}</button>
@@ -33,7 +35,7 @@
                        'wcf.acp.page.add': '{lang}wcf.acp.page.add{/lang}'
                });
                
-               AcpUiPageAdd.init('{link controller='PageAdd' encode=false}{literal}pageType={$pageType}&isMultilingual={$isMultilingual}{/literal}{/link}');
+               AcpUiPageAdd.init('{link controller='PageAdd' encode=false}{literal}pageType={$pageType}&isMultilingual={$isMultilingual}{/literal}{/link}', {@$availableLanguages|count});
                
                {if $showPageAddDialog}
                        window.setTimeout(function() {
index 87b0713c4e8c47ffa825e3e0e16fade4f046480f..08c439fdf0f00826c20e4f3b6f08b4444f96e419 100644 (file)
@@ -9,7 +9,7 @@
 define(['Core', 'Language', 'Ui/Dialog'], function(Core, Language, UiDialog) {
        "use strict";
        
-       var _link;
+       var _languages, _link;
        
        /**
         * @exports     WoltLab/WCF/Acp/Ui/Page/Add
@@ -18,9 +18,11 @@ define(['Core', 'Language', 'Ui/Dialog'], function(Core, Language, UiDialog) {
                /**
                 * Initializes the page add handler.
                 * 
-                * @param       {string}        link    redirect URL
+                * @param       {string}        link            redirect URL
+                * @param       {int}           languages       number of available languages
                 */
-               init: function(link) {
+               init: function(link, languages) {
+                       _languages = languages;
                        _link = link;
                        
                        var buttons = elBySelAll('.jsButtonPageAdd');
@@ -51,7 +53,7 @@ define(['Core', 'Language', 'Ui/Dialog'], function(Core, Language, UiDialog) {
                                                        event.preventDefault();
                                                        
                                                        var pageType = elBySel('input[name="pageType"]:checked', content).value;
-                                                       var isMultilingual = elBySel('input[name="isMultilingual"]:checked', content).value;
+                                                       var isMultilingual = (_languages > 1) ? elBySel('input[name="isMultilingual"]:checked', content).value : 0;
                                                        
                                                        window.location = _link.replace(/{\$pageType}/, pageType).replace(/{\$isMultilingual}/, isMultilingual);
                                                });
index 4f80e76e35d5b32e70de39d3adfe8fef481ee9f8..98bd0bb6d59aaf1e182dab8a5c2924ca150e2df4 100644 (file)
@@ -155,8 +155,6 @@ class PageAddForm extends AbstractForm {
        public function readParameters() {
                parent::readParameters();
                
-               $this->readPageType();
-               
                // get available applications
                $applicationList = new ApplicationList();
                $applicationList->readObjects();
@@ -170,6 +168,8 @@ class PageAddForm extends AbstractForm {
                $boxList->sqlOrderBy = 'box.name';
                $boxList->readObjects();
                $this->availableBoxes = $boxList->getObjects();
+               
+               $this->readPageType();
        }
        
        /**
@@ -273,7 +273,7 @@ class PageAddForm extends AbstractForm {
                        throw new UserInputException('pageType');
                }
                
-               if ($this->pageType == 'system') {
+               if ($this->pageType == 'system' || count($this->availableLanguages) === 1) {
                        $this->isMultilingual = 0;
                }
        }
index 03e5318e4e9a2b961c228ec994469966374d78a9..4932b6460e4f5a1a32e2a74bb1939868b5eafd30 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\application\Application;
 use wcf\data\application\ApplicationList;
 use wcf\data\page\PageList;
 use wcf\page\SortablePage;
+use wcf\system\language\LanguageFactory;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
 
@@ -146,6 +147,7 @@ class PageListPage extends SortablePage {
                        'applicationPackageID' => $this->applicationPackageID,
                        'pageType' => $this->pageType,
                        'availableApplications' => $this->availableApplications,
+                       'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
                        'showPageAddDialog' => $this->showPageAddDialog
                ]);
        }