コード例 #1
0
 public function getPhotoInfo($photoId, $albumId = NULL)
 {
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto();
     $objModelVote = new Application_Model_Vote();
     $arrPhotoIds = array();
     $valAlbumPhoto = $objModelAlbumPhoto->find($photoId);
     if (empty($valAlbumPhoto)) {
         $this->_redirect('/album/my-photos/album-photos/id/' . $albumId);
     }
     $this->view->photo = $valAlbumPhoto->getImage();
     $this->view->name = $valAlbumPhoto->getName();
     $this->view->caption = strip_tags(stripslashes($valAlbumPhoto->getCaption()));
     $this->view->location = $valAlbumPhoto->getLocation();
     $this->view->permission = $valAlbumPhoto->getPermission();
     $albumId = $valAlbumPhoto->getAlbumId();
     $this->view->myLatitude = $latitude = $valAlbumPhoto->getLatitude();
     $this->view->myLongitude = $longitude = $valAlbumPhoto->getLongitude();
     $this->getAlbumInfo($albumId);
     // Get album info
     $this->view->albumId = $albumId;
     $this->view->photoId = $photoId;
     $this->view->likeSrcUrl = Zend_Registry::get('siteurl') . "%2Falbum%2Fmy-photos%2Fphoto%2Falbum%2F" . $albumId . "%2Fid%2F" . $photoId;
     /*-----------------------------------------------------------------------*/
     $whereAlbumPhoto = "album_id='{$albumId}' AND status='1'";
     $orderAlbumPhoto = "addedon DESC";
     $arrAlbumPhoto = $objModelAlbumPhoto->fetchAll($whereAlbumPhoto, $orderAlbumPhoto);
     foreach ($arrAlbumPhoto as $photo) {
         $arrPhotoIds[] = $photo->id;
     }
     $position = array_search($photoId, $arrPhotoIds);
     $nextPosition = $position + 1;
     $prevPosition = $position - 1;
     $arrSize = count($arrPhotoIds);
     $this->view->photoPosition = $nextPosition;
     $this->view->numPhotoAlbum = $arrSize;
     if (array_key_exists($nextPosition, $arrPhotoIds)) {
         $this->view->nextId = $arrPhotoIds[$nextPosition];
     } else {
         $this->view->nextId = $arrPhotoIds[0];
     }
     if (array_key_exists($prevPosition, $arrPhotoIds)) {
         $this->view->prevId = $arrPhotoIds[$prevPosition];
     } else {
         $this->view->prevId = $arrPhotoIds[$arrSize - 1];
     }
     /*------------------ CHECK LIKED-UNLIKED ALBUM ------------------*/
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     $whereVote = "item_type='album_photo' AND item_id='{$photoId}' AND user_id='{$userId}' AND vote='1'";
     $arrVote = $objModelVote->fetchAll($whereVote);
     if (count($arrVote) > 0) {
         $this->view->numVote = 1;
     } else {
         $this->view->numVote = 0;
     }
 }
コード例 #2
0
 public function albumSlideShowAction()
 {
     $this->_helper->layout()->disableLayout();
     $albumId = $this->_getParam('album_id');
     $objModelAlbum = new Album_Model_AlbumPhoto();
     $whereAlbum = "album_id='{$albumId}'";
     $orderAlbum = "addedon DESC";
     $arrAlbum = $objModelAlbum->fetchAll($whereAlbum, $orderAlbum);
     $this->view->arrAlbum = $arrAlbum;
     $this->view->countAlbum = count($arrAlbum);
 }
コード例 #3
0
 public function getPhotoInfo($photoId, $userId = NULL, $albumId = NULL)
 {
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto();
     $objModelVote = new Application_Model_Vote();
     /*------------------------- CHECK RELATION ------------------------------*/
     $userNs = new Zend_Session_Namespace('members');
     $this->view->loggedInUserId = $loggedInUserId = $userNs->userId;
     $relationCondition = $this->checkRelation($userId, $loggedInUserId);
     $this->view->relationCondition = $relationCondition;
     /*-----------------------------------------------------------------------*/
     $wherePhoto = "id='{$photoId}' AND ({$relationCondition})";
     $arrPhotoIds = array();
     $valAlbumPhoto = $objModelAlbumPhoto->fetchAll($wherePhoto);
     if (!empty($valAlbumPhoto)) {
         $this->view->photo = $valAlbumPhoto[0]->image;
         $this->view->name = $valAlbumPhoto[0]->name;
         $this->view->caption = stripslashes($valAlbumPhoto[0]->caption);
         $this->view->location = $valAlbumPhoto[0]->location;
         $this->view->permission = $valAlbumPhoto[0]->permission;
         $albumId = $valAlbumPhoto[0]->albumId;
         $this->view->myLatitude = $latitude = $valAlbumPhoto[0]->latitude;
         $this->view->myLongitude = $longitude = $valAlbumPhoto[0]->longitude;
     } else {
         $this->view->imageNotExist = 1;
     }
     $this->getAlbumInfo($albumId);
     // Get album info
     $this->view->albumId = $albumId;
     $this->view->photoId = $photoId;
     $objModelUser = new Application_Model_User();
     $valUser = $objModelUser->find($userId);
     $frienUserName = $valUser->getUsername();
     $this->view->likeSrcUrl = Zend_Registry::get('siteurl') . "%2Fprofile%2Fphoto%2Fusername%2F" . $frienUserName . "%2Falbum%2F" . $albumId . "%2Fid%2F" . $photoId;
     $whereAlbumPhoto = "album_id='{$albumId}' AND status='1' AND ({$relationCondition})";
     $orderAlbumPhoto = "addedon DESC";
     $arrAlbumPhoto = $objModelAlbumPhoto->fetchAll($whereAlbumPhoto, $orderAlbumPhoto);
     foreach ($arrAlbumPhoto as $photo) {
         $arrPhotoIds[] = $photo->id;
     }
     $position = array_search($photoId, $arrPhotoIds);
     $nextPosition = $position + 1;
     $prevPosition = $position - 1;
     $arrSize = count($arrPhotoIds);
     $this->view->photoPosition = $nextPosition;
     $this->view->numPhotoAlbum = $arrSize;
     if (array_key_exists($nextPosition, $arrPhotoIds)) {
         $this->view->nextId = $arrPhotoIds[$nextPosition];
     } else {
         if (isset($arrPhotoIds[0])) {
             $this->view->nextId = $arrPhotoIds[0];
         }
     }
     if (array_key_exists($prevPosition, $arrPhotoIds)) {
         $this->view->prevId = $arrPhotoIds[$prevPosition];
     } else {
         if (isset($arrPhotoIds[$arrSize - 1])) {
             $this->view->prevId = $arrPhotoIds[$arrSize - 1];
         }
     }
     /*------------------ CHECK LIKED-UNLIKED ALBUM ------------------*/
     $whereVote = "item_type='album_photo' AND item_id='{$photoId}' AND user_id='{$loggedInUserId}' AND vote='1'";
     $arrVote = $objModelVote->fetchAll($whereVote);
     if (count($arrVote) > 0) {
         $this->view->numVote = 1;
     } else {
         $this->view->numVote = 0;
     }
 }