{if $excludingPackages|count > 0}
<div class="error">{lang}wcf.acp.package.install.error.excludingPackages{/lang}
<ul>
- {foreach from=$excludingPackages item=excludingPackage}
- <li>{lang}wcf.acp.package.install.error.excludingPackages.excludingPackage{/lang}</li>
- {/foreach}
+ {foreach from=$excludingPackages item=excludingPackage}
+ <li>{lang}wcf.acp.package.install.error.excludingPackages.excludingPackage{/lang}</li>
+ {/foreach}
</ul>
</div>
{/if}
{if $excludedPackages|count > 0}
<div class="error">{lang}wcf.acp.package.install.error.excludedPackages{/lang}
<ul>
- {foreach from=$excludedPackages item=excludedPackage}
- <li>{lang}wcf.acp.package.install.error.excludedPackages.excludedPackage{/lang}</li>
- {/foreach}
+ {foreach from=$excludedPackages item=excludedPackage}
+ <li>{lang}wcf.acp.package.install.error.excludedPackages.excludedPackage{/lang}</li>
+ {/foreach}
</ul>
</div>
{/if}
+{if $installingImportedStyle}
+ <p class="info">{lang}wcf.acp.package.install.installingImportedStyle{/lang}</p>
+{/if}
+
<div class="container containerPadding marginTop">
<fieldset>
<legend>{lang}wcf.acp.package.information.properties{/lang}</legend>
<h1>{lang}{@$pageTitle}{/lang}</h1>
</header>
+{if $errorField && $installingImportedStyle}
+ <p class="info">{lang}wcf.acp.package.install.installingImportedStyle{/lang}</p>
+{/if}
+
{include file='formError'}
<div class="contentNavigation">
*/
public $queue = null;
+ /**
+ * location of the package uploaded via style import
+ * @var string
+ */
+ public $stylePackageImportLocation = '';
+
+ /**
+ * @see \wcf\page\IPage::readParameters()
+ */
+ public function readParameters() {
+ parent::readParameters();
+
+ $this->stylePackageImportLocation = WCF::getSession()->getVar('stylePackageImportLocation');
+ if ($this->stylePackageImportLocation) {
+ $_POST['t'] = WCF::getSession()->getSecurityToken();
+ }
+ }
+
/**
* @see \wcf\form\IForm::readFormParameters()
*/
public function readFormParameters() {
parent::readFormParameters();
- if (isset($_POST['downloadPackage'])) $this->downloadPackage = StringUtil::trim($_POST['downloadPackage']);
- if (isset($_FILES['uploadPackage'])) $this->uploadPackage = $_FILES['uploadPackage'];
+ if (!$this->stylePackageImportLocation) {
+ if (isset($_POST['downloadPackage'])) $this->downloadPackage = StringUtil::trim($_POST['downloadPackage']);
+ if (isset($_FILES['uploadPackage'])) $this->uploadPackage = $_FILES['uploadPackage'];
+ }
}
/**
public function validate() {
parent::validate();
- if (!empty($this->uploadPackage['name'])) {
+ if ($this->stylePackageImportLocation) {
+ $this->archive = new PackageArchive($this->stylePackageImportLocation, $this->package);
+
+ try {
+ $this->validateArchive('uploadPackage');
+ }
+ catch (UserInputException $e) {
+ WCF::getSession()->unregister('stylePackageImportLocation');
+
+ throw $e;
+ }
+ }
+ else if (!empty($this->uploadPackage['name'])) {
$this->validateUploadPackage();
}
else if (!empty($this->downloadPackage)) {
// obey foreign key
$packageID = ($this->package) ? $this->package->packageID : null;
+ $archive = $this->downloadPackage;
+ if ($this->stylePackageImportLocation) {
+ $archive = $this->stylePackageImportLocation;
+ }
+ else if (!empty($this->uploadPackage['tmp_name'])) {
+ $archive = $this->uploadPackage['name'];
+ }
+
// insert queue
$isApplication = $this->archive->getPackageInfo('isApplication');
$this->queue = PackageInstallationQueueEditor::create(array(
'package' => $this->archive->getPackageInfo('name'),
'packageName' => $this->archive->getLocalizedPackageInfo('packageName'),
'packageID' => $packageID,
- 'archive' => (!empty($this->uploadPackage['tmp_name']) ? $this->uploadPackage['name'] : $this->downloadPackage),
+ 'archive' => $archive,
'action' => ($this->package != null ? 'update' : 'install'),
'isApplication' => (!$isApplication ? '0' : '1')
));
parent::assignVariables();
WCF::getTPL()->assign(array(
- 'package' => $this->package
+ 'package' => $this->package,
+ 'installingImportedStyle' => $this->stylePackageImportLocation != ''
));
}
use wcf\data\style\StyleEditor;
use wcf\form\AbstractForm;
use wcf\system\cache\builder\StyleCacheBuilder;
+use wcf\system\exception\SystemException;
use wcf\system\exception\UserInputException;
+use wcf\system\package\PackageArchive;
+use wcf\system\request\LinkHandler;
use wcf\system\WCF;
+use wcf\util\FileUtil;
+use wcf\util\HeaderUtil;
/**
* Shows the style import form.
throw new UserInputException('source', 'uploadFailed');
}
+ try {
+ // check if the uploaded file is a package
+ $archive = new PackageArchive($this->source['tmp_name']);
+ $archive->openArchive();
+
+ // check if the package includes a style
+ if ($archive->getPackageInfo('isApplication')) {
+ throw new SystemException("Package is application");
+ }
+
+ $containsStyle = false;
+ $installInstructions = $archive->getInstallInstructions();
+ foreach ($installInstructions as $instruction) {
+ if ($instruction['pip'] == 'style') {
+ $containsStyle = true;
+ break;
+ }
+ }
+
+ if (!$containsStyle) {
+ throw new SystemException("Package contains no style");
+ }
+
+ $filename = FileUtil::getTemporaryFilename('package_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($this->source['name'])));
+
+ if (!@move_uploaded_file($this->source['tmp_name'], $filename)) {
+ throw new SystemException("Cannot move uploaded file");
+ }
+
+ WCF::getSession()->register('stylePackageImportLocation', $filename);
+
+ HeaderUtil::redirect(LinkHandler::getInstance()->getLink('PackageStartInstall', array(
+ 'action' => 'install'
+ )));
+ exit;
+ }
+ catch (SystemException $e) {
+ // ignore errors
+ }
+
try {
$this->style = StyleEditor::import($this->source['tmp_name']);
}
*/
public $requirements = array();
+ /**
+ * true if the package to be installed was uploaded via the import style
+ * form
+ * @var boolean
+ */
+ public $installingImportedStyle = false;
+
/**
* @see \wcf\page\IPage::readParameters()
*/
else {
WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage'));
}
+
+ $this->installingImportedStyle = WCF::getSession()->getVar('stylePackageImportLocation') !== null;
+ if ($this->installingImportedStyle) {
+ WCF::getSession()->unregister('stylePackageImportLocation');
+ }
}
/**
'missingPackages' => $this->missingPackages,
'excludingPackages' => $this->packageInstallationDispatcher->getArchive()->getConflictedExcludingPackages(),
'excludedPackages' => $this->packageInstallationDispatcher->getArchive()->getConflictedExcludedPackages(),
- 'queue' => $this->queue
+ 'queue' => $this->queue,
+ 'installingImportedStyle' => $this->installingImportedStyle
));
}
<item name="wcf.acp.package.install.error.excludingPackages"><![CDATA[Die folgenden bereits installierten Pakete schließen eine Installation dieses Pakets aus:]]></item>
<item name="wcf.acp.package.install.error.excludingPackages.excludingPackage"><![CDATA[„{$excludingPackage}“ ({$excludingPackage->package}){if $excludingPackage->excludedPackageVersion} (ausgeschlossene Version: {$excludingPackage->excludedPackageVersion}){/if}]]></item>
<item name="wcf.acp.package.install.error.missingRequirements"><![CDATA[Die Abhängigkeiten dieses Paketes konnten nicht aufgelöst werden.]]></item>
+ <item name="wcf.acp.package.install.installingImportedStyle"><![CDATA[Bei der hochgeladenen Datei handelt es sich um ein Paket, welches einen Stil enthält.]]></item>
<item name="wcf.acp.package.install.optionalPackage.missingRequirements"><![CDATA[Installation nicht möglich, nicht alle benötigten Pakete sind installiert.]]></item>
<item name="wcf.acp.package.install.step.prepare"><![CDATA[Installation wird vorbereitet …]]></item>
<item name="wcf.acp.package.install.title"><![CDATA[Paket-Installation]]></item>
<item name="wcf.acp.package.install.error.excludingPackages"><![CDATA[The following, already installed packages prohibit installing this package:]]></item>
<item name="wcf.acp.package.install.error.excludingPackages.excludingPackage"><![CDATA[“{$excludingPackage}” ({$excludingPackage->package}){if $excludingPackage->excludedPackageVersion} (excluded version: {$excludingPackage->excludedPackageVersion}){/if}]]></item>
<item name="wcf.acp.package.install.error.missingRequirements"><![CDATA[Unable to resolve requirements of this package.]]></item>
+ <item name="wcf.acp.package.install.installingImportedStyle"><![CDATA[The uploaded file is a package containg a style.]]></item>
<item name="wcf.acp.package.install.optionalPackage.missingRequirements"><![CDATA[Unable to install, some or all required packages are not installed.]]></item>
<item name="wcf.acp.package.install.step.prepare"><![CDATA[Preparing Installation …]]></item>
<item name="wcf.acp.package.install.title"><![CDATA[Installation]]></item>