DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:directorylist

directorylist Plugin

Compatible with DokuWiki

Binky, 2013-12-08

plugin Specify a directory and this plugin will list all contained items and make them downloadable.

Last updated on
2016-02-04
Provides
Syntax, Action
Repository
Source

Similar to filelist

Tagged with directory, files, filesystem, intranet

About

Specify a directory and this plugin will list all contained items and made them downloadable.

This is mostly used for intranets.

Contact me if anything.

Installation & Usage

Please visit the github page for detailed information!

https://github.com/alexwenzel/dokuwiki-plugin-directorylist

Discussion

The plugin currently only supports the 'download' hyperref option, which means that all links result in a downloaded file.

By adding a new argument, 'type', and slightly altering the formatLink() function we can support direct links.

I've done a slight hack to get the correct url path.

Below is the diff output for my changes on the directorylist/syntax/directorylist.php file.

107,110d106
<                       // check and set default: type argument
<                       if ( ! isset($data['type']) || empty($data['type']) ) 
<                               $data['type'] = 'link';
< 
161c157
<                                       $this->renderer->doc .= '<li class="file">'.$this->formatLink($value,$data).$this->formatBytes($value).'</li>';
---
>                                       $this->renderer->doc .= '<li class="file">'.$this->formatLink($value).$this->formatBytes($value).'</li>';
210,212d205
< 
< 
< 
218c211
<       private function formatLink(SplFileInfo $file, array $data)
---
>       private function formatLink(SplFileInfo $file)
220,238c213,214
<               global $conf;
< 
<               $link  = '<a href="';
<               if( $data['type']=='download' ) {
<                   $link .= '?do=download&file='.rawurlencode($file->getRealPath());
<               } else if( $data['type']=='direct' ) {
<                   $link .= 'file://'.$file->getRealPath();
<               } else if ($data['type']=='link'){
<                   $startpos = strpos( $file->getRealPath(), $conf['basedir'] );
<                   $link .= $conf['baseurl'].substr( $file->getRealPath(), $startpos);
<               } else {
<                   $link .= '';
<               }
<               $link .= '"';
<               if( $data['type']=='download' ) {
<                   $link .= ' target="_blank"';
<               }
<               $link .= ' title="'.$file->getFilename().'"';
<               $link .= '>';
---
>               $link = '<a href="?do=download&file='.rawurlencode($file->getRealPath()).'" target="_blank" ';
>               $link .= 'title="'.$file->getFilename().'">';

simon.wsimon.w

2015-06-02 16:27

Hi, I have accepted your pull request. Thank you

alexwenzel

plugin/directorylist.txt · Last modified: 2016-02-05 11:11 by 2a02:8109:8a40:12a0:14d2:6d00:f940:f890