+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This file is used for xml files which install, update or delete clip board item types. -->
-<xs:schema id="data" targetNamespace="http://www.woltlab.com" xmlns="http://www.woltlab.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified">
- <!-- type element -->
- <xs:element name="type">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="listclassname" type="xs:string" minOccurs="0" />
- </xs:sequence>
- <xs:attribute name="name" form="unqualified" type="xs:string" />
- </xs:complexType>
- </xs:element>
-
- <!-- data element -->
- <xs:element name="data">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="type" />
- <xs:element name="import">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="delete">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:choice>
- </xs:complexType>
- </xs:element>
-</xs:schema>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/clipboardItemType.xsd">
- <import>
- <type name="com.woltlab.wcf.user">
- <listclassname><![CDATA[wcf\data\user\UserList]]></listclassname>
- </type>
- </import>
-</data>
<instruction type="cronjob">cronjob.xml</instruction>
<instruction type="coreObject">coreObject.xml</instruction>
<instruction type="clipboardAction">clipboardAction.xml</instruction>
- <instruction type="clipboardItemType">clipboardItemType.xml</instruction>
</instructions>
</package>
<pip name="acpMenu">wcf\system\package\plugin\ACPMenuPackageInstallationPlugin</pip>
<pip name="acpTemplate">wcf\system\package\plugin\ACPTemplatePackageInstallationPlugin</pip>
<pip name="clipboardAction">wcf\system\package\plugin\ClipboardActionPackageInstallationPlugin</pip>
- <pip name="clipboardItemType">wcf\system\package\plugin\ClipboardItemTypePackageInstallationPlugin</pip>
<pip name="coreObject">wcf\system\package\plugin\CoreObjectPackageInstallationPlugin</pip>
<pip name="cronjob">wcf\system\package\plugin\CronjobPackageInstallationPlugin</pip>
<pip name="eventListener">wcf\system\package\plugin\EventListenerPackageInstallationPlugin</pip>
protected $type = '';
/**
- * clipboard item type id
+ * object type id
* @var integer
*/
- protected $typeID = 0;
+ protected $objectTypeID = 0;
/**
* @see wcf\action\AbstractAction::_construct()
$this->validate();
// execute action
- ClipboardHandler::getInstance()->{$this->action}($this->objectIDs, $this->typeID);
+ ClipboardHandler::getInstance()->{$this->action}($this->objectIDs, $this->objectTypeID);
}
/**
throw new AJAXException("Clipboard action '".$this->action."' is invalid.");
}
- $this->typeID = (!empty($this->type)) ? ClipboardHandler::getInstance()->getTypeID($this->type) : null;
- if ($this->typeID === null) {
- throw new AJAXException("Clipboard item type '".$this->type."' is invalid.");
+ $this->objectTypeID = (!empty($this->type)) ? ClipboardHandler::getInstance()->getObjectTypeID($this->type) : null;
+ if ($this->objectTypeID === null) {
+ throw new AJAXException("object type '".$this->type."' is invalid.");
}
}
}
+++ /dev/null
-<?php
-namespace wcf\data\clipboard\item\type;
-use wcf\data\DatabaseObject;
-
-/**
- * Represents a clipboard item type.
- *
- * @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.clipboard.item.type
- * @category Community Framework
- */
-class ClipboardItemType extends DatabaseObject {
- /**
- * @see wcf\data\DatabaseObject::$databaseTableName
- */
- protected static $databaseTableName = 'clipboard_item_type';
-
- /**
- * @see wcf\data\DatabaseObject::$databaseTableIndexName
- */
- protected static $databaseTableIndexName = 'typeID';
-}
+++ /dev/null
-<?php
-namespace wcf\data\clipboard\item\type;
-use wcf\data\AbstractDatabaseObjectAction;
-
-/**
- * Executes clipboard item 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.clipboard.item.type
- * @category Community Framework
- */
-class ClipboardItemTypeAction extends AbstractDatabaseObjectAction {
- /**
- * @see wcf\data\AbstractDatabaseObjectAction::$className
- */
- protected $className = 'wcf\data\clipboard\item\type\ClipboardItemTypeEditor';
-}
+++ /dev/null
-<?php
-namespace wcf\data\clipboard\item\type;
-use wcf\data\DatabaseObjectEditor;
-
-/**
- * Provides functions to edit clipboard item 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.clipboard.item.type
- * @category Community Framework
- */
-class ClipboardItemTypeEditor extends DatabaseObjectEditor {
- /**
- * @see wcf\data\DatabaseObjectDecorator::$baseClass
- */
- protected static $baseClass = 'wcf\data\clipboard\item\type\ClipboardItemType';
-}
+++ /dev/null
-<?php
-namespace wcf\data\clipboard\item\type;
-use wcf\data\DatabaseObjectList;
-
-/**
- * Represents a list of clipboard item 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.clipboard.item.type
- * @category Community Framework
- */
-class ClipboardItemTypeList extends DatabaseObjectList {
- /**
- * @see wcf\data\DatabaseObjectList::$className
- */
- public $className = 'wcf\data\clipboard\item\type\ClipboardItemType';
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\clipboard\item\type\ClipboardItemTypeList;
-use wcf\system\package\PackageDependencyHandler;
-
-/**
- * Caches clipboard item 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 system.cache.builder
- * @category Community Framework
- */
-class ClipboardItemTypeCacheBuilder implements ICacheBuilder {
- /**
- * @see wcf\system\cache\ICacheBuilder::getData()
- */
- public function getData(array $cacheResource) {
- $typeList = new ClipboardItemTypeList();
- $typeList->getConditionBuilder()->add("clipboard_item_type.packageID IN (?)", array(PackageDependencyHandler::getDependencies()));
- $typeList->sqlLimit = 0;
- $typeList->readObjects();
-
- $data = array(
- 'typeNames' => array(),
- 'types' => array()
- );
- foreach ($typeList->getObjects() as $typeID => $type) {
- $data['typeNames'][$type->typeName] = $typeID;
- $data['types'][$typeID] = $type;
- }
-
- return $data;
- }
-}
<?php
namespace wcf\system\clipboard;
+use wcf\data\object\type\ObjectTypeCache;
use wcf\system\cache\CacheHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\SystemException;
* cached list of clipboard item types
* @var array<array>
*/
- protected $typeCache = null;
+ protected $cache = null;
/**
* @see wcf\system\SingletonFactory::init()
*/
protected function init() {
- CacheHandler::getInstance()->addResource(
- 'clipboard-itemType-'.PACKAGE_ID,
- WCF_DIR.'cache/cache.clipboard-itemType-'.PACKAGE_ID.'.php',
- 'wcf\system\cache\builder\ClipboardItemTypeCacheBuilder'
+ $this->cache = array(
+ 'objectTypes' => array(),
+ 'objectTypeNames' => array()
);
- $this->typeCache = CacheHandler::getInstance()->get('clipboard-itemType-'.PACKAGE_ID);
+ $cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.clipboardItem');
+ foreach ($cache as $objectType) {
+ $this->cache['objectTypes'][$objectType->objectTypeID] = $objectType;
+ $this->cache['objectTypeNames'][$objectType->objectType] = $objectType->objectTypeID;
+ }
CacheHandler::getInstance()->addResource(
'clipboard-page-'.PACKAGE_ID,
* Marks objects as marked.
*
* @param array $objectIDs
- * @param integer $typeID
+ * @param integer $objectTypeID
*/
- public function mark(array $objectIDs, $typeID) {
+ public function mark(array $objectIDs, $objectTypeID) {
// remove existing entries first, prevents conflict with INSERT
- $this->unmark($objectIDs, $typeID);
+ $this->unmark($objectIDs, $objectTypeID);
$sql = "INSERT INTO wcf".WCF_N."_clipboard_item
- (typeID, userID, objectID)
+ (objectTypeID, userID, objectID)
VALUES (?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($objectIDs as $objectID) {
$statement->execute(array(
- $typeID,
+ $objectTypeID,
WCF::getUser()->userID,
$objectID
));
* Removes an object marking.
*
* @param array $objectIDs
- * @param integer $typeID
+ * @param integer $objectTypeID
*/
- public function unmark(array $objectIDs, $typeID) {
+ public function unmark(array $objectIDs, $objectTypeID) {
$conditions = new PreparedStatementConditionBuilder();
- $conditions->add("typeID = ?", array($typeID));
+ $conditions->add("objectTypeID = ?", array($objectTypeID));
$conditions->add("objectID IN (?)", array($objectIDs));
$conditions->add("userID = ?", array(WCF::getUser()->userID));
* @param string $typeName
* @return integer
*/
- public function getTypeID($typeName) {
- if (isset($this->typeCache['typeNames'][$typeName])) {
- return $this->typeCache['typeNames'][$typeName];
+ public function getObjectTypeID($typeName) {
+ if (isset($this->cache['objectTypeNames'][$typeName])) {
+ return $this->cache['objectTypeNames'][$typeName];
}
return null;
* Returns a type by type id.
*
* @param integer $typeID
- * @return wcf\data\clipboard\item\type\ClipboardItemType
+ * @return wcf\data\object\type\ObjectType
*/
- public function getType($typeID) {
- if (isset($this->typeCache['types'][$typeID])) {
- return $this->typeCache['types'][$typeID];
+ public function getObjectType($typeID) {
+ if (isset($this->cache['objectTypes'][$typeID])) {
+ return $this->cache['objectTypes'][$typeID];
}
return null;
if ($typeID !== null) $conditions->add("typeID = ?", array($typeID));
// fetch object ids
- $sql = "SELECT typeID, objectID
+ $sql = "SELECT objectTypeID, objectID
FROM wcf".WCF_N."_clipboard_item
".$conditions;
$statement = WCF::getDB()->prepareStatement($sql);
// group object ids by type name
$data = array();
while ($row = $statement->fetchArray()) {
- $type = $this->getType($row['typeID']);
- if ($type === null) {
+ $objectType = $this->getObjectType($row['objectTypeID']);
+ if ($objectType === null) {
continue;
}
- if (!isset($data[$type->typeName])) {
- $data[$type->typeName] = array(
- 'className' => $type->listClassName,
+ if (!isset($data[$objectType->objectType])) {
+ $data[$objectType->objectType] = array(
+ 'className' => $objectType->listClassName,
'objectIDs' => array()
);
}
- $data[$type->typeName]['objectIDs'][] = $row['objectID'];
+ $data[$objectType->objectType]['objectIDs'][] = $row['objectID'];
}
// read objects
$this->markedItems = array();
- foreach ($data as $typeName => $objectData) {
+ foreach ($data as $objectType => $objectData) {
$objectList = new $objectData['className']();
$objectList->getConditionBuilder()->add($objectList->getDatabaseTableAlias() . "." . $objectList->getDatabaseTableIndexName() . " IN (?)", array($objectData['objectIDs']));
$objectList->sqlLimit = 0;
$objectList->readObjects();
- $this->markedItems[$typeName] = $objectList->getObjects();
+ $this->markedItems[$objectType] = $objectList->getObjects();
}
}
+++ /dev/null
-<?php
-namespace wcf\system\package\plugin;
-use wcf\system\WCF;
-
-/**
- * This PIP installs, updates or deletes clipboard item 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 ClipboardItemTypePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
- /**
- * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
- */
- public $className = 'wcf\data\clipboard\item\type\ClipboardItemTypeEditor';
-
- /**
- * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
- */
- public $tableName = 'clipboard_item_type';
-
- /**
- * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
- */
- public $tagName = 'type';
-
- /**
- * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
- */
- protected function handleDelete(array $items) {
- $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
- WHERE typeName = ?
- 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(
- 'listClassName' => $data['elements']['listclassname'],
- 'typeName' => $data['attributes']['name']
- );
- }
-
- /**
- * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
- */
- protected function findExistingItem(array $data) {
- $sql = "SELECT *
- FROM wcf".WCF_N."_".$this->tableName."
- WHERE typeName = ?
- AND packageID = ?";
- $parameters = array(
- $data['typeName'],
- $this->installation->getPackageID()
- );
-
- return array(
- 'sql' => $sql,
- 'parameters' => $parameters
- );
- }
-}
DROP TABLE IF EXISTS wcf1_clipboard_item;
CREATE TABLE wcf1_clipboard_item (
- typeID INT(10) NOT NULL DEFAULT 0,
+ objectTypeID INT(10) NOT NULL DEFAULT 0,
userID INT(10) NOT NULL DEFAULT 0,
- objectID INT(10) NOT NULL DEFAULT 0
-);
-
-DROP TABLE IF EXISTS wcf1_clipboard_item_type;
-CREATE TABLE wcf1_clipboard_item_type (
- typeID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- packageID INT(10) NOT NULL DEFAULT 0,
- typeName VARCHAR(80) NOT NULL DEFAULT '',
- listClassName VARCHAR(200) NOT NULL DEFAULT '',
- UNIQUE KEY typeName (typeName)
+ objectID INT(10) NOT NULL DEFAULT 0,
+ UNIQUE KEY (objectTypeID, userID, objectID)
);
DROP TABLE IF EXISTS wcf1_clipboard_page;
ALTER TABLE wcf1_clipboard_action ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
-ALTER TABLE wcf1_clipboard_item ADD FOREIGN KEY (typeID) REFERENCES wcf1_clipboard_item_type (typeID) ON DELETE CASCADE;
-
-ALTER TABLE wcf1_clipboard_item_type ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
+ALTER TABLE wcf1_clipboard_item ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE;
ALTER TABLE wcf1_clipboard_page ADD FOREIGN KEY (actionID) REFERENCES wcf1_clipboard_action (actionID) ON DELETE CASCADE;
ALTER TABLE wcf1_clipboard_page ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;