Browse Source

add getMediaPathByUri method

main
ghost 9 months ago
parent
commit
26d85269e8
  1. 12
      README.md
  2. 26
      src/Dokuwiki/Filesystem.php

12
README.md

@ -174,6 +174,18 @@ var_dump (
); );
``` ```
#### Filesystem::getMediaPathByUri
Return absolute path to stored media file
```
var_dump (
$filesystem->getMediaPathByUri(
'hello:world'
)
);
```
#### Filesystem::getData #### Filesystem::getData
Return file content if path match storage item Return file content if path match storage item

26
src/Dokuwiki/Filesystem.php

@ -163,7 +163,31 @@ class Filesystem
return $path; return $path;
} }
public function getData(string $path): ?string public function getMediaPathByUri(string $uri): ?string
{
$path = sprintf(
'%s/media/%s',
$this->_path,
str_replace(
':',
'/',
mb_strtolower(
urldecode(
$uri
)
)
)
);
if (!in_array($path, $this->_list) || !is_file($path) || !is_readable($path))
{
return null;
}
return $path;
}
public function getData(?string $path): ?string
{ {
if (in_array($path, $this->_list) && is_file($path) || is_readable($path)) if (in_array($path, $this->_list) && is_file($path) || is_readable($path))
{ {

Loading…
Cancel
Save