Added option to search or filter the media list by title
authorMarcel Werk <burntime@woltlab.com>
Mon, 5 Dec 2016 12:45:42 +0000 (13:45 +0100)
committerMarcel Werk <burntime@woltlab.com>
Mon, 5 Dec 2016 12:45:47 +0000 (13:45 +0100)
wcfsetup/install/files/acp/templates/mediaList.tpl
wcfsetup/install/files/lib/acp/page/MediaListPage.class.php

index ce64f7c863cba6f354a9331cd25408a5a1e7f5cc..381d8f8480663820ec66deecb0cda8c391c7db83 100644 (file)
@@ -37,7 +37,7 @@
                        <dl class="col-xs-12 col-md-4">
                                <dt></dt>
                                <dd>
-                                       <input type="text" id="filename" name="filename" value="{$filename}" placeholder="{lang}wcf.media.filename{/lang}" class="long">
+                                       <input type="text" id="q" name="q" value="{$q}" placeholder="{lang}wcf.media.search.placeholder{/lang}" class="long">
                                </dd>
                        </dl>
                        
@@ -63,7 +63,7 @@
                {content}
                        {assign var='linkParameters' value=''}
                        {if $username}{capture append=linkParameters}&username={@$username|rawurlencode}{/capture}{/if}
-                       {if $filename}{capture append=linkParameters}&filename={@$filename|rawurlencode}{/capture}{/if}
+                       {if $q}{capture append=linkParameters}&q={@$q|rawurlencode}{/capture}{/if}
                        
                        {pages print=true assign=pagesLinks controller="MediaList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
                {/content}
@@ -78,6 +78,7 @@
                                        <th class="columnMark"><label><input type="checkbox" class="jsClipboardMarkAll"></label></th>
                                        <th class="columnID columnMediaID{if $sortField == 'mediaID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=mediaID&sortOrder={if $sortField == 'mediaID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
                                        <th class="columnTitle columnFilename{if $sortField == 'filename'} active {@$sortOrder}{/if}"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=filename&sortOrder={if $sortField == 'filename' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.media.filename{/lang}</a></th>
+                                       <th class="columnText columnMediaTitle{if $sortField == 'title'} active {@$sortOrder}{/if}"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=title&sortOrder={if $sortField == 'title' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.title{/lang}</a></th>
                                        <th class="columnDate columnUploadTime{if $sortField == 'uploadTime'} active {@$sortOrder}{/if}"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=uploadTime&sortOrder={if $sortField == 'uploadTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.media.uploadTime{/lang}</a></th>
                                        <th class="columnDigits columnFilesize{if $sortField == 'filesize'} active {@$sortOrder}{/if}"><a href="{link controller='MediaList'}pageNo={@$pageNo}&sortField=filesize&sortOrder={if $sortField == 'filesize' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.media.filesize{/lang}</a></th>
                                        
                                                                </div>
                                                        </div>
                                                </td>
+                                               <td class="columnText columnMediaTitle">{$media->title|tableWordwrap}</td>
                                                <td class="columnDate columnUploadTime">{@$media->uploadTime|time}</td>
                                                <td class="columnDigits columnFilesize">{@$media->filesize|filesize}</td>
                                                
index 1ea6f830c32173b58810bbf5e34ef8f95334a6f6..fe8994be4b4968e9c72623a1ba80d66281d66383 100644 (file)
@@ -35,10 +35,10 @@ class MediaListPage extends SortablePage {
        public $defaultSortOrder = 'DESC';
        
        /**
-        * searched media filename
+        * searched media query
         * @var string
         */
-       public $filename = '';
+       public $query = '';
        
        /**
         * @inheritDoc
@@ -79,7 +79,7 @@ class MediaListPage extends SortablePage {
                parent::assignVariables();
                
                WCF::getTPL()->assign([
-                       'filename' => $this->filename,
+                       'q' => $this->query,
                        'hasMarkedItems' => ClipboardHandler::getInstance()->hasMarkedItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.media')),
                        'username' => $this->username
                ]);
@@ -91,8 +91,8 @@ class MediaListPage extends SortablePage {
        protected function initObjectList() {
                parent::initObjectList();
                
-               if ($this->filename) {
-                       $this->objectList->addSearchConditions($this->filename);
+               if ($this->query) {
+                       $this->objectList->addSearchConditions($this->query);
                }
                if ($this->username) {
                        $this->objectList->getConditionBuilder()->add('media.username LIKE ?', ['%'.addcslashes($this->username, '_%').'%']);
@@ -105,13 +105,13 @@ class MediaListPage extends SortablePage {
        public function readParameters() {
                parent::readParameters();
                
-               if (isset($_REQUEST['filename'])) $this->filename = StringUtil::trim($_REQUEST['filename']);
+               if (isset($_REQUEST['q'])) $this->query = StringUtil::trim($_REQUEST['q']);
                if (isset($_REQUEST['username'])) $this->username = StringUtil::trim($_REQUEST['username']);
                
                $parameters = [];
                if ($this->sortField) $parameters['sortField'] = $this->sortField;
                if ($this->sortOrder) $parameters['sortOrder'] = $this->sortOrder;
-               if ($this->filename) $parameters['filename'] = $this->filename;
+               if ($this->query) $parameters['q'] = $this->query;
                if ($this->username) $parameters['username'] = $this->username;
                
                $this->canonicalURL = LinkHandler::getInstance()->getLink('MediaList', $parameters);