Moved media id conversion to utility function and called it at appropriate locations
This commit is contained in:
13
syntax.php
13
syntax.php
@@ -204,7 +204,7 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
$link['more'] = '';
|
$link['more'] = '';
|
||||||
$link['class'] = 'media';
|
$link['class'] = 'media';
|
||||||
if (!$params['direct']) {
|
if (!$params['direct']) {
|
||||||
$link['url'] = ml(':'.str_replace('/', ':', substr($filepath, strlen($this->mediadir))));
|
$link['url'] = ml(':'.$this->_convert_mediapath($filepath));
|
||||||
} else {
|
} else {
|
||||||
$link['url'] = $webdir.substr($filepath, strlen($basedir));
|
$link['url'] = $webdir.substr($filepath, strlen($basedir));
|
||||||
}
|
}
|
||||||
@@ -612,8 +612,8 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
|
|
||||||
if (!$params['direct']) {
|
if (!$params['direct']) {
|
||||||
// exclude prohibited media files via ACLs
|
// exclude prohibited media files via ACLs
|
||||||
$mid = str_replace('/', ':', substr($filepath, strlen($this->mediadir)));
|
$mid = $this->_convert_mediapath($filepath);
|
||||||
$perm = auth_quickaclcheck(ltrim($mid,":"));
|
$perm = auth_quickaclcheck($mid);
|
||||||
if ($perm < AUTH_READ) continue;
|
if ($perm < AUTH_READ) continue;
|
||||||
} else {
|
} else {
|
||||||
if (!is_readable($filepath)) continue;
|
if (!is_readable($filepath)) continue;
|
||||||
@@ -623,7 +623,7 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
if (is_dir($filepath)) {
|
if (is_dir($filepath)) {
|
||||||
$titlefile = $filepath . '/' . $params['titlefile'];
|
$titlefile = $filepath . '/' . $params['titlefile'];
|
||||||
if (!$params['direct']) {
|
if (!$params['direct']) {
|
||||||
$mid = str_replace('/', ':', substr($titlefile, strlen($this->mediadir)));
|
$mid = $this->_convert_mediapath($titlefile);
|
||||||
$perm = auth_quickaclcheck($mid);
|
$perm = auth_quickaclcheck($mid);
|
||||||
if (is_readable($titlefile) && $perm >= AUTH_READ) {
|
if (is_readable($titlefile) && $perm >= AUTH_READ) {
|
||||||
$filename = io_readFile($titlefile, false);
|
$filename = io_readFile($titlefile, false);
|
||||||
@@ -793,5 +793,10 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
return ($path[0] == '/');
|
return ($path[0] == '/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _convert_mediapath($path) {
|
||||||
|
$mid = str_replace('/', ':', substr($path, strlen($this->mediadir))); // strip media base dir
|
||||||
|
return ltrim($mid, ':'); // strip leading :
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user