Fixed obsolete multilingualism choice if only one language is installed
authorMarcel Werk <burntime@woltlab.com>
Thu, 29 Sep 2016 09:51:51 +0000 (11:51 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 29 Sep 2016 09:51:58 +0000 (11:51 +0200)
wcfsetup/install/files/acp/templates/articleList.tpl
wcfsetup/install/files/acp/templates/boxAddDialog.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Box/Add.js
wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php
wcfsetup/install/files/lib/acp/page/ArticleListPage.class.php
wcfsetup/install/files/lib/acp/page/BoxListPage.class.php

index c2b96ad9900e423dfe64ac430472e45744f2a661..64bb36f548b3f8d527cb11d7bad379f552c99f78 100644 (file)
        
        <nav class="contentHeaderNavigation">
                <ul>
-                       <li><a href="#" class="button jsButtonArticleAdd"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.article.add{/lang}</span></a></li>
+                       {if $availableLanguages|count > 1}
+                               <li><a href="#" class="button jsButtonArticleAdd"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.article.add{/lang}</span></a></li>
+                       {else}
+                               <li><a href="{link controller='ArticleAdd'}{/link}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.article.add{/lang}</span></a></li>
+                       {/if}
                        
                        {event name='contentHeaderNavigation'}
                </ul>
                
                <nav class="contentFooterNavigation">
                        <ul>
-                               <li><a href="#" class="button jsButtonArticleAdd"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.article.add{/lang}</span></a></li>
+                               {if $availableLanguages|count > 1}
+                                       <li><a href="#" class="button jsButtonArticleAdd"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.article.add{/lang}</span></a></li>
+                               {else}
+                                       <li><a href="{link controller='ArticleAdd'}{/link}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.article.add{/lang}</span></a></li>
+                               {/if}
                                
                                {event name='contentFooterNavigation'}
                        </ul>
index 9e4334ffd67d04dce0831e999190881f1d0f0d70..d7d22ea9bca4211241e29a98971bf3da837bc381 100644 (file)
                        </dd>
                </dl>
                
-               <dl>
-                       <dt>{lang}wcf.acp.box.i18n{/lang}</dt>
-                       <dd>
-                               <label><input type="radio" name="isMultilingual" value="0" checked> {lang}wcf.acp.box.i18n.none{/lang}</label>
-                               <small>{lang}wcf.acp.box.i18n.none.description{/lang}</small>
-                               <label><input type="radio" name="isMultilingual" value="1"> {lang}wcf.acp.box.i18n.i18n{/lang}</label>
-                               <small>{lang}wcf.acp.box.i18n.i18n.description{/lang}</small>
-                       </dd>
-               </dl>
+               {if $availableLanguages|count > 1}
+                       <dl>
+                               <dt>{lang}wcf.acp.box.i18n{/lang}</dt>
+                               <dd>
+                                       <label><input type="radio" name="isMultilingual" value="0" checked> {lang}wcf.acp.box.i18n.none{/lang}</label>
+                                       <small>{lang}wcf.acp.box.i18n.none.description{/lang}</small>
+                                       <label><input type="radio" name="isMultilingual" value="1"> {lang}wcf.acp.box.i18n.i18n{/lang}</label>
+                                       <small>{lang}wcf.acp.box.i18n.i18n.description{/lang}</small>
+                               </dd>
+                       </dl>
+               {/if}
                
                <div class="formSubmit">
                        <button class="buttonPrimary">{lang}wcf.global.button.next{/lang}</button>
@@ -35,7 +37,7 @@
                        'wcf.acp.box.add': '{lang}wcf.acp.box.add{/lang}'
                });
                
-               AcpUiBoxAdd.init('{link controller='BoxAdd' encode=false}{literal}boxType={$boxType}&isMultilingual={$isMultilingual}{/literal}{/link}');
+               AcpUiBoxAdd.init('{link controller='BoxAdd' encode=false}{literal}boxType={$boxType}&isMultilingual={$isMultilingual}{/literal}{/link}', {@$availableLanguages|count});
                
                {if $showBoxAddDialog}
                        window.setTimeout(function() {
index 6bbeda22e01f709eafb3cbddb0b1f0f26d15b8cf..70fad3d1dae5ce54418bbac5fe1d5581e2f90a75 100644 (file)
@@ -9,7 +9,7 @@
 define(['Core', 'Language', 'Ui/Dialog'], function(Core, Language, UiDialog) {
        "use strict";
        
-       var _link;
+       var _languages, _link;
        
        /**
         * @exports     WoltLabSuite/Core/Acp/Ui/Box/Add
@@ -19,8 +19,10 @@ define(['Core', 'Language', 'Ui/Dialog'], function(Core, Language, UiDialog) {
                 * Initializes the box add handler.
                 * 
                 * @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('.jsButtonBoxAdd');
@@ -52,7 +54,7 @@ define(['Core', 'Language', 'Ui/Dialog'], function(Core, Language, UiDialog) {
                                                        
                                                        var boxType = elBySel('input[name="boxType"]:checked', content).value;
                                                        var isMultilingual = 0;
-                                                       if (boxType !== 'system') isMultilingual = elBySel('input[name="isMultilingual"]:checked', content).value;
+                                                       if (boxType !== 'system' && _languages > 1) isMultilingual = elBySel('input[name="isMultilingual"]:checked', content).value;
                                                        
                                                        window.location = _link.replace(/{\$boxType}/, boxType).replace(/{\$isMultilingual}/, isMultilingual);
                                                });
index b3eaeaf691c40347dbb34369d4f36f5edff8c2c2..88f3adbe80c41a2d54b1a701b71f754feaa02b01 100644 (file)
@@ -159,10 +159,10 @@ class ArticleAddForm extends AbstractForm {
                
                if (isset($_REQUEST['categoryID'])) $this->categoryID = intval($_REQUEST['categoryID']);
                
-               $this->readMultilingualSetting();
-               
                // get available languages
                $this->availableLanguages = LanguageFactory::getInstance()->getLanguages();
+               
+               $this->readMultilingualSetting();
        }
        
        /**
@@ -172,7 +172,7 @@ class ArticleAddForm extends AbstractForm {
                if (!empty($_REQUEST['isMultilingual'])) $this->isMultilingual = 1;
                
                // work-around to force adding article via dialog overlay
-               if (empty($_POST) && !isset($_REQUEST['isMultilingual'])) {
+               if (count($this->availableLanguages) > 1 && empty($_POST) && !isset($_REQUEST['isMultilingual'])) {
                        $parameters = ['showArticleAddDialog' => 1];
                        if ($this->categoryID) $parameters['categoryID'] = $this->categoryID;
                        HeaderUtil::redirect(LinkHandler::getInstance()->getLink('ArticleList', $parameters));
index 10293de9b473b33ceb0dcd35ad811ce20bfc8beb..244caa1ec5edd9a49fac5af7343e7cc572f295ee 100644 (file)
@@ -6,6 +6,7 @@ use wcf\data\article\ViewableArticleList;
 use wcf\data\category\CategoryNodeTree;
 use wcf\data\user\User;
 use wcf\page\SortablePage;
+use wcf\system\language\LanguageFactory;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
 
@@ -145,6 +146,7 @@ class ArticleListPage extends SortablePage {
                        'title' => $this->title,
                        'content' => $this->content,
                        'showArticleAddDialog' => $this->showArticleAddDialog,
+                       'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
                        'categoryNodeList' => (new CategoryNodeTree('com.woltlab.wcf.article.category'))->getIterator()
                ]);
        }
index b578766453812c43a7b77b954fb055d71831a362..42996f1733c77bd39a323a4e49813916b15d6c15 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\acp\page;
 use wcf\data\box\Box;
 use wcf\data\box\BoxList;
 use wcf\page\SortablePage;
+use wcf\system\language\LanguageFactory;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
 
@@ -137,6 +138,7 @@ class BoxListPage extends SortablePage {
                        'boxType' => $this->boxType,
                        'position' => $this->position,
                        'availablePositions' => Box::$availablePositions,
+                       'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
                        'showBoxAddDialog' => $this->showBoxAddDialog
                ]);
        }