private function setModel($row) { $model = new Album_Model_PhotoTag(); $model->setId($row->id)->setPhotoId($row->photo_id)->setUserId($row->user_id)->setTaggedId($row->tagged_id)->setKeyword($row->keyword)->setPhotoTag($row->photo_tag)->setHtmlTag($row->html_tag)->setCounter($row->counter)->setCreated($row->created); return $model; }
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; }
public function loadTaggingTagAction() { $this->_helper->layout()->disableLayout(); $objModelPhotoTag = new Album_Model_PhotoTag(); $arrPostVal = $this->getRequest()->getParams(); $photoId = $arrPostVal['photoId']; $wherePhotoTagging = "photo_id='{$photoId}'"; $arrPhotoTagging = $objModelPhotoTag->fetchAll($wherePhotoTagging); $strTagging = ""; foreach ($arrPhotoTagging as $tagging) { $strTagging .= stripslashes($tagging->htmlTag); } echo $strTagging; exit; }