Exemplo n.º 1
0
 /**
  * Adds slide and stores temporary slide image 
  * 
  * @param string $uniqName
  * @param array $file
  */
 public function addTmpSlide($uniqName, array $file)
 {
     if (!$uniqName) {
         return false;
     }
     $ext = UTIL_File::getExtension($file['name']);
     $image = new UTIL_Image($file['tmp_name']);
     $slide = new SLIDESHOW_BOL_Slide();
     $slide->widgetId = $uniqName;
     $slide->width = $image->getWidth();
     $slide->height = $image->getHeight();
     $slide->ext = $ext;
     $slide->order = $this->slideDao->getNextOrder($uniqName);
     $slide->addStamp = time();
     $this->slideDao->save($slide);
     $path = $this->getImageTmpDir($slide->id, $uniqName, $slide->addStamp, $ext);
     try {
         $image->resizeImage(1000, null)->saveImage($path);
         if ($image->imageResized()) {
             $image = new UTIL_Image($path);
             $slide->width = $image->getWidth();
             $slide->height = $image->getHeight();
             $this->slideDao->save($slide);
         }
     } catch (Exception $e) {
         $this->slideDao->deleteById($slide->id);
         return false;
     }
     return $slide->id;
 }