Commit d38d2986 authored by Crell's avatar Crell
Browse files

Merge remote branch 'upstream/8.x' into kernel

parents 1afec3a9 20f26110
......@@ -40,6 +40,8 @@
* @link http://pear.php.net/package/Archive_Tar
*/
namespace Drupal\Component\Archiver;
//require_once 'PEAR.php';
//
//
......@@ -54,7 +56,7 @@
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package Archive_Tar
*/
class Archive_Tar // extends PEAR
class ArchiveTar // extends PEAR
{
/**
* @var string Name of the Tar
......
......@@ -2,9 +2,11 @@
/**
* @file
* Shared classes and interfaces for the archiver system.
* Definition of Drupal\Component\Archiver\ArchiverInterface.
*/
namespace Drupal\Component\Archiver;
/**
* Defines the common interface for all Archiver classes.
*/
......@@ -13,7 +15,7 @@ interface ArchiverInterface {
/**
* Constructs a new archiver instance.
*
* @param $file_path
* @param string $file_path
* The full system path of the archive to manipulate. Only local files
* are supported. If the file does not yet exist, it will be created if
* appropriate.
......@@ -23,11 +25,11 @@ public function __construct($file_path);
/**
* Adds the specified file or directory to the archive.
*
* @param $file_path
* @param string $file_path
* The full system path of the file or directory to add. Only local files
* and directories are supported.
*
* @return ArchiverInterface
* @return Drupal\Component\Archiver\ArchiverInterface
* The called object.
*/
public function add($file_path);
......@@ -35,10 +37,10 @@ public function add($file_path);
/**
* Removes the specified file from the archive.
*
* @param $path
* @param string $path
* The file name relative to the root of the archive to remove.
*
* @return ArchiverInterface
* @return Drupal\Component\Archiver\ArchiverInterface
* The called object.
*/
public function remove($path);
......@@ -46,14 +48,14 @@ public function remove($path);
/**
* Extracts multiple files in the archive to the specified path.
*
* @param $path
* @param string $path
* A full system path of the directory to which to extract files.
* @param $files
* @param array $files
* Optionally specify a list of files to be extracted. Files are
* relative to the root of the archive. If not specified, all files
* in the archive will be extracted.
*
* @return ArchiverInterface
* @return Drupal\Component\Archiver\ArchiverInterface
* The called object.
*/
public function extract($path, array $files = array());
......@@ -61,7 +63,7 @@ public function extract($path, array $files = array());
/**
* Lists all files in the archive.
*
* @return
* @return array
* An array of file names relative to the root of the archive.
*/
public function listContents();
......
<?php
/**
* @file
* Definition of Drupal\Component\Archiver\Tar.
*/
namespace Drupal\Component\Archiver;
/**
* Defines a archiver implementation for .tar files.
*/
class Tar implements ArchiverInterface {
/**
* The underlying ArchiveTar instance that does the heavy lifting.
*
* @var Drupal\Component\Archiver\ArchiveTar
*/
protected $tar;
/**
* Constructs a Tar object.
*/
public function __construct($file_path) {
$this->tar = new ArchiveTar($file_path);
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::add().
*/
public function add($file_path) {
$this->tar->add($file_path);
return $this;
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::remove().
*/
public function remove($file_path) {
// @todo Archive_Tar doesn't have a remove operation
// so we'll have to simulate it somehow, probably by
// creating a new archive with everything but the removed
// file.
return $this;
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::extract().
*/
public function extract($path, array $files = array()) {
if ($files) {
$this->tar->extractList($files, $path);
}
else {
$this->tar->extract($path);
}
return $this;
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::listContents().
*/
public function listContents() {
$files = array();
foreach ($this->tar->listContent() as $file_data) {
$files[] = $file_data['filename'];
}
return $files;
}
/**
* Retrieves the tar engine itself.
*
* In some cases it may be necessary to directly access the underlying
* Archive_Tar object for implementation-specific logic. This is for advanced
* use only as it is not shared by other implementations of ArchiveInterface.
*
* @return Archive_Tar
* The Archive_Tar object used by this object.
*/
public function getArchive() {
return $this->tar;
}
}
......@@ -2,80 +2,19 @@
/**
* @file
* Archiver implementations provided by the system module.
* Definition of Drupal\Component\Archiver\Zip.
*/
/**
* Archiver for .tar files.
*/
class ArchiverTar implements ArchiverInterface {
/**
* The underlying Archive_Tar instance that does the heavy lifting.
*
* @var Archive_Tar
*/
protected $tar;
public function __construct($file_path) {
$this->tar = new Archive_Tar($file_path);
}
public function add($file_path) {
$this->tar->add($file_path);
return $this;
}
public function remove($file_path) {
// @todo Archive_Tar doesn't have a remove operation
// so we'll have to simulate it somehow, probably by
// creating a new archive with everything but the removed
// file.
return $this;
}
public function extract($path, Array $files = array()) {
if ($files) {
$this->tar->extractList($files, $path);
}
else {
$this->tar->extract($path);
}
return $this;
}
namespace Drupal\Component\Archiver;
public function listContents() {
$files = array();
foreach ($this->tar->listContent() as $file_data) {
$files[] = $file_data['filename'];
}
return $files;
}
/**
* Retrieve the tar engine itself.
*
* In some cases it may be necessary to directly access the underlying
* Archive_Tar object for implementation-specific logic. This is for advanced
* use only as it is not shared by other implementations of ArchiveInterface.
*
* @return
* The Archive_Tar object used by this object.
*/
public function getArchive() {
return $this->tar;
}
}
use ZipArchive;
/**
* Archiver for .zip files.
* Defines a archiver implementation for .zip files.
*
* @link http://php.net/zip
*/
class ArchiverZip implements ArchiverInterface {
class Zip implements ArchiverInterface {
/**
* The underlying ZipArchive instance that does the heavy lifting.
......@@ -84,6 +23,12 @@ class ArchiverZip implements ArchiverInterface {
*/
protected $zip;
/**
* Constructs a Tar object.
*
* @param string $file_path
* The full system path of the archive to manipulate.
*/
public function __construct($file_path) {
$this->zip = new ZipArchive();
if ($this->zip->open($file_path) !== TRUE) {
......@@ -92,18 +37,27 @@ public function __construct($file_path) {
}
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::add().
*/
public function add($file_path) {
$this->zip->addFile($file_path);
return $this;
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::remove().
*/
public function remove($file_path) {
$this->zip->deleteName($file_path);
return $this;
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::extract().
*/
public function extract($path, Array $files = array()) {
if ($files) {
$this->zip->extractTo($path, $files);
......@@ -115,6 +69,9 @@ public function extract($path, Array $files = array()) {
return $this;
}
/**
* Implements Drupal\Component\Archiver\ArchiveInterface::listContents().
*/
public function listContents() {
$files = array();
for ($i=0; $i < $this->zip->numFiles; $i++) {
......@@ -124,13 +81,13 @@ public function listContents() {
}
/**
* Retrieve the zip engine itself.
* Retrieves the zip engine itself.
*
* In some cases it may be necessary to directly access the underlying
* ZipArchive object for implementation-specific logic. This is for advanced
* use only as it is not shared by other implementations of ArchiveInterface.
*
* @return
* @return ZipArchive
* The ZipArchive object used by this object.
*/
public function getArchive() {
......
<?xml version="1.0"?>
<config>
<name>large</name>
<effects>
<image_scale_480_480_1>
<name>image_scale</name>
<ieid>image_scale_480_480_1</ieid>
<data>
<width>480</width>
<height>480</height>
<upscale>1</upscale>
</data>
<weight>0</weight>
</image_scale_480_480_1>
</effects>
</config>
<?xml version="1.0"?>
<config>
<name>medium</name>
<effects>
<image_scale_220_220_1>
<name>image_scale</name>
<ieid>image_scale_220_220_1</ieid>
<data>
<width>220</width>
<height>220</height>
<upscale>1</upscale>
</data>
<weight>0</weight>
</image_scale_220_220_1>
</effects>
</config>
<?xml version="1.0"?>
<config>
<name>thumbnail</name>
<effects>
<image_scale_100_100_1>
<name>image_scale</name>
<ieid>image_scale_100_100_1</ieid>
<data>
<width>100</width>
<height>100</height>
<upscale>1</upscale>
</data>
<weight>0</weight>
</image_scale_100_100_1>
</effects>
</config>
......@@ -3493,7 +3493,7 @@ function hook_action_info_alter(&$actions) {
function hook_archiver_info() {
return array(
'tar' => array(
'class' => 'ArchiverTar',
'class' => 'Drupal\Component\Archiver\Tar',
'extensions' => array('tar', 'tar.gz', 'tar.bz2'),
),
);
......
......@@ -3,8 +3,6 @@ description = Handles general site configuration for administrators.
package = Core
version = VERSION
core = 8.x
files[] = system.archiver.inc
files[] = system.tar.inc
files[] = system.test
required = TRUE
configure = admin/config/system
......@@ -3948,12 +3948,12 @@ function system_date_format_delete($dfid) {
*/
function system_archiver_info() {
$archivers['tar'] = array(
'class' => 'ArchiverTar',
'class' => 'Drupal\Component\Archiver\Tar',
'extensions' => array('tar', 'tgz', 'tar.gz', 'tar.bz2'),
);
if (function_exists('zip_open')) {
$archivers['zip'] = array(
'class' => 'ArchiverZip',
'class' => 'Drupal\Component\Archiver\Zip',
'extensions' => array('zip'),
);
}
......
......@@ -121,7 +121,7 @@ function update_test_archiver_info() {
return array(
'update_test_archiver' => array(
// This is bogus, we only care about the extensions for now.
'class' => 'ArchiverUpdateTest',
'class' => 'Drupal\Component\Archiver\UpdateTest',
'extensions' => array('update-test-extension'),
),
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment