/** 
  * @see	wcf\system\package\plugin\IPackageInstallationPlugin::install()
  */
 public function install()
 {
     parent::install();
     // extract style tar
     $filename = $this->installation->getArchive()->extractTar($this->instructions['value'], 'style_');
     // import style
     $style = StyleEditor::import($filename, $this->installation->getPackageID());
     // set style as default
     if (isset($this->instruction['attributes']['default'])) {
         $style->setAsDefault();
     }
     // remove tmp file
     @unlink($filename);
 }
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->source['name'])) {
         throw new UserInputException('source');
     }
     if (empty($this->source['tmp_name'])) {
         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 is an application
         if ($archive->getPackageInfo('isApplication')) {
             throw new SystemException("Package is application");
         }
         // check if the package includes a style
         $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']);
     } catch (\Exception $e) {
         @unlink($this->source['tmp_name']);
         throw new UserInputException('source', 'importFailed');
     }
 }