From: Alexander Ebert Date: Wed, 7 Sep 2011 13:35:20 +0000 (+0200) Subject: Clipboard API X-Git-Tag: 2.0.0_Beta_1~1765^2~53 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0e6741f863469146b6c66185dad088cee2fb3d56;p=GitHub%2FWoltLab%2FWCF.git Clipboard API Renamed column according to PIP, added missing (foreign) keys and cache builders. --- diff --git a/wcfsetup/install/files/lib/system/cache/builder/ClipboardActionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ClipboardActionCacheBuilder.class.php new file mode 100644 index 0000000000..e86c1ed042 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/ClipboardActionCacheBuilder.class.php @@ -0,0 +1,28 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class ClipboardActionCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData(array $cacheResource) { + $actionList = new ClipboardActionList(); + $actionList->getConditionBuilder()->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + $actionList->sqlLimit = 0; + $actionList->readObjects(); + + return $actionList->getObjects(); + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/ClipboardItemTypeCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ClipboardItemTypeCacheBuilder.class.php new file mode 100644 index 0000000000..a7bc8d53f0 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/ClipboardItemTypeCacheBuilder.class.php @@ -0,0 +1,37 @@ + + * @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; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php new file mode 100644 index 0000000000..1d752fad3f --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php @@ -0,0 +1,42 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class ClipboardPageCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData(array $cacheResource) { + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + + $sql = "SELECT pageClassName, actionID + FROM wcf".WCF_N."_clipboard_page + ".$conditions; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + + $data = array(); + while ($row = $statement->fetchArray()) { + if (!isset($data[$row['pageClassName']])) { + $data[$row['pageClassName']] = array(); + } + + $data[$row['pageClassName']][] = $row['actionID']; + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 0cfa703ce0..21779bdc11 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -166,7 +166,7 @@ class ClipboardHandler extends SingletonFactory { if (!isset($data[$type->typeName])) { $data[$type->typeName] = array( - 'className' => $type->className, + 'className' => $type->listClassName, 'objectIDs' => array() ); } @@ -196,8 +196,7 @@ class ClipboardHandler extends SingletonFactory { */ public function getEditorItems($page) { // ignore unknown pages - if (!isset($this->pageCache[$page])) die('page '.$page.' is unknown'); - #return null; + if (!isset($this->pageCache[$page])) return null; // get objects $objects = $this->getMarkedItems(); diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 7037876840..10e2458e54 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -102,7 +102,8 @@ CREATE TABLE wcf1_clipboard_action ( packageID INT(10) NOT NULL DEFAULT 0, actionName VARCHAR(50) NOT NULL DEFAULT '', actionClassName VARCHAR(200) NOT NULL DEFAULT '', - sortOrder INT(10) NOT NULL DEFAULT 0 + sortOrder INT(10) NOT NULL DEFAULT 0, + UNIQUE KEY actionName (packageID, actionName) ); DROP TABLE IF EXISTS wcf1_clipboard_item; @@ -117,7 +118,8 @@ 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 '', - className VARCHAR(200) NOT NULL DEFAULT '' + listClassName VARCHAR(200) NOT NULL DEFAULT '', + UNIQUE KEY typeName (typeName) ); DROP TABLE IF EXISTS wcf1_clipboard_page; @@ -729,6 +731,15 @@ ALTER TABLE wcf1_cleanup_listener ADD FOREIGN KEY (packageID) REFERENCES wcf1_pa ALTER TABLE wcf1_cleanup_log ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; +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_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; + ALTER TABLE wcf1_core_object ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE; ALTER TABLE wcf1_cronjob ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;