Revision [3611]
This is an old revision of ListfilesAction made by ChristianBarthelemy on 2004-12-22 12:39:25.
An action to list the files attached to the WikiPage
This is another transformation of the files action from Mod015fFilesAction (check also the FilesManagementHandler).
It allows to get the links to the attached files but not to upload nor to delete any.
Apply Mod015fFilesAction and create the below listfiles.php to be placed in the actions folder
<?php
if ($download <> '') {
// link to download a file
if ($text == '') $text = $download;
echo "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=download&file='.urlencode($download))."\">".$text."</a>";
} elseif ($this->page AND ($this->method <> 'print.xml') AND ($this->method <> 'edit')) {
// upload path
if ($this->config['upload_path'] == '') $this->config['upload_path'] = 'files';
$upload_path = $this->config['upload_path'].'/'.$this->GetPageTag();
if (is_dir($upload_path)) {
// form
$result = "<form action=\"".$this->href()."\" method=\"post\" enctype=\"multipart/form-data\">\n";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref()."\">\n";
echo $result;
echo $this->FormClose();
// uploaded files
$dir = opendir($upload_path);
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$download_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=download&file='.urlencode($file))."\">".$file."</a>";
if ($file == $uploaded['name'])
print "<em>{$download_link}</em>\n";
else
print $download_link;
print '<br>';
}
}
closedir($dir);
}
else {
print "There are no files attached to this page.";
}
}
?>
if ($download <> '') {
// link to download a file
if ($text == '') $text = $download;
echo "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=download&file='.urlencode($download))."\">".$text."</a>";
} elseif ($this->page AND ($this->method <> 'print.xml') AND ($this->method <> 'edit')) {
// upload path
if ($this->config['upload_path'] == '') $this->config['upload_path'] = 'files';
$upload_path = $this->config['upload_path'].'/'.$this->GetPageTag();
if (is_dir($upload_path)) {
// form
$result = "<form action=\"".$this->href()."\" method=\"post\" enctype=\"multipart/form-data\">\n";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref()."\">\n";
echo $result;
echo $this->FormClose();
// uploaded files
$dir = opendir($upload_path);
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$download_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=download&file='.urlencode($file))."\">".$file."</a>";
if ($file == $uploaded['name'])
print "<em>{$download_link}</em>\n";
else
print $download_link;
print '<br>';
}
}
closedir($dir);
}
else {
print "There are no files attached to this page.";
}
}
?>