abafea3f1415efdc8aaf4316b0d7580595f2e9f9
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\package\plugin;
3 use wcf\system\cache\CacheHandler;
4 use wcf\system\WCF;
5
6 /**
7 * This PIP installs, updates or deletes ACP search providers.
8 *
9 * @author Alexander Ebert
10 * @copyright 2001-2012 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package com.woltlab.wcf
13 * @subpackage system.package.plugin
14 * @category Community Framework
15 */
16 class ACPSearchProviderPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
17 /**
18 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
19 */
20 public $className = 'wcf\data\acp\search\provider\ACPSearchProviderEditor';
21
22 /**
23 * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
24 */
25 public $tableName = 'acp_search_provider';
26
27 /**
28 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
29 */
30 public $tagName = 'acpsearchprovider';
31
32 /**
33 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
34 */
35 protected function handleDelete(array $items) {
36 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
37 WHERE providerName = ?
38 AND packageID = ?";
39 $statement = WCF::getDB()->prepareStatement($sql);
40 foreach ($items as $item) {
41 $statement->execute(array(
42 $item['attributes']['name'],
43 $this->installation->getPackageID()
44 ));
45 }
46 }
47
48 /**
49 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
50 */
51 protected function prepareImport(array $data) {
52 // get show order
53 $showOrder = (isset($data['elements']['showorder'])) ? $data['elements']['showorder'] : null;
54 $showOrder = $this->getShowOrder($showOrder);
55
56 return array(
57 'className' => $data['elements']['classname'],
58 'providerName' => $data['attributes']['name'],
59 'showOrder' => $showOrder
60 );
61 }
62
63 /**
64 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
65 */
66 protected function findExistingItem(array $data) {
67 $sql = "SELECT *
68 FROM wcf".WCF_N."_".$this->tableName."
69 WHERE providerName = ?
70 AND packageID = ?";
71 $parameters = array(
72 $data['providerName'],
73 $this->installation->getPackageID()
74 );
75
76 return array(
77 'sql' => $sql,
78 'parameters' => $parameters
79 );
80 }
81
82 /**
83 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
84 */
85 protected function cleanup() {
86 CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.acpSearchProvider-*.php');
87 }
88
89 /**
90 * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
91 */
92 public function uninstall() {
93 parent::uninstall();
94
95 // clear cache immediately
96 CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.acpSearchProvider-*.php');
97 }
98 }