Added global disable switch for languages
authorMarcel Werk <burntime@woltlab.com>
Tue, 24 May 2016 17:08:44 +0000 (19:08 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 24 May 2016 17:08:48 +0000 (19:08 +0200)
CHANGELOG.md
wcfsetup/install/files/acp/templates/languageList.tpl
wcfsetup/install/files/lib/data/language/LanguageAction.class.php
wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php
wcfsetup/setup/db/install.sql

index 821f1df8397844aeb8e16772b437d5271162f5c6..9b640a61443141a960f569c5fabf86c152ce659f 100644 (file)
@@ -53,6 +53,7 @@
 * Added support for embedded youtube playlists
 * Scaled embedded youtube videos to maximum width
 * `\wcf\form\AbstractCaptchaForm`: added parameter to force captcha usage for registered users.
+* Added global disable switch for languages.
 
 #### CMS
 
index b0a637c385f79b4967e0572c75c909f5fb056a96..caba7032941cdfce1a26b51a69a0e6d6b6499843 100644 (file)
@@ -13,6 +13,7 @@
                                window.location.reload();
                        }
                });
+               new WCF.Action.Toggle('wcf\\data\\language\\LanguageAction', $('.jsLanguageRow'));
        });
        //]]>
 </script>
                                                        <a href="{link controller='LanguageExport' id=$language->languageID}{/link}" title="{lang}wcf.acp.language.export{/lang}" class="jsTooltip"><span class="icon icon16 fa-download"></span></a>
                                                        
                                                        {if !$language->isDefault}
-                                                               <span class="icon icon16 fa-check-square-o jsSetAsDefaultButton jsTooltip pointer" title="{lang}wcf.acp.language.setAsDefault{/lang}" title="{lang}wcf.acp.language.setAsDefault{/lang}" data-object-id="{@$language->languageID}"></span>
+                                                               <span class="icon icon16 fa-{if !$language->isDisabled}check-{/if}square-o jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if $language->isDisabled}enable{else}disable{/if}{/lang}" data-object-id="{@$language->languageID}"></span>
+                                                               <span class="icon icon16 fa-check-circle jsSetAsDefaultButton jsTooltip pointer" title="{lang}wcf.acp.language.setAsDefault{/lang}" title="{lang}wcf.acp.language.setAsDefault{/lang}" data-object-id="{@$language->languageID}"></span>
                                                        {else}
-                                                               <span class="icon icon16 fa-check-square-o disabled" title="{lang}wcf.acp.language.setAsDefault{/lang}"></span>
+                                                               <span class="icon icon16 fa-{if !$language->isDisabled}check-{/if}square-o disabled" title="{lang}wcf.global.button.{if $language->isDisabled}enable{else}disable{/if}{/lang}"></span>
+                                                               <span class="icon icon16 fa-check-circle disabled" title="{lang}wcf.acp.language.setAsDefault{/lang}"></span>
                                                        {/if}
                                                        
                                                        <a href="{link controller='LanguageEdit' id=$language->languageID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
+                                                       
                                                        {if !$language->isDefault}
                                                                <span class="icon icon16 fa-times jsTooltip jsDeleteButton pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$language->languageID}" data-confirm-message="{lang}wcf.acp.language.delete.sure{/lang}"></span>
                                                        {else}
index 20bb5853f1902e131666622f9e37640d30aa63b2..72a443f81cbbd6a90f20c26d6c0a21f9320bd7de 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\language;
 use wcf\data\AbstractDatabaseObjectAction;
+use wcf\data\IToggleAction;
 use wcf\system\WCF;
 
 /**
@@ -17,7 +18,7 @@ use wcf\system\WCF;
  * @method     LanguageEditor[]        getObjects()
  * @method     LanguageEditor          getSingleObject()
  */
-class LanguageAction extends AbstractDatabaseObjectAction {
+class LanguageAction extends AbstractDatabaseObjectAction implements IToggleAction {
        /**
         * @inheritDoc
         */
@@ -64,4 +65,27 @@ class LanguageAction extends AbstractDatabaseObjectAction {
        public function setAsDefault() {
                $this->languageEditor->setAsDefault();
        }
+       
+       /**
+        * @inheritdoc
+        */
+       public function validateToggle() {
+               parent::validateUpdate();
+               
+               foreach ($this->objects as $language) {
+                       if ($language->isDefault) {
+                               throw new UserInputException('objectIDs');
+                       }
+               }
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function toggle() {
+               foreach ($this->objects as $language) {
+                       $isDisabled = ($language->isDisabled) ? 0 : 1;
+                       $language->update(['isDisabled' => $isDisabled]);
+               }
+       }
 }
index cfd4ac6af6510b66158bde6ab1ca34730bd82a27..fc141893f26a26eb6dcd3456f4fb10d2ab905a4b 100644 (file)
@@ -31,6 +31,7 @@ class LanguageCacheBuilder extends AbstractCacheBuilder {
                
                // get languages
                $languageList = new LanguageList();
+               $languageList->getConditionBuilder()->add('language.isDisabled = ?', [0]);
                $languageList->readObjects();
                $data['languages'] = $languageList->getObjects();
                foreach ($languageList->getObjects() as $language) {
index a3f06dc442d75cb6fcb309d7945a41b393c91030..29f617b29acfa27597e029a63f8e26a5d9ec441a 100644 (file)
@@ -485,6 +485,7 @@ CREATE TABLE wcf1_language (
        countryCode VARCHAR(10) NOT NULL DEFAULT '',
        isDefault TINYINT(1) NOT NULL DEFAULT 0,
        hasContent TINYINT(1) NOT NULL DEFAULT 0,
+       isDisabled TINYINT(1) NOT NULL DEFAULT 0,
        UNIQUE KEY languageCode (languageCode)
 );