+++ /dev/null
-<?php
-namespace wcf\data\page\location;
-use wcf\data\ProcessibleDatabaseObject;
-
-/**
- * Represents a page location.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.location
- * @category Community Framework
- */
-class PageLocation extends ProcessibleDatabaseObject {
- /**
- * @see wcf\data\DatabaseObject::$databaseTableName
- */
- protected static $databaseTableName = 'page_location';
-
- /**
- * @see wcf\data\DatabaseObject::$databaseIndexName
- */
- protected static $databaseIndexName = 'locationID';
-
- /**
- * @see wcf\data\ProcessibleDatabaseObject::$processorInterface
- */
- protected static $processorInterface = 'wcf\system\page\location\IPageLocation';
-}
+++ /dev/null
-<?php
-namespace wcf\data\page\location;
-use wcf\data\AbstractDatabaseObjectAction;
-
-/**
- * Executes page location-related actions.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.location
- * @category Community Framework
- */
-class PageLocationAction extends AbstractDatabaseObjectAction {
- /**
- * @see wcf\data\AbstractDatabaseObjectAction::$className
- */
- protected $className = 'wcf\data\page\location\PageLocationEditor';
-}
+++ /dev/null
-<?php
-namespace wcf\data\page\location;
-use wcf\data\DatabaseObjectEditor;
-
-/**
- * Provides functions to edit page locations.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.location
- * @category Community Framework
- */
-class PageLocationEditor extends DatabaseObjectEditor {
- /**
- * @see wcf\data\DatabaseObjectDecorator::$baseClass
- */
- protected static $baseClass = 'wcf\data\page\location\PageLocation';
-}
+++ /dev/null
-<?php
-namespace wcf\data\page\location;
-use wcf\data\DatabaseObjectList;
-
-/**
- * Represents a list of page locations.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.location
- * @category Community Framework
- */
-class PageLocationList extends DatabaseObjectList {
- /**
- * @see wcf\data\DatabaseObjectList::$className
- */
- public $className = 'wcf\data\page\location\PageLocation';
-}
+++ /dev/null
-<?php
-namespace wcf\data\page\menu\item;
-use wcf\data\ProcessibleDatabaseObject;
-use wcf\system\application\ApplicationHandler;
-use wcf\system\menu\page\DefaultPageMenuItemProvider;
-use wcf\system\menu\ITreeMenuItem;
-use wcf\system\request\LinkHandler;
-
-/**
- * Represents an page menu item.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.menu.item
- * @category Community Framework
- */
-class PageMenuItem extends ProcessibleDatabaseObject implements ITreeMenuItem {
- /**
- * @see wcf\data\DatabaseObject::$databaseTableName
- */
- protected static $databaseTableName = 'page_menu_item';
-
- /**
- * @see wcf\data\DatabaseObject::$databaseTableIndexName
- */
- protected static $databaseTableIndexName = 'menuItemID';
-
- /**
- * @see wcf\data\ProcessibleDatabaseObject::$processorInterface
- */
- protected static $processorInterface = 'wcf\system\menu\page\IPageMenuItemProvider';
-
- /**
- * @see wcf\data\ProcessibleDatabaseObject::getProcessor()
- */
- public function getProcessor() {
- if (parent::getProcessor() === null) {
- $this->processor = new DefaultPageMenuItemProvider($this);
- }
-
- return $this->processor;
- }
-
- /**
- * @see wcf\system\menu\ITreeMenuItem::getLink()
- */
- public function getLink() {
- $abbreviation = ApplicationHandler::getInstance()->getAbbreviation($this->packageID);
-
- $parameters = array();
- if ($abbreviation) {
- $parameters['application'] = $abbreviation;
- }
-
- return LinkHandler::getInstance()->getLink(null, $parameters, $this->menuItemLink);
- }
-}
+++ /dev/null
-<?php
-namespace wcf\data\page\menu\item;
-use wcf\data\AbstractDatabaseObjectAction;
-
-/**
- * Executes page menu item-related actions.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.menu.item
- * @category Community Framework
- */
-class PageMenuItemAction extends AbstractDatabaseObjectAction {
- /**
- * @see wcf\data\AbstractDatabaseObjectAction::$className
- */
- protected $className = 'wcf\data\page\menu\item\PageMenuItemEditor';
-}
+++ /dev/null
-<?php
-namespace wcf\data\page\menu\item;
-use wcf\data\DatabaseObjectEditor;
-use wcf\data\IEditableCachedObject;
-use wcf\system\cache\CacheHandler;
-use wcf\system\WCF;
-
-/**
- * Provides functions to edit page menu items.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.menu.item
- * @category Community Framework
- */
-class PageMenuItemEditor extends DatabaseObjectEditor implements IEditableCachedObject {
- /**
- * @see wcf\data\DatabaseObjectDecorator::$baseClass
- */
- protected static $baseClass = 'wcf\data\page\menu\item\PageMenuItem';
-
- /**
- * @see wcf\data\IEditableObject::create()
- *
- * @todo Handle language id and create related language item
- */
- public static function create(array $parameters = array()) {
- // calculate show order
- $parameters['showOrder'] = self::getShowOrder($parameters['showOrder'], $parameters['menuPosition']);
-
- return parent::create($parameters);
- }
-
- /**
- * @see wcf\data\IEditableObject::update()
- *
- * @todo Handle language id and update related language item
- */
- public function update(array $parameters = array()) {
- if (isset($parameters['menuPosition']) && isset($parameters['showOrder'])) {
- $this->updateShowOrder($parameters['showOrder'], $parameters['menuPosition']);
- }
-
- parent::update($parameters);
- }
-
- /**
- * @see wcf\data\IEditableObject::delete()
- */
- public function delete() {
- // update show order
- $sql = "UPDATE wcf".WCF_N."_page_menu_item
- SET showOrder = showOrder - 1
- WHERE showOrder >= ?
- AND menuPosition = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $this->showOrder,
- $this->menuPosition
- ));
-
- parent::delete();
- }
-
- /**
- * Updates the positions of a page menu item directly.
- *
- * @param integer $menuItemID
- * @param string $menuPosition
- * @param integer $showOrder
- */
- public static function setShowOrder($menuItemID, $menuPosition = 'header', $showOrder = 1) {
- // Update
- $sql = "UPDATE wcf".WCF_N."_page_menu_item
- SET showOrder = ?,
- menuPosition = ?
- WHERE menuItemID = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $showOrder,
- $menuPosition,
- $menuItemID
- ));
- }
-
- /**
- * Updates show order for current menu item.
- *
- * @param integer $showOrder
- * @param string $menuPosition
- */
- protected function updateShowOrder($showOrder, $menuPosition) {
- if ($menuPosition == $this->menuPosition) {
- if ($this->showOrder != $showOrder) {
- if ($showOrder < $this->showOrder) {
- $sql = "UPDATE wcf".WCF_N."_page_menu_item
- SET showOrder = showOrder + 1
- WHERE showOrder >= ?
- AND showOrder < ?
- AND menuPosition = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $showOrder,
- $this->showOrder,
- $menuPosition
- ));
- }
- else if ($showOrder > $this->showOrder) {
- $sql = "UPDATE wcf".WCF_N."_page_menu_item
- SET showOrder = showOrder - 1
- WHERE showOrder <= ?
- AND showOrder > ?
- AND menuPosition = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $showOrder,
- $this->showOrder,
- $menuPosition
- ));
- }
- }
- }
- else {
- $sql = "UPDATE wcf".WCF_N."_page_menu_item
- SET showOrder = showOrder - 1
- WHERE showOrder >= ?
- AND menuPosition = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $this->showOrder,
- $this->menuPosition
- ));
-
- $sql = "UPDATE wcf".WCF_N."_page_menu_item
- SET showOrder = showOrder + 1
- WHERE showOrder >= ?
- AND menuPosition = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $showOrder,
- $menuPosition
- ));
- }
- }
-
- /**
- * Returns show order for a new menu item.
- *
- * @param integer $showOrder
- * @param string $menuPosition
- * @return integer
- */
- protected static function getShowOrder($showOrder, $menuPosition) {
- if ($showOrder == 0) {
- // get next number in row
- $sql = "SELECT MAX(showOrder) AS showOrder
- FROM wcf".WCF_N."_page_menu_item
- WHERE menuPosition = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($menuPosition));
- $row = $statement->fetchArray();
- if (!empty($row)) $showOrder = intval($row['showOrder']) + 1;
- else $showOrder = 1;
- }
- else {
- $sql = "UPDATE wcf".WCF_N."_page_menu_item
- SET showOrder = showOrder + 1
- WHERE showOrder >= ?
- AND menuPosition = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $showOrder,
- $menuPosition
- ));
- }
-
- return $showOrder;
- }
-
- /**
- * @see wcf\data\IEditableCachedObject::resetCache()
- */
- public static function resetCache() {
- CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.pageMenu-*.php');
- }
-}
+++ /dev/null
-<?php
-namespace wcf\data\page\menu\item;
-use wcf\data\DatabaseObjectList;
-
-/**
- * Represents a list of page menu items.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage data.page.menu.item
- * @category Community Framework
- */
-class PageMenuItemList extends DatabaseObjectList {
- /**
- * @see wcf\data\DatabaseObjectList::$className
- */
- public $className = 'wcf\data\page\menu\item\PageMenuItem';
-}
+++ /dev/null
-<?php
-namespace wcf\system\page\location;
-use wcf\data\page\location\PageLocation;
-use wcf\data\IDatabaseObjectProcessor;
-
-/**
- * Any page location class should implement this interface.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.page.location
- * @category Community Framework
- */
-interface IPageLocation extends IDatabaseObjectProcessor {
- /**
- * Caches the information of a page location.
- *
- * @param wcf\data\page\location\PageLocation $location
- * @param string $requestURI
- * @param string $requestMethod
- * @param array $match
- */
- public function cache(PageLocation $location, $requestURI, $requestMethod, array $match);
-
- /**
- * Returns the information of a page location.
- *
- * @param wcf\data\page\location\PageLocation $location
- * @param string $requestURI
- * @param string $requestMethod
- * @param array $match
- * @return string
- */
- public function get(PageLocation $location, $requestURI, $requestMethod, array $match);
-}
UNIQUE KEY packageUpdateID (packageUpdateID, packageVersion)
);
-DROP TABLE IF EXISTS wcf1_page_location;
-CREATE TABLE wcf1_page_location (
- locationID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- locationPattern VARCHAR(255) NOT NULL DEFAULT '',
- locationName VARCHAR(255) NOT NULL DEFAULT '',
- packageID INT(10) NOT NULL,
- className varchar(255) NOT NULL DEFAULT '',
- UNIQUE KEY (packageID, locationName)
-);
-
DROP TABLE IF EXISTS wcf1_page_menu_item;
CREATE TABLE wcf1_page_menu_item (
menuItemID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,