<?php
namespace wcf\acp\form;
-use wcf\data\package\Package;
use wcf\data\style\Style;
use wcf\data\style\StyleEditor;
use wcf\form\AbstractForm;
use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\UserInputException;
use wcf\system\WCF;
use wcf\util\StringUtil;
*/
public $neededPermissions = ['admin.style.canManageStyle'];
- /**
- * package identifier
- * @var string
- */
- public $packageName = '';
-
/**
* style object
* @var \wcf\data\style\Style
if ($this->canExportImages && isset($_POST['exportImages'])) $this->exportImages = true;
if ($this->canExportTemplates && isset($_POST['exportTemplates'])) $this->exportTemplates = true;
- if (isset($_POST['exportAsPackage'])) {
+ if ($this->style->packageName && isset($_POST['exportAsPackage'])) {
$this->exportAsPackage = true;
-
- if (isset($_POST['packageName'])) $this->packageName = StringUtil::trim($_POST['packageName']);
- }
- }
-
- /**
- * @inheritDoc
- */
- 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');
- }
}
}
header('Content-Type: application/x-gzip; charset=utf-8');
if ($this->exportAsPackage) {
- header('Content-Disposition: attachment; filename="'.$this->packageName.'.tar.gz"');
+ header('Content-Disposition: attachment; filename="'.$this->style->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->packageName);
+ $styleEditor->export($this->exportTemplates, $this->exportImages, $this->style->packageName);
// call saved event
$this->saved();
'exportAsPackage' => $this->exportAsPackage,
'exportImages' => $this->exportImages,
'exportTemplates' => $this->exportTemplates,
- 'packageName' => $this->packageName,
'style' => $this->style,
'styleID' => $this->styleID
]);