From: Marcel Werk Date: Sun, 17 Apr 2016 15:21:48 +0000 (+0200) Subject: Added application package id for cms pages X-Git-Tag: 3.0.0_Beta_1~1869 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=19dadfda50333b76fcc8cfb543e70fd5155ca94f;p=GitHub%2FWoltLab%2FWCF.git Added application package id for cms pages --- diff --git a/wcfsetup/install/files/acp/templates/pageAdd.tpl b/wcfsetup/install/files/acp/templates/pageAdd.tpl index 4d1b85d80f..d10e09554b 100644 --- a/wcfsetup/install/files/acp/templates/pageAdd.tpl +++ b/wcfsetup/install/files/acp/templates/pageAdd.tpl @@ -105,20 +105,20 @@ - -
+ +
- originIsSystem} disabled="disabled"{/if}> {foreach from=$availableApplications item=availableApplication} - + {/foreach} - {if $errorField == 'parentPageID'} + {if $errorField == 'applicationPackageID'} {if $errorType == 'empty'} {lang}wcf.global.form.error.empty{/lang} {else} - {lang}wcf.acp.page.packageID.error.{@$errorType}{/lang} + {lang}wcf.acp.page.applicationPackageID.error.{@$errorType}{/lang} {/if} {/if} diff --git a/wcfsetup/install/files/acp/templates/pageList.tpl b/wcfsetup/install/files/acp/templates/pageList.tpl index 1972e72de7..3b6c80afe4 100644 --- a/wcfsetup/install/files/acp/templates/pageList.tpl +++ b/wcfsetup/install/files/acp/templates/pageList.tpl @@ -32,7 +32,7 @@ {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 $applicationPackageID}{capture append=linkParameters}&applicationPackageID={@$applicationPackageID}{/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"} @@ -70,10 +70,10 @@
diff --git a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php index 36072c5da0..28a1954500 100644 --- a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php @@ -75,10 +75,10 @@ class PageAddForm extends AbstractForm { public $isLandingPage = 0; /** - * package id of the page + * application id of the page * @var integer */ - public $packageID = 1; + public $applicationPackageID = 1; /** * list of available applications @@ -165,7 +165,7 @@ class PageAddForm extends AbstractForm { 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['applicationPackageID'])) $this->applicationPackageID = intval($_POST['applicationPackageID']); if (isset($_POST['controller'])) $this->controller = StringUtil::trim($_POST['controller']); if (isset($_POST['customURL']) && is_array($_POST['customURL'])) $this->customURL = ArrayUtil::trim($_POST['customURL']); @@ -188,7 +188,7 @@ class PageAddForm extends AbstractForm { $this->validateParentPageID(); - $this->validatePackageID(); + $this->validateApplicationPackageID(); $this->validateController(); @@ -233,9 +233,9 @@ class PageAddForm extends AbstractForm { /** * Validates package id. */ - protected function validatePackageID() { - if (!isset($this->availableApplications[$this->packageID])) { - throw new UserInputException('packageID', 'invalid'); + protected function validateApplicationPackageID() { + if (!isset($this->availableApplications[$this->applicationPackageID])) { + throw new UserInputException('applicationPackageID', 'invalid'); } } @@ -340,11 +340,12 @@ class PageAddForm extends AbstractForm { 'name' => $this->name, 'isDisabled' => ($this->isDisabled) ? 1 : 0, 'isLandingPage' => 0, - 'packageID' => ($this->packageID ?: null), + 'applicationPackageID' => $this->applicationPackageID, 'lastUpdateTime' => TIME_NOW, 'isMultilingual' => $this->isMultilingual, 'identifier' => '', - 'controller' => $this->controller + 'controller' => $this->controller, + 'packageID' => 1 ]), 'content' => $content, 'boxToPage' => $this->getBoxToPage()]); /** @var Page $page */ @@ -368,7 +369,7 @@ class PageAddForm extends AbstractForm { // reset variables $this->parentPageID = $this->isDisabled = $this->isLandingPage = 0; - $this->packageID = 1; + $this->applicationPackageID = 1; $this->name = $this->controller = ''; $this->pageType = 'text'; $this->customURL = $this->title = $this->content = $this->metaDescription = $this->metaKeywords = []; @@ -404,7 +405,7 @@ class PageAddForm extends AbstractForm { 'isDisabled' => $this->isDisabled, 'isLandingPage' => $this->isLandingPage, 'isMultilingual' => $this->isMultilingual, - 'packageID' => $this->packageID, + 'applicationPackageID' => $this->applicationPackageID, 'controller' => $this->controller, 'customURL' => $this->customURL, 'title' => $this->title, diff --git a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php index 78858b5916..bca4e3ceee 100644 --- a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php @@ -59,7 +59,7 @@ class PageEditForm extends PageAddForm { $this->pageType = $this->page->pageType; if ($this->page->originIsSystem) { $this->parentPageID = $this->page->parentPageID; - $this->packageID = $this->page->packageID; + $this->applicationPackageID = $this->page->applicationPackageID; $this->controller = $this->page->controller; } @@ -89,7 +89,7 @@ class PageEditForm extends PageAddForm { 'isDisabled' => ($this->isDisabled) ? 1 : 0, 'lastUpdateTime' => TIME_NOW, 'parentPageID' => ($this->parentPageID ?: null), - 'packageID' => $this->packageID + 'applicationPackageID' => $this->applicationPackageID ); if ($this->pageType == 'system') { @@ -145,7 +145,7 @@ class PageEditForm extends PageAddForm { $this->name = $this->page->name; $this->parentPageID = $this->page->parentPageID; $this->pageType = $this->page->pageType; - $this->packageID = $this->page->packageID; + $this->applicationPackageID = $this->page->applicationPackageID; $this->controller = $this->page->controller; if ($this->page->controllerCustomURL) $this->customURL[0] = $this->page->controllerCustomURL; if ($this->page->isLandingPage) $this->isLandingPage = 1; @@ -176,7 +176,7 @@ class PageEditForm extends PageAddForm { } /** - * @see \wcf\page\IPage::assignVariables() + * @inheritDoc */ public function assignVariables() { parent::assignVariables(); diff --git a/wcfsetup/install/files/lib/acp/page/PageListPage.class.php b/wcfsetup/install/files/lib/acp/page/PageListPage.class.php index 9f7d66b823..f782a616ce 100644 --- a/wcfsetup/install/files/lib/acp/page/PageListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PageListPage.class.php @@ -61,10 +61,10 @@ class PageListPage extends SortablePage { public $content = ''; /** - * package id of the page + * application id of the page * @var integer */ - public $packageID = 0; + public $applicationPackageID = 0; /** * page type @@ -87,7 +87,7 @@ 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 (isset($_REQUEST['applicationPackageID'])) $this->applicationPackageID = intval($_REQUEST['applicationPackageID']); if (!empty($_REQUEST['pageType'])) $this->pageType = $_REQUEST['pageType']; // get available applications @@ -111,8 +111,8 @@ 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 (!empty($this->applicationPackageID)) { + $this->objectList->getConditionBuilder()->add('page.applicationPackageID = ?', array($this->applicationPackageID)); } if ($this->pageType == 'static') { $this->objectList->getConditionBuilder()->add('page.pageType IN (?, ?, ?)', array('text', 'html', 'tpl')); @@ -132,7 +132,7 @@ class PageListPage extends SortablePage { 'name' => $this->name, 'title' => $this->title, 'content' => $this->content, - 'packageID' => $this->packageID, + 'applicationPackageID' => $this->applicationPackageID, 'pageType' => $this->pageType, 'availableApplications' => $this->availableApplications )); diff --git a/wcfsetup/install/files/lib/data/page/Page.class.php b/wcfsetup/install/files/lib/data/page/Page.class.php index 92634afc7d..20229c2c41 100644 --- a/wcfsetup/install/files/lib/data/page/Page.class.php +++ b/wcfsetup/install/files/lib/data/page/Page.class.php @@ -24,11 +24,13 @@ use wcf\system\WCF; * @property-read integer|null $parentPageID * @property-read string $identifier * @property-read string $name + * @property-read string $pageType * @property-read integer $isDisabled * @property-read integer $isLandingPage * @property-read integer $isMultilingual * @property-read integer $originIsSystem * @property-read integer $packageID + * @property-read integer $applicationPackageID * @property-read string $controller * @property-read string $handler * @property-read string $controllerCustomURL @@ -180,7 +182,7 @@ class Page extends DatabaseObject { * @return \wcf\data\application\Application */ public function getApplication() { - return ApplicationHandler::getInstance()->getApplicationByID($this->packageID); + return ApplicationHandler::getInstance()->getApplicationByID($this->applicationPackageID); } /** diff --git a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php index 0b66b41ba7..a187f11089 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/RoutingCacheBuilder.class.php @@ -107,7 +107,7 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { } // fetch pages with a controller and a custom url - $sql = "SELECT controller, controllerCustomURL, packageID + $sql = "SELECT controller, controllerCustomURL, applicationPackageID FROM wcf".WCF_N."_page WHERE controller <> '' AND controllerCustomURL <> ''"; @@ -119,7 +119,7 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { } // fetch content pages using the common page controller - $sql = "SELECT page_content.customURL AS controllerCustomURL, page_content.pageID, page_content.languageID, page.packageID + $sql = "SELECT page_content.customURL AS controllerCustomURL, page_content.pageID, page_content.languageID, page.applicationPackageID FROM wcf".WCF_N."_page_content page_content LEFT JOIN wcf".WCF_N."_page page ON (page.pageID = page_content.pageID)"; @@ -132,7 +132,7 @@ class RoutingCacheBuilder extends AbstractCacheBuilder { $abbreviations = []; foreach ($rows as $row) { $customUrl = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($row['controllerCustomURL'])); - $packageID = $row['packageID']; + $packageID = $row['applicationPackageID']; if (!isset($abbreviations[$packageID])) { $abbreviations[$packageID] = ApplicationHandler::getInstance()->getAbbreviation($packageID); } 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 13d26ac66e..158d9a7cf6 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -1,5 +1,7 @@ installation->getPackage()->isApplication) { + $applicationPackageID = $this->installation->getPackageID(); + } + if (!empty($data['elements']['application'])) { + $application = PackageCache::getInstance()->getPackageByIdentifier($data['elements']['application']); + if ($application === null || !$application->isApplication) { + throw new SystemException("Unknown application '".$data['elements']['application']."' for page '{$identifier}"); + } + $applicationPackageID = $application->packageID; + } + return [ 'pageType' => $pageType, 'content' => ($isStatic) ? $data['elements']['content'] : [], @@ -196,6 +211,7 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin 'name' => $name, 'originIsSystem' => 1, 'parentPageID' => $parentPageID, + 'applicationPackageID' => $applicationPackageID, 'requireObjectID' => (!empty($data['elements']['requireObjectID'])) ? 1 : 0, 'options' => (isset($data['elements']['options'])) ? $data['elements']['options'] : '', 'permissions' => (isset($data['elements']['permissions'])) ? $data['elements']['permissions'] : '' diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index e3fa182578..1f31a49103 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -908,6 +908,7 @@ CREATE TABLE wcf1_page ( isMultilingual TINYINT(1) NOT NULL DEFAULT 0, originIsSystem TINYINT(1) NOT NULL DEFAULT 0, packageID INT(10) NOT NULL, + applicationPackageID INT(10), controller VARCHAR(255) NOT NULL DEFAULT '', handler VARCHAR(255) NOT NULL DEFAULT '', controllerCustomURL VARCHAR(255) NOT NULL DEFAULT '', @@ -1742,6 +1743,7 @@ ALTER TABLE wcf1_paid_subscription_transaction_log ADD FOREIGN KEY (paymentMetho ALTER TABLE wcf1_page ADD FOREIGN KEY (parentPageID) REFERENCES wcf1_page (pageID) ON DELETE SET NULL; ALTER TABLE wcf1_page ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; +ALTER TABLE wcf1_page ADD FOREIGN KEY (applicationPackageID) REFERENCES wcf1_package (packageID) ON DELETE SET NULL; ALTER TABLE wcf1_page_content ADD FOREIGN KEY (pageID) REFERENCES wcf1_page (pageID) ON DELETE CASCADE; ALTER TABLE wcf1_page_content ADD FOREIGN KEY (languageID) REFERENCES wcf1_language (languageID) ON DELETE CASCADE;