You are here

protected function MediaReadOnlyStreamWrapper::_parse_url in D7 Media 7

Same name and namespace in other branches
  1. 7.4 includes/MediaReadOnlyStreamWrapper.inc \MediaReadOnlyStreamWrapper::_parse_url()
  2. 7.2 includes/MediaReadOnlyStreamWrapper.inc \MediaReadOnlyStreamWrapper::_parse_url()
  3. 7.3 includes/MediaReadOnlyStreamWrapper.inc \MediaReadOnlyStreamWrapper::_parse_url()

Returns an array of any parameters stored in the URL's path.

Parameters

$url: The URL to parse, such as youtube://v/[video-code]/t/[tags+more-tags]. @return An associative array of all the parameters in the path, or FALSE if the $url is ill-formed.

2 calls to MediaReadOnlyStreamWrapper::_parse_url()
MediaReadOnlyStreamWrapper::setUri in includes/MediaReadOnlyStreamWrapper.inc
Base implementation of setUri().
MediaReadOnlyStreamWrapper::stream_open in includes/MediaReadOnlyStreamWrapper.inc
Support for fopen(), file_get_contents(), file_put_contents() etc.

File

includes/MediaReadOnlyStreamWrapper.inc, line 171

Class

MediaReadOnlyStreamWrapper
A base class for Resource Stream Wrappers.

Code

protected function _parse_url($url) {
  $path = explode('://', $url);
  $parts = explode('/', $path[1]);
  $params = array();
  $count = 0;
  $total = count($parts);
  if (!$total || $total % 2) {

    // If we have no parts, or an odd number of parts, it's malformed.
    return FALSE;
  }
  while ($count < $total) {

    // We iterate count for each step of the assignment to keep us honest.
    $params[$parts[$count++]] = $parts[$count++];
  }
  return $params;
}