Example #1
0
 public function getAlbumPictures($album_id = null)
 {
     if (is_null($album_id)) {
         $album_id = $this->getId();
     }
     $pictures = new Application_Model_Pictures();
     return $pictures->fetchAll("album_id='{$album_id}'", "addedon desc");
 }
Example #2
0
 public function uploadPicturesAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $options = $this->_getAllParams();
     $model = new Application_Model_Pictures();
     echo $model->uploadPicture($options);
 }
Example #3
0
 public function uploadPicture($options)
 {
     $upload = new Zend_File_Transfer_Adapter_Http();
     $albumId = $options['album_id'];
     $targetFolder = PUBLIC_PATH . "/media/picture/album/{$albumId}";
     if (!is_dir($targetFolder)) {
         mkdir(str_replace('//', '/', $targetFolder), 0755, true);
     }
     if ($upload->isValid('Filedata')) {
         $upload->setDestination($targetFolder);
         try {
             $upload->receive('Filedata');
         } catch (Zend_File_Transfer_Exception $e) {
             $msg = $e->getMessage();
         }
         $upload->setOptions(array('useByteString' => false));
         $file_name = $upload->getFileName('Filedata');
         $model = new Application_Model_Pictures();
         $model->setAlbumId($albumId);
         $model->setImage($file_name);
         $id = $model->save();
         $cardImageTypeArr = explode(".", $file_name);
         $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
         $target_file_name = "album_picture_" . $id . ".{$ext}";
         $targetPath = $targetFolder . '/' . $target_file_name;
         $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
         $filterFileRename->filter($file_name);
         /*--- Generate Profile Picture ---*/
         $thumb = Base_Image_PhpThumbFactory::create($targetPath);
         $thumb->resize(600, 600);
         $thumb->save($targetFolder . '/small_' . $target_file_name);
         $thumb = Base_Image_PhpThumbFactory::create($targetPath);
         $thumb->resize(150, 150);
         $thumb->save($targetFolder . '/thumb_' . $target_file_name);
         $model = new Application_Model_Pictures();
         $model = $model->find($id);
         $model->setImage($target_file_name);
         $model->save();
         $str = "<div class='album_pic_thumb_box' id='pic_container_" . $model->getId() . "'>";
         $str .= '<a class="album_pic_slide"  href="' . $model->getPictureSmallUrl() . '"><img class="album_pic_thumb" src="' . $model->getPictureThumbUrl() . '"/></a>';
         $str .= '<br class="clear">';
         $str .= "<a href=\"javascript: deletePic('" . $model->getId() . "');\">";
         $str .= "<img src=\"/images/icons/cross_circle.png\" alt=\"Click here to delete!\">";
         $str .= "</a>";
         $str .= "</div>";
         return $str;
     }
 }