Skip to content

Commit

Permalink
added composer setup and the first composer package php-archive
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed May 15, 2015
1 parent 05790a0 commit 605f8e8
Show file tree
Hide file tree
Showing 22 changed files with 2,538 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -56,3 +56,10 @@
!/lib/plugins/remote.php
!/lib/plugins/syntax.php
lib/images/*/local/*

# composer default ignores
vendor/*/*/tests/*
vendor/*/*/test/*
vendor/*/*/doc/*
vendor/*/*/docs/*

5 changes: 5 additions & 0 deletions composer.json
@@ -0,0 +1,5 @@
{
"require": {
"splitbrain/php-archive": "~1.0"
}
}
65 changes: 65 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions inc/init.php
Expand Up @@ -191,6 +191,7 @@ function_exists('ob_gzhandler') &&
if (empty($plugin_controller_class)) $plugin_controller_class = 'Doku_Plugin_Controller';

// load libraries
require_once(DOKU_INC.'vendor/autoload.php');
require_once(DOKU_INC.'inc/load.php');

// disable gzip if not available
Expand Down
27 changes: 9 additions & 18 deletions lib/plugins/extension/helper/extension.php
Expand Up @@ -1035,33 +1035,24 @@ private function decompress($file, $target) {

$ext = $this->guess_archive($file);
if(in_array($ext, array('tar', 'bz', 'gz'))) {
switch($ext) {
case 'bz':
$compress_type = Tar::COMPRESS_BZIP;
break;
case 'gz':
$compress_type = Tar::COMPRESS_GZIP;
break;
default:
$compress_type = Tar::COMPRESS_NONE;
}

$tar = new Tar();
try {
$tar->open($file, $compress_type);
$tar = new \splitbrain\PHPArchive\Tar();
$tar->open($file);
$tar->extract($target);
} catch (Exception $e) {
} catch (\splitbrain\PHPArchive\ArchiveIOException $e) {
throw new Exception($this->getLang('error_decompress').' '.$e->getMessage());
}

return true;
} elseif($ext == 'zip') {

$zip = new ZipLib();
$ok = $zip->Extract($file, $target);

if($ok == -1){
throw new Exception($this->getLang('error_decompress').' Error extracting the zip archive');
try {
$zip = new \splitbrain\PHPArchive\Zip();
$zip->open($file);
$zip->extract($target);
} catch (\splitbrain\PHPArchive\ArchiveIOException $e) {
throw new Exception($this->getLang('error_decompress').' '.$e->getMessage());
}

return true;
Expand Down
7 changes: 7 additions & 0 deletions vendor/autoload.php
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInita19a915ee98347a0c787119619d2ff9b::getLoader();

0 comments on commit 605f8e8

Please sign in to comment.