2 namespace wcf\system\package\plugin
;
3 use wcf\data\application\Application
;
4 use wcf\data\package\Package
;
5 use wcf\system\package\ACPTemplatesFileHandler
;
9 * Installs, updates and deletes ACP templates.
11 * @author Alexander Ebert, Matthias Schmidt
12 * @copyright 2001-2014 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package com.woltlab.wcf
15 * @subpackage system.package.plugin
16 * @category Community Framework
18 class ACPTemplatePackageInstallationPlugin
extends AbstractPackageInstallationPlugin
{
20 * @see \wcf\system\package\plugin\AbstractPackageInstallationPlugin::$tableName
22 public $tableName = 'acp_template';
25 * @see \wcf\system\package\plugin\IPackageInstallationPlugin::install()
27 public function install() {
30 $abbreviation = 'wcf';
31 if (isset($this->instruction
['attributes']['application'])) {
32 $abbreviation = $this->instruction
['attributes']['application'];
34 else if ($this->installation
->getPackage()->isApplication
) {
35 $abbreviation = Package
::getAbbreviation($this->installation
->getPackage()->package
);
38 // absolute path to package dir
39 $packageDir = Application
::getDirectory($abbreviation);
41 // extract files.tar to temp folder
42 $sourceFile = $this->installation
->getArchive()->extractTar($this->instruction
['value'], 'acptemplates_');
44 // create file handler
45 $fileHandler = new ACPTemplatesFileHandler($this->installation
, $abbreviation);
48 $this->installation
->extractFiles($packageDir.'acp/templates/', $sourceFile, $fileHandler);
50 // delete temporary sourceArchive
55 * @see \wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
57 public function uninstall() {
58 // fetch ACP templates from log
59 $sql = "SELECT templateName, application
60 FROM wcf".WCF_N
."_acp_template
62 $statement = WCF
::getDB()->prepareStatement($sql);
63 $statement->execute(array($this->installation
->getPackageID()));
66 while ($row = $statement->fetchArray()) {
67 if (!isset($templates[$row['application']])) {
68 $templates[$row['application']] = array();
71 $templates[$row['application']][] = 'acp/templates/'.$row['templateName'].'.tpl';
74 foreach ($templates as $application => $templateNames) {
75 $this->installation
->deleteFiles(Application
::getDirectory($application), $templateNames, false, $this->installation
->getPackage()->isApplication
);