You are here

public function elFinderVolumeDrupal::drupalpathtouri in elFinder file manager 7.2

Same name and namespace in other branches
  1. 8.2 src/Controller/elFinderVolumeDrupal.php \elFinderVolumeDrupal::drupalpathtouri()
  2. 7.3 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::drupalpathtouri()

Convert path to Drupal file URI

@author Alexey Sukhotin

Parameters

string $path file path:

Return value

string

4 calls to elFinderVolumeDrupal::drupalpathtouri()
elFinderVolumeDrupal::_copy in inc/elfinder.drupalfs.driver.inc
Copy file into another file
elFinderVolumeDrupal::_drupalfileobject in inc/elfinder.drupalfs.driver.inc
Create Drupal file object
elFinderVolumeDrupal::_mkfile in inc/elfinder.drupalfs.driver.inc
Create file
elFinderVolumeDrupal::_move in inc/elfinder.drupalfs.driver.inc
Move file into another parent dir Return new file path or false

File

inc/elfinder.drupalfs.driver.inc, line 38
elFinder driver for Drupal filesystem.

Class

elFinderVolumeDrupal
@file

Code

public function drupalpathtouri($path) {
  $pvtpath = drupal_realpath('private://');
  $pubpath = drupal_realpath('public://');
  $tmppath = drupal_realpath('temporary://');
  $uri = '';
  if (strpos($path, $pvtpath) === 0) {
    $uri = 'private://' . substr($path, strlen($pvtpath) + 1);
  }
  elseif (strpos($path, $tmppath) === 0) {
    $uri = 'temporary://' . substr($path, strlen($tmppath) + 1);
  }
  else {
    $uri = 'public://' . substr($path, strlen($pubpath) + 1);
  }
  return @file_stream_wrapper_uri_normalize($uri);
}