Overhauled language item list
authorMarcel Werk <burntime@woltlab.com>
Sat, 25 Jun 2016 16:36:25 +0000 (18:36 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sat, 25 Jun 2016 16:36:35 +0000 (18:36 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.Language.js
wcfsetup/install/files/acp/templates/languageItemList.tpl
wcfsetup/install/files/acp/templates/languageList.tpl
wcfsetup/install/files/acp/templates/pageList.tpl
wcfsetup/install/files/lib/acp/page/LanguageItemListPage.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 5c50d83084a5d54b2cbcadcd635d820fc47321e5..4a1c2dfdeef126cfdbb0da357f0ae5ac7f9a1cf3 100644 (file)
@@ -34,11 +34,8 @@ WCF.ACP.Language.ItemList = Class.extend({
        
        /**
         * Initializes the WCF.ACP.Style.List class.
-        * 
-        * @param       integer         count
-        * @param       integer         pageNo
         */
-       init: function(count, pageNo) {
+       init: function() {
                this._proxy = new WCF.Action.Proxy({
                        success: $.proxy(this._success, this)
                });
@@ -50,40 +47,6 @@ WCF.ACP.Language.ItemList = Class.extend({
                        var self = this;
                        $button.click(function() { self._click($languageItemID); });
                }, this));
-               
-               count = ~~count;
-               if (count > 100) {
-                       this._createPagination(count, pageNo);
-               }
-       },
-       
-       /**
-        * Creates a pagination for current search result.
-        * 
-        * @param       integer         count
-        * @param       integer         pageNo
-        */
-       _createPagination: function(count, pageNo) {
-               var navs = [];
-               
-               // pagination top
-               var contentNavigation = $('<div class="paginationTop"><nav class="pagination" /></div>').insertBefore($('.section.sectionContainerList'));
-               navs.push(contentNavigation[0].children[0]);
-               
-               // pagination bottom
-               contentNavigation = $('<div class="paginationBottom"><nav class="pagination" /></div>').prependTo($('.contentFooter'));
-               navs.push(contentNavigation[0].children[0]);
-               
-               navs.forEach(function(nav) {
-                       $(nav).wcfPages({
-                               activePage: parseInt(pageNo) || 1,
-                               maxPage: Math.ceil(count / 100)
-                       }).on('wcfpagesswitched', function(event, data) {
-                               var $form = $('#languageItemSearchForm');
-                               $('<input type="hidden" name="pageNo" value="' + data.activePage + '" />').appendTo($form);
-                               $form.submit();
-                       });
-               });
        },
        
        /**
index 4158f9c028f60335abb865a199be76cffa52e001..8330ac814d9e817eb6078e33c44f63cb9ec9aed9 100644 (file)
@@ -4,7 +4,7 @@
 <script data-relocate="true">
        //<![CDATA[
        $(function() {
-               new WCF.ACP.Language.ItemList({@$count}, {@$pageNo});
+               new WCF.ACP.Language.ItemList();
        });
        //]]>
 </script>
@@ -33,7 +33,7 @@
                        <dl class="col-xs-12 col-md-4">
                                <dt></dt>
                                <dd>
-                                       <select name="id" id="languageID">
+                                       <select name="languageID" id="languageID">
                                                <option value="0">{lang}wcf.user.language{/lang}</option>
                                                {foreach from=$availableLanguages item=availableLanguage}
                                                        <option value="{@$availableLanguage->languageID}"{if $availableLanguage->languageID == $languageID} selected{/if}>{$availableLanguage->languageName} ({$availableLanguage->languageCode})</option>
@@ -66,6 +66,7 @@
                                <dd>
                                        <input type="text" id="languageItemValue" name="languageItemValue" value="{$languageItemValue}" placeholder="{lang}wcf.acp.language.item.value{/lang}" class="long">
                                        <label><input type="checkbox" name="hasCustomValue" value="1"{if $hasCustomValue == 1} checked{/if}> {lang}wcf.acp.language.item.customValues{/lang}</label>
+                                       <label><input type="checkbox" name="hasDisabledCustomValue" value="1"{if $hasDisabledCustomValue == 1} checked{/if}> {lang}wcf.acp.language.item.disabledCustomValues{/lang}</label>
                                </dd>
                        </dl>
                        
        </section>
 </form>
 
+{hascontent}
+       <div class="paginationTop">
+               {content}
+                       {assign var='linkParameters' value=''}
+                       {if $languageID}{capture append=linkParameters}&languageID={@$languageID}{/capture}{/if}
+                       {if $languageCategoryID}{capture append=linkParameters}&languageCategoryID={@$languageCategoryID}{/capture}{/if}
+                       {if $languageItem}{capture append=linkParameters}&languageItem={@$languageItem|rawurlencode}{/capture}{/if}
+                       {if $languageItemValue}{capture append=linkParameters}&languageItemValue={@$languageItemValue|rawurlencode}{/capture}{/if}
+                       {if $hasCustomValue}{capture append=linkParameters}&hasCustomValue=1{/capture}{/if}
+                       
+                       {pages print=true assign=pagesLinks controller="LanguageItemList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
+               {/content}
+       </div>
+{/hascontent}
+
 {if $objects|count}
-       <div class="section sectionContainerList">
-               <ol class="containerList">
-                       {foreach from=$objects item=item}
-                               <li>
-                                       <div>
-                                               <div class="details">
-                                                       <div class="containerHeadline">
-                                                               <h3><a class="jsLanguageItem" data-language-item-id="{@$item->languageItemID}">{$item->languageItem}</a>{if $item->languageCustomItemValue !== null} <span class="icon icon16 fa-bookmark jsTooltip" title="{lang}wcf.acp.language.item.hasCustomValue{/lang}"></span>{/if}</h3>
-                                                       </div>
-                                                       
-                                                       <p class="containerContent">{if $item->languageUseCustomValue}{$item->languageCustomItemValue|truncate:255}{else}{$item->languageItemValue|truncate:255}{/if}</p>
-                                               </div>
-                                       </div>
-                               </li>
-                       {/foreach}
-               </ol>
+       <div class="section tabularBox">
+               <table class="table">
+                       <thead>
+                               <tr>
+                                       <th class="columnTitle columnLanguageItem{if $sortField == 'languageItem'} active {@$sortOrder}{/if}"><a href="{link controller='LanguageItemList'}pageNo={@$pageNo}&sortField=languageItem&sortOrder={if $sortField == 'languageItem' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.name{/lang}</a></th>
+                                       <th class="columnText columnLanguageItemValue">{lang}wcf.acp.language.item.value{/lang}</th>
+                                       <th class="columnText columnLanguageCustomItemValue">{lang}wcf.acp.language.item.customValue{/lang}</th>
+                                       
+                                       {event name='columnHeads'}
+                               </tr>
+                       </thead>
+                       
+                       <tbody>
+                               {foreach from=$objects item=item}
+                                       <tr>
+                                               <td class="columnTitle columnLanguageItem"><a class="jsLanguageItem" data-language-item-id="{@$item->languageItemID}">{$item->languageItem}</a></td>
+                                               <td class="columnText columnLanguageItemValue">{$item->languageItemValue|truncate:255}</td>
+                                               <td class="columnText columnLanguageCustomItemValue">{if !$item->languageUseCustomValue}<s>{/if}{$item->languageCustomItemValue|truncate:255}{if !$item->languageUseCustomValue}</s>{/if}</td>
+                                               
+                                               {event name='columns'}
+                                       </tr>
+                               {/foreach}
+                       </tbody>
+               </table>
        </div>
        
        <footer class="contentFooter">
+               {hascontent}
+                       <div class="paginationBottom">
+                               {content}{@$pagesLinks}{/content}
+                       </div>
+               {/hascontent}
+               
                {hascontent}
                        <nav class="contentFooterNavigation">
                                <ul>
                                        {content}
-                                       
-                                       
-                                       {event name='contentFooterNavigation'}
+                                               {event name='contentFooterNavigation'}
                                        {/content}
                                </ul>
                        </nav>
index 64da9fa9fc0ea12ec4114a4797e8eef3414322d9..b570f8084dace391a04e161816d775987588e029 100644 (file)
@@ -81,8 +81,8 @@
                                                <td class="columnID columnLanguageID">{@$language->languageID}</td>
                                                <td class="columnTitle columnLanguageName"><a href="{link controller='LanguageEdit' id=$language->languageID}{/link}">{$language->languageName} ({@$language->languageCode})</a></td>
                                                <td class="columnDigits columnUsers">{#$language->users}</td>
-                                               <td class="columnDigits columnVariables"><a href="{link controller='LanguageItemList' id=$language->languageID}{/link}">{#$language->variables}</a></td>
-                                               <td class="columnDigits columnCustomVariables">{if $language->customVariables > 0}<a href="{link controller='LanguageItemList' id=$language->languageID}hasCustomValue=1{/link}">{#$language->customVariables}</a>{else}{#$language->customVariables}{/if}</td>
+                                               <td class="columnDigits columnVariables"><a href="{link controller='LanguageItemList'}languageID={@$language->languageID}{/link}">{#$language->variables}</a></td>
+                                               <td class="columnDigits columnCustomVariables">{if $language->customVariables > 0}<a href="{link controller='LanguageItemList'}languageID={@$language->languageID}&hasCustomValue=1{/link}">{#$language->customVariables}</a>{else}{#$language->customVariables}{/if}</td>
                                                
                                                {event name='columns'}
                                        </tr>
index dd704dd4d8f61c0670a0192281c822f14c3387fb..d1229bd5af30307ea522a19aa29fa285a0d27533 100644 (file)
 {hascontent}
        <div class="paginationTop">
                {content}
-               {assign var='linkParameters' value=''}
-               {if $name}{capture append=linkParameters}&name={@$name|rawurlencode}{/capture}{/if}
-               {if $title}{capture append=linkParameters}&title={@$title|rawurlencode}{/capture}{/if}
-               {if $content}{capture append=linkParameters}&content={@$content|rawurlencode}{/capture}{/if}
-               {if $applicationPackageID}{capture append=linkParameters}&applicationPackageID={@$applicationPackageID}{/capture}{/if}
-               {if $pageType}{capture append=linkParameters}&pageType={@$pageType|rawurlencode}{/capture}{/if}
-               
-               {pages print=true assign=pagesLinks controller="PageList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
+                       {assign var='linkParameters' value=''}
+                       {if $name}{capture append=linkParameters}&name={@$name|rawurlencode}{/capture}{/if}
+                       {if $title}{capture append=linkParameters}&title={@$title|rawurlencode}{/capture}{/if}
+                       {if $content}{capture append=linkParameters}&content={@$content|rawurlencode}{/capture}{/if}
+                       {if $applicationPackageID}{capture append=linkParameters}&applicationPackageID={@$applicationPackageID}{/capture}{/if}
+                       {if $pageType}{capture append=linkParameters}&pageType={@$pageType|rawurlencode}{/capture}{/if}
+                       
+                       {pages print=true assign=pagesLinks controller="PageList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
                {/content}
        </div>
 {/hascontent}
index 3dcd8d905fd420df128cad30db82610b84019e2a..2a809fc6642818dcb6d2bb7f9425223a17691f23 100644 (file)
@@ -2,7 +2,7 @@
 namespace wcf\acp\page;
 use wcf\data\language\category\LanguageCategoryList;
 use wcf\data\language\item\LanguageItemList;
-use wcf\page\AbstractPage;
+use wcf\page\SortablePage;
 use wcf\system\language\LanguageFactory;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
@@ -15,28 +15,31 @@ use wcf\util\StringUtil;
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    WoltLabSuite\Core\Acp\Page
  */
-class LanguageItemListPage extends AbstractPage {
+class LanguageItemListPage extends SortablePage {
        /**
         * @inheritDoc
         */
        public $activeMenuItem = 'wcf.acp.menu.link.language.item.list';
        
        /**
-        * number of matching phrases
-        * @var integer
+        * @inheritDoc
         */
-       public $count = 0;
+       public $neededPermissions = ['admin.language.canManageLanguage'];
        
        /**
         * @inheritDoc
         */
-       public $neededPermissions = ['admin.language.canManageLanguage'];
+       public $itemsPerPage = 100;
+       
+       /**
+        * @inheritDoc
+        */
+       public $validSortFields = ['languageItem'];
        
        /**
-        * language item list
-        * @var \wcf\data\language\item\LanguageItemList
+        * @inheritDoc
         */
-       public $languageItemList = null;
+       public $defaultSortField = 'languageItem';
        
        /**
         * language id
@@ -68,6 +71,12 @@ class LanguageItemListPage extends AbstractPage {
         */
        public $hasCustomValue = 0;
        
+       /**
+        * search for disabled custom values
+        * @var boolean
+        */
+       public $hasDisabledCustomValue = 0;
+       
        /**
         * available languages
         * @var array
@@ -80,32 +89,37 @@ class LanguageItemListPage extends AbstractPage {
         */
        public $availableLanguageCategories = [];
        
-       /**
-        * current page no
-        * @var integer
-        */
-       public $pageNo = 1;
-       
        /**
         * @inheritDoc
         */
        public function readParameters() {
                parent::readParameters();
                
-               if (isset($_REQUEST['id'])) $this->languageID = intval($_REQUEST['id']);
+               if (isset($_REQUEST['languageID'])) $this->languageID = intval($_REQUEST['languageID']);
                if (isset($_REQUEST['languageCategoryID'])) $this->languageCategoryID = intval($_REQUEST['languageCategoryID']);
                if (isset($_REQUEST['languageItem'])) $this->languageItem = StringUtil::trim($_REQUEST['languageItem']);
                if (isset($_REQUEST['languageItemValue'])) $this->languageItemValue = $_REQUEST['languageItemValue'];
                if (!empty($_REQUEST['hasCustomValue'])) $this->hasCustomValue = 1;
-               if (isset($_REQUEST['pageNo'])) $this->pageNo = intval($_REQUEST['pageNo']);
+               if (!empty($_REQUEST['hasDisabledCustomValue'])) $this->hasDisabledCustomValue = 1;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       protected function initObjectList() {
+               $this->objectList = new LanguageItemList();
+               $this->objectList->getConditionBuilder()->add('languageID = ?', [$this->languageID]);
+               if ($this->languageCategoryID) $this->objectList->getConditionBuilder()->add('languageCategoryID = ?', [$this->languageCategoryID]);
+               if ($this->languageItem) $this->objectList->getConditionBuilder()->add('languageItem LIKE ?', ['%'.$this->languageItem.'%']);
+               if ($this->languageItemValue) $this->objectList->getConditionBuilder()->add('((languageUseCustomValue = 0 AND languageItemValue LIKE ?) OR languageCustomItemValue LIKE ?)', ['%'.$this->languageItemValue.'%', '%'.$this->languageItemValue.'%']);
+               if ($this->hasCustomValue || $this->hasDisabledCustomValue) $this->objectList->getConditionBuilder()->add("languageCustomItemValue IS NOT NULL");
+               if ($this->hasDisabledCustomValue) $this->objectList->getConditionBuilder()->add("languageUseCustomValue = ?", [0]);
        }
        
        /**
         * @inheritDoc
         */
        public function readData() {
-               parent::readData();
-               
                // get languages
                $this->availableLanguages = LanguageFactory::getInstance()->getLanguages();
                
@@ -122,26 +136,7 @@ class LanguageItemListPage extends AbstractPage {
                        $this->languageCategoryID = 0;
                }
                
-               // get items
-               $this->languageItemList = new LanguageItemList();
-               $this->languageItemList->getConditionBuilder()->add('languageID = ?', [$this->languageID]);
-               if ($this->languageCategoryID) $this->languageItemList->getConditionBuilder()->add('languageCategoryID = ?', [$this->languageCategoryID]);
-               if ($this->languageItem) $this->languageItemList->getConditionBuilder()->add('languageItem LIKE ?', ['%'.$this->languageItem.'%']);
-               if ($this->languageItemValue) $this->languageItemList->getConditionBuilder()->add('((languageUseCustomValue = 0 AND languageItemValue LIKE ?) OR languageCustomItemValue LIKE ?)', ['%'.$this->languageItemValue.'%', '%'.$this->languageItemValue.'%']);
-               if ($this->hasCustomValue) $this->languageItemList->getConditionBuilder()->add("languageCustomItemValue IS NOT NULL");
-               $this->languageItemList->sqlLimit = 100;
-               
-               if (!empty($_POST)) {
-                       $this->count = $this->languageItemList->countObjects();
-                       $maxPages = ceil($this->count / 100);
-                       $this->pageNo = max(min($this->pageNo, $maxPages), 1);
-                       
-                       if ($this->pageNo > 1) {
-                               $this->languageItemList->sqlOffset = ($this->pageNo - 1) * 100;
-                       }
-               }
-               
-               $this->languageItemList->readObjects();
+               parent::readData();
        }
        
        /**
@@ -151,14 +146,12 @@ class LanguageItemListPage extends AbstractPage {
                parent::assignVariables();
                
                WCF::getTPL()->assign([
-                       'objects' => $this->languageItemList,
-                       'count' => $this->count,
-                       'pageNo' => $this->pageNo,
                        'languageID' => $this->languageID,
                        'languageCategoryID' => $this->languageCategoryID,
                        'languageItem' => $this->languageItem,
                        'languageItemValue' => $this->languageItemValue,
                        'hasCustomValue' => $this->hasCustomValue,
+                       'hasDisabledCustomValue' => $this->hasDisabledCustomValue,
                        'availableLanguages' => $this->availableLanguages,
                        'availableLanguageCategories' => $this->availableLanguageCategories
                ]);
index 9974952178a4ce67dc601ef117fce997aed37b12..59b5a38a82abdc4460a90ab4fc925fb5c5e19e6c 100644 (file)
                <item name="wcf.acp.language.item.value"><![CDATA[Inhalt]]></item>
                <item name="wcf.acp.language.item.customValue"><![CDATA[Eigener Inhalt]]></item>
                <item name="wcf.acp.language.item.useCustomValue"><![CDATA[Eigene Version verwenden]]></item>
-               <item name="wcf.acp.language.item.hasCustomValue"><![CDATA[Inhalte mit eigener Version]]></item>
                <item name="wcf.acp.language.item.customValues"><![CDATA[Veränderte Inhalte finden]]></item>
+               <item name="wcf.acp.language.item.disabledCustomValues"><![CDATA[Deaktivierte veränderte Inhalte finden]]></item>
                <item name="wcf.acp.language.name.description"><![CDATA[Name der Sprache]]></item>
                <item name="wcf.acp.language.add.source.description"><![CDATA[Die ausgewählte Sprache wird als Vorlage benutzt. Alle Sprachvariablen werden in die neue Sprache kopiert.]]></item>
        </category>
index 9c11f687304d5591a6e6e4607d23c1ae379eff61..fa4131eb945ae048f5bde252d953be6764ba7a8f 100644 (file)
@@ -549,8 +549,8 @@ Examples for medium ID detection:
                <item name="wcf.acp.language.item.value"><![CDATA[Content]]></item>
                <item name="wcf.acp.language.item.customValue"><![CDATA[Custom Value]]></item>
                <item name="wcf.acp.language.item.useCustomValue"><![CDATA[Use custom value]]></item>
-               <item name="wcf.acp.language.item.hasCustomValue"><![CDATA[Phrases with custom values]]></item>
                <item name="wcf.acp.language.item.customValues"><![CDATA[Customized values]]></item>
+               <item name="wcf.acp.language.item.disabledCustomValues"><![CDATA[Disabled customized values]]></item>
                <item name="wcf.acp.language.name.description"><![CDATA[Language Name]]></item>
                <item name="wcf.acp.language.add.source.description"><![CDATA[The selected language will be used as origin, all phrases will be copied into the new language.]]></item>
        </category>