2 namespace wcf\system\package\plugin;
3 use wcf\system\cache\CacheHandler;
7 * This PIP installs, updates or deletes template listeners.
9 * @author Alexander Ebert
10 * @copyright 2001-2011 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
16 class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin {
18 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className
20 public $className = 'wcf\data\template\listener\TemplateListenerEditor';
23 * @see wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
25 public $tableName = 'template_listener';
28 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$tagName
30 public $tagName = 'templatelistener';
33 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::handleDelete()
35 protected function handleDelete(array $items) {
36 $sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."
41 AND templateName = ?";
42 $statement = WCF::getDB()->prepareStatement($sql);
43 foreach ($items as $item) {
44 $statement->execute(array(
45 $this->installation->getPackageID(),
46 $item['elements']['environment'],
47 $item['elements']['eventname'],
48 $item['attributes']['name'],
49 $item['elements']['templatename']
55 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport()
57 protected function prepareImport(array $data) {
59 'environment' => $data['elements']['environment'],
60 'eventName' => $data['elements']['eventname'],
61 'name' => $data['attributes']['name'],
62 'templateCode' => $data['elements']['templatecode'],
63 'templateName' => $data['elements']['templatename']
68 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem()
70 protected function findExistingItem(array $data) {
72 FROM wcf".WCF_N."_".$this->tableName."
79 $this->installation->getPackageID(),
81 $data['templateName'],
88 'parameters' => $parameters
93 * @see wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
95 public function uninstall() {
102 * @see wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::cleanup()
104 protected function cleanup() {
105 // clear cache immediately
106 CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.templateListener-*.php');
107 CacheHandler::getInstance()->clear(WCF_DIR.'cache/templateListener', '*.php');