From a0fdb136b07132eaa80e09a2ec395b80b5aeeb88 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 28 Nov 2015 21:14:00 +0100 Subject: [PATCH] Some minor updates --- .../install/files/acp/templates/pageList.tpl | 12 ++--- .../files/lib/acp/form/PageAddForm.class.php | 52 ++++++++++++------- .../PagePackageInstallationPlugin.class.php | 15 +++--- wcfsetup/setup/db/install.sql | 2 +- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/pageList.tpl b/wcfsetup/install/files/acp/templates/pageList.tpl index c07d846767..4c8851ec5c 100644 --- a/wcfsetup/install/files/acp/templates/pageList.tpl +++ b/wcfsetup/install/files/acp/templates/pageList.tpl @@ -49,22 +49,22 @@ {if $page->canDisable()} - + {else} - + {/if} - + {if $page->canDelete()} - + {else} - + {/if} {event name='rowButtons'} {@$page->pageID} {$page->displayName} - {$page->customURL} + {$page->controllerCustomURL} {@$page->lastUpdateTime|time} {event name='columns'} diff --git a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php index e64c3f8c48..c90d5d66a0 100644 --- a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php @@ -1,5 +1,6 @@ + * @var Application[] */ - public $availableApplications = array(); + public $availableApplications = []; /** * page custom URL * @var array */ - public $customURL = array(); + public $customURL = []; /** * page titles * @var array */ - public $title = array(); + public $title = []; /** * page contents * @var array */ - public $content = array(); + public $content = []; /** * page meta descriptions * @var array */ - public $metaDescription = array(); + public $metaDescription = []; /** * page meta keywords * @var array */ - public $metaKeywords = array(); + public $metaKeywords = []; /** * @see \wcf\page\IPage::readParameters() @@ -149,6 +151,8 @@ class PageAddForm extends AbstractForm { $this->validateParentPageID(); $this->validatePackageID(); + + $this->validateCustomUrl(); } protected function validateDisplayName() { @@ -175,35 +179,43 @@ class PageAddForm extends AbstractForm { } } + protected function validateCustomUrl() { + foreach ($this->customURL as $type => $customURL) { + if (!empty($customURL) && !RouteHandler::isValidCustomUrl($customURL)) { + throw new UserInputException('customURL_' . $type, 'invalid'); + } + } + } + /** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); - $content = array(); + $content = []; if ($this->isMultilingual) { foreach (LanguageFactory::getInstance()->getLanguages() as $language) { - $content[$language->languageID] = array( + $content[$language->languageID] = [ 'customURL' => (!empty($_POST['customURL'][$language->languageID]) ? $_POST['customURL'][$language->languageID] : ''), 'title' => (!empty($_POST['title'][$language->languageID]) ? $_POST['title'][$language->languageID] : ''), 'content' => (!empty($_POST['content'][$language->languageID]) ? $_POST['content'][$language->languageID] : ''), 'metaDescription' => (!empty($_POST['metaDescription'][$language->languageID]) ? $_POST['metaDescription'][$language->languageID] : ''), 'metaKeywords' => (!empty($_POST['metaKeywords'][$language->languageID]) ? $_POST['metaKeywords'][$language->languageID] : '') - ); + ]; } } else { - $content[0] = array( + $content[0] = [ 'customURL' => (!empty($_POST['customURL'][0]) ? $_POST['customURL'][0] : ''), 'title' => (!empty($_POST['title'][0]) ? $_POST['title'][0] : ''), 'content' => (!empty($_POST['content'][0]) ? $_POST['content'][0] : ''), 'metaDescription' => (!empty($_POST['metaDescription'][0]) ? $_POST['metaDescription'][0] : ''), 'metaKeywords' => (!empty($_POST['metaKeywords'][0]) ? $_POST['metaKeywords'][0] : '') - ); + ]; } - $this->objectAction = new PageAction(array(), 'create', array('data' => array_merge($this->additionalFields, array( + $this->objectAction = new PageAction([], 'create', ['data' => array_merge($this->additionalFields, [ 'parentPageID' => ($this->parentPageID ?: null), 'displayName' => $this->displayName, 'isDisabled' => ($this->isDisabled) ? 1 : 0, @@ -212,13 +224,13 @@ class PageAddForm extends AbstractForm { 'lastUpdateTime' => TIME_NOW, 'isMultilingual' => $this->isMultilingual, 'name' => '' - )), 'content' => $content)); + ]), 'content' => $content]); $returnValues = $this->objectAction->executeAction(); // set generic page name $pageEditor = new PageEditor($returnValues['returnValues']); - $pageEditor->update(array( + $pageEditor->update([ 'name' => 'com.woltlab.wcf.generic'.$pageEditor->pageID - )); + ]); // call saved event $this->saved(); @@ -230,7 +242,7 @@ class PageAddForm extends AbstractForm { $this->parentPageID = $this->isDisabled = $this->isLandingPage = 0; $this->packageID = 1; $this->displayName = ''; - $this->customURL = $this->title = $this->content = $this->metaDescription = $this->metaKeywords = array(); + $this->customURL = $this->title = $this->content = $this->metaDescription = $this->metaKeywords = []; } /** @@ -241,7 +253,7 @@ class PageAddForm extends AbstractForm { $pageNodeList = new PageNodeTree(); - WCF::getTPL()->assign(array( + WCF::getTPL()->assign([ 'action' => 'add', 'parentPageID' => $this->parentPageID, 'displayName' => $this->displayName, @@ -257,6 +269,6 @@ class PageAddForm extends AbstractForm { 'availableApplications' => $this->availableApplications, 'availableLanguages' => LanguageFactory::getInstance()->getLanguages(), 'pageNodeList' => $pageNodeList->getNodeList() - )); + ]); } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php index 22c9c6b3c4..3d856b0b16 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -45,7 +45,7 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin WCF::getDB()->beginTransaction(); foreach ($items as $item) { $statement->execute([ - $item['attributes']['name'], + $item['attributes']['identifier'], $this->installation->getPackageID() ]); } @@ -93,7 +93,7 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin $content = []; foreach ($data['elements']['content'] as $language => $contentData) { if (!RouteHandler::isValidCustomUrl($contentData['customurl'])) { - throw new SystemException("Invalid custom url for page content '" . $language . "', page identifier '" . $data['attributes']['name'] . "'"); + throw new SystemException("Invalid custom url for page content '" . $language . "', page identifier '" . $data['attributes']['identifier'] . "'"); } $content[$language] = [ @@ -132,7 +132,7 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin $statement->execute([$data['elements']['parent']]); $row = $statement->fetchSingleRow(); if ($row === false) { - throw new SystemException("Unknown parent page '" . $data['elements']['parent'] . "' for page identifier '" . $data['attributes']['name'] . "'"); + throw new SystemException("Unknown parent page '" . $data['elements']['parent'] . "' for page identifier '" . $data['attributes']['identifier'] . "'"); } $parentPageID = $row['pageID']; @@ -140,7 +140,7 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin $customUrl = ($isStatic || empty($data['elements']['customurl'])) ? '' : $data['elements']['customurl']; if ($customUrl && !RouteHandler::isValidCustomUrl($customUrl)) { - throw new SystemException("Invalid custom url for page identifier '" . $data['attributes']['name'] . "'"); + throw new SystemException("Invalid custom url for page identifier '" . $data['attributes']['identifier'] . "'"); } return [ @@ -148,7 +148,10 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin 'controller' => ($isStatic) ? '' : $data['elements']['controller'], 'controllerCustomURL' => $customUrl, 'displayName' => $displayName, - 'name' => $data['attributes']['name'], + 'identifier' => $data['attributes']['identifier'], + 'isMultilingual' => ($isStatic) ? 1 : 0, + 'lastUpdateTime' => TIME_NOW, + 'originIsSystem' => 1, 'parentPageID' => $parentPageID ]; } @@ -162,7 +165,7 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin WHERE name = ? AND packageID = ?"; $parameters = array( - $data['name'], + $data['identifier'], $this->installation->getPackageID() ); diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 4a9f74b3b0..15fead56ee 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -823,7 +823,7 @@ DROP TABLE IF EXISTS wcf1_page; CREATE TABLE wcf1_page ( pageID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, parentPageID INT(10), - name VARCHAR(255) NOT NULL, + identifier VARCHAR(255) NOT NULL, displayName VARCHAR(255) NOT NULL, isDisabled TINYINT(1) NOT NULL DEFAULT 0, isLandingPage TINYINT(1) NOT NULL DEFAULT 0, -- 2.20.1