f2f74b9a9be59d05d15882f2d376beb4a14c9bd4
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\package\plugin;
3 use wcf\system\WCF;
4
5 /**
6 * This PIP installs, updates or deletes clipboard item types.
7 *
8 * @author Alexander Ebert
9 * @copyright 2001-2011 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf
12 * @subpackage acp.package.plugin
13 * @category Community Framework
14 */
15 class ClipboardItemTypePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
16 /**
17 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
18 */
19 public $className = 'wcf\data\clipboard\item\type\ClipboardItemTypeEditor';
20
21 /**
22 * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
23 */
24 public $tableName = 'clipboard_item_type';
25
26 /**
27 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
28 */
29 public $tagName = 'type';
30
31 /**
32 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
33 */
34 protected function handleDelete(array $items) {
35 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
36 WHERE typeName = ?
37 AND packageID = ?";
38 $statement = WCF::getDB()->prepareStatement($sql);
39 foreach ($items as $item) {
40 $statement->execute(array(
41 $item['attributes']['name'],
42 $this->installation->getPackageID()
43 ));
44 }
45 }
46
47 /**
48 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
49 */
50 protected function prepareImport(array $data) {
51 return array(
52 'listClassName' => $data['elements']['listclassname'],
53 'typeName' => $data['attributes']['name']
54 );
55 }
56
57 /**
58 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
59 */
60 protected function findExistingItem(array $data) {
61 $sql = "SELECT *
62 FROM wcf".WCF_N."_".$this->tableName."
63 WHERE typeName = ?
64 AND packageID = ?";
65 $parameters = array(
66 $data['typeName'],
67 $this->installation->getPackageID()
68 );
69
70 return array(
71 'sql' => $sql,
72 'parameters' => $parameters
73 );
74 }
75 }