Example #1
0
 public function testFormatNotSupportedAfterDisablingAllMethods()
 {
     $this->setExpectedException('Distill\\Exception\\IO\\Input\\FileFormatNotSupportedException');
     $target = $this->getTemporaryPath();
     $this->clearTemporaryPath();
     $this->distill->disableMethod(Cabextract::getName());
     $this->distill->disableMethod(Gcab::getName());
     $this->distill->disableMethod(X7zip::getName());
     $result = $this->distill->extract($this->filesPath . 'file_ok.cab', $target, new Format\Simple\Cab());
     $this->clearTemporaryPath();
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(sprintf("distill-cli %s by Raul Fraile.\n", $this->appVersion));
     $output->write(sprintf("Uncompressing '%s' into '%s' ", $input->getArgument('file'), $input->getArgument('target')));
     $distill = new Distill();
     $response = $distill->extract($input->getArgument('file'), $input->getArgument('target'));
     if (true == $response) {
         $output->writeln('[<info>OK</info>]');
         return 0;
     }
     $output->writeln('<error>ERROR</error>');
     return 1;
 }
 /**
  * Lists all Module models.
  *
  * @return mixed
  */
 public function actionUpload()
 {
     $model = new ThemezipForm();
     if (\Yii::$app->getRequest()->getIsPost() == true && ($uploaded = UploadedFile::getInstance($model, "themezip")) != null) {
         $distill = new Distill();
         $extractFileName = dirname($uploaded->tempName) . DIRECTORY_SEPARATOR . $uploaded->name;
         if (move_uploaded_file($uploaded->tempName, $extractFileName) == true) {
             $target = dirname($uploaded->tempName) . DIRECTORY_SEPARATOR . md5($extractFileName . time());
             mkdir($target);
             if ($distill->extract($extractFileName, $target)) {
                 $newTheme = \Yii::$app->get("themeManager")->findByPath($target . DIRECTORY_SEPARATOR . $uploaded->getBaseName());
                 if (count($newTheme) === 1) {
                     $theme = \Yii::$app->get("themeManager")->findOne($newTheme->getPackage());
                     if ($theme == null) {
                         $themePath = Yii::getAlias(\Yii::$app->get("themeManager")->getThemePath());
                         if ($distill->extract($extractFileName, $themePath)) {
                             $this->flash("success", "上传主题文件成功");
                         }
                     } else {
                         $this->flash("error", "主题路径已经存在该主题ID");
                     }
                 } else {
                     $this->flash("error", "上传主题配置文件不存在或者上传主题有错误");
                 }
             } else {
                 $this->flash("error", "解压文件失败");
             }
         } else {
             $this->flash("error", "移动文件失败,请确定你的临时目录是可写的");
         }
         if (file_exists($uploaded->tempName)) {
             unlink($uploaded->tempName);
         }
         if (file_exists($extractFileName)) {
             unlink($extractFileName);
         }
         FileHelper::removeDirectory($target);
         return $this->refresh();
     }
     return $this->render('upload', ["model" => $model]);
 }
Example #4
0
    /**
     * Extracts the archive
     *
     * @param OutputInterface $output
     * @param $file
     * @param $target
     * @param $oxidVersion
     */
    protected function extractArchive(OutputInterface $output, $file, $target, $oxidVersion)
    {
        $distill = new Distill();
        $output->writeLn("Extracting");
        $distill->extract($file, $target);
        $filesystem = new Filesystem();
        $filesystem->mirror($target . '/' . $oxidVersion['folder'] . '/source', $target);
        $filesystem->remove($target . '/' . $oxidVersion['folder']);
        $pkgInfo = <<<EOT
[Package info]
revision = "{$oxidVersion['hash']}"
edition = "CE"
version = "{$oxidVersion['versionTag']}"
encoder-version = ""
timestamp = "{timestamp()}"
EOT;
        file_put_contents($target . '/pkg.info', $pkgInfo);
    }
Example #5
0
    /**
     * Extracts the archive
     *
     * @param OutputInterface $output
     * @param $file
     * @param $target
     * @param $oxidVersion
     */
    protected function extractArchive(OutputInterface $output, $file, $target, $oxidVersion)
    {
        $distill = new Distill();
        $output->writeLn("Extracting");
        $distill->extract($file, $target);
        $filesystem = new Filesystem();
        $filesystem->mirror($target . '/' . $oxidVersion['folder'] . '/source', $target);
        $filesystem->remove($target . '/' . $oxidVersion['folder']);
        $oxidVersion['timestamp'] = date('Y-m-d H:i:s');
        $oxidVersion['build'] = preg_replace('/[^\\d]+/', '', $oxidVersion['versionTag']);
        $pkgInfo = <<<EOT
[Builder]
build = {$oxidVersion['build']}

[Package info]
revision = "{$oxidVersion['sha']}"
edition = "CE"
version = "{$oxidVersion['versionTag']}"
encoder-version = ""
timestamp = "{$oxidVersion['timestamp']}"
EOT;
        file_put_contents($target . '/pkg.info', $pkgInfo);
        file_put_contents($target . '/pkg.rev', $oxidVersion['sha']);
    }
Example #6
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use Distill\Distill;
$distill = new Distill();
$distill->extract(__DIR__ . '/../tests/files/file_ok.zip', __DIR__ . '/extract');