<pip name="eventListener">wcf\system\package\plugin\EventListenerPackageInstallationPlugin</pip>
<pip name="file">wcf\system\package\plugin\FilePackageInstallationPlugin</pip>
<pip name="language">wcf\system\package\plugin\LanguagePackageInstallationPlugin</pip>
+ <pip name="objectType">wcf\system\package\plugin\ObjectTypePackageInstallationPlugin</pip>
+ <pip name="objectTypeDefinition">wcf\system\package\plugin\ObjectTypeDefinitionInstallationPlugin</pip>
<pip name="option">wcf\system\package\plugin\OptionPackageInstallationPlugin</pip>
<pip name="pageMenu">wcf\system\package\plugin\PageMenuPackageInstallationPlugin</pip>
<pip name="script">wcf\system\package\plugin\ScriptPackageInstallationPlugin</pip>
<!-- logo -->
<div id="logo" class="logo">
<!-- clickable area -->
- <a href="{@SID_ARG_1ST}">
+ <a href="{link controller='Index'}{/link}">
<h1>WoltLab Community Framework 2.0 Pre-Alpha 1</h1>
<img src="{@RELATIVE_WCF_DIR}acp/images/wcfLogoWhite.svg" width="300" height="58" alt="Product-logo" title="WoltLab Community Framework 2.0 Pre-Alpha 1" />
</a>
* @copyright 2001-2011 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
- * @subpackage data.event
+ * @subpackage data.event.listener
* @category Community Framework
*/
class EventListenerAction extends AbstractDatabaseObjectAction {
* @copyright 2001-2011 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
- * @subpackage data.event
+ * @subpackage data.event.listener
* @category Community Framework
*/
class EventListenerList extends DatabaseObjectList {
--- /dev/null
+<?php
+namespace wcf\data\object\type;
+use wcf\data\ProcessibleDatabaseObject;
+use wcf\system\exception\SystemException;
+use wcf\util\ClassUtil;
+
+/**
+ * Represents an object type.
+ *
+ * @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 data.object.type
+ * @category Community Framework
+ */
+class ObjectType extends ProcessibleDatabaseObject {
+ /**
+ * @see wcf\data\DatabaseObject::$databaseTableName
+ */
+ protected static $databaseTableName = 'object_type';
+
+ /**
+ * @see wcf\data\DatabaseObject::$databaseTableIndexName
+ */
+ protected static $databaseTableIndexName = 'objectTypeID';
+
+ /**
+ * @see wcf\data\ProcessibleDatabaseObject::getProcessor()
+ */
+ public function getProcessor() {
+ if ($this->processor === null) {
+ if ($this->className) {
+ if (!class_exists($this->className)) {
+ throw new SystemException("Unable to find class '".$this->className."'");
+ }
+ if (!ClassUtil::isInstanceOf($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
+ throw new SystemException("'".$this->className."' should implement wcf\data\IDatabaseObjectProcessor");
+ }
+ if (($definitionInterface = ObjectTypeCache::getInstance()->getDefinition($this->definitionID)->interfaceName) && !ClassUtil::isInstanceOf($this->className, $definitionInterface)) {
+ throw new SystemException("'".$this->className."' should implement ".$definitionInterface);
+ }
+
+ $this->processor = new $this->className($this);
+ }
+ }
+
+ return $this->processor;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type;
+use wcf\data\AbstractDatabaseObjectAction;
+
+/**
+ * Executes object type-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.object.type
+ * @category Community Framework
+ */
+class ObjectTypeAction extends AbstractDatabaseObjectAction {
+ /**
+ * @see wcf\data\AbstractDatabaseObjectAction::$className
+ */
+ protected $className = 'wcf\data\object\type\ObjectTypeEditor';
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type;
+use wcf\system\cache\CacheHandler;
+use wcf\system\SingletonFactory;
+
+/**
+ * Manages the object type cache.
+ *
+ * @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 data.object.type
+ * @category Community Framework
+ */
+class ObjectTypeCache extends SingletonFactory {
+ /**
+ * object type definitions
+ * @var array<wcf\data\object\type\definition\ObjectTypeDefinition>
+ */
+ protected $definitions = array();
+
+ /**
+ * object type definitions sorted by name
+ * @var array<wcf\data\object\type\definition\ObjectTypeDefinition>
+ */
+ protected $definitionsByName = array();
+
+ /**
+ * object types
+ * @var array<wcf\data\object\type\ObjectType>
+ */
+ protected $objectTypes = array();
+
+ /**
+ * object types grouped by definition
+ * @var array
+ */
+ protected $groupedObjectTypes = array();
+
+ /**
+ * @see wcf\system\SingletonFactory::init()
+ */
+ protected function init() {
+ // get definition cache
+ CacheHandler::getInstance()->addResource('objectType-'.PACKAGE_ID, WBB_DIR.'cache/cache.objectType-'.PACKAGE_ID.'.php', 'wcf\system\cache\builder\ObjectTypeCacheBuilder');
+ $this->definitions = CacheHandler::getInstance()->get('objectType-'.PACKAGE_ID, 'definitions');
+ foreach ($this->definitions as $definition) {
+ $this->definitionsByName[$definition->definitionName] = $definition;
+ }
+
+ // get object type cache
+ $this->objectTypes = CacheHandler::getInstance()->get('objectType-'.PACKAGE_ID, 'objectTypes');
+ foreach ($this->objectTypes as $objectType) {
+ $definition = $this->getDefinition($objectType->definitionID);
+ if (!isset($this->groupedObjectTypes[$definition->definitionName])) {
+ $this->groupedObjectTypes[$definition->definitionName] = array();
+ }
+
+ $this->groupedObjectTypes[$definition->definitionName][$objectType->objectTypeName] = $objectType;
+ }
+ }
+
+ /**
+ * Gets an object type definition by id
+ *
+ * @param integer $definitionID
+ * @return wcf\data\object\type\definition\ObjectTypeDefinition
+ */
+ public function getDefinition($definitionID) {
+ if (isset($this->definitions[$definitionID])) {
+ return $this->definitions[$definitionID];
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets an object type definition by name
+ *
+ * @param string $definitionName
+ * @return wcf\data\object\type\definition\ObjectTypeDefinition
+ */
+ public function getDefinitionByName($definitionName) {
+ if (isset($this->definitionsByName[$definitionName])) {
+ return $this->definitionsByName[$definitionName];
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets an object type by id
+ *
+ * @param integer $objectTypeID
+ * @return wcf\data\object\type\ObjectType
+ */
+ public function getObjectType($objectTypeID) {
+ if (isset($this->objectTypes[$objectTypeID])) {
+ return $this->objectTypes[$objectTypeID];
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns a list of object types.
+ *
+ * @param string $definitionName
+ * @return array<wcf\data\object\type\ObjectType>
+ */
+ public function getObjectTypes($definitionName) {
+ if (isset($this->groupedObjectTypes[$definitionName])) {
+ return $this->groupedObjectTypes[$definitionName];
+ }
+
+ return array();
+ }
+
+ /**
+ * Returns an object type.
+ *
+ * @param string $definitionName
+ * @param string $objectTypeName
+ * @return wcf\data\object\type\ObjectType
+ */
+ public function getObjectTypeByName($definitionName, $objectTypeName) {
+ if (isset($this->groupedObjectTypes[$definitionName]) && isset($this->groupedObjectTypes[$definitionName][$typeName])) {
+ return $this->groupedObjectTypes[$definitionName][$typeName];
+ }
+
+ return null;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type;
+use wcf\data\DatabaseObjectEditor;
+
+/**
+ * Provides functions to edit object types.
+ *
+ * @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.object.type
+ * @category Community Framework
+ */
+class ObjectTypeEditor extends DatabaseObjectEditor {
+ /**
+ * @see wcf\data\DatabaseObjectDecorator::$baseClass
+ */
+ public static $baseClass = 'wcf\data\object\type\ObjectType';
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type;
+use wcf\data\DatabaseObjectList;
+
+/**
+ * Represents a list of object types.
+ *
+ * @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.object.type.definition
+ * @category Community Framework
+ */
+class ObjectTypeList extends DatabaseObjectList {
+ /**
+ * @see wcf\data\DatabaseObjectList::$className
+ */
+ public $className = 'wcf\data\object\type\ObjectType';
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type\definition;
+use wcf\data\DatabaseObject;
+
+/**
+ * Represents an object type definition.
+ *
+ * @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.object.type.definition
+ * @category Community Framework
+ */
+class ObjectTypeDefinition extends DatabaseObject {
+ /**
+ * @see wcf\data\DatabaseObject::$databaseTableName
+ */
+ protected static $databaseTableName = 'object_type_definition';
+
+ /**
+ * @see wcf\data\DatabaseObject::$databaseTableIndexName
+ */
+ protected static $databaseTableIndexName = 'definitionID';
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type\definition;
+use wcf\data\AbstractDatabaseObjectAction;
+
+/**
+ * Executes object type definition-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.object.type.definition
+ * @category Community Framework
+ */
+class ObjectTypeDefinitionAction extends AbstractDatabaseObjectAction {
+ /**
+ * @see wcf\data\AbstractDatabaseObjectAction::$className
+ */
+ protected $className = 'wcf\data\object\type\definition\ObjectTypeDefinitionEditor';
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type\definition;
+use wcf\data\DatabaseObjectEditor;
+
+/**
+ * Provides functions to edit object type definitions.
+ *
+ * @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.object.type.definition
+ * @category Community Framework
+ */
+class ObjectTypeDefinitionEditor extends DatabaseObjectEditor {
+ /**
+ * @see wcf\data\DatabaseObjectDecorator::$baseClass
+ */
+ public static $baseClass = 'wcf\data\object\type\definition\ObjectTypeDefinition';
+}
--- /dev/null
+<?php
+namespace wcf\data\object\type\definition;
+use wcf\data\DatabaseObjectList;
+
+/**
+ * Represents a list of object type definitions.
+ *
+ * @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.object.type.definition
+ * @category Community Framework
+ */
+class ObjectTypeDefinitionList extends DatabaseObjectList {
+ /**
+ * @see wcf\data\DatabaseObjectList::$className
+ */
+ public $className = 'wcf\data\object\type\definition\ObjectTypeDefinition';
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\object\type\definition\ObjectTypeDefinition;
+use wcf\system\WCF;
+
+/**
+ * Caches object types and object type definitions.
+ *
+ * @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.cache.builder
+ * @category Community Framework
+ */
+class ObjectTypeCacheBuilder implements ICacheBuilder {
+ /**
+ * @see wcf\system\cache\ICacheBuilder::getData()
+ */
+ public function getData(array $cacheResource) {
+ list($cache, $packageID) = explode('-', $cacheResource['cache']);
+ $data = array(
+ 'definitions' => array(),
+ 'objectTypes' => array()
+ );
+
+ // get definitions
+ $sql = "SELECT object_type_definition.*
+ FROM wcf".WCF_N."_package_dependency package_dependency,
+ wcf".WCF_N."_object_type_definition object_type_definition
+ WHERE object_type_definition.packageID = package_dependency.dependency
+ AND package_dependency.packageID = ?
+ ORDER BY package_dependency.priority";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($packageID));
+ while ($row = $statement->fetchArray()) {
+ $data['definitions'][$row['definitionID']] = new ObjectTypeDefinition(null, $row);
+ }
+
+ // get object types
+ $sql = "SELECT object_type.*
+ FROM wcf".WCF_N."_package_dependency package_dependency,
+ wcf".WCF_N."_object_type object_type
+ WHERE object_type.packageID = package_dependency.dependency
+ AND package_dependency.packageID = ?
+ ORDER BY package_dependency.priority";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($packageID));
+ while ($row = $statement->fetchArray()) {
+ $data['objectTypes'][$row['objectTypeID']] = new ObjectType(null, $row);
+ }
+
+ return $data;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\WCF;
+
+/**
+ * This PIP installs, updates or deletes object type definitions.
+ *
+ * @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 acp.package.plugin
+ * @category Community Framework
+ */
+class ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
+ */
+ public $className = 'wcf\data\object\type\definition\ObjectTypeDefinitionEditor';
+
+ /**
+ * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+ */
+ public $tableName = 'object_type_definition';
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
+ */
+ public $tagName = 'definition';
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
+ */
+ protected function handleDelete(array $items) {
+ $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
+ WHERE definitionName = ?
+ AND packageID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ foreach ($items as $item) {
+ $statement->execute(array(
+ $item['attributes']['name'],
+ $this->installation->getPackageID()
+ ));
+ }
+ }
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
+ */
+ protected function prepareImport(array $data) {
+ return array(
+ 'interfaceName' => (isset($data['elements']['interfacename']) ? $data['elements']['interfacename'] : ''),
+ 'definitionName' => $data['attributes']['name']
+ );
+ }
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
+ */
+ protected function findExistingItem(array $data) {
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_".$this->tableName."
+ WHERE definitionName = ?
+ AND packageID = ?";
+ $parameters = array(
+ $data['definitionName'],
+ $this->installation->getPackageID()
+ );
+
+ return array(
+ 'sql' => $sql,
+ 'parameters' => $parameters
+ );
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\package\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\WCF;
+
+/**
+ * This PIP installs, updates or deletes object types.
+ *
+ * @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 acp.package.plugin
+ * @category Community Framework
+ */
+class ObjectTypePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
+ */
+ public $className = 'wcf\data\object\type\ObjectTypeEditor';
+
+ /**
+ * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
+ */
+ public $tableName = 'object_type';
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
+ */
+ public $tagName = 'type';
+
+ /**
+ * Gets the definition id by name
+ *
+ * @param string $definitionName
+ * @return integer
+ */
+ protected function getDefinitionID($definitionName) {
+ // get object type id
+ $sql = "SELECT notification_object_type.definitionID
+ FROM wcf".WCF_N."_package_dependency package_dependency,
+ wcf".WCF_N."_object_type_definition object_type_definition
+ WHERE object_type_definition.packageID = package_dependency.dependency
+ AND package_dependency.packageID = ?
+ AND object_type_definition.definitionName = ?
+ ORDER BY package_dependency.priority DESC";
+ $statement = WCF::getDB()->prepareStatement($sql, 1);
+ $statement->execute(array($this->installation->getPackageID(), $definitionName));
+ $row = $statement->fetchArray();
+ if (empty($row['definitionID'])) throw new SystemException("unknown object type definition '".$definitionName."' given");
+ return $row['definitionID'];
+ }
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
+ */
+ protected function handleDelete(array $items) {
+ $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
+ WHERE objectType = ?
+ definitionID = ?
+ AND packageID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ foreach ($items as $item) {
+ $statement->execute(array(
+ $item['attributes']['name'],
+ $this->getDefinitionID($data['elements']['definitionname']),
+ $this->installation->getPackageID()
+ ));
+ }
+ }
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
+ */
+ protected function prepareImport(array $data) {
+ return array(
+ 'definitionID' => $this->getDefinitionID($data['elements']['definitionname']),
+ 'objectType' => $data['attributes']['name'],
+ 'className' => (isset($data['elements']['classname']) ? $data['elements']['classname'] : ''),
+ 'additionalData' => serialize(isset($data['elements']['additionaldata']) ? $data['elements']['additionaldata'] : array())
+ );
+ }
+
+ /**
+ * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
+ */
+ protected function findExistingItem(array $data) {
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_".$this->tableName."
+ WHERE objectType = ?
+ definitionID = ?
+ AND packageID = ?";
+ $parameters = array(
+ $data['objectType'],
+ $data['definitionID'],
+ $this->installation->getPackageID()
+ );
+
+ return array(
+ 'sql' => $sql,
+ 'parameters' => $parameters
+ );
+ }
+}
UNIQUE KEY languageID (languageID, packageID)
);
+DROP TABLE IF EXISTS wcf1_object_type;
+CREATE TABLE wcf1_object_type (
+ objectTypeID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ definitionID INT(10) NOT NULL,
+ packageID INT(10) NOT NULL,
+ objectType VARCHAR(255) NOT NULL,
+ className VARCHAR(255) NOT NULL DEFAULT '',
+ additionalData MEDIUMTEXT,
+ UNIQUE KEY objectType (objectType, definitionID, packageID)
+);
+
+DROP TABLE IF EXISTS wcf1_object_type_definition;
+CREATE TABLE wcf1_object_type_definition (
+ definitionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ definitionName VARCHAR(255) NOT NULL,
+ packageID INT(10) NOT NULL,
+ interfaceName VARCHAR(255) NOT NULL DEFAULT '',
+ UNIQUE KEY definitionName (definitionName, packageID)
+);
+
DROP TABLE IF EXISTS wcf1_option;
CREATE TABLE wcf1_option (
optionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
ALTER TABLE wcf1_language_to_package ADD FOREIGN KEY (languageID) REFERENCES wcf1_language (languageID) ON DELETE CASCADE;
ALTER TABLE wcf1_language_to_package ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
+ALTER TABLE wcf1_object_type ADD FOREIGN KEY (definitionID) REFERENCES wcf1_object_type_definition (definitionID) ON DELETE CASCADE;
+ALTER TABLE wcf1_object_type ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
+
+ALTER TABLE wcf1_object_type_definition ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
+
ALTER TABLE wcf1_option ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
ALTER TABLE wcf1_option_category ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;