90f79563205db4e32bb3e18eebb93f37c7b78d23
[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 object type definitions.
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 ObjectTypeDefinitionPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
16 /**
17 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
18 */
19 public $className = 'wcf\data\object\type\definition\ObjectTypeDefinitionEditor';
20
21 /**
22 * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
23 */
24 public $tableName = 'object_type_definition';
25
26 /**
27 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
28 */
29 public $tagName = 'definition';
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 definitionName = ?
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 'interfaceName' => (isset($data['elements']['interfacename']) ? $data['elements']['interfacename'] : ''),
53 'definitionName' => $data['elements']['name'],
54 'categoryName' => (isset($data['elements']['categoryname']) ? $data['elements']['categoryname'] : '')
55 );
56 }
57
58 /**
59 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
60 */
61 protected function findExistingItem(array $data) {
62 $sql = "SELECT *
63 FROM wcf".WCF_N."_".$this->tableName."
64 WHERE definitionName = ?
65 AND packageID = ?";
66 $parameters = array(
67 $data['definitionName'],
68 $this->installation->getPackageID()
69 );
70
71 return array(
72 'sql' => $sql,
73 'parameters' => $parameters
74 );
75 }
76 }