You are here

abstract class SystemStreamWrapper in System stream wrapper 7

Drupal system stream wrapper abstract class.

Hierarchy

Expanded class hierarchy of SystemStreamWrapper

File

./SystemStreamWrapper.inc, line 6

View source
abstract class SystemStreamWrapper extends DrupalLocalStreamWrapper {

  /**
   * Get the module, theme, or profile name of the current URI.
   */
  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);

    // Remove erroneous leading or trailing, forward-slashes and backslashes.
    $target = trim($target, '\\/');

    // Remove the module/theme/profile name form the file path. This is always
    // the first part of the path.
    $target = explode('/', $target);
    array_shift($target);
    $target = implode('/', $target);

    // Trim again.
    $target = trim($target, '\\/');
    return $target;
  }

  /**
   * Gets the path that the wrapper is responsible for.
   *
   * @return
   *   String specifying the path.
   */

  //abstract public function getDirectoryPath();

  /**
   * 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);
  }

  /**
   * DrupalStreamWrapperInterface requires that these methods be implemented,
   * but none of them apply to a read-only stream wrapper. On failure they
   * are expected to return FALSE.
   */
  public function stream_write($data) {
    return FALSE;
  }
  public function unlink($uri) {

    // Although the remote file itself can't be deleted, return TRUE so that
    // file_delete() can remove the file record from the database.
    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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalLocalStreamWrapper::$context public property Stream context resource.
DrupalLocalStreamWrapper::$handle public property A generic resource handle.
DrupalLocalStreamWrapper::$uri protected property Instance URI (stream).
DrupalLocalStreamWrapper::dir_closedir public function Support for closedir(). Overrides StreamWrapperInterface::dir_closedir
DrupalLocalStreamWrapper::dir_opendir public function Support for opendir(). Overrides StreamWrapperInterface::dir_opendir
DrupalLocalStreamWrapper::dir_readdir public function Support for readdir(). Overrides StreamWrapperInterface::dir_readdir
DrupalLocalStreamWrapper::dir_rewinddir public function Support for rewinddir(). Overrides StreamWrapperInterface::dir_rewinddir
DrupalLocalStreamWrapper::getDirectoryPath abstract function Gets the path that the wrapper is responsible for. @TODO: Review this method name in D8 per http://drupal.org/node/701358 4
DrupalLocalStreamWrapper::getLocalPath protected function Returns the canonical absolute path of the URI, if possible.
DrupalLocalStreamWrapper::getMimeType static function Base implementation of getMimeType(). Overrides DrupalStreamWrapperInterface::getMimeType
DrupalLocalStreamWrapper::getUri function Base implementation of getUri(). Overrides DrupalStreamWrapperInterface::getUri
DrupalLocalStreamWrapper::realpath function Base implementation of realpath(). Overrides DrupalStreamWrapperInterface::realpath 1
DrupalLocalStreamWrapper::setUri function Base implementation of setUri(). Overrides DrupalStreamWrapperInterface::setUri
DrupalLocalStreamWrapper::stream_cast public function Retrieve the underlying stream resource.
DrupalLocalStreamWrapper::stream_close public function Support for fclose(). Overrides StreamWrapperInterface::stream_close
DrupalLocalStreamWrapper::stream_eof public function Support for feof(). Overrides StreamWrapperInterface::stream_eof
DrupalLocalStreamWrapper::stream_flush public function Support for fflush(). Overrides StreamWrapperInterface::stream_flush
DrupalLocalStreamWrapper::stream_lock public function Support for flock(). Overrides StreamWrapperInterface::stream_lock
DrupalLocalStreamWrapper::stream_metadata public function Sets metadata on the stream.
DrupalLocalStreamWrapper::stream_open public function Support for fopen(), file_get_contents(), file_put_contents() etc. Overrides StreamWrapperInterface::stream_open
DrupalLocalStreamWrapper::stream_read public function Support for fread(), file_get_contents() etc. Overrides StreamWrapperInterface::stream_read
DrupalLocalStreamWrapper::stream_seek public function Support for fseek(). Overrides StreamWrapperInterface::stream_seek
DrupalLocalStreamWrapper::stream_set_option public function Change stream options.
DrupalLocalStreamWrapper::stream_stat public function Support for fstat(). Overrides StreamWrapperInterface::stream_stat
DrupalLocalStreamWrapper::stream_tell public function Support for ftell(). Overrides StreamWrapperInterface::stream_tell
DrupalLocalStreamWrapper::stream_truncate public function Truncate stream.
DrupalLocalStreamWrapper::url_stat public function Support for stat(). Overrides StreamWrapperInterface::url_stat
SystemStreamWrapper::chmod public function Base implementation of chmod(). Overrides DrupalLocalStreamWrapper::chmod
SystemStreamWrapper::dirname public function Gets the name of the directory from a given path. Overrides DrupalLocalStreamWrapper::dirname
SystemStreamWrapper::getExternalUrl public function Overrides getExternalUrl(). Overrides DrupalStreamWrapperInterface::getExternalUrl
SystemStreamWrapper::getSystemName protected function Get the module, theme, or profile name of the current URI. 2
SystemStreamWrapper::getTarget protected function Returns the local writable target of the resource within the stream. Overrides DrupalLocalStreamWrapper::getTarget
SystemStreamWrapper::mkdir public function Support for mkdir(). Overrides DrupalLocalStreamWrapper::mkdir
SystemStreamWrapper::rename public function Support for rename(). Overrides DrupalLocalStreamWrapper::rename
SystemStreamWrapper::rmdir public function Support for rmdir(). Overrides DrupalLocalStreamWrapper::rmdir
SystemStreamWrapper::stream_write public function DrupalStreamWrapperInterface requires that these methods be implemented, but none of them apply to a read-only stream wrapper. On failure they are expected to return FALSE. Overrides DrupalLocalStreamWrapper::stream_write
SystemStreamWrapper::unlink public function Support for unlink(). Overrides DrupalLocalStreamWrapper::unlink