Merge branch 'kernel' into kernel-real-responses
commit
ad5fd1a16f
|
@ -95,7 +95,7 @@ DirectoryIndex index.php index.html index.htm
|
|||
#
|
||||
# If your site is running in a VirtualDocumentRoot at http://example.com/,
|
||||
# uncomment the following line:
|
||||
#RewriteBase /
|
||||
# RewriteBase /
|
||||
|
||||
# Redirect common PHP files to their new locations.
|
||||
RewriteCond %{REQUEST_URI} ^(.*)?/(update.php) [OR]
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
* @link http://pear.php.net/package/Archive_Tar
|
||||
*/
|
||||
|
||||
namespace Drupal\Component\Archiver;
|
||||
|
||||
//require_once 'PEAR.php';
|
||||
//
|
||||
//
|
||||
|
@ -54,7 +56,7 @@ define ('ARCHIVE_TAR_END_BLOCK', pack("a512", ''));
|
|||
* @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 @@ interface ArchiverInterface {
|
|||
/**
|
||||
* 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 @@ interface ArchiverInterface {
|
|||
/**
|
||||
* 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 @@ interface ArchiverInterface {
|
|||
/**
|
||||
* 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 @@ interface ArchiverInterface {
|
|||
/**
|
||||
* Lists all files in the archive.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array of file names relative to the root of the archive.
|
||||
*/
|
||||
public function listContents();
|
|
@ -0,0 +1,88 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\Component\Archiver\Zip.
|
||||
*/
|
||||
|
||||
namespace Drupal\Component\Archiver;
|
||||
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Defines a archiver implementation for .zip files.
|
||||
*
|
||||
* @link http://php.net/zip
|
||||
*/
|
||||
class Zip implements ArchiverInterface {
|
||||
|
||||
/**
|
||||
* The underlying ZipArchive instance that does the heavy lifting.
|
||||
*
|
||||
* @var ZipArchive
|
||||
*/
|
||||
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) {
|
||||
// @todo: This should be an interface-specific exception some day.
|
||||
throw new Exception(t('Cannot open %file_path', array('%file_path' => $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);
|
||||
}
|
||||
else {
|
||||
$this->zip->extractTo($path);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Drupal\Component\Archiver\ArchiveInterface::listContents().
|
||||
*/
|
||||
public function listContents() {
|
||||
$files = array();
|
||||
for ($i=0; $i < $this->zip->numFiles; $i++) {
|
||||
$files[] = $this->zip->getNameIndex($i);
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ZipArchive
|
||||
* The ZipArchive object used by this object.
|
||||
*/
|
||||
public function getArchive() {
|
||||
return $this->zip;
|
||||
}
|
||||
}
|
|
@ -34,7 +34,8 @@ class HtmlSubscriber implements EventSubscriberInterface {
|
|||
* True if it is an event we should process as HTML, False otherwise.
|
||||
*/
|
||||
protected function isHtmlRequestEvent(GetResponseEvent $event) {
|
||||
return (boolean)array_intersect(array('text/html', '*/*'), $event->getRequest()->getAcceptableContentTypes());
|
||||
$acceptable_content_types = $event->getRequest()->getAcceptableContentTypes();
|
||||
return in_array('text/html', $acceptable_content_types) || in_array('*/*', $acceptable_content_types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,6 +128,9 @@ class HtmlSubscriber implements EventSubscriberInterface {
|
|||
$page_callback_result = $event->getControllerResult();
|
||||
$event->setResponse(new Response(drupal_render_page($page_callback_result)));
|
||||
}
|
||||
else {
|
||||
$event->setResponse(new Response('Unsupported Media Type', 415));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,12 +36,6 @@ class PathSubscriber implements EventSubscriberInterface {
|
|||
|
||||
$path = ltrim($request->getPathInfo(), '/');
|
||||
|
||||
// Temporary BC shiv to support automated tests that still rely on old-
|
||||
// style dirty URLs.
|
||||
if (isset($_GET['q'])) {
|
||||
$path = $_GET['q'];
|
||||
}
|
||||
|
||||
if (empty($path)) {
|
||||
// @todo Temporary hack. Fix when configuration is injectable.
|
||||
$path = variable_get('site_frontpage', 'user');
|
||||
|
|
|
@ -38,15 +38,6 @@ class UrlMatcher extends SymfonyUrlMatcher {
|
|||
// Symfony uses a prefixing / but we don't yet.
|
||||
$dpathinfo = ltrim($pathinfo, '/');
|
||||
|
||||
// Temporary BC shiv to support automated tests that still rely on old-
|
||||
// style dirty URLs.
|
||||
// @todo Remove this once testbot knows how to deal with Symfony-style
|
||||
// dirty URLs.
|
||||
if (isset($_GET['q'])) {
|
||||
$dpathinfo = $_GET['q'];
|
||||
$pathinfo = '/' . $dpathinfo;
|
||||
}
|
||||
|
||||
// Do our fancy frontpage logic.
|
||||
if (empty($dpathinfo)) {
|
||||
$dpathinfo = variable_get('site_frontpage', 'user');
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?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>
|
|
@ -0,0 +1,16 @@
|
|||
<?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>
|
|
@ -0,0 +1,16 @@
|
|||
<?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'),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Archiver implementations provided by the system module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Archiver for .zip files.
|
||||
*
|
||||
* @link http://php.net/zip
|
||||
*/
|
||||
class ArchiverZip implements ArchiverInterface {
|
||||
|
||||
/**
|
||||
* The underlying ZipArchive instance that does the heavy lifting.
|
||||
*
|
||||
* @var ZipArchive
|
||||
*/
|
||||
protected $zip;
|
||||
|
||||
public function __construct($file_path) {
|
||||
$this->zip = new ZipArchive();
|
||||
if ($this->zip->open($file_path) !== TRUE) {
|
||||
// @todo: This should be an interface-specific exception some day.
|
||||
throw new Exception(t('Cannot open %file_path', array('%file_path' => $file_path)));
|
||||
}
|
||||
}
|
||||
|
||||
public function add($file_path) {
|
||||
$this->zip->addFile($file_path);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function remove($file_path) {
|
||||
$this->zip->deleteName($file_path);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function extract($path, Array $files = array()) {
|
||||
if ($files) {
|
||||
$this->zip->extractTo($path, $files);
|
||||
}
|
||||
else {
|
||||
$this->zip->extractTo($path);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function listContents() {
|
||||
$files = array();
|
||||
for ($i=0; $i < $this->zip->numFiles; $i++) {
|
||||
$files[] = $this->zip->getNameIndex($i);
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve 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
|
||||
* The ZipArchive object used by this object.
|
||||
*/
|
||||
public function getArchive() {
|
||||
return $this->zip;
|
||||
}
|
||||
}
|
|
@ -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'),
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue