Commit 68813fe1 authored by aaronwinborn's avatar aaronwinborn

* Initial backport to d6 (aaron).

parent c2d48cd8
<?php
// $Id$
/**
* private:// stream wrapper class.
......
<?php
// $Id$
/**
* public:// stream wrapper class.
*
* This class provides support for storing publicly
*
* This class provides support for storing publicly
* accessible files with the Drupal resource api.
*/
class ResourcePublicStreamWrapper extends ResourceStreamWrapper {
......@@ -26,14 +27,14 @@ class ResourcePublicStreamWrapper extends ResourceStreamWrapper {
*/
function interpolateUrl($url) {
$basepath = variable_get($this->pathKey, $this->pathDefault);
// just in case stream_public_path is s3://, ftp://, etc. Don't call PHP's
// realpath().
if (parse_url($basepath, PHP_URL_SCHEME)) {
$path = $basepath . parse_url($url, PHP_URL_PATH);;
}
else {
// interpolate relative paths for basepath, and strip relative paths from
// interpolate relative paths for basepath, and strip relative paths from
// url path.
$path = realpath($basepath) . str_replace('/..','', parse_url($url, PHP_URL_PATH));
}
......
<?php
// $Id$
/**
* Definition for a Resource stream wrapper in Drupal.
......@@ -19,7 +20,7 @@ interface ResourceStreamWrapperInterface extends StreamWrapperInterface {
* Stream wrapper resource url.
* @return string
*/
function mime($url);
function mime($url);
/**
* Return an absolute stream resource URL.
......@@ -67,16 +68,16 @@ interface StreamWrapperInterface {
*
* DrupalStreamWrapper implementations need to override at least the interpolateUrl
* method to rewrite the URL before is it passed back into the calling function.
*
*
*/
abstract class ResourceStreamWrapper implements ResourceStreamWrapperInterface {
private $handle = NULL;
function interpolateUrl($url) {
function interpolateUrl($url) {
return $url;
}
function htmlUrl($url) {
function htmlUrl($url) {
return $url;
}
......@@ -153,7 +154,7 @@ abstract class ResourceStreamWrapper implements ResourceStreamWrapperInterface {
/**
* Support for fseek().
*
*
* @param $offset
* The byte offset to got to.
* @param $whence
......@@ -222,7 +223,7 @@ abstract class ResourceStreamWrapper implements ResourceStreamWrapperInterface {
/**
* Support for rename().
*
* @param $fromUrl,
* @param $fromUrl,
* The url to the file to rename.
* @param $toUrl
* The new url for file.
......
<?php
// $Id$
/**
* The StreamWrapperManager provides a class for managing and querying
......@@ -28,7 +29,7 @@ class ResourceStreamWrapperManager {
* Register a class to handle a scheme.
* @param string $scheme URI scheme.
* @param string $class classname for the stream wrapper.
* @return bool result of stream_wrapper_register
* @return bool result of stream_wrapper_register
* @see: http://us3.php.net/manual/en/function.stream-wrapper-register.php
*/
function register($scheme, $classname) {
......@@ -67,7 +68,7 @@ class ResourceStreamWrapperManager {
/**
* Return the DrupalStreamWrapperManager's wrapper registry.
*/
*/
function wrappers() {
return self::$this->wrappers;
}
......
// $Id$
Changelog for the Resource module.
January 2009
------------
* Initial backport to d6 (aaron).
* Initial development (dopry).
......@@ -2,9 +2,5 @@
name = Resource
description = A stream wrapper enabled replacement for core filehandling.
package = Media
core = 7.x
files[] = resource.module
files[] = ResourceStreamWrapperManager.inc
files[] = ResourceStreamWrapper.inc
files[] = ResourcePublicStreamWrapper.inc
files[] = ResourcePrivateStreamWrapper.inc
core = 6.x
......@@ -2,6 +2,7 @@
// $Id$
function resource_install() {
variable_set('resource_path', drupal_get_path('module', 'resource'));
drupal_install_schema('resource');
}
......@@ -14,21 +15,21 @@ function resource_enable() {
$path = file_directory_path();
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
$scheme = 'public:';
}
}
else {
$scheme = 'private:';
}
//db_query('INSERT INTO {file_backup} SELECT * FROM {files}');
//db_query('DELETE FROM {files}');
db_query("
INSERT INTO {resource} (rid, uid, name, url, mimetype, size, status, timestamp)
SELECT
SELECT
fid, uid, filename, REPLACE(filepath, '%s', '%s'), filemime, filesize, status, timestamp
FROM {files}
", $path, $scheme);
}
function resource_disable() {
......
This diff is collapsed.
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