diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php new file mode 100644 index 0000000..0245deb --- /dev/null +++ b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php @@ -0,0 +1,126 @@ +getSystemName()); + } +} \ No newline at end of file diff --git a/core/lib/Drupal/Core/StreamWrapper/ProfileStream.php b/core/lib/Drupal/Core/StreamWrapper/ProfileStream.php new file mode 100644 index 0000000..a21c896 --- /dev/null +++ b/core/lib/Drupal/Core/StreamWrapper/ProfileStream.php @@ -0,0 +1,41 @@ +getSystemName()); + } +} \ No newline at end of file diff --git a/core/lib/Drupal/Core/StreamWrapper/SystemStream.php b/core/lib/Drupal/Core/StreamWrapper/SystemStream.php new file mode 100644 index 0000000..55211d5 --- /dev/null +++ b/core/lib/Drupal/Core/StreamWrapper/SystemStream.php @@ -0,0 +1,61 @@ +uri; + } + list($scheme, $target) = explode('://', $uri, 2); + $pos = strpos($target, '/'); + return $pos === FALSE ? $target : substr($target, 0, $pos); + } + + protected function getTarget($uri = NULL) { + if (!isset($uri)) { + $uri = $this->uri; + } + + list($scheme, $target) = explode('://', $uri, 2); + + // Remove erroneous leading or trailing, forward-slashes and backslashes. + $target = trim($target, '\/'); + + // Remove the module/theme/profile name form the file path. + $target = substr($target, strlen($this->getSystemName())); + + // Trim again. + $target = trim($target, '\/'); + return $target; + } + + /** + * Overrides getExternalUrl(). + * + * Return the HTML URI of a system file. + */ + public function getExternalUrl() { + $dir = $this->getDirectoryPath(); + if (empty($dir)) { + return FALSE; + } + + $path = str_replace('\\', '/', $this->getTarget()); + return $GLOBALS['base_url'] . '/' . $dir . '/' . drupal_encode_path($path); + } +} diff --git a/core/lib/Drupal/Core/StreamWrapper/ThemeStream.php b/core/lib/Drupal/Core/StreamWrapper/ThemeStream.php new file mode 100644 index 0000000..4a632cf --- /dev/null +++ b/core/lib/Drupal/Core/StreamWrapper/ThemeStream.php @@ -0,0 +1,25 @@ +getSystemName()); + } +} \ No newline at end of file diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 94fd3e0..a504801 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1689,6 +1689,24 @@ function system_stream_wrappers() { 'description' => t('Temporary local files for upload and previews.'), 'type' => STREAM_WRAPPERS_LOCAL_HIDDEN, ), + 'module' => array( + 'name' => t('Module files'), + 'class' => 'ModuleSystemStreamWrapper', + 'description' => t('Local module files.'), + 'type' => STREAM_WRAPPERS_READ, + ), + 'theme' => array( + 'name' => t('Theme files'), + 'class' => 'ThemeSystemStreamWrapper', + 'description' => t('Local theme files.'), + 'type' => STREAM_WRAPPERS_READ, + ), + 'profile' => array( + 'name' => t('Profile files'), + 'class' => 'ProfileSystemStreamWrapper', + 'description' => t('Local profile files.'), + 'type' => STREAM_WRAPPERS_READ, + ), ); // Only register the private file stream wrapper if a file path has been set.