Fixed code duplication for the link's URL generation.
This commit is contained in:
40
syntax.php
40
syntax.php
@@ -205,15 +205,8 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
$link['pre'] = '';
|
$link['pre'] = '';
|
||||||
$link['suf'] = '';
|
$link['suf'] = '';
|
||||||
$link['more'] = '';
|
$link['more'] = '';
|
||||||
$urlparams = '';
|
$link['url'] = $this->_get_link_url ($filepath, $basedir, $webdir, $params['randlinks'], $params['direct']);
|
||||||
if ($params['randlinks']) {
|
|
||||||
$urlparams = '?'.time();
|
|
||||||
}
|
|
||||||
if (!$params['direct']) {
|
|
||||||
$link['url'] = ml(':'.$this->_convert_mediapath($filepath)).$urlparams;
|
|
||||||
} else {
|
|
||||||
$link['url'] = $webdir.substr($filepath, strlen($basedir)).$urlparams;
|
|
||||||
}
|
|
||||||
$link['name'] = $filename;
|
$link['name'] = $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"';
|
||||||
@@ -944,11 +937,8 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
protected function _render_preview_image ($filepath, $basedir, $webdir, $params, Doku_Renderer $renderer) {
|
protected function _render_preview_image ($filepath, $basedir, $webdir, $params, Doku_Renderer $renderer) {
|
||||||
$imagepath = $this->get_preview_image_path($filepath, $params);
|
$imagepath = $this->get_preview_image_path($filepath, $params);
|
||||||
if (!empty($imagepath)) {
|
if (!empty($imagepath)) {
|
||||||
if (!$params['direct']) {
|
$imgLink = $this->_get_link_url ($imagepath, $basedir, $webdir, 0, $params['direct']);
|
||||||
$imgLink = ml(':'.$this->_convert_mediapath($imagepath));
|
|
||||||
} else {
|
|
||||||
$imgLink = $webdir.substr($imagepath, strlen($basedir));
|
|
||||||
}
|
|
||||||
$previewsize = $params['previewsize'];
|
$previewsize = $params['previewsize'];
|
||||||
if ($previewsize == 0) {
|
if ($previewsize == 0) {
|
||||||
$previewsize = 32;
|
$previewsize = 32;
|
||||||
@@ -956,4 +946,26 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
$renderer->doc .= '<img style=" max-height: '.$previewsize.'px; max-width: '.$previewsize.'px;" src="'.$imgLink.'">';
|
$renderer->doc .= '<img style=" max-height: '.$previewsize.'px; max-width: '.$previewsize.'px;" src="'.$imgLink.'">';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create URL for file $filepath.
|
||||||
|
*
|
||||||
|
* @param $filepath the file for which a preview image shall be rendered
|
||||||
|
* @param $basedir the basedir to use
|
||||||
|
* @param $webdir the webdir to use
|
||||||
|
* @param $params the parameters of the filelist call
|
||||||
|
* @return string the generated URL
|
||||||
|
*/
|
||||||
|
protected function _get_link_url ($filepath, $basedir, $webdir, $randlinks, $direct) {
|
||||||
|
$urlparams = '';
|
||||||
|
if ($randlinks) {
|
||||||
|
$urlparams = '?'.time();
|
||||||
|
}
|
||||||
|
if (!$direct) {
|
||||||
|
$url = ml(':'.$this->_convert_mediapath($filepath)).$urlparams;
|
||||||
|
} else {
|
||||||
|
$url = $webdir.substr($filepath, strlen($basedir)).$urlparams;
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user