DataObjects/core.sql
[Pman.Core] / DataObjects / Images.php
index ea87fdf..287b1c9 100644 (file)
@@ -58,15 +58,12 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
     {
         if (isset($q['_remote_upload'])) {
             require_once 'System.php';
-            static $tmpdir = false;
-            if (!$tmpdir) {
-                $tmpdir  = System::mktemp("-d remote_upload");
-            }
+            
+            $tmpdir  = System::mktemp("-d remote_upload");
             
             $path = $tmpdir . '/' . basename($q['_remote_upload']);
             
             if(!file_exists($path)){
-                // use HTTP_Request
                file_put_contents($path, file_get_contents($q['_remote_upload'])); 
             }
             
@@ -77,8 +74,10 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
             $ext = $y->toExt(trim((string) $imageInfo['mime'] ));
             
             if (!preg_match("/\." . $ext."$/", $path, $matches)) {
-                rename($path,$path.$ext);
+                rename($path,$path.".".$ext);
+                $path.= ".".$ext;
             }
+            
             if (!$this->createFrom($path)) {
                 $roo->jerr("erro making image" . $q['_remote_upload']);
             }
@@ -95,7 +94,7 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
         
     }
     
-    
+     
     /**
      * create an email from file.
      * these must have been set first.
@@ -263,9 +262,9 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
     
     // direct via roo...
     /// ctrl not used??
-    function onUpload($ctrl)
+    function onUpload($roo)
     {
-        
+//        echo $_FILES['imageUpload']['type'];exit;
         if (empty($_FILES['imageUpload']['tmp_name']) || 
             empty($_FILES['imageUpload']['name']) || 
             empty($_FILES['imageUpload']['type'])
@@ -486,8 +485,15 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
             $sy = $sz[1];
         }
         // create it?
-         
-        return '<img src="' . $this->URL($size, $provider) . '" width="'. $sx . '" height="'. $sy . '">';
+        $extra = '';
+        if (strlen($this->title)) {
+            $extra = ' title="'. htmlspecialchars($this->title) . '"';
+        }
+        
+        return '<img src="' . $this->URL($size, $provider) . '"' .
+                $extra .
+                ' width="'. $sx . '"' .
+                ' height="'. $sy . '">';
         
         
     }
@@ -527,10 +533,6 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
     {
         // not sure why we do this.. 
         
-        
-        
-        
-        
         // if imgtype starts with '-' ? then we set the 'old' (probably to delete later)
         if (!empty($ar['imgtype']) && !empty($ar['ontable']) && !empty($ar['onid']) && ($ar['imgtype'][0] == '-')) {
             $this->setFrom($ar);
@@ -582,8 +584,11 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
             return; // standard update...
         }
         
-        if ( !$this->onUpload($this)) {
-            $roo->jerr("File upload failed : ". $this->err);
+        
+//        print_r(!$this->onUpload($this));
+        
+        if ( !$this->onUpload($this)) { 
+            $roo->jerr("File upload failed : ". (!empty($this->err) ? $this->err : ''));
         }
         
         $roo->addEvent("ADD", $this, $this->toEventString());
@@ -609,4 +614,5 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
         return $this->filename .' - on ' . $this->ontable . ':' . $this->onid;
         //$p->toEventString();
     }
+    
  }