Improved display of custom URLs
authorAlexander Ebert <ebert@woltlab.com>
Thu, 19 Oct 2017 17:52:25 +0000 (19:52 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 19 Oct 2017 17:52:25 +0000 (19:52 +0200)
wcfsetup/install/files/acp/templates/pageList.tpl
wcfsetup/install/files/lib/acp/page/PageListPage.class.php
wcfsetup/install/files/lib/data/page/Page.class.php

index e2407f095f3afbaaa017652fb9a8e21a12c6f457..337abd66e12b8b09cf87d45d31521ce229f79cf1 100644 (file)
@@ -76,6 +76,7 @@
                                <dt></dt>
                                <dd>
                                        <label><input type="checkbox" name="originIsNotSystem" value="1"{if $originIsNotSystem} checked{/if}> {lang}wcf.acp.page.originIsNotSystem{/lang}</label>
+                                       <label><input type="checkbox" name="controllerCustomURL" value="1"{if $controllerCustomURL} checked{/if}> {lang}wcf.acp.page.customURL{/lang}</label>
                                </dd>
                        </dl>
                        
                        {if $applicationPackageID}{capture append=linkParameters}&applicationPackageID={@$applicationPackageID}{/capture}{/if}
                        {if $pageType}{capture append=linkParameters}&pageType={@$pageType|rawurlencode}{/capture}{/if}
                        {if $originIsNotSystem}{capture append=linkParameters}&originIsNotSystem=1{/capture}{/if}
+                       {if $controllerCustomURL}{capture append=linkParameters}&controllerCustomURL=1{/capture}{/if}
                        
                        {pages print=true assign=pagesLinks controller="PageList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
                {/content}
                                                <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">
                                                        {$page->getDisplayLink()}
+                                                       {if $page->controllerCustomURL}
+                                                               <span class="icon icon16 fa-exclamation-circle blue jsTooltip" title="{lang}wcf.acp.page.customURL{/lang}"></span>
+                                                       {/if}
                                                </td>
                                                <td class="columnText columnPageType">{lang}wcf.acp.page.type.{@$page->pageType}{/lang}</td>
                                                <td class="columnDate columnLastUpdateTime">{@$page->lastUpdateTime|time}</td>
index 676aadc887ff71c16f786de6b2f2e5f484ae6f26..2af4496862ea36c34bb73f586ea77bddd3da220f 100644 (file)
@@ -98,6 +98,12 @@ class PageListPage extends SortablePage {
         */
        public $originIsNotSystem = 0;
        
+       /**
+        * filters the list of pages showing only pages with custom urls
+        * @var boolean
+        */
+       public $controllerCustomURL = 0;
+       
        /**
         * @inheritDoc
         */
@@ -111,6 +117,7 @@ class PageListPage extends SortablePage {
                if (!empty($_REQUEST['pageType'])) $this->pageType = $_REQUEST['pageType'];
                if (!empty($_REQUEST['showPageAddDialog'])) $this->showPageAddDialog = 1;
                if (!empty($_REQUEST['originIsNotSystem'])) $this->originIsNotSystem = 1;
+               if (!empty($_REQUEST['controllerCustomURL'])) $this->controllerCustomURL = 1;
                
                // get available applications
                $applicationList = new ApplicationList();
@@ -142,6 +149,9 @@ class PageListPage extends SortablePage {
                if ($this->originIsNotSystem) {
                        $this->objectList->getConditionBuilder()->add('page.originIsSystem = ?', [0]);
                }
+               if ($this->controllerCustomURL) {
+                       $this->objectList->getConditionBuilder()->add("page.controllerCustomURL <> ''");
+               }
        }
        
        /**
@@ -159,7 +169,8 @@ class PageListPage extends SortablePage {
                        'availableApplications' => $this->availableApplications,
                        'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
                        'showPageAddDialog' => $this->showPageAddDialog,
-                       'originIsNotSystem' => $this->originIsNotSystem
+                       'originIsNotSystem' => $this->originIsNotSystem,
+                       'controllerCustomURL' => $this->controllerCustomURL
                ]);
        }
 }
index 12286bb8cdbfd28b0b05d2f05bf5f6eaa01e9213..630a6b887cfcda788879b719243fd88b0dfb9ac7 100644 (file)
@@ -179,7 +179,16 @@ class Page extends DatabaseObject implements ILinkableObject, ITitledObject {
         * @return      string
         */
        public function getDisplayLink() {
-               return preg_replace('~^https?://~', '', $this->getLink());
+               $link = preg_replace('~^https?://~', '', $this->getLink());
+               if ($this->controllerCustomURL) {
+                       $link = preg_replace('~(index\.php\?)[^/]+/$~', "\$1{$this->controllerCustomURL}/", $link);
+               }
+               
+               if (URL_OMIT_INDEX_PHP) {
+                       $link = str_replace('index.php?', '', $link);
+               }
+               
+               return $link;
        }
        
        /**