commit 9eb2f43008b060f7d8f5eb00498bdd676c2ddc52
parent ca8bfa2959bdbefe8122a45d86cf5c7dd52f2183
Author: dankert <devnull@localhost>
Date: Thu, 22 Nov 2007 22:21:45 +0100
Dateien auch per HTTP-Link anlegen.
Diffstat:
3 files changed, 71 insertions(+), 22 deletions(-)
diff --git a/actionClasses/FolderAction.class.php b/actionClasses/FolderAction.class.php
@@ -20,6 +20,9 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// ---------------------------------------------------------------------------
// $Log$
+// Revision 1.45 2007-11-22 21:21:45 dankert
+// Dateien auch per HTTP-Link anlegen.
+//
// Revision 1.44 2007-11-15 21:41:59 dankert
// Warnmeldung, wenn es keine Seitenvorlagen gibt.
//
@@ -218,12 +221,20 @@ class FolderAction extends ObjectAction
case 'file':
$upload = new Upload();
-
+
+ if ( !$upload->isValid() )
+ {
+ $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
+ $this->callSubAction('createfile');
+ return;
+ }
// Prüfen der maximal erlaubten Dateigröße.
- if ( $upload->size > $this->maxFileSize() )
+ elseif ( $upload->size > $this->maxFileSize() )
{
// Maximale Dateigröße ist überschritten
- $this->addNotice('file',$file->name,'MAX_FILE_SIZE_EXCEEDED','failed');
+ $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED');
+ $this->callSubAction('createfile');
+ return;
}
elseif( $upload->size > 0 )
{
@@ -336,17 +347,50 @@ class FolderAction extends ObjectAction
$filename = $this->getRequestVar('filename' );
$description = $this->getRequestVar('description');
- $file = new File();
- $upload = new Upload();
-
- $file->desc = !empty($description)?$name:$upload->filename;
- $file->filename = $upload->filename;
- $file->name = !empty($name)?$name:$upload->filename;
- $file->extension = $upload->extension;
- $file->size = $upload->size;
- $file->parentid = $this->folder->objectid;
-
- $file->value = $upload->value;
+ $file = new File();
+
+ if ( $this->hasRequestVar('url') )
+ {
+ $url = $this->getRequestVar('url');
+ $http = new Http();
+ $http->setUrl( $url );
+
+ $ok = $http->request();
+
+ if ( !$ok )
+ {
+ $this->addValidationError('url','COMMON_VALIDATION_ERROR',array(),$http->error);
+ $this->callSubAction('createfile');
+ return;
+ }
+
+ $file->desc = $description;
+ $file->filename = basename($url);
+ $file->name = !empty($name)?$name:basename($url);
+ $file->size = strlen($http->body);
+ $file->value = $http->body;
+ $file->parentid = $this->folder->objectid;
+ }
+ else
+ {
+ $upload = new Upload();
+
+ if ( !$upload->isValid() )
+ {
+ $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
+ $this->callSubAction('createfile');
+ return;
+ }
+
+ $file->desc = $description;
+ $file->filename = $upload->filename;
+ $file->name = !empty($name)?$name:$upload->filename;
+ $file->extension = $upload->extension;
+ $file->size = $upload->size;
+ $file->parentid = $this->folder->objectid;
+
+ $file->value = $upload->value;
+ }
$file->add(); // Datei hinzufuegen
$this->addNotice('file',$file->name,'ADDED','ok');
diff --git a/themes/default/include/html/upload.inc.php b/themes/default/include/html/upload.inc.php
@@ -1 +1 @@
-<input size="<?php echo $attr_size ?>" id="id_<?php echo $attr_name ?>" type="file" <?php if (isset($attr_maxlength))echo ' maxlength="'.$attr_maxlength.'"' ?> name="<?php echo $attr_name ?>" class="<?php echo $attr_class ?>" />-
\ No newline at end of file
+<input size="<?php echo $attr_size ?>" id="id_<?php echo $attr_name ?>" type="file" <?php if (isset($attr_maxlength))echo ' maxlength="'.$attr_maxlength.'"' ?> name="<?php echo $attr_name ?>" class="<?php echo $attr_class ?>" <?php if (in_array($attr_name,$errors)) echo 'style="border-rightx:10px solid red; background-colorx:yellow; border:2px dashed red;"' ?> />+
\ No newline at end of file
diff --git a/themes/default/templates/folder/createfile.tpl.src.php b/themes/default/templates/folder/createfile.tpl.src.php
@@ -3,21 +3,26 @@ page
hidden name:type default:file
window title: name:
- row
- cell colspan:2
- fieldset title:message:file
+ #row
+ # cell colspan:2
+ # fieldset title:message:file
row
cell class:fx
text text:global_FILE
cell class:fx
upload name:file maxlength:var:maxlength
- row
+ row
cell colspan:2
- text class:help text:message:file_max_size
+ text class:help text:message:file_max_size
text raw:_
- text text:var:max_size
+ text text:var:max_size
newline
newline
+ row
+ cell class:fx
+ text text:global_URL
+ cell class:fx
+ input name:url size:50
row
cell colspan:2
fieldset title:message:description