X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=plugins%2FFileList.php;h=2399b79cd5ef66f4b35e22b66de7a68e233e390d;hb=c03ed8e37e5664ba33ab246676cdf01ab0afc8ad;hp=07acbfd03106ac98b0e2c2a8f6824529077a95b7;hpb=b2c16bf312cd037e252e568974a5523407e42099;p=diogenes.git diff --git a/plugins/FileList.php b/plugins/FileList.php index 07acbfd..2399b79 100644 --- a/plugins/FileList.php +++ b/plugins/FileList.php @@ -35,17 +35,9 @@ class FileList extends Diogenes_Plugin_Filter { /** Plugin description */ var $description = "This plugin allows you to insert a directory listing with icons and modification date. To make use of this plugin, insert {FileList} in your page where the file list should appear."; - - /** Constructor. - */ - function FileList() - { - global $page; - $this->declareParam('dirbase', ''); - $this->declareParam('urlbase', ''); - $this->declareParam('match', ''); - } - + /** Plugin parameters */ + var $params = array('dirbase' => "", 'urlbase' => "", 'match' => ""); + /** Prepare the output for a single file of the list. * @@ -93,7 +85,7 @@ class FileList extends Diogenes_Plugin_Filter { /* display the link */ if ($show) - return "$title$modified$size$desc\n"; + return "\"file\"$title$modified$size$desc\n"; } @@ -105,21 +97,21 @@ class FileList extends Diogenes_Plugin_Filter { { global $page; $bbarel = $page->barrel; - + // process arguments - $instance_vals = array(); - foreach($this->getParamNames() as $key) { - $instance_vals[$key] = isset($args[$key]) ? $args[key] : $this->getParamValue($key); + $params = array(); + foreach($this->params as $key => $val) { + $params[$key] = isset($args[$key]) ? $args[$key] : $this->params[$key]; } - //print_r($instance_vals); - if (empty($instance_vals['dirbase'])) { - $instance_vals['dirbase'] = $bbarel->spool->spoolPath($page->curpage->props['PID']); + //print_r($params); + if (empty($params['dirbase'])) { + $params['dirbase'] = $bbarel->spool->spoolPath($page->curpage->props['PID']); } // process parameters $output = ''; - $dir = $instance_vals['dirbase']; + $dir = $params['dirbase']; if (is_dir($dir) && ($dh = opendir($dir))) { $output .= ' @@ -133,7 +125,7 @@ class FileList extends Diogenes_Plugin_Filter { /* get the matching files */ while (($fname = readdir($dh)) !== false) { if ( is_file("$dir/$fname") - && preg_match('/^'.$instance_vals['match'].'/',$fname) ) + && preg_match('/^'.$params['match'].'/',$fname) ) $filelist[] = $fname; } closedir($dh); @@ -142,7 +134,7 @@ class FileList extends Diogenes_Plugin_Filter { if (is_array($filelist)) { rsort($filelist); while(list ($key,$val) = each($filelist)) { - $output .= $this->list_file("$dir/$val",$val,$instance_vals['urlbase'].$val); + $output .= $this->list_file("$dir/$val",$val,$params['urlbase'].$val); } } else { $output .= '';
'.__("no files").'