Ejemplo n.º 1
0
 public function saveImage($goalId, $imagePath, $imageId)
 {
     $storage = OW::getStorage();
     $goal = $this->goalDao->findById($goalId);
     if (!$imageId) {
         $imageId = uniqid();
         $goal->image = $imageId;
         $this->goalDao->save($goal);
     } elseif ($storage->fileExists($this->generateImagePath($imageId))) {
         $storage->removeFile($this->generateImagePath($imageId));
         $storage->removeFile($this->generateImagePath($imageId, false));
         $imageId = uniqid();
         $goal->image = $imageId;
         $this->goalDao->save($goal);
     }
     $pluginfilesDir = Ow::getPluginManager()->getPlugin('ocsfundraising')->getPluginFilesDir();
     $tmpImgPath = $pluginfilesDir . 'project_image_' . $imageId . '.jpg';
     $tmpIconPath = $pluginfilesDir . 'project_icon_' . $imageId . '.jpg';
     $image = new UTIL_Image($imagePath);
     $image->resizeImage(300, null)->saveImage($tmpImgPath)->resizeImage(170, 130, true)->saveImage($tmpIconPath);
     unlink($imagePath);
     $storage->copyFile($tmpIconPath, $this->generateImagePath($imageId));
     $storage->copyFile($tmpImgPath, $this->generateImagePath($imageId, false));
     unlink($tmpImgPath);
     unlink($tmpIconPath);
 }
Ejemplo n.º 2
0
 /**
  * Returns an instance of class.
  *
  * @return OCSFUNDRAISING_BOL_GoalDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }