From 13641948e66fd3a33d3219b7e0009a89c1cd49fe Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 12 Oct 2012 19:33:56 +0200 Subject: [PATCH] Added ability to export styles as packages --- acptemplates/styleExport.tpl | 29 ++++++++++ files/lib/acp/form/StyleExportForm.class.php | 56 +++++++++++++++++++- language/de.xml | 7 +++ 3 files changed, 90 insertions(+), 2 deletions(-) diff --git a/acptemplates/styleExport.tpl b/acptemplates/styleExport.tpl index cc6ad03c14..444c7eb39f 100644 --- a/acptemplates/styleExport.tpl +++ b/acptemplates/styleExport.tpl @@ -36,6 +36,35 @@ + +
+ {lang}wcf.acp.style.exportStyle.asPackage{/lang} + {lang}wcf.acp.style.exportStyle.asPackage.description{/lang} + +
+
+ +
+
+ +
+ +
+
+ + {if $errorField == 'packageName'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.style.packageName.error.{$errorType}{/lang} + {/if} + + {/if} + {lang}wcf.acp.style.packageName.description{/lang} +
+ +
diff --git a/files/lib/acp/form/StyleExportForm.class.php b/files/lib/acp/form/StyleExportForm.class.php index 3cdf15bd73..229c7f255b 100644 --- a/files/lib/acp/form/StyleExportForm.class.php +++ b/files/lib/acp/form/StyleExportForm.class.php @@ -1,5 +1,9 @@ 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; + + if (isset($_POST['exportAsPackage'])) { + $this->exportAsPackage = true; + + if (isset($_POST['packageName'])) $this->packageName = StringUtil::trim($_POST['packageName']); + } + } + + /** + * @see wcf\form\IForm::validate() + */ + public function validate() { + parent::validate(); + + if ($this->exportAsPackage) { + if (empty($this->packageName)) { + throw new UserInputException('packageName'); + } + + if (!Package::isValidPackageName($this->packageName)) { + throw new UserInputException('packageName', 'notValid'); + } + + // 3rd party packages may never have com.woltlab.* as name + if (strpos($this->packageName, 'com.woltlab.') === 0) { + throw new UserInputException('packageName', 'reserved'); + } + } } /** @@ -110,11 +154,17 @@ class StyleExportForm extends AbstractForm { // send headers header('Content-Type: application/x-gzip; charset=utf-8'); - header('Content-Disposition: attachment; filename="'.$filename.'-style.tgz"'); + + if ($this->exportAsPackage) { + header('Content-Disposition: attachment; filename="'.$this->packageName.'.tar.gz"'); + } + else { + header('Content-Disposition: attachment; filename="'.$filename.'-style.tgz"'); + } // export style $styleEditor = new StyleEditor($this->style); - $styleEditor->export($this->exportTemplates, $this->exportImages, $this->exportIcons); + $styleEditor->export($this->exportTemplates, $this->exportImages, $this->exportIcons, $this->packageName); // call saved event $this->saved(); @@ -132,9 +182,11 @@ class StyleExportForm extends AbstractForm { 'canExportIcons' => $this->canExportIcons, 'canExportImages' => $this->canExportImages, 'canExportTemplates' => $this->canExportTemplates, + 'exportAsPackage' => $this->exportAsPackage, 'exportIcons' => $this->exportIcons, 'exportImages' => $this->exportImages, 'exportTemplates' => $this->exportTemplates, + 'packageName' => $this->packageName, 'style' => $this->style, 'styleID' => $this->styleID )); diff --git a/language/de.xml b/language/de.xml index 250e3306aa..241677b3be 100644 --- a/language/de.xml +++ b/language/de.xml @@ -37,10 +37,13 @@ styleName}“ wirklich duplizieren?]]> styleName}“ wirklich löschen?]]> + iconPath})]]> imagePath})]]> + + styleName}“ als Paket exportieren möchten. Pakete können über die Paketverwaltung installiert oder in den WoltLab® Plugin-Store hochgeladen werden.]]> styleName}“ mit exportiert werden sollen]]> @@ -62,6 +65,10 @@ + + + + -- 2.20.1