SystemStreamWrapper.inc in System stream wrapper 7
File
SystemStreamWrapper.inc
View source
<?php
abstract class SystemStreamWrapper extends DrupalLocalStreamWrapper {
protected function getSystemName($uri = NULL) {
if (!isset($uri)) {
$uri = $this->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);
$target = trim($target, '\\/');
$target = explode('/', $target);
array_shift($target);
$target = implode('/', $target);
$target = trim($target, '\\/');
return $target;
}
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);
}
public function stream_write($data) {
return FALSE;
}
public function unlink($uri) {
return TRUE;
}
public function rename($from_uri, $to_uri) {
return FALSE;
}
public function mkdir($uri, $mode, $options) {
return FALSE;
}
public function rmdir($uri, $options) {
return FALSE;
}
public function chmod($mode) {
return FALSE;
}
public function dirname($uri = NULL) {
return FALSE;
}
}
class ModuleSystemStreamWrapper extends SystemStreamWrapper {
public function getDirectoryPath() {
return drupal_get_path('module', $this
->getSystemName());
}
}
class ThemeSystemStreamWrapper extends SystemStreamWrapper {
protected function getSystemName($uri = NULL) {
$name = parent::getSystemName($uri);
if ($name == 'current') {
return $GLOBALS['theme'];
}
elseif ($name == 'default') {
return variable_get('theme_default', 'stark');
}
elseif ($name == 'admin') {
return variable_get('admin_theme', variable_get('theme_default', 'stark'));
}
else {
return $name;
}
}
public function getDirectoryPath() {
return drupal_get_path('theme', $this
->getSystemName());
}
}
class ProfileSystemStreamWrapper extends SystemStreamWrapper {
protected function getSystemName($uri = NULL) {
$name = parent::getSystemName($uri);
if ($name == 'current') {
return drupal_get_profile();
}
else {
return $name;
}
}
public function getDirectoryPath() {
if ($profile = $this
->getSystemName()) {
return 'profiles/' . $profile;
}
}
}
class LibrarySystemStreamWrapper extends SystemStreamWrapper {
public function getDirectoryPath() {
if ($library = $this
->getSystemName()) {
return libraries_get_path($library);
}
}
}