<parent>wcf.acp.menu.link.cms</parent>
<permissions>admin.content.cms.canManagePage</permissions>
</acpmenuitem>
- <acpmenuitem name="wcf.acp.menu.link.cms.page.landing">
- <controller><![CDATA[wcf\acp\form\PageLandingForm]]></controller>
- <parent>wcf.acp.menu.link.cms.page.list</parent>
- <permissions>admin.content.cms.canManagePage</permissions>
- <icon>fa-home</icon>
- </acpmenuitem>
<acpmenuitem name="wcf.acp.menu.link.cms.page.add">
<controller><![CDATA[wcf\acp\form\PageAddForm]]></controller>
<parent>wcf.acp.menu.link.cms.page.list</parent>
{include file='documentHeader'}
<head>
- <title>{if $__wcf->getPageMenu()->getLandingPage()->menuItem != 'wcf.user.dashboard'}{lang}wcf.user.dashboard{/lang} - {/if}{PAGE_TITLE|language}</title>
+ <title>{if !$__wcf->isLandingPage()}{lang}wcf.user.dashboard{/lang} - {/if}{PAGE_TITLE|language}</title>
{include file='headInclude'}
{include file='header'}
-{if $__wcf->getPageMenu()->getLandingPage()->menuItem == 'wcf.user.dashboard'}
+{if $__wcf->isLandingPage()}
<header class="contentHeader">
<div class="contentHeaderTitle">
<h1 class="contentTitle">{PAGE_TITLE|language}</h1>
use wcf\system\session\SessionHandler;
use wcf\system\WCF;
use wcf\util\DateUtil;
-use wcf\util\StringUtil;
/**
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @category Community Framework
$sql = "UPDATE wcf".WCF_N."_package_installation_plugin
SET priority = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(1));
+$statement->execute([1]);
// reset sessions
SessionHandler::resetSessions();
$sql = "UPDATE wcf".WCF_N."_acp_template
SET packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(1));
+$statement->execute([1]);
// update language
$sql = "UPDATE wcf".WCF_N."_language_item
SET packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(1));
+$statement->execute([1]);
// update installation logs
$sql = "UPDATE wcf".WCF_N."_package_installation_file_log
SET packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(1));
+$statement->execute([1]);
$sql = "UPDATE wcf".WCF_N."_package_installation_sql_log
SET packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(1));
+$statement->execute([1]);
// update pips
$sql = "UPDATE wcf".WCF_N."_package_installation_plugin
SET packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(1));
+$statement->execute([1]);
// group options
$sql = "UPDATE wcf".WCF_N."_user_group_option
SET packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(1));
+$statement->execute([1]);
+
+// landing page
+$sql = "UPDATE wcf".WCF_N."_page
+ SET isLandingPage = ?
+ WHERE identifier = ?";
+$statement = WCF::getDB()->prepareStatement($sql);
+$statement->execute([
+ 1,
+ 'com.woltlab.wcf.Dashboard'
+]);
// get server timezone
if ($timezone = @date_default_timezone_get()) {
SET optionValue = ?
WHERE optionName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($timezone, 'timezone'));
+ $statement->execute([
+ $timezone,
+ 'timezone'
+ ]);
}
}
</dl>
{/if}
- <dl>
- <dt></dt>
- <dd>
- <label><input type="checkbox" id="isLandingPage" name="isLandingPage" value="1" {if $isLandingPage}checked="checked" {/if}{if $action == 'edit' && $page->isLandingPage}disabled="disabled" {/if}/> {lang}wcf.acp.page.isLandingPage{/lang}</label>
- </dd>
- </dl>
+ {if $action != 'edit' || !$page->requireObjectID}
+ <dl>
+ <dt></dt>
+ <dd>
+ <label><input type="checkbox" id="isLandingPage" name="isLandingPage" value="1" {if $isLandingPage}checked="checked" {/if}{if $action == 'edit' && $page->isLandingPage}disabled="disabled" {/if}/> {lang}wcf.acp.page.isLandingPage{/lang}</label>
+ </dd>
+ </dl>
+ {/if}
<dl>
<dt></dt>
+++ /dev/null
-{include file='header' pageTitle='wcf.acp.page.landing'}
-
-<header class="contentHeader">
- <h1 class="contentTitle">{lang}wcf.acp.page.landing{/lang}</h1>
-</header>
-
-{include file='formError'}
-
-{if $success|isset}
- <p class="success">{lang}wcf.global.success.{$action}{/lang}</p>
-{/if}
-
-<div class="contentNavigation">
- <nav>
- <ul>
- <li><a href="{link controller='PageList'}{/link}" class="button"><span class="icon icon16 fa-list"></span> <span>{lang}wcf.acp.menu.link.cms.page.list{/lang}</span></a></li>
-
- {event name='contentNavigationButtons'}
- </ul>
- </nav>
-</div>
-
-<form method="post" action="{link controller='PageLanding'}{/link}">
- <div class="section tabularBox">
- <table class="table">
- <thead>
- <tr>
- <th class="columnText">{lang}wcf.acp.page.landing.application{/lang}</th>
- <th class="columnURL">{lang}wcf.acp.page.landing.pageURL{/lang}</th>
- <th class="columnText">{lang}wcf.acp.page.landing.landingPage{/lang}</th>
- </tr>
- </thead>
-
- <tbody>
- {foreach from=$applications item=application}
- <tr>
- <td class="columnText">{$application->getPackage()}</td>
- <td class="columnURL">{$application->getPageURL()}</td>
- <td class="columnText">
- <select name="landingPages[{@$application->packageID}]">
- <option value="-1">{lang}wcf.acp.page.landing.applicationDefault{/lang}</option>
- {foreach from=$pageNodeList item=pageNode}
- <option value="{@$pageNode->getPage()->pageID}"{if $pageNode->getPage()->pageID == $application->landingPageID} selected{/if}>{if $pageNode->getDepth() > 1}{@" "|str_repeat:($pageNode->getDepth() - 1)}{/if}{$pageNode->getPage()}</option>
- {/foreach}
- </select>
- </td>
- </tr>
- {/foreach}
- </tbody>
- </table>
- </div>
-
- <div class="formSubmit">
- <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
- {@SECURITY_TOKEN_INPUT_TAG}
- </div>
-</form>
-
-{include file='footer'}
'pageType' => $this->pageType,
'name' => $this->name,
'isDisabled' => ($this->isDisabled) ? 1 : 0,
- 'isLandingPage' => ($this->isLandingPage) ? 1 : 0,
+ 'isLandingPage' => 0,
'packageID' => ($this->packageID ?: null),
'lastUpdateTime' => TIME_NOW,
'isMultilingual' => $this->isMultilingual,
'identifier' => '',
'controller' => $this->controller
]), 'content' => $content]);
- $returnValues = $this->objectAction->executeAction();
+
+ /** @var Page $page */
+ $page = $this->objectAction->executeAction()['returnValues'];
+
// set generic page identifier
- $pageEditor = new PageEditor($returnValues['returnValues']);
+ $pageEditor = new PageEditor($page);
$pageEditor->update([
'identifier' => 'com.woltlab.wcf.generic'.$pageEditor->pageID
]);
+ if ($this->isLandingPage) {
+ $page->setAsLandingPage();
+ }
+
// call saved event
$this->saved();
$this->packageID = $this->page->packageID;
$this->controller = $this->page->controller;
}
+
+ if ($this->page->requireObjectID) {
+ // pages that require an object id can never be set as landing page
+ $this->isLandingPage = 0;
+ }
}
/**
$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
$this->objectAction->executeAction();
}
+ if ($this->isLandingPage != $this->page->isLandingPage) {
+ $this->page->setAsLandingPage();
+ }
+
// call saved event
$this->saved();
+++ /dev/null
-<?php
-namespace wcf\acp\form;
-use wcf\data\application\Application;
-use wcf\data\application\ApplicationAction;
-use wcf\data\application\ApplicationList;
-use wcf\data\page\Page;
-use wcf\data\page\PageList;
-use wcf\data\page\PageNodeTree;
-use wcf\form\AbstractForm;
-use wcf\system\exception\UserInputException;
-use wcf\system\WCF;
-use wcf\util\ArrayUtil;
-
-/**
- * Shows the page add form.
- *
- * @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage acp.form
- * @category Community Framework
- */
-class PageLandingForm extends AbstractForm {
- /**
- * @inheritDoc
- */
- public $activeMenuItem = 'wcf.acp.menu.link.cms.page.landing';
-
- /**
- * list of available applications
- * @var Application[]
- */
- public $applications;
-
- /**
- * landing page id per application package id
- * @var integer[]
- */
- public $landingPages = [];
-
- /**
- * @inheritDoc
- */
- public $neededPermissions = ['admin.content.cms.canManagePage'];
-
- /**
- * list of available pages
- * @var Page[]
- */
- public $pages = [];
-
- /**
- * @inheritDoc
- */
- public function readParameters() {
- parent::readParameters();
-
- // get available applications and pages
- $applicationList = new ApplicationList();
- $applicationList->readObjects();
- $this->applications = $applicationList->getObjects();
-
- $pageList = new PageList();
- $pageList->readObjects();
- foreach ($pageList as $page) {
- if (!isset($this->pages[$page->packageID])) $this->pages[$page->packageID] = [];
-
- $this->pages[$page->packageID][$page->pageID] = $page;
- }
- }
-
- /**
- * @inheritDoc
- */
- public function readFormParameters() {
- parent::readFormParameters();
-
- if (isset($_POST['landingPages']) && is_array($_POST['landingPages'])) $this->landingPages = ArrayUtil::toIntegerArray($_POST['landingPages']);
- }
-
- /**
- * @inheritDoc
- */
- public function validate() {
- parent::validate();
-
- foreach ($this->applications as $packageID => $application) {
- if (empty($this->landingPages[$packageID])) {
- throw new UserInputException('landingPage');
- }
-
- // handle application default
- if ($this->landingPages[$packageID] === -1) {
- $this->landingPages[$packageID] = null;
-
- continue;
- }
-
- $page = new Page($this->landingPages[$packageID]);
- if (!$page->pageID) {
- throw new UserInputException('landingPage', 'notValid');
- }
- }
- }
-
- /**
- * @inheritDoc
- */
- public function save() {
- parent::save();
-
- $this->objectAction = new ApplicationAction($this->applications, 'setLandingPage', ['landingPages' => $this->landingPages]);
- $this->objectAction->executeAction();
-
- // call saved event
- $this->saved();
-
- // show success
- WCF::getTPL()->assign('success', true);
- }
-
- /**
- * @inheritDoc
- */
- public function assignVariables() {
- parent::assignVariables();
-
- WCF::getTPL()->assign([
- 'applications' => $this->applications,
- 'pageNodeList' => (new PageNodeTree())->getNodeList()
- ]);
- }
-}
use wcf\data\TDatabaseObjectPermissions;
use wcf\system\application\ApplicationHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\SystemException;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
return true;
}
+ /**
+ * Sets the current page as landing page.
+ *
+ * @throws SystemException
+ */
+ public function setAsLandingPage() {
+ if ($this->requireObjectID) {
+ throw new SystemException('Pages requiring an object id cannot be set as landing page.');
+ }
+
+ // unmark existing landing page
+ $sql = "UPDATE wcf".WCF_N."_page
+ SET isLandingPage = ?
+ AND isLandingPage = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ 0,
+ 1
+ ]);
+
+ // set current page as landing page
+ $sql = "UPDATE wcf".WCF_N."_page
+ SET isLandingPage = ?
+ WHERE pageID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ 1,
+ $this->pageID
+ ]);
+ }
+
/**
* Returns the page's internal name.
*
use wcf\system\exception\SystemException;
use wcf\system\language\LanguageFactory;
use wcf\system\package\PackageInstallationDispatcher;
+use wcf\system\request\RequestHandler;
use wcf\system\request\RouteHandler;
use wcf\system\session\SessionFactory;
use wcf\system\session\SessionHandler;
* It holds the database connection, access to template and language engine.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system
return self::getPath() . 'images/favicon.ico';
}
+ /**
+ * Returns true if currently active request represents the landing page.
+ *
+ * @return boolean
+ */
+ public function isLandingPage() {
+ return RequestHandler::getInstance()->getActiveRequest()->isLandingPage();
+ }
+
/**
* Initialises the cronjobs.
*/
<?php
namespace wcf\system\cache\builder;
+use wcf\data\page\Page;
use wcf\data\page\PageList;
/**
$data = [
'identifier' => [],
'controller' => [],
- 'pages' => []
+ 'pages' => [],
+ 'landingPage' => null
];
$pageList = new PageList();
$data['pages'] = $pageList->getObjects();
// build lookup table
+ /** @var Page $page */
foreach ($pageList as $page) {
$data['identifier'][$page->identifier] = $page->pageID;
$data['controller'][$page->controller] = $page->pageID;
+
+ if ($page->isLandingPage) {
+ $data['landingPage'] = $page;
+ }
}
return $data;
namespace wcf\system\cache\builder;
use wcf\data\application\Application;
use wcf\data\page\Page;
+use wcf\page\CmsPage;
use wcf\system\application\ApplicationHandler;
use wcf\system\request\ControllerMap;
use wcf\system\WCF;
}
foreach (ApplicationHandler::getInstance()->getApplications() as $application) {
- if ($application->landingPageID) {
- $page = new Page($application->landingPageID);
- if ($page->controller) {
- $controller = $page->controller;
+ $controller = null;
+
+ if ($application->packageID == 1) {
+ // handle WCF
+ $page = PageCacheBuilder::getInstance()->getData([], 'landingPage');
+ if ($page === null) {
+ // no landing page defined
+ $controller = ['', '', ''];
}
else {
- $controller = '__WCF_CMS__' . $page->pageID;
- $controller = [$controller, $controller];
+ if ($page->controller) {
+ $controller = $page->controller;
+ }
+ else {
+ $controller = '__WCF_CMS__' . $page->pageID;
+ $controller = [$controller, $controller, CmsPage::class];
+ }
+
}
}
- else if ($application->packageID == 1) {
- // WCF has no default controller
- $controller = ['', ''];
- }
else {
- $controller = preg_replace('~^.*?\\\([^\\\]+)(?:Action|Form|Page)$~', '\\1', WCF::getApplicationObject($application)->getPrimaryController());
+ $controller = WCF::getApplicationObject($application)->getPrimaryController();
+ }
+
+ if (is_string($controller)) {
+ $fqnController = $controller;
+ $controller = preg_replace('~^.*?\\\([^\\\]+)(?:Action|Form|Page)$~', '\\1', $controller);
$controller = [
$controller,
- ControllerMap::transformController($controller)
+ ControllerMap::transformController($controller),
+ $fqnController
];
}
return false;
}
+ /**
+ * Returns true if currently active request represents the landing page.
+ *
+ * @param string[] $classData
+ * @param array $metaData
+ * @return boolean
+ */
+ public function isLandingPage(array $classData, array $metaData) {
+ if ($classData['className'] !== $this->landingPages['wcf'][2]) {
+ return false;
+ }
+
+ if ($classData['className'] === CmsPage::class) {
+ // check if page id matches
+ if ($this->landingPages['wcf'][1] !== '__WCF_CMS__' . $metaData['cms']['pageID']) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/**
* Returns the class data for the active request or null if for the given
* configuration no proper class exist.
*/
protected $className = '';
+ /**
+ * @var boolean
+ */
+ protected $isLandingPage = false;
+
/**
* request meta data
* @var string[]
$this->pageType = $pageType;
}
+ /**
+ * Marks this request as landing page.
+ */
+ public function setIsLandingPage() {
+ $this->isLandingPage = true;
+ }
+
/**
* Executes this request.
*/
return ($this->requestObject !== null);
}
+ /**
+ * Returns true if this request represents the landing page.
+ *
+ * @return boolean
+ */
+ public function isLandingPage() {
+ return $this->isLandingPage;
+ }
+
/**
* Returns the page class name of this request.
*
}
$this->activeRequest = new Request($classData['className'], $classData['controller'], $classData['pageType'], $metaData);
+
+ // determine if current request matches the landing page
+ if (ControllerMap::getInstance()->isLandingPage($classData, $metaData)) {
+ $this->activeRequest->setIsLandingPage();
+ }
}
catch (SystemException $e) {
throw new IllegalLinkException();
}
/**
- * @see IRequestRoute::setIsACP()
+ * @inheritDoc
*/
public function setIsACP($isACP) {
$this->isACP = $isACP;
protected $staticController = '';
/**
- * @see \wcf\system\request\route\IRequestRoute::setIsACP()
+ * @inheritDoc
*/
public function setIsACP($isACP) {
// static routes are disallowed for ACP
}
/**
- * @see \wcf\system\request\IRoute::buildLink()
+ * @inheritDoc
*/
public function buildLink(array $components) {
// static routes don't have these components
}
/**
- * @see \wcf\system\request\IRoute::canHandle()
+ * @inheritDoc
*/
public function canHandle(array $components) {
if (isset($components['application']) && $components['application'] == $this->staticApplication) {
}
/**
- * @see \wcf\system\request\IRoute::matches()
+ * @inheritDoc
*/
public function matches($requestURL) {
if (parent::matches($requestURL)) {
domainName VARCHAR(255) NOT NULL,
domainPath VARCHAR(255) NOT NULL DEFAULT '/',
cookieDomain VARCHAR(255) NOT NULL,
- cookiePath VARCHAR(255) NOT NULL DEFAULT '/',
- landingPageID INT(10) NULL
+ cookiePath VARCHAR(255) NOT NULL DEFAULT '/'
);
DROP TABLE IF EXISTS wcf1_attachment;