From 7f00beb88ac73fbce3c4ebf8f16d23e702889400 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 12 Oct 2012 03:29:47 +0200 Subject: [PATCH] Added form to export styles --- acptemplates/styleExport.tpl | 47 ++++++ files/lib/acp/form/StyleExportForm.class.php | 142 +++++++++++++++++++ language/de.xml | 6 + 3 files changed, 195 insertions(+) create mode 100644 acptemplates/styleExport.tpl create mode 100644 files/lib/acp/form/StyleExportForm.class.php diff --git a/acptemplates/styleExport.tpl b/acptemplates/styleExport.tpl new file mode 100644 index 0000000000..cc6ad03c14 --- /dev/null +++ b/acptemplates/styleExport.tpl @@ -0,0 +1,47 @@ +{include file='header'} + +
+
+

{lang}wcf.acp.style.exportStyle{/lang}

+
+
+ +
+ +
+ +
+
+
+ {lang}wcf.acp.style.exportStyle.components{/lang} + {lang}wcf.acp.style.exportStyle.components.description{/lang} + +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+ + +
+
+ +{include file='footer'} \ No newline at end of file diff --git a/files/lib/acp/form/StyleExportForm.class.php b/files/lib/acp/form/StyleExportForm.class.php new file mode 100644 index 0000000000..3cdf15bd73 --- /dev/null +++ b/files/lib/acp/form/StyleExportForm.class.php @@ -0,0 +1,142 @@ + + * @package com.woltlab.wcf.acp.style + * @subpackage acp.form + * @category Community Framework + */ +class StyleExportForm extends AbstractForm { + /** + * true, if style has custom icons + * @var boolean + */ + public $canExportIcons = false; + + /** + * true, if style has custom images + * @var boolean + */ + public $canExportImages = false; + + /** + * true, if style has custom templates + * @var boolean + */ + public $canExportTemplates = false; + + /** + * true, if icons should be exported + * @var boolean + */ + public $exportIcons = false; + + /** + * true, if images should be exported + * @var boolean + */ + public $exportImages = false; + + /** + * true, if templates should be exported + * @var boolean + */ + public $exportTemplates = false; + + /** + * @see wcf\page\AbstractPage::$neededPermissions + */ + public $neededPermissions = array('admin.style.canEditStyle'); + + /** + * style object + * @var wcf\data\style\Style + */ + public $style = null; + + /** + * style id + * @var integer + */ + public $styleID = 0; + + /** + * @see wcf\page\IPage::readParameters() + */ + public function readParameters() { + parent::readParameters(); + + if (isset($_REQUEST['id'])) $this->styleID = intval($_REQUEST['id']); + $this->style = new Style($this->styleID); + if (!$this->style->styleID) { + throw new IllegalLinkException(); + } + + if ($this->style->iconPath && $this->style->iconPath != 'icon/') $this->canExportIcons = true; + if ($this->style->imagePath && $this->style->imagePath != 'images/') $this->canExportImages = true; + if ($this->style->templateGroupID) $this->canExportTemplates = true; + } + + /** + * @see wcf\form\IForm::readFormParameters() + */ + public function readFormParameters() { + parent::readFormParameters(); + + if ($this->canExportIcons && isset($_POST['exportIcons'])) $this->exportIcons = true; + if ($this->canExportImages && isset($_POST['exportImages'])) $this->exportImages = true; + if ($this->canExportTemplates && isset($_POST['exportTemplates'])) $this->exportTemplates = true; + } + + /** + * @see wcf\form\IForm::save() + */ + public function save() { + parent::save(); + + // get style filename + $filename = str_replace(' ', '-', preg_replace('/[^a-z0-9 _-]/', '', StringUtil::toLowerCase($this->style->styleName))); + + // send headers + header('Content-Type: application/x-gzip; charset=utf-8'); + header('Content-Disposition: attachment; filename="'.$filename.'-style.tgz"'); + + // export style + $styleEditor = new StyleEditor($this->style); + $styleEditor->export($this->exportTemplates, $this->exportImages, $this->exportIcons); + + // call saved event + $this->saved(); + + exit; + } + + /** + * @see wcf\form\IForm::assignVariables() + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign(array( + 'canExportIcons' => $this->canExportIcons, + 'canExportImages' => $this->canExportImages, + 'canExportTemplates' => $this->canExportTemplates, + 'exportIcons' => $this->exportIcons, + 'exportImages' => $this->exportImages, + 'exportTemplates' => $this->exportTemplates, + 'style' => $this->style, + 'styleID' => $this->styleID + )); + } +} diff --git a/language/de.xml b/language/de.xml index 11df806458..250e3306aa 100644 --- a/language/de.xml +++ b/language/de.xml @@ -10,6 +10,7 @@ + @@ -36,7 +37,12 @@ styleName}“ wirklich duplizieren?]]> styleName}“ wirklich löschen?]]> + iconPath})]]> + imagePath})]]> + + + styleName}“ mit exportiert werden sollen]]> -- 2.20.1