From ee61e640f9fc16cb2032d8bfa796fd2a6787f03c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 2 Jan 2013 00:48:03 +0100 Subject: [PATCH] Merged com.woltlab.wcf.acp.language --- com.woltlab.wcf/acpMenu.xml | 40 ++++ .../files/acp/templates/languageAdd.tpl | 137 +++++++++++ .../files/acp/templates/languageExport.tpl | 72 ++++++ .../files/acp/templates/languageList.tpl | 143 ++++++++++++ .../acp/templates/languageMultilingualism.tpl | 55 +++++ .../files/acp/templates/languageServerAdd.tpl | 59 +++++ .../acp/templates/languageServerList.tpl | 106 +++++++++ .../lib/acp/form/LanguageAddForm.class.php | 217 ++++++++++++++++++ .../lib/acp/form/LanguageExportForm.class.php | 156 +++++++++++++ .../LanguageMultilingualismForm.class.php | 153 ++++++++++++ .../acp/form/LanguageServerAddForm.class.php | 103 +++++++++ .../acp/form/LanguageServerEditForm.class.php | 95 ++++++++ .../lib/acp/page/LanguageListPage.class.php | 64 ++++++ .../acp/page/LanguageServerListPage.class.php | 52 +++++ wcfsetup/install/lang/de.xml | 42 ++++ 15 files changed, 1494 insertions(+) create mode 100644 wcfsetup/install/files/acp/templates/languageAdd.tpl create mode 100644 wcfsetup/install/files/acp/templates/languageExport.tpl create mode 100644 wcfsetup/install/files/acp/templates/languageList.tpl create mode 100644 wcfsetup/install/files/acp/templates/languageMultilingualism.tpl create mode 100644 wcfsetup/install/files/acp/templates/languageServerAdd.tpl create mode 100644 wcfsetup/install/files/acp/templates/languageServerList.tpl create mode 100644 wcfsetup/install/files/lib/acp/form/LanguageAddForm.class.php create mode 100644 wcfsetup/install/files/lib/acp/form/LanguageExportForm.class.php create mode 100644 wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php create mode 100644 wcfsetup/install/files/lib/acp/form/LanguageServerAddForm.class.php create mode 100644 wcfsetup/install/files/lib/acp/form/LanguageServerEditForm.class.php create mode 100644 wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php create mode 100644 wcfsetup/install/files/lib/acp/page/LanguageServerListPage.class.php diff --git a/com.woltlab.wcf/acpMenu.xml b/com.woltlab.wcf/acpMenu.xml index e46669698c..e54538c985 100644 --- a/com.woltlab.wcf/acpMenu.xml +++ b/com.woltlab.wcf/acpMenu.xml @@ -254,6 +254,46 @@ 3 + + + wcf.acp.menu.link.display + + + + wcf.acp.menu.link.language + + admin.language.canEditLanguage,admin.language.canDeleteLanguage + + + + wcf.acp.menu.link.language + + admin.language.canAddLanguage + + + + wcf.acp.menu.link.language + + admin.language.canEditLanguage + + + + wcf.acp.menu.link.language + + + + + wcf.acp.menu.link.language.server + admin.language.canEditServer,admin.language.canDeleteServer + + + + + wcf.acp.menu.link.language.server + admin.language.canAddServer + + + wcf.acp.menu.link.display diff --git a/wcfsetup/install/files/acp/templates/languageAdd.tpl b/wcfsetup/install/files/acp/templates/languageAdd.tpl new file mode 100644 index 0000000000..507ce64167 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageAdd.tpl @@ -0,0 +1,137 @@ +{include file='header' pageTitle='wcf.acp.language.add'} + + + +
+
+

{lang}wcf.acp.language.add{/lang}

+
+
+ +{if $errorField} +

{lang}wcf.global.form.error{/lang}

+{/if} + +{if $success|isset} +

{lang}wcf.global.form.add.success{/lang}

+{/if} + +{hascontent} +
+ +
+{/hascontent} + +
+
+
+ {lang}wcf.acp.language.add.mode{/lang} + +
+
+ + +
+
+
+ +
+ {lang}wcf.acp.language.import.source{/lang} + + +
+
+ + {if $errorField == 'languageFile'} + + {if $errorType == 'empty'} + {lang}wcf.global.error.empty{/lang} + {else} + {lang}wcf.acp.language.import.error{/lang} {$errorType} + {/if} + + {/if} + {lang}wcf.acp.language.import.source.file.description{/lang} +
+ + + +
+
+ + {if $errorField == 'languageUpload'} + + {lang}wcf.acp.language.import.error{/lang} {$errorType} + + {/if} +
+ +
+ +
+ {lang}wcf.acp.language.add.new{/lang} + + +
+
+ + {if $errorField == 'languageCode'} + + {if $errorType == 'empty'} + {lang}wcf.global.error.empty{/lang} + {else} + {lang}wcf.acp.language.add.languageCode.error.{@$errorType}{/lang} + {/if} + + {/if} + {lang}wcf.acp.language.code.description{/lang} +
+ + + +
+
+ + {if $errorField == 'sourceLanguageID'} + + {if $errorType == 'empty'} + {lang}wcf.global.error.empty{/lang} + {else} + {lang}wcf.acp.language.add.source.error.{@$errorType}{/lang} + {/if} + + {/if} +
+ +
+ + {event name='fieldsets'} +
+ +
+ +
+
+ +{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/languageExport.tpl b/wcfsetup/install/files/acp/templates/languageExport.tpl new file mode 100644 index 0000000000..e0e2af949f --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageExport.tpl @@ -0,0 +1,72 @@ +{include file='header' pageTitle='wcf.acp.language.export'} + +
+
+

{lang}wcf.acp.language.export{/lang}

+
+
+ +{if $errorField} +

{lang}wcf.global.form.error{/lang}

+{/if} + +{if $success|isset} +

{lang}wcf.acp.language.add.success{/lang}

+{/if} + +{hascontent} +
+ +
+{/hascontent} + +
+
+
+ {lang}wcf.acp.language.export{/lang} + +
+
+
+ {htmlOptions options=$languages selected=$languageID name='languageID' id='languageID'} +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+ +{include file='footer'} \ No newline at end of file diff --git a/wcfsetup/install/files/acp/templates/languageList.tpl b/wcfsetup/install/files/acp/templates/languageList.tpl new file mode 100644 index 0000000000..eab0115782 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageList.tpl @@ -0,0 +1,143 @@ +{include file='header' pageTitle='wcf.acp.language.list'} + + + +
+
+

{lang}wcf.acp.language.list{/lang}

+
+
+ +
+ {pages print=true assign=pagesLinks controller='LanguageList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"} + + {hascontent} + + {/hascontent} +
+ +{if $objects|count} +
+
+

{lang}wcf.acp.language.list{/lang} {#$items}

+
+ + + + + + + + + + + + + + {foreach from=$objects item=language} + + + + + + + + + {/foreach} + +
{lang}wcf.global.objectID{/lang}{if $sortField == 'languageID'} {/if}{lang}wcf.acp.language.name{/lang}{if $sortField == 'languageName'} {/if}{lang}wcf.acp.language.users{/lang}{if $sortField == 'users'} {/if}{lang}wcf.acp.language.variables{/lang}{if $sortField == 'variables'} {/if}{lang}wcf.acp.language.customVariables{/lang}{if $sortField == 'customVariables'} {/if}
+ {if $__wcf->getSession()->getPermission('admin.language.canEditLanguage')} + + {else} + + {/if} + + {if $__wcf->getSession()->getPermission('admin.language.canEditLanguage')} + {if !$language->isDefault} + + {else} + + {/if} + {else} + + {/if} + + {if $__wcf->getSession()->getPermission('admin.language.canEditLanguage')} + + {else} + + {/if} + {if $__wcf->getSession()->getPermission('admin.language.canDeleteLanguage')} + {if !$language->isDefault} + + {else} + + {/if} + {else} + + {/if} + {@$language->languageID} + {if $__wcf->getSession()->getPermission('admin.language.canEditLanguage')} + {$language->languageName} ({@$language->languageCode}) + {else} + {$language->languageName} ({@$language->languageCode}) + {/if} + {#$language->users}{#$language->variables}{if $language->customVariables > 0 && $__wcf->getSession()->getPermission('admin.language.canEditLanguage')}{#$language->customVariables}{else}{#$language->customVariables}{/if}
+
+ +
+ {@$pagesLinks} + + {hascontent} + + {/hascontent} +
+{/if} + +{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/languageMultilingualism.tpl b/wcfsetup/install/files/acp/templates/languageMultilingualism.tpl new file mode 100644 index 0000000000..1dc94b15a0 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageMultilingualism.tpl @@ -0,0 +1,55 @@ +{include file='header' pageTitle='wcf.acp.language.multilingualism'} + + + +
+
+

{lang}wcf.acp.language.multilingualism{/lang}

+
+
+ +{if $errorField} +

{lang}wcf.global.form.error{/lang}

+{/if} + +{if $success|isset} +

{lang}wcf.acp.language.multilingualism.success{/lang}

+{/if} + +
+
+
+ + {lang}wcf.acp.language.multilingualism.enable.description{/lang} + +
+
+
+ {htmlCheckboxes options=$languages name=languageIDs selected=$languageIDs disableEncoding=true} + + {if $errorField == 'languageIDs'} + + {lang}wcf.acp.language.multilingualism.languages.error.{@$errorType}{/lang} + + {/if} +
+
+ + {event name='additionalFields'} +
+
+ +
+ +
+
+ +{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/languageServerAdd.tpl b/wcfsetup/install/files/acp/templates/languageServerAdd.tpl new file mode 100644 index 0000000000..b90a029ca7 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageServerAdd.tpl @@ -0,0 +1,59 @@ +{include file='header' pageTitle='wcf.acp.languageServer.'|concat:$action} + +
+
+

{lang}wcf.acp.languageServer.{$action}{/lang}

+
+
+ +{if $errorField} +

{lang}wcf.global.form.error{/lang}

+{/if} + +{if $success|isset} +

{lang}wcf.acp.languageServer.{$action}.success{/lang}

+{/if} + +{hascontent} +
+ +
+{/hascontent} + +
+
+
+ {lang}wcf.acp.languageServer.data{/lang} + + +
+
+ + {if $errorField == 'server'} + + {if $errorType == 'empty'}{lang}wcf.global.error.empty{/lang}{/if} + {if $errorType == 'notValid'}{lang}wcf.acp.languageServer.server.error.notValid{/lang}{/if} + + {/if} + {lang}wcf.acp.languageServer.server.description{/lang} +
+ +
+
+ +
+ +
+
+ +{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/languageServerList.tpl b/wcfsetup/install/files/acp/templates/languageServerList.tpl new file mode 100644 index 0000000000..b4861e18d4 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/languageServerList.tpl @@ -0,0 +1,106 @@ +{include file='header' pageTitle='wcf.acp.languageServer.list'} + + + +
+
+

{lang}wcf.acp.languageServer.list{/lang}

+
+
+ +
+ {pages print=true assign=pagesLinks controller='LanguageServerList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"} + + {hascontent} + + {/hascontent} +
+ +{if !$languageServers|count} +

{lang}wcf.acp.languageServer.view.noneAvailable{/lang}

+{else} +
+
+

{lang}wcf.acp.languageServer.list{/lang} {#$items}

+
+ + + + + + + + + + {foreach from=$languageServers item=languageServer} + + + + + + {/foreach} + +
{lang}wcf.global.objectID{/lang}{if $sortField == 'languageServerID'} {/if}{lang}wcf.acp.languageServer.serverURL{/lang}{if $sortField == 'serverURL'} {/if}
+ {if $__wcf->getSession()->getPermission('admin.language.canEditServer')} + + + {else} + + + {/if} + + {if $__wcf->getSession()->getPermission('admin.language.canDeleteServer')} + + {else} + + {/if} + {@$languageServer->languageServerID} + {if $__wcf->getSession()->getPermission('admin.language.canEditServer')} + {@$languageServer->serverURL} + {else} + {@$languageServer->serverURL} + {/if} +
+
+ +
+ {@$pagesLinks} + + {hascontent} + + {/hascontent} +
+{/if} + +{include file='footer'} diff --git a/wcfsetup/install/files/lib/acp/form/LanguageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageAddForm.class.php new file mode 100644 index 0000000000..af033abb94 --- /dev/null +++ b/wcfsetup/install/files/lib/acp/form/LanguageAddForm.class.php @@ -0,0 +1,217 @@ + + * @package com.woltlab.wcf + * @subpackage acp.form + * @category Community Framework + */ +class LanguageAddForm extends AbstractForm { + /** + * @see wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.language.add'; + + /** + * file name + * @var string + */ + public $filename = ''; + + /** + * import field + * @var string + */ + public $importField = 'languageFile'; + + /** + * language object + * @var wcf\data\language\Language + */ + public $language = null; + + /** + * language code + * @var string + */ + public $languageCode = ''; + + /** + * import language file + * @var string + */ + public $languageFile = ''; + + /** + * list of available languages + * @var array + */ + public $languages = array(); + + /** + * mode + * @var string + */ + public $mode = 'import'; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.language.canAddLanguage'); + + /** + * source language object + * @var wcf\data\language\Language + */ + public $sourceLanguage = null; + + /** + * source language id + * @var integer + */ + public $sourceLanguageID = 0; + + /** + * @see wcf\form\Form::readFormParameters() + */ + public function readFormParameters() { + parent::readFormParameters(); + + // mode + if (isset($_POST['mode'])) $this->mode = $_POST['mode']; + + // copy + if (isset($_POST['languageCode'])) $this->languageCode = $_POST['languageCode']; + if (isset($_POST['sourceLanguageID'])) $this->sourceLanguageID = intval($_POST['sourceLanguageID']); + + // import + if (isset($_POST['languageFile']) && !empty($_POST['languageFile'])) { + $this->languageFile = $_POST['languageFile']; + $this->filename = $_POST['languageFile']; + } + if (isset($_FILES['languageUpload']) && !empty($_FILES['languageUpload']['tmp_name'])) { + $this->importField = 'languageUpload'; + $this->filename = $_FILES['languageUpload']['tmp_name']; + } + } + + /** + * @see wcf\form\Form::validate() + */ + public function validate() { + parent::validate(); + + if ($this->mode == 'copy') { + // language code + if (empty($this->languageCode)) { + throw new UserInputException('languageCode'); + } + + // + if (LanguageFactory::getInstance()->getLanguageByCode($this->languageCode)) { + throw new UserInputException('languageCode', 'notUnique'); + } + + // source language id + if (empty($this->sourceLanguageID)) { + throw new UserInputException('sourceLanguageID'); + } + + // get language + $this->sourceLanguage = LanguageFactory::getInstance()->getLanguage($this->sourceLanguageID); + if (!$this->sourceLanguage->languageID) { + throw new UserInputException('sourceLanguageID'); + } + } + else { + // check file + if (!file_exists($this->filename)) { + throw new UserInputException('languageFile'); + } + + // try to import + try { + // open xml document + $xml = new XML(); + $xml->load($this->filename); + + // import xml document + $this->language = LanguageEditor::importFromXML($xml, PACKAGE_ID); + } + catch (SystemException $e) { + throw new UserInputException($this->importField, $e->getMessage()); + } + } + } + + /** + * @see wcf\form\Form::save() + */ + public function save() { + parent::save(); + + if ($this->mode == 'copy') { + $this->language = LanguageEditor::create(array( + 'languageCode' => StringUtil::toLowerCase($this->languageCode) + )); + $languageEditor = new LanguageEditor($this->sourceLanguage); + $languageEditor->copy($this->language); + } + + LanguageFactory::getInstance()->clearCache(); + LanguageFactory::getInstance()->deleteLanguageCache(); + + $this->saved(); + + // show success message + WCF::getTPL()->assign('success', true); + } + + /** + * @see wcf\page\Page::readData() + */ + public function readData() { + parent::readData(); + + $this->languages = LanguageFactory::getInstance()->getLanguages(); + } + + /** + * @see wcf\page\Page::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'mode' => $this->mode, + 'languageCode' => $this->languageCode, + 'sourceLanguageID' => $this->sourceLanguageID, + 'languages' => $this->languages, + 'languageFile' => $this->languageFile + )); + } + + /** + * @see wcf\page\Page::show() + */ + public function show() { + // check master password + WCFACP::checkMasterPassword(); + + parent::show(); + } +} diff --git a/wcfsetup/install/files/lib/acp/form/LanguageExportForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageExportForm.class.php new file mode 100644 index 0000000000..e05b861dd1 --- /dev/null +++ b/wcfsetup/install/files/lib/acp/form/LanguageExportForm.class.php @@ -0,0 +1,156 @@ + + * @package com.woltlab.wcf + * @subpackage acp.form + * @category Community Framework + */ +class LanguageExportForm extends AbstractForm { + /** + * @see wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.language'; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.language.canEditLanguage'); + + /** + * language id + * @var integer + */ + public $languageID = 0; + + /** + * language editor object + * @var wcf\data\language\LanguageEditor + */ + public $language = null; + + /** + * selected packages + * @var array + */ + public $selectedPackages = array(); + + /** + * available packages + * @var array + */ + public $packages = array(); + + /** + * true to export custom variables + * @var boolean + */ + public $exportCustomValues = false; + + /** + * max package name length + * @var integer + */ + public $packageNameLength = 0; + + /** + * @see wcf\page\IPage::readParameters() + */ + 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); + } + + /** + * @see wcf\form\IForm::readFormParameters() + */ + public function readFormParameters() { + parent::readFormParameters(); + + if (isset($_POST['selectedPackages']) && is_array($_POST['selectedPackages'])) { + $selectedPackages = ArrayUtil::toIntegerArray($_POST['selectedPackages']); + $this->selectedPackages = array_combine($selectedPackages, $selectedPackages); + if (isset($this->selectedPackages[0])) unset($this->selectedPackages[0]); + } + + if (isset($_POST['exportCustomValues'])) { + $this->exportCustomValues = intval($_POST['exportCustomValues']); + } + } + + /** + * @see wcf\page\IPage::readData() + */ + public function readData() { + parent::readData(); + + $this->readPackages(); + } + + /** + * @see wcf\form\IForm::save() + */ + public function save() { + parent::save(); + + // send headers + header('Content-Type: text/xml; charset=UTF-8'); + header('Content-Disposition: attachment; filename="'.$this->language->languageCode.'.xml"'); + $this->language->export($this->selectedPackages, $this->exportCustomValues); + exit; + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'languageID' => $this->languageID, + 'languages' => LanguageFactory::getInstance()->getLanguages(), + 'selectedPackages' => $this->selectedPackages, + 'packages' => $this->packages, + 'selectAllPackages' => true, + 'packageNameLength' => $this->packageNameLength + )); + } + + /** + * Read available packages. + */ + protected function readPackages() { + $sql = "SELECT * + FROM wcf".WCF_N."_package + ORDER BY packageName"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($this->languageID)); + while ($row = $statement->fetchArray()) { + $row['packageNameLength'] = StringUtil::length(WCF::getLanguage()->get($row['packageName'])); + $this->packages[] = new Package(null, $row); + if ($row['packageNameLength'] > $this->packageNameLength) { + $this->packageNameLength = $row['packageNameLength']; + } + } + } +} diff --git a/wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php new file mode 100644 index 0000000000..7c1e326fa3 --- /dev/null +++ b/wcfsetup/install/files/lib/acp/form/LanguageMultilingualismForm.class.php @@ -0,0 +1,153 @@ + + * @package com.woltlab.wcf + * @subpackage acp.form + * @category Community Framework + */ +class LanguageMultilingualismForm extends AbstractForm { + /** + * @see wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.language.multilingualism'; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.language.canEditLanguage'); + + // data + // todo: comment + public $enable = 0; + public $languageIDs = array(); + public $languages = array(); + public $languageList = array(); + + /** + * @see wcf\page\IPage::readParameters() + */ + public function readParameters() { + parent::readParameters(); + + $this->languages = LanguageFactory::getInstance()->getLanguages(); + } + + /** + * @see wcf\form\IForm::readFormParameters() + */ + public function readFormParameters() { + parent::readFormParameters(); + + if (isset($_POST['enable'])) $this->enable = intval($_POST['enable']); + if (isset($_POST['languageIDs']) && is_array($_POST['languageIDs'])) $this->languageIDs = ArrayUtil::toIntegerArray($_POST['languageIDs']); + } + + /** + * @see wcf\form\IForm::validate() + */ + public function validate() { + parent::validate(); + + if ($this->enable == 1) { + // add default language + if (!in_array(LanguageFactory::getInstance()->getDefaultLanguageID(), $this->languageIDs)) { + $this->languageIDs[] = LanguageFactory::getInstance()->getDefaultLanguageID(); + } + + // validate language ids + $contentLanguages = 0; + foreach ($this->languageIDs as $languageID) { + if (isset($this->languages[$languageID])) { + $contentLanguages++; + } + } + + if ($contentLanguages < 2) { + throw new UserInputException('languageIDs'); + } + } + } + + /** + * @see wcf\form\IForm::save() + */ + public function save() { + parent::save(); + + // save + LanguageEditor::enableMultilingualism(($this->enable == 1 ? $this->languageIDs : array())); + + // clear cache + CacheHandler::getInstance()->clear(WCF_DIR.'cache/', 'cache.language.php'); + $this->saved(); + + // show success message + WCF::getTPL()->assign('success', true); + } + + /** + * @see wcf\page\IPage::readData() + */ + public function readData() { + parent::readData(); + + if (empty($_POST)) { + // default values + $contentLanguages = 0; + foreach ($this->languages as $languageID => $language) { + if ($language->hasContent) { + $contentLanguages++; + $this->languageIDs[] = $languageID; + } + } + + // add default language + if (!in_array(LanguageFactory::getInstance()->getDefaultLanguageID(), $this->languageIDs)) { + $this->languageIDs[] = LanguageFactory::getInstance()->getDefaultLanguageID(); + } + + if ($contentLanguages > 1) { + $this->enable = 1; + } + } + + $this->languageList = LanguageFactory::getInstance()->getLanguages(); + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'enable' => $this->enable, + 'languageIDs' => $this->languageIDs, + 'languages' => $this->languageList + )); + } + + /** + * @see wcf\page\IPage::show() + */ + public function show() { + // check master password + WCFACP::checkMasterPassword(); + + parent::show(); + } +} diff --git a/wcfsetup/install/files/lib/acp/form/LanguageServerAddForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageServerAddForm.class.php new file mode 100644 index 0000000000..bde18715e5 --- /dev/null +++ b/wcfsetup/install/files/lib/acp/form/LanguageServerAddForm.class.php @@ -0,0 +1,103 @@ + + * @package com.woltlab.wcf + * @subpackage acp.form + * @category Community Framework + */ +class LanguageServerAddForm extends AbstractForm { + /** + * @see wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.language.server.add'; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.language.canAddServer'); + + /** + * server url + * @var string + */ + public $server = ''; + + /** + * @see wcf\form\IForm::readFormParameters() + */ + public function readFormParameters() { + parent::readFormParameters(); + + if (isset($_POST['server'])) $this->server = StringUtil::trim($_POST['server']); + } + + /** + * @see wcf\form\IForm::validate() + */ + public function validate() { + parent::validate(); + + if (empty($this->server)) { + throw new UserInputException('server'); + } + + if (!PackageUpdateServer::isValidServerURL($this->server)) { + throw new UserInputException('server', 'notValid'); + } + } + + /** + * @see wcf\form\IForm::save() + */ + public function save() { + parent::save(); + + // save server + $this->objectAction = new LanguageServerAction(array(), 'create', array('data' => array( + 'serverURL' => $this->server + ))); + $this->objectAction->executeAction(); + $this->saved(); + + // reset values + $this->server = ''; + + // show success message + WCF::getTPL()->assign('success', true); + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'server' => $this->server, + 'action' => 'add' + )); + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function show() { + // check master password + WCFACP::checkMasterPassword(); + + parent::show(); + } +} diff --git a/wcfsetup/install/files/lib/acp/form/LanguageServerEditForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageServerEditForm.class.php new file mode 100644 index 0000000000..30f2981a13 --- /dev/null +++ b/wcfsetup/install/files/lib/acp/form/LanguageServerEditForm.class.php @@ -0,0 +1,95 @@ + + * @package com.woltlab.wcf + * @subpackage acp.form + * @category Community Framework + */ +class LanguageServerEditForm extends LanguageServerAddForm { + /** + * @see wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.language.server'; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.language.canAddServer'); + + /** + * language server id + * @var integer + */ + public $languageServerID = 0; + + /** + * active language server + * @var wcf\data\language\server\LanguageServer + */ + public $languageServer = null; + + /** + * @see wcf\page\IPage::readParameters() + */ + public function readParameters() { + parent::readParameters(); + + if (isset($_REQUEST['id'])) $this->languageServerID = intval($_REQUEST['id']); + $this->languageServer = new LanguageServer($this->languageServerID); + if (!$this->languageServer->languageServerID) { + throw new IllegalLinkException(); + } + } + + /** + * @see wcf\form\IForm::save() + */ + public function save() { + AbstractForm::save(); + + // save server + $this->objectAction = new LanguageServerAction(array($this->languageServerID), 'update', array('data' => array( + 'serverURL' => $this->server + ))); + $this->objectAction->executeAction(); + $this->saved(); + + // show success message + WCF::getTPL()->assign('success', true); + } + + /** + * @see wcf\page\IPage::readData() + */ + public function readData() { + parent::readData(); + + if (empty($_POST)) { + $this->server = $this->languageServer->serverURL; + } + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'languageServerID' => $this->languageServerID, + 'languageServer' => $this->languageServer, + 'action' => 'edit' + )); + } +} diff --git a/wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php b/wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php new file mode 100644 index 0000000000..63d9739b9d --- /dev/null +++ b/wcfsetup/install/files/lib/acp/page/LanguageListPage.class.php @@ -0,0 +1,64 @@ + + * @package com.woltlab.wcf + * @subpackage acp.page + * @category Community Framework + */ +class LanguageListPage extends SortablePage { + /** + * @see wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.language.list'; + + /** + * @see wcf\page\SortablePage::$defaultSortField + */ + public $defaultSortField = 'languageName'; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.language.canEditLanguage', 'admin.language.canDeleteLanguage'); + + /** + * @see wcf\page\MultipleLinkPage::$objectListClassName + */ + public $objectListClassName = 'wcf\data\language\LanguageList'; + + /** + * @see wcf\page\SortablePage::$validSortFields + */ + public $validSortFields = array('languageID', 'languageCode', 'languageName', 'users', 'variables', 'customVariables'); + + /** + * @see wcf\page\MultipleLinkPage::initObjectList() + */ + public function initObjectList() { + parent::initObjectList(); + + $this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf".WCF_N."_user user WHERE languageID = language.languageID) AS users,"; + $this->objectList->sqlSelects .= "(SELECT COUNT(*) FROM wcf".WCF_N."_language_item WHERE languageID = language.languageID) AS variables,"; + $this->objectList->sqlSelects .= "(SELECT COUNT(*) FROM wcf".WCF_N."_language_item WHERE languageID = language.languageID AND languageCustomItemValue <> NULL) AS customVariables"; + $this->sqlOrderBy = "cronjob.".$this->sortField." ".$this->sortOrder; + } + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'languages' => $this->objectList->getObjects() + )); + } +} diff --git a/wcfsetup/install/files/lib/acp/page/LanguageServerListPage.class.php b/wcfsetup/install/files/lib/acp/page/LanguageServerListPage.class.php new file mode 100644 index 0000000000..df44962b1c --- /dev/null +++ b/wcfsetup/install/files/lib/acp/page/LanguageServerListPage.class.php @@ -0,0 +1,52 @@ + + * @package com.woltlab.wcf + * @subpackage acp.page + * @category Community Framework + */ +class LanguageServerListPage extends SortablePage { + /** + * @see wcf\page\AbstractPage::$activeMenuItem + */ + public $activeMenuItem = 'wcf.acp.menu.link.language.server.list'; + + /** + * @see wcf\page\SortablePage::$defaultSortField + */ + public $defaultSortField = 'serverURL'; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.language.canEditServer', 'admin.language.canDeleteServer'); + + /** + * @see wcf\page\MultipleLinkPage::$objectListClassName + */ + public $objectListClassName = 'wcf\data\language\server\LanguageServerList'; + + /** + * @see wcf\page\SortablePage::$validSortFields + */ + public $validSortFields = array('languageServerID', 'serverURL'); + + /** + * @see wcf\page\IPage::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'languageServers' => $this->objectList->getObjects() + )); + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index c1f3c26646..3b3afffbd4 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -171,6 +171,42 @@ + + + + + + + + + + ISO 639-1 an. Weitere Informationen zu Sprachcodes finden Sie unter http://de.wikipedia.org/wiki/ISO_639-1.]]> + + languageName}“ wirklich löschen?]]> + + + + + + + + + + + + + + + + + + + + + + + + @@ -194,6 +230,12 @@ + + + + + + -- 2.20.1