tabs -> spaces
This commit is contained in:
386
syntax.php
386
syntax.php
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if(!defined('DOKU_INC'))
|
if(!defined('DOKU_INC'))
|
||||||
define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
|
define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
|
||||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||||
|
|
||||||
require_once(DOKU_PLUGIN.'syntax.php');
|
require_once(DOKU_PLUGIN.'syntax.php');
|
||||||
@@ -23,13 +23,13 @@ define('DOKU_PLUGIN_FILELIST_OUTSIDEJAIL', -2);
|
|||||||
*/
|
*/
|
||||||
class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
||||||
|
|
||||||
var $mediadir;
|
var $mediadir;
|
||||||
|
|
||||||
function syntax_plugin_filelist() {
|
function syntax_plugin_filelist() {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$this->mediadir = rp(DOKU_INC.'/'.$conf['savedir'].'/media').'/';
|
$this->mediadir = rp(DOKU_INC.'/'.$conf['savedir'].'/media').'/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return some info
|
* return some info
|
||||||
@@ -44,55 +44,55 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
'url' => 'http://wiki.foosel.net/snippets/dokuwiki/filelist',
|
'url' => 'http://wiki.foosel.net/snippets/dokuwiki/filelist',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType(){ return 'substition'; }
|
function getType(){ return 'substition'; }
|
||||||
function getPType(){ return 'block'; }
|
function getPType(){ return 'block'; }
|
||||||
function getSort(){ return 222; }
|
function getSort(){ return 222; }
|
||||||
|
|
||||||
function connectTo($mode) {
|
function connectTo($mode) {
|
||||||
$this->Lexer->addSpecialPattern('\{\{filename>.+?\}\}',$mode,'plugin_filelist');
|
$this->Lexer->addSpecialPattern('\{\{filename>.+?\}\}',$mode,'plugin_filelist');
|
||||||
$this->Lexer->addSpecialPattern('\{\{filelist>.+?\}\}',$mode,'plugin_filelist');
|
$this->Lexer->addSpecialPattern('\{\{filelist>.+?\}\}',$mode,'plugin_filelist');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the match
|
* Handle the match
|
||||||
*/
|
*/
|
||||||
function handle($match, $state, $pos, &$handler) {
|
function handle($match, $state, $pos, &$handler) {
|
||||||
|
|
||||||
// do not allow the syntax in comments
|
// do not allow the syntax in comments
|
||||||
if (!$this->getConf('allow_in_comments') && isset($_REQUEST['comment']))
|
if (!$this->getConf('allow_in_comments') && isset($_REQUEST['comment']))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$match = substr($match, 2, -2);
|
$match = substr($match, 2, -2);
|
||||||
list($type, $match) = split('>', $match, 2);
|
list($type, $match) = split('>', $match, 2);
|
||||||
list($pattern, $flags) = split('&', $match, 2);
|
list($pattern, $flags) = split('&', $match, 2);
|
||||||
|
|
||||||
if ($type == 'filename') {
|
if ($type == 'filename') {
|
||||||
if (strpos($flags, '|') !== FALSE) {
|
if (strpos($flags, '|') !== FALSE) {
|
||||||
list($flags, $title) = split('\|', $flags);
|
list($flags, $title) = split('\|', $flags);
|
||||||
} else {
|
} else {
|
||||||
$title = '';
|
$title = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$flags = split('&', $flags);
|
$flags = split('&', $flags);
|
||||||
$params = array(
|
$params = array(
|
||||||
'sort' => 'name',
|
'sort' => 'name',
|
||||||
'order' => 'asc',
|
'order' => 'asc',
|
||||||
'index' => 0,
|
'index' => 0,
|
||||||
'limit' => 0,
|
'limit' => 0,
|
||||||
'offset' => 0,
|
'offset' => 0,
|
||||||
'style' => 'list',
|
'style' => 'list',
|
||||||
'tableheader' => 0,
|
'tableheader' => 0,
|
||||||
'tableshowsize' => 0,
|
'tableshowsize' => 0,
|
||||||
'tableshowdate' => 0,
|
'tableshowdate' => 0,
|
||||||
'direct' => 0,
|
'direct' => 0,
|
||||||
);
|
);
|
||||||
foreach($flags as $flag) {
|
foreach($flags as $flag) {
|
||||||
list($name, $value) = split('=', $flag);
|
list($name, $value) = split('=', $flag);
|
||||||
$params[trim($name)] = trim($value);
|
$params[trim($name)] = trim($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($type, $pattern, $params, $title);
|
return array($type, $pattern, $params, $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,17 +101,17 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
*/
|
*/
|
||||||
function render($mode, &$renderer, $data) {
|
function render($mode, &$renderer, $data) {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$renderer->info['cache'] = false;
|
$renderer->info['cache'] = false;
|
||||||
list($type, $pattern, $params, $title) = $data;
|
list($type, $pattern, $params, $title) = $data;
|
||||||
$files = $this->_create_filelist($pattern, $params);
|
$files = $this->_create_filelist($pattern, $params);
|
||||||
|
|
||||||
if ($files == DOKU_PLUGIN_FILELIST_NOMATCH) {
|
if ($files == DOKU_PLUGIN_FILELIST_NOMATCH) {
|
||||||
$renderer->doc .= '[n/a: ' . $this->getLang('error_nomatch') . ']';
|
$renderer->doc .= '[n/a: ' . $this->getLang('error_nomatch') . ']';
|
||||||
return true;
|
return true;
|
||||||
} else if ($files == DOKU_PLUGIN_FILELIST_OUTSIDEJAIL) {
|
} else if ($files == DOKU_PLUGIN_FILELIST_OUTSIDEJAIL) {
|
||||||
$renderer->doc .= '[n/a: ' . $this->getLang('error_outsidejail') . ']';
|
$renderer->doc .= '[n/a: ' . $this->getLang('error_outsidejail') . ']';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if limit is set for a filelist, cut out the relevant slice from the files
|
// if limit is set for a filelist, cut out the relevant slice from the files
|
||||||
@@ -121,110 +121,110 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
$files['ctimes'] = array_slice($files['ctimes'], $params['offset'], $params['limit']);
|
$files['ctimes'] = array_slice($files['ctimes'], $params['offset'], $params['limit']);
|
||||||
$files['sizes'] = array_slice($files['sizes'], $params['offset'], $params['limit']);
|
$files['sizes'] = array_slice($files['sizes'], $params['offset'], $params['limit']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mode == 'xhtml') {
|
if ($mode == 'xhtml') {
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
|
||||||
case 'filename':
|
case 'filename':
|
||||||
$filename = $files['names'][$params['index']];
|
$filename = $files['names'][$params['index']];
|
||||||
if ($title == '') {
|
if ($title == '') {
|
||||||
$title = basename($filename);
|
$title = basename($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 'filelist':
|
|
||||||
if (count($files['names']) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
$renderer->doc .= '<div class="filelist-plugin">'.DOKU_LF;
|
|
||||||
switch ($params['style']) {
|
|
||||||
case 'list':
|
|
||||||
$renderer->listu_open();
|
|
||||||
foreach ($files['names'] as $filename) {
|
|
||||||
$renderer->listitem_open(1);
|
|
||||||
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
|
||||||
$renderer->listitem_close();
|
|
||||||
}
|
|
||||||
$renderer->listu_close();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'olist':
|
|
||||||
$renderer->listo_open();
|
|
||||||
foreach ($files['names'] as $filename) {
|
|
||||||
$renderer->listitem_open(1);
|
|
||||||
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
|
||||||
$renderer->listitem_close();
|
|
||||||
}
|
|
||||||
$renderer->listo_close();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'table':
|
|
||||||
$renderer->table_open();
|
|
||||||
|
|
||||||
if ($params['tableheader']) {
|
|
||||||
$renderer->tableheader_open();
|
|
||||||
$renderer->doc .= $this->getLang('filename');
|
|
||||||
$renderer->tableheader_close();
|
|
||||||
|
|
||||||
if ($params['tableshowsize']) {
|
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
||||||
$renderer->tableheader_open();
|
return true;
|
||||||
$renderer->doc .= $this->getLang('filesize');
|
|
||||||
$renderer->tableheader_close();
|
case 'filelist':
|
||||||
}
|
if (count($files['names']) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
$renderer->doc .= '<div class="filelist-plugin">'.DOKU_LF;
|
||||||
|
switch ($params['style']) {
|
||||||
|
case 'list':
|
||||||
|
$renderer->listu_open();
|
||||||
|
foreach ($files['names'] as $filename) {
|
||||||
|
$renderer->listitem_open(1);
|
||||||
|
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
||||||
|
$renderer->listitem_close();
|
||||||
|
}
|
||||||
|
$renderer->listu_close();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'olist':
|
||||||
|
$renderer->listo_open();
|
||||||
|
foreach ($files['names'] as $filename) {
|
||||||
|
$renderer->listitem_open(1);
|
||||||
|
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
||||||
|
$renderer->listitem_close();
|
||||||
|
}
|
||||||
|
$renderer->listo_close();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'table':
|
||||||
|
$renderer->table_open();
|
||||||
|
|
||||||
|
if ($params['tableheader']) {
|
||||||
|
$renderer->tableheader_open();
|
||||||
|
$renderer->doc .= $this->getLang('filename');
|
||||||
|
$renderer->tableheader_close();
|
||||||
|
|
||||||
|
if ($params['tableshowsize']) {
|
||||||
|
$renderer->tableheader_open();
|
||||||
|
$renderer->doc .= $this->getLang('filesize');
|
||||||
|
$renderer->tableheader_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params['tableshowdate']) {
|
||||||
|
$renderer->tableheader_open();
|
||||||
|
$renderer->doc .= $this->getLang('lastmodified');
|
||||||
|
$renderer->tableheader_close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < count($files['names']); $i++) {
|
||||||
|
$filename = $files['names'][$i];
|
||||||
|
$filemtime = $files['mtimes'][$i];
|
||||||
|
$filectime = $files['ctimes'][$i];
|
||||||
|
$filesize = $files['sizes'][$i];
|
||||||
|
|
||||||
|
$renderer->tablerow_open();
|
||||||
|
$renderer->tablecell_open();
|
||||||
|
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
||||||
|
$renderer->tablecell_close();
|
||||||
|
|
||||||
|
if ($params['tableshowsize']) {
|
||||||
|
$renderer->tablecell_open(1, 'right');
|
||||||
|
$renderer->doc .= $filesize;
|
||||||
|
$renderer->tablecell_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params['tableshowdate']) {
|
||||||
|
$renderer->tablecell_open();
|
||||||
|
$renderer->doc .= strftime($conf['dformat'], $filemtime);
|
||||||
|
$renderer->tablecell_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
$renderer->tablerow_close();
|
||||||
|
}
|
||||||
|
$renderer->table_close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$renderer->doc .= '</div>'.DOKU_LF;
|
||||||
|
return true;
|
||||||
|
|
||||||
if ($params['tableshowdate']) {
|
|
||||||
$renderer->tableheader_open();
|
|
||||||
$renderer->doc .= $this->getLang('lastmodified');
|
|
||||||
$renderer->tableheader_close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for ($i = 0; $i < count($files['names']); $i++) {
|
|
||||||
$filename = $files['names'][$i];
|
|
||||||
$filemtime = $files['mtimes'][$i];
|
|
||||||
$filectime = $files['ctimes'][$i];
|
|
||||||
$filesize = $files['sizes'][$i];
|
|
||||||
|
|
||||||
$renderer->tablerow_open();
|
|
||||||
$renderer->tablecell_open();
|
|
||||||
$this->_create_link($filename, $files['basedir'], $files['webdir'], $params, $renderer);
|
|
||||||
$renderer->tablecell_close();
|
|
||||||
|
|
||||||
if ($params['tableshowsize']) {
|
|
||||||
$renderer->tablecell_open(1, 'right');
|
|
||||||
$renderer->doc .= $filesize;
|
|
||||||
$renderer->tablecell_close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($params['tableshowdate']) {
|
|
||||||
$renderer->tablecell_open();
|
|
||||||
$renderer->doc .= strftime($conf['dformat'], $filemtime);
|
|
||||||
$renderer->tablecell_close();
|
|
||||||
}
|
|
||||||
|
|
||||||
$renderer->tablerow_close();
|
|
||||||
}
|
|
||||||
$renderer->table_close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$renderer->doc .= '</div>'.DOKU_LF;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the downloadlink for the given filename, based on the given
|
* Creates the downloadlink for the given filename, based on the given
|
||||||
* parameters, and adds it to the output of the renderer.
|
* parameters, and adds it to the output of the renderer.
|
||||||
*/
|
*/
|
||||||
function _create_link($filename, $basedir, $webdir, $params, &$renderer) {
|
function _create_link($filename, $basedir, $webdir, $params, &$renderer) {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
//prepare for formating
|
//prepare for formating
|
||||||
$link['target'] = $conf['target']['extern'];
|
$link['target'] = $conf['target']['extern'];
|
||||||
$link['style'] = '';
|
$link['style'] = '';
|
||||||
@@ -232,105 +232,105 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
$link['suf'] = '';
|
$link['suf'] = '';
|
||||||
$link['more'] = '';
|
$link['more'] = '';
|
||||||
$link['class'] = 'media';
|
$link['class'] = 'media';
|
||||||
if (!$params['direct']) {
|
if (!$params['direct']) {
|
||||||
$link['url'] = ml(':'.str_replace('/', ':', substr($filename, strlen($this->mediadir))));
|
$link['url'] = ml(':'.str_replace('/', ':', substr($filename, strlen($this->mediadir))));
|
||||||
} else {
|
} else {
|
||||||
$link['url'] = $webdir.substr($filename, strlen($basedir));
|
$link['url'] = $webdir.substr($filename, strlen($basedir));
|
||||||
}
|
}
|
||||||
$link['name'] = basename($filename);
|
$link['name'] = basename($filename);
|
||||||
$link['title'] = $renderer->_xmlEntities($link['url']);
|
$link['title'] = $renderer->_xmlEntities($link['url']);
|
||||||
if($conf['relnofollow']) $link['more'] .= ' rel="nofollow"';
|
if($conf['relnofollow']) $link['more'] .= ' rel="nofollow"';
|
||||||
|
|
||||||
list($ext,$mime) = mimetype(basename($filename));
|
list($ext,$mime) = mimetype(basename($filename));
|
||||||
$link['class'] .= ' mediafile mf_'.$ext;
|
$link['class'] .= ' mediafile mf_'.$ext;
|
||||||
|
|
||||||
//output formatted
|
//output formatted
|
||||||
$renderer->doc .= $renderer->_formatLink($link);
|
$renderer->doc .= $renderer->_formatLink($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the filelist based on the given glob-pattern and
|
* Creates the filelist based on the given glob-pattern and
|
||||||
* sorting and ordering parameters.
|
* sorting and ordering parameters.
|
||||||
*/
|
*/
|
||||||
function _create_filelist($pattern, $params) {
|
function _create_filelist($pattern, $params) {
|
||||||
global $conf;
|
global $conf;
|
||||||
global $ID;
|
global $ID;
|
||||||
|
|
||||||
// we don't want to use $conf['media'] here as that path has symlinks resolved
|
// we don't want to use $conf['media'] here as that path has symlinks resolved
|
||||||
|
|
||||||
$files = array(
|
$files = array(
|
||||||
'names' => array(),
|
'names' => array(),
|
||||||
'mtimes' => array(),
|
'mtimes' => array(),
|
||||||
'ctimes' => array(),
|
'ctimes' => array(),
|
||||||
'sizes' => array(),
|
'sizes' => array(),
|
||||||
'basedir' => false,
|
'basedir' => false,
|
||||||
'webdir' => false,
|
'webdir' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$params['direct']) {
|
if (!$params['direct']) {
|
||||||
// if media path is not absolute, precede it with the current namespace
|
// if media path is not absolute, precede it with the current namespace
|
||||||
if (substr($pattern, 0, 1) != ':')
|
if (substr($pattern, 0, 1) != ':')
|
||||||
$pattern = ':'.getNS($ID) . ':' . $pattern;
|
$pattern = ':'.getNS($ID) . ':' . $pattern;
|
||||||
// replace : with / and prepend mediadir
|
// replace : with / and prepend mediadir
|
||||||
$pattern = $this->mediadir . str_replace(':', '/', $pattern);
|
$pattern = $this->mediadir . str_replace(':', '/', $pattern);
|
||||||
} else {
|
} else {
|
||||||
// if path is not absolute, precede it with DOKU_INC
|
// if path is not absolute, precede it with DOKU_INC
|
||||||
if (substr($pattern, 0, 1) != '/')
|
if (substr($pattern, 0, 1) != '/')
|
||||||
$pattern = DOKU_INC.$pattern;
|
$pattern = DOKU_INC.$pattern;
|
||||||
}
|
}
|
||||||
// get the canonicalized basedir (without resolving symlinks)
|
// get the canonicalized basedir (without resolving symlinks)
|
||||||
$dir = rp(dirname($pattern)).'/';
|
$dir = rp(dirname($pattern)).'/';
|
||||||
|
|
||||||
// if the directory is non existant, we of course have no matches
|
// if the directory is non existant, we of course have no matches
|
||||||
if (!$dir || !file_exists($dir))
|
if (!$dir || !file_exists($dir))
|
||||||
return DOKU_PLUGIN_FILELIST_NOMATCH;
|
return DOKU_PLUGIN_FILELIST_NOMATCH;
|
||||||
|
|
||||||
$allowed_absolute_paths = split(',', $this->getConf('allowed_absolute_paths'));
|
$allowed_absolute_paths = split(',', $this->getConf('allowed_absolute_paths'));
|
||||||
$web_paths = split(',', $this->getConf('web_paths'));
|
$web_paths = split(',', $this->getConf('web_paths'));
|
||||||
$basedir = false;
|
$basedir = false;
|
||||||
$webdir = false;
|
$webdir = false;
|
||||||
if (count($allowed_absolute_paths) == count($web_paths)) {
|
if (count($allowed_absolute_paths) == count($web_paths)) {
|
||||||
for($i = 0; $i < count($allowed_absolute_paths); $i++) {
|
for($i = 0; $i < count($allowed_absolute_paths); $i++) {
|
||||||
if (strstr($dir, trim($allowed_absolute_paths[$i])) == $dir) {
|
if (strstr($dir, trim($allowed_absolute_paths[$i]) == $dir) {
|
||||||
$basedir = trim($allowed_absolute_paths[$i]);
|
$basedir = trim($allowed_absolute_paths[$i]);
|
||||||
$webdir = trim($web_paths[$i]);
|
$webdir = trim($web_paths[$i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $basedir is false if $dir was not in one of the allowed paths
|
// $basedir is false if $dir was not in one of the allowed paths
|
||||||
if ($basedir === false)
|
if ($basedir === false)
|
||||||
return DOKU_PLUGIN_FILELIST_OUTSIDEJAIL;
|
return DOKU_PLUGIN_FILELIST_OUTSIDEJAIL;
|
||||||
|
|
||||||
// glob away
|
// glob away
|
||||||
$filenames = @safe_glob($pattern);
|
$filenames = @safe_glob($pattern);
|
||||||
if (!$filenames)
|
if (!$filenames)
|
||||||
return DOKU_PLUGIN_FILELIST_NOMATCH;
|
return DOKU_PLUGIN_FILELIST_NOMATCH;
|
||||||
|
|
||||||
// retrieve fileinformation and filter out directories
|
// retrieve fileinformation and filter out directories
|
||||||
$files['basedir'] = $basedir;
|
$files['basedir'] = $basedir;
|
||||||
$files['webdir'] = $webdir;
|
$files['webdir'] = $webdir;
|
||||||
foreach ($filenames as $filename) {
|
foreach ($filenames as $filename) {
|
||||||
if ($filename[0]=='.') continue; // exclude hidden files
|
if ($filename[0]=='.') continue; // exclude hidden files
|
||||||
$filename = $dir.$filename;
|
$filename = $dir.$filename;
|
||||||
if (is_dir($filename)) continue; // exclude directories
|
if (is_dir($filename)) continue; // exclude directories
|
||||||
if (!$params['direct']) { // exclude prohibited media files via ACLs
|
if (!$params['direct']) { // exclude prohibited media files via ACLs
|
||||||
$mid = str_replace('/', ':', substr($filename, strlen($this->mediadir)));
|
$mid = str_replace('/', ':', substr($filename, strlen($this->mediadir)));
|
||||||
$perm = auth_quickaclcheck($mid);
|
$perm = auth_quickaclcheck($mid);
|
||||||
if ($perm < AUTH_READ) continue;
|
if ($perm < AUTH_READ) continue;
|
||||||
} else { // exclude not readable files
|
} else { // exclude not readable files
|
||||||
if (!is_readable($filename)) continue;
|
if (!is_readable($filename)) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
array_push($files['names'], $filename);
|
array_push($files['names'], $filename);
|
||||||
array_push($files['mtimes'], filemtime($filename));
|
array_push($files['mtimes'], filemtime($filename));
|
||||||
array_push($files['ctimes'], filectime($filename));
|
array_push($files['ctimes'], filectime($filename));
|
||||||
array_push($files['sizes'], filesize($filename));
|
array_push($files['sizes'], filesize($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$reverseflag = false;
|
$reverseflag = false;
|
||||||
if ($params['sort'] == 'mtime') {
|
if ($params['sort'] == 'mtime') {
|
||||||
array_multisort($files['mtimes'], $files['names'], $files['ctimes'], $files['sizes']);
|
array_multisort($files['mtimes'], $files['names'], $files['ctimes'], $files['sizes']);
|
||||||
if ($params['order'] == 'asc') $reverseflag = true;
|
if ($params['order'] == 'asc') $reverseflag = true;
|
||||||
@@ -344,21 +344,19 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
array_multisort($files['names'], $files['ctimes'], $files['mtimes'], $files['sizes']);
|
array_multisort($files['names'], $files['ctimes'], $files['mtimes'], $files['sizes']);
|
||||||
if ($params['order'] == 'desc') $reverseflag = true;
|
if ($params['order'] == 'desc') $reverseflag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reverseflag) {
|
if ($reverseflag) {
|
||||||
$files['names'] = array_reverse($files['names']);
|
$files['names'] = array_reverse($files['names']);
|
||||||
$files['ctimes'] = array_reverse($files['ctimes']);
|
$files['ctimes'] = array_reverse($files['ctimes']);
|
||||||
$files['mtimes'] = array_reverse($files['mtimes']);
|
$files['mtimes'] = array_reverse($files['mtimes']);
|
||||||
$files['sizes'] = array_reverse($files['sizes']);
|
$files['sizes'] = array_reverse($files['sizes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($files['names']) > 0)
|
if (count($files['names']) > 0)
|
||||||
return $files;
|
return $files;
|
||||||
else
|
else
|
||||||
return DOKU_PLUGIN_FILELIST_NOMATCH;
|
return DOKU_PLUGIN_FILELIST_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,12 +384,12 @@ function safe_glob($pattern, $flags=0) {
|
|||||||
return $glob;
|
return $glob;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement for fnmatch() for windows systems.
|
* Replacement for fnmatch() for windows systems.
|
||||||
*
|
*
|
||||||
* @author jk at ricochetsolutions dot com
|
* @author jk at ricochetsolutions dot com
|
||||||
* @see <http://www.php.net/manual/en/function.fnmatch.php#71725>
|
* @see <http://www.php.net/manual/en/function.fnmatch.php#71725>
|
||||||
*/
|
*/
|
||||||
@@ -403,7 +401,7 @@ if(!function_exists('fnmatch')) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Canonicalizes a given path. A bit like realpath, but without the resolving of symlinks.
|
* Canonicalizes a given path. A bit like realpath, but without the resolving of symlinks.
|
||||||
*
|
*
|
||||||
* @author anonymous
|
* @author anonymous
|
||||||
* @see <http://www.php.net/manual/en/function.realpath.php#73563>
|
* @see <http://www.php.net/manual/en/function.realpath.php#73563>
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user