Added language multilingualism
authorSiora <siora@web-produktion.com>
Wed, 4 Apr 2012 20:21:58 +0000 (22:21 +0200)
committerSiora <siora@web-produktion.com>
Wed, 4 Apr 2012 20:21:58 +0000 (22:21 +0200)
acpMenu.xml
acptemplates/languageMultilingualism.tpl [new file with mode: 0644]
files/lib/acp/form/LanguageMultilingualismForm.class.php [new file with mode: 0644]
language/de.xml

index d4e3af27b58eab88a9a0f93069a023f44c25d2ee..0721d2cf86bd39b1bbaa5f397f3a8361717d151c 100644 (file)
                        <permissions>admin.language.canAddLanguage</permissions>
                </acpmenuitem>
                
+               <acpmenuitem name="wcf.acp.menu.link.language.multilingualism">
+                       <parent>wcf.acp.menu.link.language</parent>
+                       <link>index.php/LanguageMultilingualism/</link>
+                       <permissions>admin.language.canEditLanguage</permissions>
+               </acpmenuitem>
+               
                <acpmenuitem name="wcf.acp.menu.link.language.server">
                        <parent>wcf.acp.menu.link.language</parent>
                </acpmenuitem>
diff --git a/acptemplates/languageMultilingualism.tpl b/acptemplates/languageMultilingualism.tpl
new file mode 100644 (file)
index 0000000..56a1636
--- /dev/null
@@ -0,0 +1,67 @@
+{include file='header'}
+
+<script type="text/javascript">
+       //<![CDATA[
+       {if $enable == 0}
+               window.onload = function(){
+                       $('#languageIDs').hide();
+               }
+       {/if}
+       //]]>
+</script>
+
+<header class="box48 boxHeadline">
+       <img src="{@RELATIVE_WCF_DIR}icon/language1.svg" alt="" class="icon48" />
+       <hgroup>
+               <h1>{lang}wcf.acp.language.multilingualism{/lang}</h1>
+       </hgroup>
+</header>
+
+{if $errorField}
+       <p class="error">{lang}wcf.global.form.error{/lang}</p>
+{/if}
+
+{if $success|isset}
+       <p class="success">{lang}wcf.acp.language.multilingualism.success{/lang}</p>
+{/if}
+
+<form enctype="multipart/form-data" method="post" action="{link controller='LanguageMultilingualism'}{/link}">
+       <div class="container containerPadding marginTop shadow">
+               <dl>
+                       <dt><input type="checkbox" id="enable" onclick="if (this.checked) $('#languageIDs').show(); else $('#languageIDs').hide();" name="enable" value="1" {if $enable == 1}checked="checked" {/if}/></dt>
+                       <dd>
+                               <label for="enable">{lang}wcf.acp.language.multilingualism.enable{/lang}</label>
+                               <small>{lang}wcf.acp.language.multilingualism.enable.description{/lang}</small>
+                       </dd>
+               </dl>
+               
+               <dl{if $errorField == 'languageFile'} class="formError"{/if} id="languageIDs">
+                       <dt><label for="languageIDs">{lang}wcf.acp.language.multilingualism.languages{/lang}</label></dt>
+                       <dd>
+                               <fieldset>
+                                       <legend>{lang}wcf.acp.language.multilingualism.languages{/lang}</legend>
+                                       
+                                       <dd>
+                                               {htmlCheckboxes options=$languages name=languageIDs selected=$languageIDs disableEncoding=true}
+                                       </dd>
+                               </fieldset>
+                               
+                               {if $errorField == 'languageIDs'}
+                                       <small class="innerError">
+                                               {if $errorType == 'empty'}{lang}wcf.acp.language.multilingualism.languages.error.empty{/lang}{/if}
+                                       </small>
+                               {/if}
+                       </dd>
+               </dl>
+               
+               {event name='additionalFields'}
+       </div>
+       
+       <div class="formSubmit">
+               <input type="submit" accesskey="s" value="{lang}wcf.global.button.submit{/lang}" />
+               <input type="reset" accesskey="r" value="{lang}wcf.global.button.reset{/lang}" />
+               <input type="hidden" name="packageID" value="{@PACKAGE_ID}" />
+       </div>
+</form>
+
+{include file='footer'}
diff --git a/files/lib/acp/form/LanguageMultilingualismForm.class.php b/files/lib/acp/form/LanguageMultilingualismForm.class.php
new file mode 100644 (file)
index 0000000..149301f
--- /dev/null
@@ -0,0 +1,151 @@
+<?php
+namespace wcf\acp\form;
+use wcf\data\language\LanguageEditor;
+use wcf\system\language\LanguageFactory;
+use wcf\system\exception\UserInputException;
+use wcf\system\cache\CacheHandler;
+use wcf\system\WCF;
+use wcf\system\WCFACP;
+use wcf\util\ArrayUtil;
+
+/**
+ * Shows the language multilingualism form.
+ * 
+ * @author     Jean-Marc Licht
+ * @copyright  2001-2012 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf.acp.language
+ * @subpackage acp.form
+ * @category   Community Framework
+ */
+class LanguageMultilingualismForm extends ACPForm {
+       /**
+        * @see wcf\acp\form\ACPForm::$activeMenuItem
+        */
+       public $activeMenuItem = 'wcf.acp.menu.link.language.multilingualism';
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.language.canEditLanguage');
+       
+       // data
+       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.languages.php');
+               $this->saved();
+               
+               // show success message
+               WCF::getTPL()->assign('success', true);
+       }
+       
+       /**
+        * @see wcf\page\IPage::readData()
+        */
+       public function readData() {
+               parent::readData();
+               
+               if (!count($_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();
+       }
+}
index a9767b82d2c1504d2db2accfe5958836d19940ab..eff59908e4d518e1893226987156546e6d77be7d 100644 (file)
                <item name="wcf.acp.language.import.source.file"><![CDATA[Pfad zur Sprachdatei]]></item>
                <item name="wcf.acp.language.import.source.file.description"><![CDATA[Geben Sie hier den relativen Pfad zu einer gültigen XML-Sprachdatei an.]]></item>
                <item name="wcf.acp.language.import.source.upload"><![CDATA[Sprachdatei vom lokalen Computer hochladen]]></item>
+               <item name="wcf.acp.language.multilingualism"><![CDATA[Mehrsprachigkeit verwalten]]></item>
+               <item name="wcf.acp.language.multilingualism.enable"><![CDATA[Mehrsprachige Inhalte aktivieren]]></item>
+               <item name="wcf.acp.language.multilingualism.enable.description"><![CDATA[Haben Sie mehrere Sprachen installiert, können sich Ihre Mitglieder die Programmoberfläche in diesen Sprachen anzeigen lassen. Erstellte Inhalte werden durch die aktivierte Mehrsprachigkeit außerdem einer Sprache zugeordnet. Die Benutzer können in ihrem Profil auswählen, dass ausschließlich Inhalte von bestimmten Sprachen angezeigt werden. Bei der Erstellung von Inhalten ist standardmäßig die aktive Oberflächensprache vorausgewählt.]]></item>
+               <item name="wcf.acp.language.multilingualism.languages"><![CDATA[Inhalte in folgenden Sprachen zulassen]]></item>
+               <item name="wcf.acp.language.multilingualism.languages.error.empty"><![CDATA[Um die Mehrsprachigkeit zu nutzen, müssen Sie mindestens zwei Sprachen auswählen.]]></item>
+               <item name="wcf.acp.language.multilingualism.success"><![CDATA[Ihre Einstellungen wurden erfolgreich gespeichert.]]></item>
+               
        </category>
 </language>
\ No newline at end of file