コード例 #1
0
 public function getTaggesPhotoInfo($photoId)
 {
     $objModelAlbumPhoto = new Album_Model_AlbumPhoto();
     $objModelVote = new Application_Model_Vote();
     $objModelPhotoTag = new Album_Model_PhotoTag();
     $usersNs = new Zend_Session_Namespace("members");
     $userId = $usersNs->userId;
     $userFullName = $usersNs->userFullName;
     /*--------- START CHECK NEXT TAGGED IMAGE EXIST OR NOT ---------------*/
     $whereTaggedPhoto = "photo_id='{$photoId}'";
     $arrTaggedPhoto = $objModelPhotoTag->fetchRow($whereTaggedPhoto);
     if (empty($arrTaggedPhoto)) {
         $this->_redirect('/album/my-photos');
     }
     /*--------- END CHECK NEXT TAGGED IMAGE EXIST OR NOT ---------------*/
     $arrPhotoIds = array();
     $valAlbumPhoto = $objModelAlbumPhoto->find($photoId);
     $this->view->photo = $valAlbumPhoto->getImage();
     $this->view->name = $valAlbumPhoto->getName();
     $this->view->caption = 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;
     /*-----------------------------------------------------------------------*/
     $db = Zend_Registry::get('db');
     $where = "tagged_id='{$userId}'";
     $query = $db->select()->from(array("pt" => "photo_tag"), array("pt.photo_id"))->join(array("ap" => "album_photo"), "pt.photo_id=ap.id", array("ap.image", "ap.id"))->where($where)->order(array('pt.created DESC'));
     $recordSet = $db->query($query);
     $arrRecord = $recordSet->fetchAll();
     $this->view->numRecord = $numRecord = count($arrRecord);
     foreach ($arrRecord 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 ------------------*/
     $this->view->userFullName = $userFullName;
     $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;
     }
     /*----------------- GET TAGGED PHOTO COUNTER ---------------------*/
     $whereTagged = "tagged_id='{$userId}' AND photo_id='{$photoId}'";
     $queryTagged = $db->select()->from(array("pt" => "photo_tag"), array("pt.counter"))->where($whereTagged);
     $recordSetTagged = $db->query($queryTagged);
     $arrRecordTaggedCounter = $recordSetTagged->fetchAll();
     $this->view->counter = $arrRecordTaggedCounter[0]->counter;
     /*----------------- GET ALL TAGE FOR PHOTO -------------------------*/
     $objAlbumPhotoTag = new Album_Model_AlbumPhotoTag();
     $objTag = new Application_Model_Tags();
     $allTagId = $objAlbumPhotoTag->fetchAll("photo_id='{$photoId}'");
     $tagStr = "";
     foreach ($allTagId as $tagId) {
         $valTag = $objTag->find($tagId->tagId);
         $tagStr .= $valTag->getTag();
     }
     $this->view->tagStr = $tagStr;
     $this->view->likeSrcUrl = Zend_Registry::get('siteurl') . "%2Falbum%2Fmy-photos%2Ftagged-photo%2Fid%2F" . $photoId;
 }
コード例 #2
0
 public function getAlbumTags($albumId)
 {
     $objModelAlbumTag = new Album_Model_AlbumTag();
     $objModelTag = new Application_Model_Tags();
     $whereAlbumTag = "album_id='{$albumId}'";
     $arrTagId = $objModelAlbumTag->fetchAll($whereAlbumTag);
     $strTag = "";
     if (!empty($arrTagId)) {
         foreach ($arrTagId as $tagId) {
             $tId = $tagId->tagId;
             $valTag = $objModelTag->find($tId);
             $strTag = $strTag . ',' . $valTag->getTag();
         }
         $strTag = substr($strTag, 1, strlen($strTag));
     }
     return $strTag;
 }