Added page types for cms pages
authorMarcel Werk <burntime@woltlab.com>
Sat, 2 Apr 2016 19:44:33 +0000 (21:44 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sat, 2 Apr 2016 19:44:33 +0000 (21:44 +0200)
com.woltlab.wcf/page.xml
com.woltlab.wcf/templates/cms.tpl
wcfsetup/install/files/acp/templates/pageAdd.tpl
wcfsetup/install/files/acp/templates/pageList.tpl
wcfsetup/install/files/lib/acp/form/PageAddForm.class.php
wcfsetup/install/files/lib/acp/form/PageEditForm.class.php
wcfsetup/install/files/lib/acp/page/PageListPage.class.php
wcfsetup/install/files/lib/data/page/Page.class.php
wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php
wcfsetup/setup/db/install.sql

index 5144bc891650801e121d0455c614097a8bef9a16..931f2683513e6bbc53254e2bbc6c5ac33f7c16ca 100644 (file)
@@ -3,6 +3,7 @@
        <import>
                <!-- dynamic -->
                <page identifier="com.woltlab.wcf.Dashboard">
+                       <pagetype>system</pagetype>
                        <controller>wcf\page\DashboardPage</controller>
                        <name language="de"><![CDATA[Dashboard]]></name>
                        <name language="en"><![CDATA[Dashboard]]></name>
@@ -10,6 +11,7 @@
                </page>
                
                <page identifier="com.woltlab.wcf.MembersList">
+                       <pagetype>system</pagetype>
                        <controller>wcf\page\MembersListPage</controller>
                        <name language="de"><![CDATA[Mitglieder]]></name>
                        <name language="en"><![CDATA[Members]]></name>
                        <options>module_members_list</options>
                </page>
                <page identifier="com.woltlab.wcf.RecentActivityList">
+                       <pagetype>system</pagetype>
                        <controller>wcf\page\RecentActivityListPage</controller>
                        <name language="de"><![CDATA[Letzte Aktivitäten]]></name>
                        <name language="en"><![CDATA[Recent Activities]]></name>
                        <parent>com.woltlab.wcf.MembersList</parent>
                </page>
                <page identifier="com.woltlab.wcf.UsersOnlineList">
+                       <pagetype>system</pagetype>
                        <controller>wcf\page\UsersOnlineListPage</controller>
                        <name language="de"><![CDATA[Benutzer Online]]></name>
                        <name language="en"><![CDATA[Users Online]]></name>
@@ -31,6 +35,7 @@
                        <options>module_users_online</options>
                </page>
                <page identifier="com.woltlab.wcf.Team">
+                       <pagetype>system</pagetype>
                        <controller>wcf\page\TeamPage</controller>
                        <name language="de"><![CDATA[Team]]></name>
                        <name language="en"><![CDATA[Team]]></name>
@@ -39,6 +44,7 @@
                        <options>module_team_page</options>
                </page>
                <page identifier="com.woltlab.wcf.UserSearch">
+                       <pagetype>system</pagetype>
                        <controller>wcf\page\UserSearchForm</controller>
                        <name language="de"><![CDATA[Benutzer suchen]]></name>
                        <name language="en"><![CDATA[Search Users]]></name>
@@ -49,6 +55,7 @@
                
                <!-- static -->
                <page identifier="com.woltlab.wcf.CookiePolicy">
+                       <pagetype>text</pagetype>
                        <name language="en">Cookie Policy</name>
                        <name language="de">Cookie-Richtlinie</name>
                        
                </page>
                
                <page identifier="com.woltlab.wcf.PrivacyPolicy">
+                       <pagetype>text</pagetype>
                        <name language="en">Privacy Policy</name>
                        <name language="de">Datenschutzerklärung</name>
                        <options>module_privacy_policy_page</options>
index 6535d44282ece5909951827cea0079c22afeabc8..1cee085e7162eb7d38a50d669674ef8fd0cb3a13 100644 (file)
 {/hascontent}
 
 {if $content[content]}
-       <section class="section cmsContent htmlContent">
+       {if $page->pageType == 'text'}
+               <section class="section cmsContent htmlContent">
+                       {@$content[content]}
+               </section>
+       {elseif $page->pageType == 'html'}
                {@$content[content]}
-       </section>
+       {elseif $page->pageType == 'tpl'}
+               {*todo*}
+       {/if}
 {/if}
 
 {hascontent}
index af67cc69417e9970c99c7217e0290450ba98a6bc..62200b484bfbfd1206af4334f0c411541d15121d 100644 (file)
                        </dd>
                </dl>
                
-               {if $action == 'add' || !$page->controller}
-                       <dl{if $errorField == 'parentPageID'} class="formError"{/if}>
-                               <dt><label for="parentPageID">{lang}wcf.acp.page.parentPageID{/lang}</label></dt>
-                               <dd>
-                                       <select name="parentPageID" id="parentPageID">
-                                               <option value="0">{lang}wcf.acp.page.parentPageID.noParentPage{/lang}</option>
-                                               
-                                               {foreach from=$pageNodeList item=pageNode}
-                                                       <option value="{@$pageNode->getPage()->pageID}"{if $pageNode->getPage()->pageID == $parentPageID} selected="selected"{/if}>{if $pageNode->getDepth() > 1}{@"&nbsp;&nbsp;&nbsp;&nbsp;"|str_repeat:($pageNode->getDepth() - 1)}{/if}{$pageNode->getPage()->name}</option>
-                                               {/foreach}
-                                       </select>
-                                       {if $errorField == 'parentPageID'}
-                                               <small class="innerError">
-                                                       {if $errorType == 'empty'}
-                                                               {lang}wcf.global.form.error.empty{/lang}
-                                                       {else}
-                                                               {lang}wcf.acp.page.parentPageID.error.{@$errorType}{/lang}
-                                                       {/if}
-                                               </small>
-                                       {/if}
-                               </dd>
-                       </dl>
-                       
-                       <dl{if $errorField == 'packageID'} class="formError"{/if}>
-                               <dt><label for="packageID">{lang}wcf.acp.page.packageID{/lang}</label></dt>
-                               <dd>
-                                       <select name="packageID" id="packageID">
-                                               {foreach from=$availableApplications item=availableApplication}
-                                                       <option value="{@$availableApplication->packageID}"{if $availableApplication->packageID == $packageID} selected="selected"{/if}>{$availableApplication->domainName}{$availableApplication->domainPath}</option>
-                                               {/foreach}
-                                       </select>
-                                       {if $errorField == 'parentPageID'}
-                                               <small class="innerError">
-                                                       {if $errorType == 'empty'}
-                                                               {lang}wcf.global.form.error.empty{/lang}
-                                                       {else}
-                                                               {lang}wcf.acp.page.packageID.error.{@$errorType}{/lang}
-                                                       {/if}
-                                               </small>
-                                       {/if}
-                               </dd>
-                       </dl>
-               {/if}
+               <dl{if $errorField == 'pageType'} class="formError"{/if}>
+                       <dt><label for="pageType">{lang}wcf.acp.page.pageType{/lang}</label></dt>
+                       <dd>
+                               <select name="pageType" id="pageType"{if $action == 'edit'} disabled="disabled"{/if}>
+                                       {foreach from=$availablePageTypes item=availablePageType}
+                                               <option value="{@$availablePageType}"{if $availablePageType == $pageType} selected="selected"{/if}>{lang}wcf.acp.page.pageType.{@$availablePageType}{/lang}</option>
+                                       {/foreach}
+                               </select>
+                               
+                               {if $errorField == 'pageType'}
+                                       <small class="innerError">
+                                               {if $errorType == 'empty'}
+                                                       {lang}wcf.global.form.error.empty{/lang}
+                                               {else}
+                                                       {lang}wcf.acp.page.pageType.error.{@$errorType}{/lang}
+                                               {/if}
+                                       </small>
+                               {/if}
+                       </dd>
+               </dl>
+       
+               <dl{if $errorField == 'parentPageID'} class="formError"{/if}>
+                       <dt><label for="parentPageID">{lang}wcf.acp.page.parentPageID{/lang}</label></dt>
+                       <dd>
+                               <select name="parentPageID" id="parentPageID"{if $action == 'edit' && $page->originIsSystem} disabled="disabled"{/if}>
+                                       <option value="0">{lang}wcf.acp.page.parentPageID.noParentPage{/lang}</option>
+                                       
+                                       {foreach from=$pageNodeList item=pageNode}
+                                               <option value="{@$pageNode->getPage()->pageID}"{if $pageNode->getPage()->pageID == $parentPageID} selected="selected"{/if}>{if $pageNode->getDepth() > 1}{@"&nbsp;&nbsp;&nbsp;&nbsp;"|str_repeat:($pageNode->getDepth() - 1)}{/if}{$pageNode->getPage()->name}</option>
+                                       {/foreach}
+                               </select>
+                               {if $errorField == 'parentPageID'}
+                                       <small class="innerError">
+                                               {if $errorType == 'empty'}
+                                                       {lang}wcf.global.form.error.empty{/lang}
+                                               {else}
+                                                       {lang}wcf.acp.page.parentPageID.error.{@$errorType}{/lang}
+                                               {/if}
+                                       </small>
+                               {/if}
+                       </dd>
+               </dl>
+               
+               <dl{if $errorField == 'packageID'} class="formError"{/if}>
+                       <dt><label for="packageID">{lang}wcf.acp.page.packageID{/lang}</label></dt>
+                       <dd>
+                               <select name="packageID" id="packageID"{if $action == 'edit' && $page->originIsSystem} disabled="disabled"{/if}>
+                                       {foreach from=$availableApplications item=availableApplication}
+                                               <option value="{@$availableApplication->packageID}"{if $availableApplication->packageID == $packageID} selected="selected"{/if}>{$availableApplication->getAbbreviation()}: {$availableApplication->domainName}{$availableApplication->domainPath}</option>
+                                       {/foreach}
+                               </select>
+                               {if $errorField == 'parentPageID'}
+                                       <small class="innerError">
+                                               {if $errorType == 'empty'}
+                                                       {lang}wcf.global.form.error.empty{/lang}
+                                               {else}
+                                                       {lang}wcf.acp.page.packageID.error.{@$errorType}{/lang}
+                                               {/if}
+                                       </small>
+                               {/if}
+                       </dd>
+               </dl>
+               
+               <dl{if $errorField == 'controller'} class="formError"{/if}>
+                       <dt><label for="controller">{lang}wcf.acp.page.controller{/lang}</label></dt>
+                       <dd>
+                               <input type="text" id="controller" name="controller" value="{$controller}" class="long"{if $action == 'edit' && $page->originIsSystem} readonly="readonly"{/if} />
+                               {if $errorField == 'controller'}
+                                       <small class="innerError">
+                                               {if $errorType == 'empty'}
+                                                       {lang}wcf.global.form.error.empty{/lang}
+                                               {else}
+                                                       {lang}wcf.acp.page.controller.error.{@$errorType}{/lang}
+                                               {/if}
+                                       </small>
+                               {/if}
+                       </dd>
+               </dl>
                
                {if !$isMultilingual}
                        <dl{if $errorField == 'customURL'} class="formError"{/if}>
index 4cfad275310280b020be4c0b17f3862983f97065..c994ca7d5a8e41e9fa4f180024223abb46b03b78 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">
        {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 $packageID}{capture append=linkParameters}&packageID={@$packageID}{/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"}
        
        <nav>
                        <li><a href="{link controller='PageLanding'}{/link}" class="button"><span class="icon icon16 fa-home"></span> {lang}wcf.acp.page.landing{/lang}</a></li>
                        <li><a href="{link controller='PageAdd'}{/link}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.page.add{/lang}</span></a></li>
                        <li><a href="{link controller='PageAdd'}isMultilingual=1{/link}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.page.addMultilingual{/lang}</span></a></li>
-               
+                       
                        {event name='contentNavigationButtonsTop'}
                </ul>
        </nav>
 </div>
 
+<form method="post" action="{link controller='PageList'}{/link}">
+       <section class="section">
+               <h2 class="sectionTitle">{lang}wcf.global.filter{/lang}</h2>
+               
+               <div class="row rowColGap">
+                       <div class="row rowColGap col-xs-12 col-md-10">
+                               <dl class="col-xs-12 col-md-4 wide">
+                                       <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 wide">
+                                       <dt></dt>
+                                       <dd>
+                                               <input type="text" id="pageTitle" name="title" value="{$title}" placeholder="{lang}wcf.acp.page.title{/lang}" class="long" />
+                                       </dd>
+                               </dl>
+                               
+                               <dl class="col-xs-12 col-md-4 wide">
+                                       <dt></dt>
+                                       <dd>
+                                               <input type="text" id="pageContent" name="content" value="{$content}" placeholder="{lang}wcf.acp.page.content{/lang}" class="long" />
+                                       </dd>
+                               </dl>
+                               
+                               <dl class="col-xs-12 col-md-4 wide">
+                                       <dt></dt>
+                                       <dd>
+                                               <select name="packageID" id="packageID">
+                                                       <option value="0">{lang}wcf.acp.page.packageID{/lang}</option>
+                                                       {foreach from=$availableApplications item=availableApplication}
+                                                               <option value="{@$availableApplication->packageID}"{if $availableApplication->packageID == $packageID} selected="selected"{/if}>{$availableApplication->getAbbreviation()}: {$availableApplication->domainName}{$availableApplication->domainPath}</option>
+                                                       {/foreach}
+                                               </select>
+                                       </dd>
+                               </dl>
+                               
+                               <dl class="col-xs-12 col-md-4 wide">
+                                       <dt></dt>
+                                       <dd>
+                                               <select name="pageType" id="pageType">
+                                                       <option value="">{lang}wcf.acp.page.pageType{/lang}</option>
+                                                       <option value="static"{if $pageType == 'static'} selected="selected"{/if}>{lang}wcf.acp.page.pageType.static{/lang}</option>
+                                                       <option value="system"{if $pageType == 'system'} selected="selected"{/if}>{lang}wcf.acp.page.pageType.system{/lang}</option>
+                                               </select>
+                                       </dd>
+                               </dl>
+                               
+                               {event name='filterFields'}
+                       </div>
+                       
+                       <div class="col-xs-12 col-md-2">
+                               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+                               {@SECURITY_TOKEN_INPUT_TAG}
+                       </div>
+               </div>
+       </section>
+</form>
+
 {if $objects|count}
        <div class="section tabularBox">
                <table class="table">
                                <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}{@$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="columnText columnURL" colspan="2">{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}{@$linkParameters}{/link}">{lang}wcf.acp.page.lastUpdateTime{/lang}</a></th>
                                        
                                        {event name='columnHeads'}
                                                </td>
                                                <td class="columnID columnPageID">{@$page->pageID}</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="columnIcon"><span class="badge label">{$page->getApplication()->getAbbreviation()}</span></td>
                                                <td class="columnText columnURL">
-                                                       <span class="badge label">{$page->getApplication()->getAbbreviation()}</span>
                                                        {$page->getDisplayLink()}
                                                </td>
                                                <td class="columnDate columnLastUpdateTime">{@$page->lastUpdateTime|time}</td>
index 425425c0ef25a1ff2e2b272753f09c2647cfb85d..7c2e31ca7cd00f9b76c1991c615d33733feea8ff 100644 (file)
@@ -42,6 +42,12 @@ class PageAddForm extends AbstractForm {
         */
        public $isMultilingual = 0;
        
+       /**
+        * page type
+        * @var string
+        */
+       public $pageType = '';
+       
        /**
         * parent page id
         * @var integer
@@ -84,6 +90,12 @@ class PageAddForm extends AbstractForm {
         */
        public $customURL = [];
        
+       /**
+        * page controller
+        * @var string
+        */
+       public $controller = '';
+       
        /**
         * page titles
         * @var string[]
@@ -129,10 +141,12 @@ class PageAddForm extends AbstractForm {
                parent::readFormParameters();
                
                if (isset($_POST['parentPageID'])) $this->parentPageID = intval($_POST['parentPageID']);
+               if (isset($_POST['pageType'])) $this->pageType = $_POST['pageType'];
                if (isset($_POST['name'])) $this->name = StringUtil::trim($_POST['name']);
                if (isset($_POST['isDisabled'])) $this->isDisabled = 1;
                if (isset($_POST['isLandingPage'])) $this->isLandingPage = 1;
                if (isset($_POST['packageID'])) $this->packageID = intval($_POST['packageID']);
+               if (isset($_POST['controller'])) $this->controller = StringUtil::trim($_POST['controller']);
                
                if (isset($_POST['customURL']) && is_array($_POST['customURL'])) $this->customURL = ArrayUtil::trim($_POST['customURL']);
                if (isset($_POST['title']) && is_array($_POST['title'])) $this->title = ArrayUtil::trim($_POST['title']);
@@ -149,10 +163,14 @@ class PageAddForm extends AbstractForm {
                
                $this->validateName();
                
+               $this->validatePageType();
+               
                $this->validateParentPageID();
                
                $this->validatePackageID();
                
+               $this->validateController();
+               
                $this->validateCustomUrl();
        }
        
@@ -168,6 +186,15 @@ class PageAddForm extends AbstractForm {
                }
        }
        
+       /**
+        * Validates page type.
+        */
+       protected function validatePageType() {
+               if (!in_array($this->pageType, Page::$availablePageTypes) || ($this->isMultilingual && $this->pageType == 'system')) {
+                       throw new UserInputException('pageType');
+               }
+       }
+       
        /**
         * Validates parent page id.
         */
@@ -189,6 +216,21 @@ class PageAddForm extends AbstractForm {
                }
        }
        
+       /**
+        * Validates controller.
+        */
+       protected function validateController() {
+               if ($this->pageType == 'system') {
+                       if (!$this->controller) {
+                               throw new UserInputException('controller');
+                       }
+                       
+                       if (!class_exists($this->controller)) {
+                               throw new UserInputException('controller', 'notFound');
+                       }
+               }
+       }
+       
        /**
         * Validates custom urls.
         */
@@ -230,13 +272,15 @@ class PageAddForm extends AbstractForm {
                
                $this->objectAction = new PageAction([], 'create', ['data' => array_merge($this->additionalFields, [
                        'parentPageID' => ($this->parentPageID ?: null),
+                       'pageType' => $this->pageType,
                        'name' => $this->name,
                        'isDisabled' => ($this->isDisabled) ? 1 : 0,
                        'isLandingPage' => ($this->isLandingPage) ? 1 : 0,
                        'packageID' => ($this->packageID ?: null),
                        'lastUpdateTime' => TIME_NOW,
                        'isMultilingual' => $this->isMultilingual,
-                       'identifier' => ''
+                       'identifier' => '',
+                       'controller' => $this->controller
                ]), 'content' => $content]);
                $returnValues = $this->objectAction->executeAction();
                // set generic page identifier
@@ -254,7 +298,8 @@ class PageAddForm extends AbstractForm {
                // reset variables
                $this->parentPageID = $this->isDisabled = $this->isLandingPage = 0;
                $this->packageID = 1;
-               $this->name = '';
+               $this->name = $this->controller = '';
+               $this->pageType = 'text';
                $this->customURL = $this->title = $this->content = $this->metaDescription = $this->metaKeywords = [];
        }
        
@@ -264,14 +309,18 @@ class PageAddForm extends AbstractForm {
        public function assignVariables() {
                parent::assignVariables();
                
+               $availablePageTypes = Page::$availablePageTypes;
+               if ($this->isMultilingual) unset($availablePageTypes[array_search('system', $availablePageTypes)]);
                WCF::getTPL()->assign([
                        'action' => 'add',
                        'parentPageID' => $this->parentPageID,
+                       'pageType' => $this->pageType,
                        'name' => $this->name,
                        'isDisabled' => $this->isDisabled,
                        'isLandingPage' => $this->isLandingPage,
                        'isMultilingual' => $this->isMultilingual,
                        'packageID' => $this->packageID,
+                       'controller' => $this->controller,
                        'customURL' => $this->customURL,
                        'title' => $this->title,
                        'content' => $this->content,
@@ -279,6 +328,7 @@ class PageAddForm extends AbstractForm {
                        'metaKeywords' => $this->metaKeywords,
                        'availableApplications' => $this->availableApplications,
                        'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
+                       'availablePageTypes' => $availablePageTypes,
                        'pageNodeList' => (new PageNodeTree())->getNodeList()
                ]);
        }
index 05d809e79848ab2cabfc8ddf31d9c9ca1a67e22e..2afc5d0340e48e0074a25c17f9236dbed85d7edb 100644 (file)
@@ -54,30 +54,23 @@ class PageEditForm extends PageAddForm {
        /**
         * @inheritDoc
         */
-       protected function validateName() {
-               if (mb_strtolower($this->name) != mb_strtolower($this->page->name)) {
-                       parent::validateName();
-               }
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       protected function validateParentPageID() {
-               if (!$this->page->controller && $this->parentPageID) {
-                       $page = new Page($this->parentPageID);
-                       if (!$page->pageID) {
-                               throw new UserInputException('parentPageID', 'invalid');
-                       }
+       public function readFormParameters() {
+               parent::readFormParameters();
+               
+               $this->pageType = $this->page->pageType;
+               if ($this->page->originIsSystem) {
+                       $this->parentPageID = $this->page->parentPageID;
+                       $this->packageID = $this->page->packageID;
+                       $this->controller = $this->page->controller;
                }
        }
        
        /**
         * @inheritDoc
         */
-       protected function validatePackageID() {
-               if (!$this->page->controller) {
-                       parent::validatePackageID();
+       protected function validateName() {
+               if (mb_strtolower($this->name) != mb_strtolower($this->page->name)) {
+                       parent::validateName();
                }
        }
        
@@ -87,19 +80,23 @@ class PageEditForm extends PageAddForm {
        public function save() {
                AbstractForm::save();
                
-               if ($this->page->controller) {
-                       $this->objectAction = new PageAction(array($this->page), 'update', array('data' => array_merge($this->additionalFields, array(
-                               'name' => $this->name,
-                               'isDisabled' => ($this->isDisabled) ? 1 : 0,
-                               'isLandingPage' => ($this->isLandingPage) ? 1 : 0,
-                               'controllerCustomURL' => (!empty($_POST['customURL'][0]) ? $_POST['customURL'][0] : ''),
-                               'lastUpdateTime' => TIME_NOW
-                       ))));
+               $data = array(
+                       'name' => $this->name,
+                       'isDisabled' => ($this->isDisabled) ? 1 : 0,
+                       'isLandingPage' => ($this->isLandingPage) ? 1 : 0,
+                       'lastUpdateTime' => TIME_NOW,
+                       'parentPageID' => ($this->parentPageID ?: null),
+                       'packageID' => $this->packageID
+               );
+               
+               if ($this->pageType == 'system') {
+                       $data['controllerCustomURL'] = (!empty($_POST['customURL'][0]) ? $_POST['customURL'][0] : '');
+                       $this->objectAction = new PageAction(array($this->page), 'update', array('data' => array_merge($this->additionalFields, $data)));
                        $this->objectAction->executeAction();
                }
                else {
                        $content = array();
-                       if ($this->isMultilingual) {
+                       if ($this->page->isMultilingual) {
                                foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
                                        $content[$language->languageID] = array(
                                                'customURL' => (!empty($_POST['customURL'][$language->languageID]) ? $_POST['customURL'][$language->languageID] : ''),
@@ -120,15 +117,7 @@ class PageEditForm extends PageAddForm {
                                );
                        }
                        
-                       $this->objectAction = new PageAction(array($this->page), 'update', array('data' => array_merge($this->additionalFields, array(
-                               'parentPageID' => ($this->parentPageID ?: null),
-                               'name' => $this->name,
-                               'isDisabled' => ($this->isDisabled) ? 1 : 0,
-                               'isLandingPage' => ($this->isLandingPage) ? 1 : 0,
-                               'packageID' => ($this->packageID ?: null),
-                               'lastUpdateTime' => TIME_NOW,
-                               'isMultilingual' => $this->isMultilingual
-                       )), 'content' => $content));
+                       $this->objectAction = new PageAction(array($this->page), 'update', array('data' => array_merge($this->additionalFields, $data), 'content' => $content));
                        $this->objectAction->executeAction();
                }
                
@@ -148,7 +137,10 @@ class PageEditForm extends PageAddForm {
                if (empty($_POST)) {
                        $this->name = $this->page->name;
                        $this->parentPageID = $this->page->parentPageID;
+                       $this->pageType = $this->page->pageType;
                        $this->packageID = $this->page->packageID;
+                       $this->controller = $this->page->controller;
+                       if ($this->page->controllerCustomURL) $this->customURL[0] = $this->page->controllerCustomURL;
                        if ($this->page->isLandingPage) $this->isLandingPage = 1;
                        if ($this->page->isDiabled) $this->isDisabled = 1;
                        
index 52e77073032494cdd3c129b24d07a7f1288da824..9f7d66b82302a41741a7241597421cd28d2bfa3e 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\acp\page;
+use wcf\data\application\ApplicationList;
 use wcf\page\SortablePage;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
@@ -59,6 +60,24 @@ class PageListPage extends SortablePage {
         */
        public $content = '';
        
+       /**
+        * package id of the page
+        * @var integer
+        */
+       public $packageID = 0;
+       
+       /**
+        * page type
+        * @var string
+        */
+       public $pageType = 'static';
+       
+       /**
+        * list of available applications
+        * @var \wcf\data\application\Application[]
+        */
+       public $availableApplications = [];
+       
        /**
         * @inheritdoc
         */
@@ -68,6 +87,13 @@ class PageListPage extends SortablePage {
                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 (isset($_REQUEST['packageID'])) $this->packageID = intval($_REQUEST['packageID']);
+               if (!empty($_REQUEST['pageType'])) $this->pageType = $_REQUEST['pageType'];
+               
+               // get available applications
+               $applicationList = new ApplicationList();
+               $applicationList->readObjects();
+               $this->availableApplications = $applicationList->getObjects();
        }
        
        /**
@@ -85,6 +111,15 @@ class PageListPage extends SortablePage {
                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.'%'));
                }
+               if (!empty($this->packageID)) {
+                       $this->objectList->getConditionBuilder()->add('page.packageID = ?', array($this->packageID));
+               }
+               if ($this->pageType == 'static') {
+                       $this->objectList->getConditionBuilder()->add('page.pageType IN (?, ?, ?)', array('text', 'html', 'tpl'));
+               }
+               else if ($this->pageType == 'system') {
+                       $this->objectList->getConditionBuilder()->add('page.pageType IN (?)', array('system'));
+               }
        }
        
        /**
@@ -96,7 +131,10 @@ class PageListPage extends SortablePage {
                WCF::getTPL()->assign(array(
                        'name' => $this->name,
                        'title' => $this->title,
-                       'content' => $this->content
+                       'content' => $this->content,
+                       'packageID' => $this->packageID,
+                       'pageType' => $this->pageType,
+                       'availableApplications' => $this->availableApplications
                ));
        }
 }
index f61ea17a6cb57d0bfef5017cbfe4fd9a055b7a40..dc3ea47e5433b23175e37cd60d51820e382e8ecf 100644 (file)
@@ -24,6 +24,12 @@ class Page extends DatabaseObject {
        use TDatabaseObjectOptions;
        use TDatabaseObjectPermissions;
        
+       /**
+        * available page types
+        * @var string[]
+        */
+       public static $availablePageTypes = ['text', 'html', 'tpl', 'system'];
+       
        /**
         * @inheritDoc
         */
index 48f7b5f3cb5e4729439bfd10ca9f3e9861a2fa15..c880414ae7730f82a6418b5da8cab5e88dcdc87f 100644 (file)
@@ -144,13 +144,53 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        throw new SystemException("Invalid custom url for page identifier '" . $data['attributes']['identifier'] . "'");
                }
                
+               // validate page type
+               $pageType = $data['elements']['pagetype'];
+               $controller = '';
+               $identifier = $data['attributes']['identifier'];
+               $isMultilingual = 0;
+               switch ($pageType) {
+                       case 'system':
+                               if (empty($data['elements']['controller'])) {
+                                       throw new SystemException("Missing required element 'controller' for 'system'-type page '{$identifier}'");
+                               }
+                               $controller = $data['elements']['controller'];
+                               break;
+                       
+                       case 'html':
+                       case 'text':
+                       case 'tpl':     
+                               if (empty($data['elements']['content'])) {
+                                       throw new SystemException("Missing required 'content' element(s) for page '{$identifier}'");
+                               }
+                               
+                               if (count($data['elements']['content']) === 1) {
+                                       if (!isset($data['elements']['content'][''])) {
+                                               throw new SystemException("Expected one 'content' element without a 'language' attribute for page '{$identifier}'");
+                                       }
+                               }
+                               else {
+                                       $isMultilingual = 1;
+                                       if (isset($data['elements']['content'][''])) {
+                                               throw new SystemException("Cannot mix 'content' elements with and without 'language' attribute for page '{$identifier}'");
+                                       }
+                               }
+                               
+                               break;
+                       
+                       default:
+                               throw new SystemException("Unknown type '{$pageType}' for page '{$identifier}");
+                               break;
+               }
+               
                return [
+                       'pageType' => $pageType,
                        'content' => ($isStatic) ? $data['elements']['content'] : [],
-                       'controller' => ($isStatic) ? '' : $data['elements']['controller'],
+                       'controller' => $controller,
                        'handler' => (!$isStatic && !empty($data['elements']['handler'])) ? $data['elements']['handler'] : '',
                        'controllerCustomURL' => $controllerCustomURL,
-                       'identifier' => $data['attributes']['identifier'],
-                       'isMultilingual' => ($isStatic) ? 1 : 0,
+                       'identifier' => $identifier,
+                       'isMultilingual' => $isMultilingual,
                        'lastUpdateTime' => TIME_NOW,
                        'name' => $name,
                        'originIsSystem' => 1,
index 9e8412db33c041a95f2e2db6653af2f059d0619a..987530e4168b6ada1c8487d400c97070e3506344 100644 (file)
@@ -906,6 +906,7 @@ CREATE TABLE wcf1_page (
        parentPageID INT(10),
        identifier VARCHAR(255) NOT NULL,
        name VARCHAR(255) NOT NULL,
+       pageType VARCHAR(255) NOT NULL,
        isDisabled TINYINT(1) NOT NULL DEFAULT 0,
        isLandingPage TINYINT(1) NOT NULL DEFAULT 0,
        isMultilingual TINYINT(1) NOT NULL DEFAULT 0,