<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>
</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>
<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>
<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>
<!-- 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>
{/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}
</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}{@" "|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}{@" "|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}>
<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>
*/
public $isMultilingual = 0;
+ /**
+ * page type
+ * @var string
+ */
+ public $pageType = '';
+
/**
* parent page id
* @var integer
*/
public $customURL = [];
+ /**
+ * page controller
+ * @var string
+ */
+ public $controller = '';
+
/**
* page titles
* @var string[]
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']);
$this->validateName();
+ $this->validatePageType();
+
$this->validateParentPageID();
$this->validatePackageID();
+ $this->validateController();
+
$this->validateCustomUrl();
}
}
}
+ /**
+ * 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.
*/
}
}
+ /**
+ * 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.
*/
$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
// 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 = [];
}
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,
'metaKeywords' => $this->metaKeywords,
'availableApplications' => $this->availableApplications,
'availableLanguages' => LanguageFactory::getInstance()->getLanguages(),
+ 'availablePageTypes' => $availablePageTypes,
'pageNodeList' => (new PageNodeTree())->getNodeList()
]);
}
/**
* @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();
}
}
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] : ''),
);
}
- $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();
}
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;
<?php
namespace wcf\acp\page;
+use wcf\data\application\ApplicationList;
use wcf\page\SortablePage;
use wcf\system\WCF;
use wcf\util\StringUtil;
*/
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
*/
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();
}
/**
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'));
+ }
}
/**
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
));
}
}
use TDatabaseObjectOptions;
use TDatabaseObjectPermissions;
+ /**
+ * available page types
+ * @var string[]
+ */
+ public static $availablePageTypes = ['text', 'html', 'tpl', 'system'];
+
/**
* @inheritDoc
*/
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,
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,