Revision history for FilesHandler


Revision [19309]

Last edited on 2008-01-28 00:14:45 by MasinAlDujaili [Modified links pointing to docs server]

No Differences

Revision [17245]

Edited on 2007-07-08 13:40:46 by MasinAlDujaili [line numbers]
Additions:
%%(php;1)
function mkdir_r ($dir) {
if (strlen($dir) == 0) return 0;
if (is_dir($dir)) return 1;
elseif (dirname($dir) == $dir) return 1;
return (mkdir_r(dirname($dir)) and mkdir($dir,0755));
// 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>";
// 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)) mkdir_r($upload_path);
// upload action
$uploaded = $_FILES['file'];
if ($_REQUEST['action'] == 'upload' AND $uploaded['size'] > 0)
copy ($uploaded['tmp_name'], $upload_path.'/'.$uploaded['name']);
// form
$result = "<form action=\"".$this->href()."/files\" method=\"post\" enctype=\"multipart/form-data\">\n";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref()."/files\">\n";
echo $result;
if ($this->HasAccess('write'))
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>";
print "[ {$delete_link} ] ";
if ($file == $uploaded['name'])
print "<em>{$download_link}</em>\n";
print $download_link;
print '<br>';
}
closedir($dir);
Deletions:
%%(php)
function mkdir_r ($dir) {
if (strlen($dir) == 0) return 0;
if (is_dir($dir)) return 1;
elseif (dirname($dir) == $dir) return 1;
return (mkdir_r(dirname($dir)) and mkdir($dir,0755));
}
// 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>";
// 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)) mkdir_r($upload_path);
// upload action
$uploaded = $_FILES['file'];
if ($_REQUEST['action'] == 'upload' AND $uploaded['size'] > 0)
copy ($uploaded['tmp_name'], $upload_path.'/'.$uploaded['name']);
// form
$result = "<form action=\"".$this->href()."/files\" method=\"post\" enctype=\"multipart/form-data\">\n";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref()."/files\">\n";
echo $result;
if ($this->HasAccess('write'))
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>";
print "[ {$delete_link} ] ";
if ($file == $uploaded['name'])
print "<em>{$download_link}</em>\n";
else
print $download_link;
print '<br>';
}
}
closedir($dir);


Revision [8580]

Edited on 2005-05-28 11:41:40 by JavaWoman [move to subcategory]
Additions:
=====Files Handler=====

>>==See also:==
Documentation: FilesHandlerInfo.>>This is the development page for the Files handler.::c::

This is another a complete refactoring of the FilesManagementHandler I proposed previously. The new overview can be found at FilesManagementSolution

===Dependancy===
None.

===The code===
//to be saved as files.php in the handlers/page directory.//

%%(php)
<div class="page">
<?php
if (! function_exists('mkdir_r')) {
function mkdir_r ($dir) {
if (strlen($dir) == 0) return 0;
if (is_dir($dir)) return 1;
elseif (dirname($dir) == $dir) return 1;
return (mkdir_r(dirname($dir)) and mkdir($dir,0755));
}
}

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)) mkdir_r($upload_path);

// upload action
$uploaded = $_FILES['file'];
if ($_REQUEST['action'] == 'upload' AND $uploaded['size'] > 0)
copy ($uploaded['tmp_name'], $upload_path.'/'.$uploaded['name']);

// form
$result = "<form action=\"".$this->href()."/files\" method=\"post\" enctype=\"multipart/form-data\">\n";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref()."/files\">\n";
echo $result;
// only if the user can write
if ($this->HasAccess('write'))
{
?>
<input type="hidden" name="action" value="upload"><input type="file" name="file"><input type="submit" value="+">
<?php
}
echo "<a href=\"".$this->Href()."\">Back to the page</a>";
echo $this->FormClose();

// uploaded files
$dir = opendir($upload_path);
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
// only if the user can write
if ($this->HasAccess('write'))
{
$delete_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=delete&file='.urlencode($file))."\">x</a>";
}
else
{
$delete_link = "-";
}
$download_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=download&file='.urlencode($file))."\">".$file."</a>";
print "[ {$delete_link} ] ";
if ($file == $uploaded['name'])
print "<em>{$download_link}</em>\n";
else
print $download_link;
print '<br>';
}
}
closedir($dir);
}
?>
</div>
%%

===To Do===
More comments in the code - comments standardization...

----
CategoryDevelopmentHandlers
Deletions:
=====Files Handler=====

>>==See also:==
Documentation: FilesHandlerInfo.>>This is the development page for the Files handler.::c::

This is another a complete refactoring of the FilesManagementHandler I proposed previously. The new overview can be found at FilesManagementSolution

===Dependancy===
None.

===The code===
//to be saved as files.php in the handlers/page directory.//

%%(php)
<div class="page">
<?php
if (! function_exists('mkdir_r')) {
function mkdir_r ($dir) {
if (strlen($dir) == 0) return 0;
if (is_dir($dir)) return 1;
elseif (dirname($dir) == $dir) return 1;
return (mkdir_r(dirname($dir)) and mkdir($dir,0755));
}
}

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)) mkdir_r($upload_path);

// upload action
$uploaded = $_FILES['file'];
if ($_REQUEST['action'] == 'upload' AND $uploaded['size'] > 0)
copy ($uploaded['tmp_name'], $upload_path.'/'.$uploaded['name']);

// form
$result = "<form action=\"".$this->href()."/files\" method=\"post\" enctype=\"multipart/form-data\">\n";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref()."/files\">\n";
echo $result;
// only if the user can write
if ($this->HasAccess('write'))
{
?>
<input type="hidden" name="action" value="upload"><input type="file" name="file"><input type="submit" value="+">
<?php
}
echo "<a href=\"".$this->Href()."\">Back to the page</a>";
echo $this->FormClose();

// uploaded files
$dir = opendir($upload_path);
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
// only if the user can write
if ($this->HasAccess('write'))
{
$delete_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=delete&file='.urlencode($file))."\">x</a>";
}
else
{
$delete_link = "-";
}
$download_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=download&file='.urlencode($file))."\">".$file."</a>";
print "[ {$delete_link} ] ";
if ($file == $uploaded['name'])
print "<em>{$download_link}</em>\n";
else
print $download_link;
print '<br>';
}
}
closedir($dir);
}
?>
</div>
%%

===To Do===
More comments in the code - comments standardization...

----
CategoryDevelopment


Revision [4630]

Edited on 2005-01-14 16:28:57 by NilsLindenberg [rechanged link + added link]
Additions:
This is another a complete refactoring of the FilesManagementHandler I proposed previously. The new overview can be found at FilesManagementSolution
Deletions:
This is another a complete refactoring of the FilesManagementSolution I proposed previously.


Revision [4629]

Edited on 2005-01-14 16:26:20 by NilsLindenberg [changed link]
Additions:
This is another a complete refactoring of the FilesManagementSolution I proposed previously.
Deletions:
This is another a complete refactoring of the FilesManagementHandler I proposed previously.


Revision [4628]

Edited on 2005-01-14 16:25:51 by NilsLindenberg [added explanation]
Additions:
//to be saved as files.php in the handlers/page directory.//


Revision [4550]

Edited on 2005-01-12 22:03:48 by ChristianBarthelemy [Files management part 4]
Additions:
=====Files Handler=====
Documentation: FilesHandlerInfo.>>This is the development page for the Files handler.::c::
This is another a complete refactoring of the FilesManagementHandler I proposed previously.
===Dependancy===
None.
===The code===
%%(php)
<div class="page">
<?php
if (! function_exists('mkdir_r')) {
function mkdir_r ($dir) {
if (strlen($dir) == 0) return 0;
if (is_dir($dir)) return 1;
elseif (dirname($dir) == $dir) return 1;
return (mkdir_r(dirname($dir)) and mkdir($dir,0755));
}
}
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)) mkdir_r($upload_path);
// upload action
$uploaded = $_FILES['file'];
if ($_REQUEST['action'] == 'upload' AND $uploaded['size'] > 0)
copy ($uploaded['tmp_name'], $upload_path.'/'.$uploaded['name']);
// form
$result = "<form action=\"".$this->href()."/files\" method=\"post\" enctype=\"multipart/form-data\">\n";
if (!$this->config["rewrite_mode"]) $result .= "<input type=\"hidden\" name=\"wakka\" value=\"".$this->MiniHref()."/files\">\n";
echo $result;
// only if the user can write
if ($this->HasAccess('write'))
{
?>
<input type="hidden" name="action" value="upload"><input type="file" name="file"><input type="submit" value="+">
<?php
}
echo "<a href=\"".$this->Href()."\">Back to the page</a>";
echo $this->FormClose();
// uploaded files
$dir = opendir($upload_path);
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
// only if the user can write
if ($this->HasAccess('write'))
{
$delete_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=delete&file='.urlencode($file))."\">x</a>";
}
else
{
$delete_link = "-";
}
$download_link = "<a href=\"".$this->href('files.xml',$this->GetPageTag(),'action=download&file='.urlencode($file))."\">".$file."</a>";
print "[ {$delete_link} ] ";
if ($file == $uploaded['name'])
print "<em>{$download_link}</em>\n";
else
print $download_link;
print '<br>';
}
}
closedir($dir);
}
?>
</div>
%%
===To Do===
More comments in the code - comments standardization...
Deletions:
=====xxxxx Handler=====
Documentation: xxxxxHandlerInfo.>>This is the development page for the xxxxx handler.::c::
//This page is a **template**. It belongs to CategoryTemplate (which contains more handy templates). To create a handler development page, [[http://wikka.jsnx.com/HandlerTemplate/clone clone this page]] to a page called **xxxxxHandler** (where xxxxx is the (capitalized) name of the handler), replace all occurrences of 'xxxxx' with the name of the handler and replace this paragraph with the actual content.//


Revision [4549]

The oldest known version of this page was created on 2005-01-12 21:59:27 by ChristianBarthelemy [Files management part 4]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki