Improved CMS page list
authorMarcel Werk <burntime@woltlab.com>
Sun, 13 Mar 2016 21:34:47 +0000 (22:34 +0100)
committerMarcel Werk <burntime@woltlab.com>
Sun, 13 Mar 2016 21:34:52 +0000 (22:34 +0100)
wcfsetup/install/files/acp/templates/pageList.tpl
wcfsetup/install/files/lib/acp/page/PageListPage.class.php
wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php
wcfsetup/install/files/lib/data/page/Page.class.php
wcfsetup/install/files/lib/system/request/LinkHandler.class.php

index 518c6db6600fe746406c24bbabc344f79553ed7d..4cfad275310280b020be4c0b17f3862983f97065 100644 (file)
        <h1 class="contentTitle">{lang}wcf.acp.page.list{/lang}</h1>
 </header>
 
+<form method="post" action="{link controller='PageList'}{/link}">
+       <section class="section">
+               <h2 class="sectionTitle">{lang}wcf.global.filter{/lang}</h2>
+               
+               <div class="row rowColGap">
+                       <dl class="col-xs-12 col-md-4">
+                               <dt><label for="name">{lang}wcf.global.name{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="name" name="name" value="{$name}" class="long" />
+                               </dd>
+                       </dl>
+                       
+                       <dl class="col-xs-12 col-md-4">
+                               <dt><label for="pageTitle">{lang}wcf.acp.page.title{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="pageTitle" name="title" value="{$title}" class="long" />
+                               </dd>
+                       </dl>
+                       
+                       <dl class="col-xs-12 col-md-4">
+                               <dt><label for="pageContent">{lang}wcf.acp.page.content{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="pageContent" name="content" value="{$content}" class="long" />
+                               </dd>
+                       </dl>
+                       
+                       {event name='filterFields'}
+               </div>
+       </section>
+       
+       <div class="formSubmit">
+               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+               {@SECURITY_TOKEN_INPUT_TAG}
+       </div>
+</form>
+
 <div class="contentNavigation">
-       {pages print=true assign=pagesLinks controller="PageList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
+       {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}
+       {pages print=true assign=pagesLinks controller="PageList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
        
        <nav>
                <ul>
                <table class="table">
                        <thead>
                                <tr>
-                                       <th class="columnPageID{if $sortField == 'pageID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='PageList'}pageNo={@$pageNo}&sortField=pageID&sortOrder={if $sortField == 'pageID' && $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='PageList'}pageNo={@$pageNo}&sortField=name&sortOrder={if $sortField == 'name' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.name{/lang}</a></th>
+                                       <th class="columnPageID{if $sortField == 'pageID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='PageList'}pageNo={@$pageNo}&sortField=pageID&sortOrder={if $sortField == 'pageID' && $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='PageList'}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 columnURL">{lang}wcf.acp.page.url{/lang}</th>
-                                       <th class="columnDate columnLastUpdateTime{if $sortField == 'lastUpdateTime'} active {@$sortOrder}{/if}"><a href="{link controller='PageList'}pageNo={@$pageNo}&sortField=lastUpdateTime&sortOrder={if $sortField == 'lastUpdateTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.page.lastUpdateTime{/lang}</a></th>
+                                       <th class="columnDate columnLastUpdateTime{if $sortField == 'lastUpdateTime'} active {@$sortOrder}{/if}"><a href="{link controller='PageList'}pageNo={@$pageNo}&sortField=lastUpdateTime&sortOrder={if $sortField == 'lastUpdateTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.page.lastUpdateTime{/lang}</a></th>
                                        
                                        {event name='columnHeads'}
                                </tr>
                                                        {else}
                                                                <span class="icon icon16 fa-times disabled" title="{lang}wcf.global.button.delete{/lang}"></span>
                                                        {/if}
+                                                       {if !$page->requireObjectID}
+                                                               <a href="{$page->getLink()}" title="{lang}wcf.acp.page.button.viewPage{/lang}" class="jsTooltip"><span class="icon icon16 fa-search"></span></a>
+                                                       {else}
+                                                               <span class="icon icon16 fa-search disabled" title="{lang}wcf.acp.page.button.viewPage{/lang}"></span>
+                                                       {/if}
                                                        
                                                        {event name='rowButtons'}
                                                </td>
                                                <td class="columnID columnPageID">{@$page->pageID}</td>
-                                               <td class="columnTitle columnName"><a href="{link controller='PageEdit' id=$page->pageID}{/link}">{$page->name}</a></td>
-                                               <td class="columnText columnURL">{$page->getURL()}</td>
+                                               <td class="columnTitle columnName">{if $page->isLandingPage}<span class="icon icon16 fa-home jsTooltip" title="{lang}wcf.acp.page.isLandingPage{/lang}"></span> {/if}<a href="{link controller='PageEdit' id=$page->pageID}{/link}">{$page->name}</a></td>
+                                               <td class="columnText columnURL">
+                                                       <span class="badge label">{$page->getApplication()->getAbbreviation()}</span>
+                                                       {$page->getDisplayLink()}
+                                               </td>
                                                <td class="columnDate columnLastUpdateTime">{@$page->lastUpdateTime|time}</td>
                                                
                                                {event name='columns'}
index 7dc654e913afa178911d95770a21cb6f833d0b52..52e77073032494cdd3c129b24d07a7f1288da824 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 namespace wcf\acp\page;
 use wcf\page\SortablePage;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
 
 /**
  * Shows a list of pages.
@@ -15,27 +17,86 @@ use wcf\page\SortablePage;
  */
 class PageListPage extends SortablePage {
        /**
-        * @see \wcf\page\AbstractPage::$activeMenuItem
+        * @inheritdoc
         */
        public $activeMenuItem = 'wcf.acp.menu.link.cms.page.list';
        
        /**
-        * @see \wcf\page\MultipleLinkPage::$objectListClassName
+        * @inheritdoc
         */
        public $objectListClassName = 'wcf\data\page\PageList';
        
        /**
-        * @see \wcf\page\AbstractPage::$neededPermissions
+        * @inheritdoc
         */
        public $neededPermissions = array('admin.content.cms.canManagePage');
        
        /**
-        * @see \wcf\page\SortablePage::$defaultSortField
+        * @inheritdoc
         */
        public $defaultSortField = 'name';
        
        /**
-        * @see \wcf\page\SortablePage::$validSortFields
+        * @inheritdoc
         */
        public $validSortFields = array('pageID', 'name', 'lastUpdateTime');
+       
+       /**
+        * name
+        * @var string
+        */
+       public $name = '';
+       
+       /**
+        * title
+        * @var string
+        */
+       public $title = '';
+       
+       /**
+        * content
+        * @var string
+        */
+       public $content = '';
+       
+       /**
+        * @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']);
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       protected function initObjectList() {
+               parent::initObjectList();
+               
+               if (!empty($this->name)) {
+                       $this->objectList->getConditionBuilder()->add('page.name LIKE ?', array('%'.$this->name.'%'));
+               }
+               if (!empty($this->title)) {
+                       $this->objectList->getConditionBuilder()->add('page.pageID IN (SELECT pageID FROM wcf'.WCF_N.'_page_content WHERE title LIKE ?)', array('%'.$this->title.'%'));
+               }
+               if (!empty($this->content)) {
+                       $this->objectList->getConditionBuilder()->add('page.pageID IN (SELECT pageID FROM wcf'.WCF_N.'_page_content WHERE content LIKE ?)', array('%'.$this->content.'%'));
+               }
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign(array(
+                       'name' => $this->name,
+                       'title' => $this->title,
+                       'content' => $this->content
+               ));
+       }
 }
index 14a7386d23ba3f9f92dfb7d56d98356a1d8a86b0..1fe322c4bfb2cdc6bc034b49b89848a81b180369 100644 (file)
@@ -80,7 +80,7 @@ class MenuItem extends DatabaseObject {
                }
                
                if ($this->pageID) {
-                       return $this->getPage()->getURL();
+                       return $this->getPage()->getLink();
                }
                else {
                        return $this->externalURL;
index a8ed4a8025771a8793b6a31b45d861afdc9b8c36..23d9135a7846a983cff20e404130b39350666be2 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 namespace wcf\data\page;
+use wcf\data\application\Application;
 use wcf\data\DatabaseObject;
+use wcf\system\application\ApplicationHandler;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
@@ -113,7 +115,7 @@ class Page extends DatabaseObject {
         * 
         * @return      string
         */
-       public function getURL() {
+       public function getLink() {
                if ($this->controller) {
                        // todo
                        $controllerParts = explode('\\', $this->controller);
@@ -121,7 +123,8 @@ class Page extends DatabaseObject {
                        $controllerName = preg_replace('/(page|action|form)$/i', '', $controllerName);
                        
                        return LinkHandler::getInstance()->getLink($controllerName, [
-                               'application' => $controllerParts[0]
+                               'application' => $controllerParts[0],
+                               'forceFrontend' => true
                        ]);
                }
                else {
@@ -129,6 +132,24 @@ class Page extends DatabaseObject {
                }       
        }
        
+       /**
+        * Returns shortened link for acp page list.
+        *
+        * @return      string
+        */
+       public function getDisplayLink() {
+               return str_replace($this->getApplication()->getPageURL(), '', $this->getLink());
+       }
+       
+       /**
+        * Returns the application of this page.
+        *
+        * @return      \wcf\data\application\Application
+        */
+       public function getApplication() {
+               return ApplicationHandler::getInstance()->getApplicationByID($this->packageID);
+       }
+       
        /**
         * Returns the associated page handler or null.
         * 
@@ -144,8 +165,8 @@ class Page extends DatabaseObject {
        
        /**
         * Returns the page's internal name.
-        * 
-        * @return string
+        *
+        * @return      string
         */
        public function __toString() {
                return $this->name;
index c8e5086bfe09be45a5e042d1afa69f6308c6affb..bd7a0647b61c4080f798010d5072b908a5a5c9ee 100644 (file)
@@ -247,7 +247,8 @@ class LinkHandler extends SingletonFactory {
                }
                
                return $this->getLink($data['controller'], [
-                       'application' => $data['application']
+                       'application' => $data['application'],
+                       'forceFrontend' => true
                ]);
        }
 }