Added filter functions in box list
authorMarcel Werk <burntime@woltlab.com>
Mon, 18 Apr 2016 09:48:21 +0000 (11:48 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 18 Apr 2016 09:48:26 +0000 (11:48 +0200)
wcfsetup/install/files/acp/templates/boxList.tpl
wcfsetup/install/files/lib/acp/page/BoxListPage.class.php

index bd1a000887bf87631a2f9cc9f1d9389f6486b4f0..11c2ac2ee273680ffb7c2ba69fcc79120be836ae 100644 (file)
 
 {hascontent}
        <div class="paginationTop">
-               {content}{pages print=true assign=pagesLinks controller="BoxList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content}
+               {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 $position}{capture append=linkParameters}&position={@$position}{/capture}{/if}
+                       {if $boxType}{capture append=linkParameters}&boxType={@$boxType|rawurlencode}{/capture}{/if}
+               
+                       {pages print=true assign=pagesLinks controller="BoxList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
+               {/content}
        </div>
 {/hascontent}
 
+<form method="post" action="{link controller='BoxList'}{/link}">
+       <section class="section">
+               <h2 class="sectionTitle">{lang}wcf.global.filter{/lang}</h2>
+               
+               <div class="row rowColGap formGrid">
+                       <dl class="col-xs-12 col-md-4">
+                               <dt></dt>
+                               <dd>
+                                       <input type="text" id="name" name="name" value="{$name}" placeholder="{lang}wcf.global.name{/lang}" class="long" />
+                               </dd>
+                       </dl>
+                       
+                       <dl class="col-xs-12 col-md-4">
+                               <dt></dt>
+                               <dd>
+                                       <input type="text" id="boxTitle" name="title" value="{$title}" placeholder="{lang}wcf.acp.box.title{/lang}" class="long" />
+                               </dd>
+                       </dl>
+                       
+                       <dl class="col-xs-12 col-md-4">
+                               <dt></dt>
+                               <dd>
+                                       <input type="text" id="boxContent" name="content" value="{$content}" placeholder="{lang}wcf.acp.box.content{/lang}" class="long" />
+                               </dd>
+                       </dl>
+                       
+                       <dl class="col-xs-12 col-md-4">
+                               <dt></dt>
+                               <dd>
+                                       <label class="selectDropdown">
+                                               <select name="position" id="boxPosition">
+                                                       <option value="0">{lang}wcf.acp.box.position{/lang}</option>
+                                                       {foreach from=$availablePositions item=availablePosition}
+                                                               <option value="{@$availablePosition}"{if $availablePosition == $position} selected="selected"{/if}>{@$availablePosition}</option>
+                                                       {/foreach}
+                                               </select>
+                                       </label>
+                               </dd>
+                       </dl>
+                       
+                       <dl class="col-xs-12 col-md-4">
+                               <dt></dt>
+                               <dd>
+                                       <label class="selectDropdown">
+                                               <select name="boxType" id="boxType">
+                                                       <option value="">{lang}wcf.acp.box.boxType{/lang}</option>
+                                                       <option value="static"{if $boxType == 'static'} selected="selected"{/if}>{lang}wcf.acp.box.boxType.static{/lang}</option>
+                                                       <option value="system"{if $boxType == 'system'} selected="selected"{/if}>{lang}wcf.acp.box.boxType.system{/lang}</option>
+                                               </select>
+                                       </label>
+                               </dd>
+                       </dl>
+                       
+                       {event name='filterFields'}
+               </div>
+               
+               <div class="formSubmit">
+                       <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+                       {@SECURITY_TOKEN_INPUT_TAG}
+               </div>
+       </section>
+</form>
+
 {if $objects|count}
        <div class="section tabularBox">
                <table class="table">
                        <thead>
                                <tr>
-                                       <th class="columnPageID{if $sortField == 'boxID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=boxID&sortOrder={if $sortField == 'boxID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
-                                       <th class="columnTitle columnName{if $sortField == 'name'} active {@$sortOrder}{/if}"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=name&sortOrder={if $sortField == 'name' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.name{/lang}</a></th>
-                                       <th class="columnText columnBoxType{if $sortField == 'boxType'} active {@$sortOrder}{/if}"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=boxType&sortOrder={if $sortField == 'boxType' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.box.boxType{/lang}</a></th>
-                                       <th class="columnText columnPosition{if $sortField == 'position'} active {@$sortOrder}{/if}"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=position&sortOrder={if $sortField == 'position' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.box.position{/lang}</a></th>
+                                       <th class="columnPageID{if $sortField == 'boxID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=boxID&sortOrder={if $sortField == 'boxID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
+                                       <th class="columnTitle columnName{if $sortField == 'name'} active {@$sortOrder}{/if}"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=name&sortOrder={if $sortField == 'name' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.name{/lang}</a></th>
+                                       <th class="columnText columnBoxType{if $sortField == 'boxType'} active {@$sortOrder}{/if}"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=boxType&sortOrder={if $sortField == 'boxType' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.box.boxType{/lang}</a></th>
+                                       <th class="columnText columnPosition{if $sortField == 'position'} active {@$sortOrder}{/if}"><a href="{link controller='BoxList'}pageNo={@$pageNo}&sortField=position&sortOrder={if $sortField == 'position' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.box.position{/lang}</a></th>
                                        
                                        {event name='columnHeads'}
                                </tr>
index e8fb0c717073668c9a7ed9a6edf1296425e448dd..954737dceded324df4d27c93876a74fb904e3955 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 namespace wcf\acp\page;
+use wcf\data\box\Box;
 use wcf\page\SortablePage;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
 
 /**
  * Shows a list of boxes.
@@ -15,30 +18,73 @@ use wcf\page\SortablePage;
  */
 class BoxListPage extends SortablePage {
        /**
-        * @see \wcf\page\AbstractPage::$activeMenuItem
+        * @inheritdoc
         */
        public $activeMenuItem = 'wcf.acp.menu.link.cms.box.list';
        
        /**
-        * @see \wcf\page\MultipleLinkPage::$objectListClassName
+        * @inheritdoc
         */
        public $objectListClassName = 'wcf\data\box\BoxList';
        
        /**
-        * @see \wcf\page\AbstractPage::$neededPermissions
+        * @inheritdoc
         */
        public $neededPermissions = array('admin.content.cms.canManageBox');
        
        /**
-        * @see \wcf\page\SortablePage::$defaultSortField
+        * @inheritdoc
         */
        public $defaultSortField = 'name';
        
        /**
-        * @see \wcf\page\SortablePage::$validSortFields
+        * @inheritdoc
         */
        public $validSortFields = array('boxID', 'name', 'boxType', 'position', 'showOrder');
        
+       /**
+        * name
+        * @var string
+        */
+       public $name = '';
+       
+       /**
+        * title
+        * @var string
+        */
+       public $title = '';
+       
+       /**
+        * content
+        * @var string
+        */
+       public $content = '';
+       
+       /**
+        * box type
+        * @var string
+        */
+       public $boxType = '';
+       
+       /**
+        * box position
+        * @var string
+        */
+       public $position = '';
+       
+       /**
+        * @inheritdoc
+        */
+       public function readParameters() {
+               parent::readParameters();
+               
+               if (!empty($_REQUEST['name'])) $this->name = StringUtil::trim($_REQUEST['name']);
+               if (!empty($_REQUEST['title'])) $this->title = StringUtil::trim($_REQUEST['title']);
+               if (!empty($_REQUEST['content'])) $this->content = StringUtil::trim($_REQUEST['content']);
+               if (!empty($_REQUEST['boxType'])) $this->boxType = $_REQUEST['boxType'];
+               if (!empty($_REQUEST['position'])) $this->position = $_REQUEST['position'];
+       }
+       
        /**
         * @inheritdoc
         */
@@ -47,5 +93,40 @@ class BoxListPage extends SortablePage {
                
                // hide menu boxes
                $this->objectList->getConditionBuilder()->add('box.boxType <> ?', array('menu'));
+               
+               if (!empty($this->name)) {
+                       $this->objectList->getConditionBuilder()->add('box.name LIKE ?', array('%'.$this->name.'%'));
+               }
+               if (!empty($this->title)) {
+                       $this->objectList->getConditionBuilder()->add('box.boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_content WHERE title LIKE ?)', array('%'.$this->title.'%'));
+               }
+               if (!empty($this->content)) {
+                       $this->objectList->getConditionBuilder()->add('box.boxID IN (SELECT boxID FROM wcf'.WCF_N.'_box_content WHERE content LIKE ?)', array('%'.$this->content.'%'));
+               }
+               if (!empty($this->position)) {
+                       $this->objectList->getConditionBuilder()->add('box.position = ?', array($this->position));
+               }
+               if ($this->boxType == 'static') {
+                       $this->objectList->getConditionBuilder()->add('box.boxType IN (?, ?, ?)', array('text', 'html', 'tpl'));
+               }
+               else if ($this->boxType == 'system') {
+                       $this->objectList->getConditionBuilder()->add('box.boxType IN (?)', array('system'));
+               }
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign(array(
+                       'name' => $this->name,
+                       'title' => $this->title,
+                       'content' => $this->content,
+                       'boxType' => $this->boxType,
+                       'position' => $this->position,
+                       'availablePositions' => Box::$availablePositions
+               ));
        }
 }