From: Alexander Ebert Date: Fri, 8 Jul 2016 14:31:36 +0000 (+0200) Subject: Properly handling installations with only one language X-Git-Tag: 3.0.0_Beta_1~1235 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1ee366225d2a24af3eedb8a3463978f6f13470ed;p=GitHub%2FWoltLab%2FWCF.git Properly handling installations with only one language --- diff --git a/wcfsetup/install/files/acp/templates/pageAddDialog.tpl b/wcfsetup/install/files/acp/templates/pageAddDialog.tpl index 122034276b..2d5647eac9 100644 --- a/wcfsetup/install/files/acp/templates/pageAddDialog.tpl +++ b/wcfsetup/install/files/acp/templates/pageAddDialog.tpl @@ -12,15 +12,17 @@ -
-
{lang}wcf.acp.page.i18n{/lang}
-
- - {lang}wcf.acp.page.i18n.none.description{/lang} - - {lang}wcf.acp.page.i18n.i18n.description{/lang} -
-
+ {if $availableLanguages|count > 1} +
+
{lang}wcf.acp.page.i18n{/lang}
+
+ + {lang}wcf.acp.page.i18n.none.description{/lang} + + {lang}wcf.acp.page.i18n.i18n.description{/lang} +
+
+ {/if}
@@ -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() { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Page/Add.js b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Page/Add.js index 87b0713c4e..08c439fdf0 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Page/Add.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Page/Add.js @@ -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); }); diff --git a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php index 4f80e76e35..98bd0bb6d5 100644 --- a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php @@ -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; } } diff --git a/wcfsetup/install/files/lib/acp/page/PageListPage.class.php b/wcfsetup/install/files/lib/acp/page/PageListPage.class.php index 03e5318e4e..4932b6460e 100644 --- a/wcfsetup/install/files/lib/acp/page/PageListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PageListPage.class.php @@ -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 ]); }