Revision history for ListfilesAction


Revision [23215]

Last edited on 2016-05-20 07:38:47 by JavaWoman [Replaces old-style internal links with new pipe-split links.]
Additions:
This relies of the [[WikkaBugsResolved | ExistsPage]] function developed by JavaWoman and part of release 1.1.6.0. You can find this version at WikkaBugsResolved under the heading "check of user-names against page-names"..
Deletions:
This relies of the [[WikkaBugsResolved ExistsPage]] function developed by JavaWoman and part of release 1.1.6.0. You can find this version at WikkaBugsResolved under the heading "check of user-names against page-names"..


Revision [19182]

Edited on 2008-01-28 00:14:36 by JavaWoman [Modified links pointing to docs server]

No Differences

Revision [16940]

Edited on 2007-05-31 23:27:30 by JavaWoman [Reverted]
Additions:
if ($file != '.' && $file != '..') {
$download_link = "<a href=\"".$upload_path."/".urlencode($file)."\">".$file."</a>";
print $download_link;
print '<br>';
}
closedir($dir);
}
else {
print "<div class=\""."inexistinglist\"".">"; // the upload path does not exist
print "There is no attachement folder linked to this page (".$page.").";
}
}
// the users is not allowed to read the page
else {
print "<div class=\""."errorlist\"".">";
print "You are not allowed to read this page (".$page.").";
}
// the page doesn't exist
else {
print "<div class=\""."errorlist\"".">";
print "The page (".$page.") does not exist.";
print "</div>";
// ***** End MAIN SECTION *****
?>
%%
Then add some nice CSS to the stylesheet file:
%%(css)
.fulllist {
border: 2px solid #CCAAAA;
background-color: #cccccc;
padding: 0px;
margin: 0px;
.emptylist {
.singlelist {
.inexistinglist {
.errorlist{
%%
===To Do===
Nothing I can think about right now.
----
CategoryDevelopmentActions
Deletions:
if ($file != '.'


Revision [16739]

Edited on 2007-05-31 10:43:15 by XdnVsx [Reverted]
Additions:
if ($file != '.'
Deletions:
if ($file != '.' && $file != '..') {
$download_link = "<a href=\"".$upload_path."/".urlencode($file)."\">".$file."</a>";
print $download_link;
print '<br>';
}
closedir($dir);
}
else {
print "<div class=\""."inexistinglist\"".">"; // the upload path does not exist
print "There is no attachement folder linked to this page (".$page.").";
}
}
// the users is not allowed to read the page
else {
print "<div class=\""."errorlist\"".">";
print "You are not allowed to read this page (".$page.").";
}
// the page doesn't exist
else {
print "<div class=\""."errorlist\"".">";
print "The page (".$page.") does not exist.";
print "</div>";
// ***** End MAIN SECTION *****
?>
%%
Then add some nice CSS to the stylesheet file:
%%(css)
.fulllist {
border: 2px solid #CCAAAA;
background-color: #cccccc;
padding: 0px;
margin: 0px;
.emptylist {
.singlelist {
.inexistinglist {
.errorlist{
%%
===To Do===
Nothing I can think about right now.
----
CategoryDevelopmentActions


Revision [8596]

Edited on 2005-05-28 15:46:57 by JavaWoman [move to subcategory]
Additions:
=====Listfiles Action=====

>>==See also:==
Documentation: ListfilesActionInfo.>>This is the development page for the Listfiles action.::c::

This is another (complete) 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.

===Dependancy===
This relies of the [[WikkaBugsResolved ExistsPage]] function developed by JavaWoman and part of release 1.1.6.0. You can find this version at WikkaBugsResolved under the heading "check of user-names against page-names"..

===The code===
%%(php)
<?php
/**
* List the files attached to a page.
*
* @package Actions
* @subpackage tbd
* @name Listfiles
*
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy} (
* @version 0.1
* @since tbd
*
* @input string $page optional: name of a wiki page;
* default: current page
* the user must be allowed to read the page (principle = if you can see the page you can see the attachments)
* @input string $file optional: name of a file;
* default: empty (means all attached files in the page have to be listed)
* @input string $title optional: title that must appear on the link to the file;
* default: empty (means the file name will be displayed as it is)
* this is only used in conjonction with $file
*
* @output list all the wished files and provide an anchor to get them;
* CSS classes used for the output:
* -emptylist if the upload path is empty
* -fulllist if the upload path contains attachements
* -singlelist if there is only one file to be listed
* -inexistinglist if the upload path does not exist
* -errorlist if the page or the file does not exist, if the users is not allowed to read the page
*
* @todo nothing I can think about right now;
* this action comes nicely with the attachment mini-action and the files handler
*/

// ***** PARAMETERS Interface *****
$uPage = $vars['page'];
if ($uPage) $page = $uPage;
else $page = $this->GetPageTag();

$uFile = $vars['file'];
if ($uFile) $file = $uFile;

// it is not useful to provide a title if there is no file parameter
if ($file) {
$uTitle = $vars['title'];
if ($uTitle) $title = $uTitle;
}
// ***** End PARAMETERS Interface *****

// ***** MAIN SECTION *****
// check if the page exists (the function exists from wikka 1.1.6.0)
if ($this->ExistsPage($page)) {
// check if the user is allowed to read
if ($this->HasAccess('read', $page)) {
// upload path
$upload_path = $this->config['upload_path'].'/'.$page;
// check if the upload path does not exist
if(is_dir($upload_path) ){
$handle = opendir($upload_path);
while( (gettype( $name = readdir($handle)) != "boolean")){
$name_array[] = $name;
}
foreach($name_array as $temp) $folder_content .= $temp;
closedir($handle);
if($folder_content == "...") {
print "<div class=\""."emptylist\"".">"; // the upload path is empty
print "There are no files attached to this page.";
} else {
// uploaded files
$dir = opendir($upload_path);
// if a file parameter has been provided
if ($file) {
$pathandfile = $upload_path."/".urlencode($file);
if (file_exists($pathandfile)) {
print "<div class=\""."singlelist\"".">"; // only one file to list
if ($title) $thetitle = $title;
else $thetitle = $file;
$download_link = "<a href=\"".$pathandfile."\">".$thetitle."</a>";
print $download_link;
}
else {
print "<div class=\""."errorlist\"".">";
print "The file (".$file.") does not exist on this page (".$page.").";
}
}
// all files have to be listed
else {
print "<div class=\""."fulllist\"".">"; // the upload path contains attachements
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$download_link = "<a href=\"".$upload_path."/".urlencode($file)."\">".$file."</a>";
print $download_link;
print '<br>';
}
}
}
closedir($dir);
}
}
else {
print "<div class=\""."inexistinglist\"".">"; // the upload path does not exist
print "There is no attachement folder linked to this page (".$page.").";
}
}
// the users is not allowed to read the page
else {
print "<div class=\""."errorlist\"".">";
print "You are not allowed to read this page (".$page.").";
}
}
// the page doesn't exist
else {
print "<div class=\""."errorlist\"".">";
print "The page (".$page.") does not exist.";
}
print "</div>";
// ***** End MAIN SECTION *****
?>
%%

Then add some nice CSS to the stylesheet file:
%%(css)
.fulllist {
border: 2px solid #CCAAAA;
background-color: #cccccc;
padding: 0px;
margin: 0px;
}
.emptylist {
}
.singlelist {
}
.inexistinglist {
}
.errorlist{
}
%%

===To Do===
Nothing I can think about right now.

----
CategoryDevelopmentActions
Deletions:
=====Listfiles Action=====

>>==See also:==
Documentation: ListfilesActionInfo.>>This is the development page for the Listfiles action.::c::

This is another (complete) 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.

===Dependancy===
This relies of the [[WikkaBugsResolved ExistsPage]] function developed by JavaWoman and part of release 1.1.6.0. You can find this version at WikkaBugsResolved under the heading "check of user-names against page-names"..

===The code===
%%(php)
<?php
/**
* List the files attached to a page.
*
* @package Actions
* @subpackage tbd
* @name Listfiles
*
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy} (
* @version 0.1
* @since tbd
*
* @input string $page optional: name of a wiki page;
* default: current page
* the user must be allowed to read the page (principle = if you can see the page you can see the attachments)
* @input string $file optional: name of a file;
* default: empty (means all attached files in the page have to be listed)
* @input string $title optional: title that must appear on the link to the file;
* default: empty (means the file name will be displayed as it is)
* this is only used in conjonction with $file
*
* @output list all the wished files and provide an anchor to get them;
* CSS classes used for the output:
* -emptylist if the upload path is empty
* -fulllist if the upload path contains attachements
* -singlelist if there is only one file to be listed
* -inexistinglist if the upload path does not exist
* -errorlist if the page or the file does not exist, if the users is not allowed to read the page
*
* @todo nothing I can think about right now;
* this action comes nicely with the attachment mini-action and the files handler
*/

// ***** PARAMETERS Interface *****
$uPage = $vars['page'];
if ($uPage) $page = $uPage;
else $page = $this->GetPageTag();

$uFile = $vars['file'];
if ($uFile) $file = $uFile;

// it is not useful to provide a title if there is no file parameter
if ($file) {
$uTitle = $vars['title'];
if ($uTitle) $title = $uTitle;
}
// ***** End PARAMETERS Interface *****

// ***** MAIN SECTION *****
// check if the page exists (the function exists from wikka 1.1.6.0)
if ($this->ExistsPage($page)) {
// check if the user is allowed to read
if ($this->HasAccess('read', $page)) {
// upload path
$upload_path = $this->config['upload_path'].'/'.$page;
// check if the upload path does not exist
if(is_dir($upload_path) ){
$handle = opendir($upload_path);
while( (gettype( $name = readdir($handle)) != "boolean")){
$name_array[] = $name;
}
foreach($name_array as $temp) $folder_content .= $temp;
closedir($handle);
if($folder_content == "...") {
print "<div class=\""."emptylist\"".">"; // the upload path is empty
print "There are no files attached to this page.";
} else {
// uploaded files
$dir = opendir($upload_path);
// if a file parameter has been provided
if ($file) {
$pathandfile = $upload_path."/".urlencode($file);
if (file_exists($pathandfile)) {
print "<div class=\""."singlelist\"".">"; // only one file to list
if ($title) $thetitle = $title;
else $thetitle = $file;
$download_link = "<a href=\"".$pathandfile."\">".$thetitle."</a>";
print $download_link;
}
else {
print "<div class=\""."errorlist\"".">";
print "The file (".$file.") does not exist on this page (".$page.").";
}
}
// all files have to be listed
else {
print "<div class=\""."fulllist\"".">"; // the upload path contains attachements
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$download_link = "<a href=\"".$upload_path."/".urlencode($file)."\">".$file."</a>";
print $download_link;
print '<br>';
}
}
}
closedir($dir);
}
}
else {
print "<div class=\""."inexistinglist\"".">"; // the upload path does not exist
print "There is no attachement folder linked to this page (".$page.").";
}
}
// the users is not allowed to read the page
else {
print "<div class=\""."errorlist\"".">";
print "You are not allowed to read this page (".$page.").";
}
}
// the page doesn't exist
else {
print "<div class=\""."errorlist\"".">";
print "The page (".$page.") does not exist.";
}
print "</div>";
// ***** End MAIN SECTION *****
?>
%%

Then add some nice CSS to the stylesheet file:
%%(css)
.fulllist {
border: 2px solid #CCAAAA;
background-color: #cccccc;
padding: 0px;
margin: 0px;
}
.emptylist {
}
.singlelist {
}
.inexistinglist {
}
.errorlist{
}
%%

===To Do===
Nothing I can think about right now.

----
CategoryDevelopment


Revision [4552]

Edited on 2005-01-12 22:12:34 by ChristianBarthelemy [Files management part 2 (with some css)]
Additions:
Then add some nice CSS to the stylesheet file:
%%(css)
.fulllist {
border: 2px solid #CCAAAA;
background-color: #cccccc;
padding: 0px;
margin: 0px;
.emptylist {
.singlelist {
.inexistinglist {
.errorlist{


Revision [4546]

Edited on 2005-01-12 21:49:33 by ChristianBarthelemy [Files management part 2]
Additions:
=====Listfiles Action=====
>>==See also:==
Documentation: ListfilesActionInfo.>>This is the development page for the Listfiles action.::c::
This is another (complete) transformation of the files action from Mod015fFilesAction (check also the FilesManagementHandler).
===Dependancy===
This relies of the [[WikkaBugsResolved ExistsPage]] function developed by JavaWoman and part of release 1.1.6.0. You can find this version at WikkaBugsResolved under the heading "check of user-names against page-names"..
===The code===
/**
* List the files attached to a page.
*
* @package Actions
* @subpackage tbd
* @name Listfiles
*
* @author {@link http://wikka.jsnx.com/ChristianBarthelemy} (
* @version 0.1
* @since tbd
*
* @input string $page optional: name of a wiki page;
* default: current page
* the user must be allowed to read the page (principle = if you can see the page you can see the attachments)
* @input string $file optional: name of a file;
* default: empty (means all attached files in the page have to be listed)
* @input string $title optional: title that must appear on the link to the file;
* default: empty (means the file name will be displayed as it is)
* this is only used in conjonction with $file
*
* @output list all the wished files and provide an anchor to get them;
* CSS classes used for the output:
* -emptylist if the upload path is empty
* -fulllist if the upload path contains attachements
* -singlelist if there is only one file to be listed
* -inexistinglist if the upload path does not exist
* -errorlist if the page or the file does not exist, if the users is not allowed to read the page
*
* @todo nothing I can think about right now;
* this action comes nicely with the attachment mini-action and the files handler
*/

// ***** PARAMETERS Interface *****
$uPage = $vars['page'];
if ($uPage) $page = $uPage;
else $page = $this->GetPageTag();
$uFile = $vars['file'];
if ($uFile) $file = $uFile;
// it is not useful to provide a title if there is no file parameter
if ($file) {
$uTitle = $vars['title'];
if ($uTitle) $title = $uTitle;
// ***** End PARAMETERS Interface *****
// ***** MAIN SECTION *****
// check if the page exists (the function exists from wikka 1.1.6.0)
if ($this->ExistsPage($page)) {
// check if the user is allowed to read
if ($this->HasAccess('read', $page)) {
// upload path
$upload_path = $this->config['upload_path'].'/'.$page;
// check if the upload path does not exist
if(is_dir($upload_path) ){
$handle = opendir($upload_path);
while( (gettype( $name = readdir($handle)) != "boolean")){
$name_array[] = $name;
}
foreach($name_array as $temp) $folder_content .= $temp;
closedir($handle);
if($folder_content == "...") {
print "<div class=\""."emptylist\"".">"; // the upload path is empty
print "There are no files attached to this page.";
} else {
// uploaded files
$dir = opendir($upload_path);
// if a file parameter has been provided
if ($file) {
$pathandfile = $upload_path."/".urlencode($file);
if (file_exists($pathandfile)) {
print "<div class=\""."singlelist\"".">"; // only one file to list
if ($title) $thetitle = $title;
else $thetitle = $file;
$download_link = "<a href=\"".$pathandfile."\">".$thetitle."</a>";
print $download_link;
}
else {
print "<div class=\""."errorlist\"".">";
print "The file (".$file.") does not exist on this page (".$page.").";
}
}
// all files have to be listed
else {
print "<div class=\""."fulllist\"".">"; // the upload path contains attachements
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$download_link = "<a href=\"".$upload_path."/".urlencode($file)."\">".$file."</a>";
print $download_link;
print '<br>';
}
}
}
closedir($dir);
}
print "<div class=\""."inexistinglist\"".">"; // the upload path does not exist
print "There is no attachement folder linked to this page (".$page.").";
}
// the users is not allowed to read the page
else {
print "<div class=\""."errorlist\"".">";
print "You are not allowed to read this page (".$page.").";
}
// the page doesn't exist
else {
print "<div class=\""."errorlist\"".">";
print "The page (".$page.") does not exist.";
print "</div>";
// ***** End MAIN SECTION *****
%%
===To Do===
Nothing I can think about right now.
----
CategoryDevelopment
Deletions:
====An action to list the files attached to the WikiPage====
This is another transformation of the files action from Mod015fFilesAction (check also the FilesManagementHandler).
This action uses the handlers files.xml.php from the FilesAction. Once the handler is in place you need to create the below listfiles.php and place it in the actions folder:
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);
print "There are no files attached to this page.";
%%


Revision [3616]

Edited on 2004-12-22 17:02:45 by ChristianBarthelemy [Precision on the code to be reused from FilesAction]
Additions:
This action uses the handlers files.xml.php from the FilesAction. Once the handler is in place you need to create the below listfiles.php and place it in the actions folder:
Deletions:
Apply Mod015fFilesAction and create the below listfiles.php to be placed in the actions folder


Revision [3611]

The oldest known version of this page was created on 2004-12-22 12:39:25 by ChristianBarthelemy [Precision on the code to be reused from FilesAction]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki