public function createAlbumAction() { $request = $this->getRequest(); $form = new Album_Form_CreateAlbum(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } if ($request->isPost()) { $params = $request->getParams(); if ($form->isValid($params)) { $userNs = new Zend_Session_Namespace('members'); $params['userId'] = $userNs->userId; $albumM = new Album_Model_UserAlbum($params); $album_id = $albumM->save(); if ($album_id > 0) { /*-----tags--------*/ if ($params['tags'] != "") { $arrTags = explode(",", $params['tags']); foreach ($arrTags as $_tag) { $_tag = trim($_tag); $tagsM = new Application_Model_Tags(); $tag = $tagsM->fetchRow("tag='{$_tag}'"); if (false === $tag) { $tagsM->setTag($_tag); $tag_id = $tagsM->save(); } else { $tag_id = $tag->getId(); } $albumTagM = new Application_Model_AlbumTag(); $albumTagM->setAlbumId($album_id); $albumTagM->setTagId($tag_id); $albumTagM->save(); } } /*----------tags-------*/ $this->view->msg = "Album created successfully. Album Id : {$album_id}"; $form->reset(); } else { $this->view->msg = "Faild to create Album. Please try again."; } } } $this->view->form = $form; }
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 getAlbumPhotoTags($photoId) { $objModelAlbumTag = new Album_Model_AlbumPhotoTag(); $objModelTag = new Application_Model_Tags(); $whereAlbumPhotoTag = "photo_id='{$photoId}'"; $arrTagId = $objModelAlbumTag->fetchAll($whereAlbumPhotoTag); $strTag = ""; if (!empty($arrTagId)) { foreach ($arrTagId as $tagId) { $tId = $tagId->tagId; $whereTag = "id='{$tId}'"; $arrTag = $objModelTag->fetchRow($whereTag); $strTag = $strTag . ',' . $arrTag->tag; } $strTag = substr($strTag, 1, strlen($strTag)); } return $strTag; }
public function albumSubmitAction() { $this->_helper->layout()->disableLayout(); $params = $this->getRequest()->getParams(); $userNs = new Zend_Session_Namespace('members'); $option['userId'] = $userNs->userId; // LoggedIn UserId $arrLatLang = explode(",", $params['latlang']); $latitude = substr($arrLatLang[0], 1, strlen($arrLatLang[0])); // Longitude of location $longitude = substr($arrLatLang[1], 0, -1); // Latitude of location $option['name'] = $params['name']; $option['description'] = addslashes(strip_tags($params['description'])); $option['location'] = $params['address']; $option['permission'] = $params['permissions']; $option['longitude'] = $longitude; $option['latitude'] = $latitude; $option['status'] = 1; $albumM = new Album_Model_Album($option); $album_id = $albumM->save(); /*----- start tags--------*/ if ($params['album_tags'] != "" && $params['album_tags'] != "Separate Tags by a comma. For example: ' Holiday, London, Travel'") { $arrTags = explode(",", $params['album_tags']); foreach ($arrTags as $_tag) { $_tag = trim($_tag); $tagsM = new Application_Model_Tags(); $tag = $tagsM->fetchRow("tag='{$_tag}'"); if (false === $tag) { $tagsM->setTag($_tag); $tag_id = $tagsM->save(); } else { $tag_id = $tag->getId(); } $albumTagM = new Album_Model_AlbumTag(); $albumTagM->setAlbumId($album_id); $albumTagM->setTagId($tag_id); $albumTagM->save(); } } echo $album_id; exit; }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 22-Feb-2011 * @Description: Delete tags and related blog tags */ public function deleteTagAction() { //get request params $id = $this->_getParam('id'); $page = $this->_getParam('page'); //delete blog tags related to this tag $blogTagM = new Application_Model_BlogTag(); $blogTagM->delete("tag_id={$id}"); //delete tag $tagM = new Application_Model_Tags(); $tagM->delete("id={$id}"); //set message and redirect $_SESSION['errorMsg'] = "Tag has been deleted successfully!"; //return $this->_helper->redirector('tags','journals',"admin"); return $this->_helper->redirector('tags', 'journals', "admin", array('page' => $page)); }
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; }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 1-Nov-2010 * @Description: Used to edit blog post information */ public function editBlogAction() { $request = $this->getRequest(); $form = new Application_Form_Blog(); $form->removeElement("weight"); //get blog information for edit $blog_id = $this->_getParam('id'); //$blog_id = base64_decode($blog_id); if (isset($blog_id)) { $objBlog = new Application_Model_Blog(); $blog = $objBlog->find($blog_id); //get blog tags $tag = new Application_Model_Tags(); $tags = $blog->getTags(); $tags = $tag->getTagsForEdit($blog_id); $blog_info["title"] = $blog->getTitle(); $blog_info["status"] = $blog->getStatus(); $blog_info["categoryId"] = $blog->getCategoryId(); $blog_info["location"] = $blog->getLocation(); $blog_info["tags"] = $tags; $blog_info["content"] = $blog->getContent(); $blog_info["comment"] = $blog->getComment(); $blog_info["publish"] = $blog->getPublish(); $blog_info["weight"] = $blog->getWeight(); $form->populate($blog_info); } $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } if ($this->getRequest()->isPost()) { $params = $request->getParams(); if ($form->isValid($params)) { $userNs = new Zend_Session_Namespace('members'); $journalM = new Application_Model_Journal(); $journal = $journalM->fetchRow("user_id='{$userNs->userId}'"); if (false !== $journal) { $params['userId'] = $userNs->userId; $params['journalId'] = $journal->getId(); $params['featured'] = $blog->getFeatured(); $params['weight'] = $blog->getWeight(); //$params['id'] = $blog_id; $blogM = new Application_Model_Blog($params); $blog = $blogM->save(); if ($blog && $blog_id != "") { //now first delete tags $albumTagM = new Application_Model_BlogTag(); //$objBlogTag = new Application_Model_BlogTag(); $albumTagM->delete("blog_id = {$blog_id}"); //insert/update blog tags if ($params['tags'] != "") { $arrTags = explode(",", $params['tags']); foreach ($arrTags as $_tag) { $_tag = trim($_tag); $tagsM = new Application_Model_Tags(); $tag = $tagsM->fetchRow("tag='{$_tag}'"); if (false === $tag) { $tagsM->setTag($_tag); $tag_id = $tagsM->save(); } else { $tag_id = $tag->getId(); } //$albumTagM=new Application_Model_BlogTag(); $albumTagM->setBlogId($blog_id); $albumTagM->setTagId($tag_id); $albumTagM->save(); } //end of foreach } //end of if /*----------tags-------*/ $_SESSION["flash_msg"] = "Journal post has been updated successfully."; $form->reset(); } else { $_SESSION["flash_msg"] = "Failed to update journal post. Please try again later."; } } else { $_SESSION["flash_msg"] = "Failed to update journal post because you have removed your journal."; } //redirect user //$this->_redirect('/journal/my-journals/'); $this->_redirect($this->view->seoUrl('/journal/my-journals/')); } //end of if } //end of if $this->view->form = $form; }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 1-Nov-2010 * @Description: Used to update blog post information */ public function updateblogAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $id = $this->_getParam('id'); //$catId = $this->_getParam('catId'); //$location = $this->_getParam('location'); //$tags = $this->_getParam('tags'); $catId = $_POST['categoryId_' . $id]; $location = $_POST['location_' . $id]; $tags = $_POST['tags_' . $id]; //print_r($_POST); //echo "id=$id, cat=$catId, loc=$location, tag=$tags";exit; if ($id == "") { echo "Please select the journal to edit."; exit; } if ($catId == "") { echo "Please select the category."; exit; } if ($location == "") { echo "Location can not be left blank."; exit; } $objModelBlog = new Application_Model_Blog(); $objModelBlog = $objModelBlog->find($id); if (false !== $objModelBlog) { $objModelBlog->setCategoryId($catId); $objModelBlog->setLocation($location); $objModelBlog->setTags($tags); $resp = $objModelBlog->save(); if ($resp) { //now first delete blog tags $objBlogTag = new Application_Model_BlogTag(); $objBlogTag = $objBlogTag->delete("blog_id='{$id}'"); //insert/update tags if ($tags != "") { $arrTags = explode(",", $tags); foreach ($arrTags as $_tag) { $_tag = trim($_tag); $tagsM = new Application_Model_Tags(); $tag = $tagsM->fetchRow("tag='{$_tag}'"); if (false === $tag) { $tagsM->setTag($_tag); $tag_id = $tagsM->save(); } else { $tag_id = $tag->getId(); } $albumTagM = new Application_Model_BlogTag(); $albumTagM->setBlogId($id); $albumTagM->setTagId($tag_id); $albumTagM->save(); } //end foreach } //end if //set confirmation message to display $tagsM = new Application_Model_Tags(); $tagStr = $tagsM->getBlogTags($id, false, false); echo "Your journal information has been successfully updated.~###~{$tagStr}"; } else { echo "Error occured. Please try again later."; } } else { echo "Invalid request."; } exit; }
public function albumEditSubmitAction() { $this->_helper->layout()->disableLayout(); $arrPostVal = $this->getRequest()->getParams(); $objModelAlbum = new Album_Model_Album(); $objModelTags = new Application_Model_Tags(); $objModelAlbumTag = new Album_Model_AlbumTag(); $name = addslashes(strip_tags($arrPostVal['name'])); $description = addslashes(strip_tags($arrPostVal['description'])); $location = $arrPostVal['location']; $permission = $arrPostVal['permissions']; $tags = $arrPostVal['tags']; $albumId = $arrPostVal['albumId']; $latlang = $arrPostVal['latlang']; $arrLatLang = explode(",", $latlang); $latitude = substr($arrLatLang[0], 1, strlen($arrLatLang[0])); // Longitude of location $longitude = substr($arrLatLang[1], 0, -1); $valAlbum = $objModelAlbum->find($albumId); $valAlbum->setName($name); $valAlbum->setDescription($description); $valAlbum->setLocation($location); $valAlbum->setPermission($permission); $valAlbum->setLatitude($latitude); $valAlbum->setLongitude($longitude); $valAlbum->save(); /*--------------------- ALBUM TAG ---------------------*/ $arrTag = explode(",", $tags); $objModelAlbumTag->delete("album_id='{$albumId}'"); foreach ($arrTag as $tag) { $newTag = trim($tag); $whereTag = ""; $whereTag = "tag='{$newTag}'"; $arrTags = $objModelTags->fetchAll($whereTag); if (count($arrTags) > 0) { $optionAlbumTag['albumId'] = $albumId; $optionAlbumTag['tagId'] = $arrTags[0]->id; $objModelAlbumTag->setOptions($optionAlbumTag); $objModelAlbumTag->save(); } else { $optionTag['tag'] = $newTag; $objModelTags->setOptions($optionTag); $id = $objModelTags->save(); /*-----------------------------------*/ $optionAlbumTag['albumId'] = $albumId; $optionAlbumTag['tagId'] = $id; $objModelAlbumTag->setOptions($optionAlbumTag); $objModelAlbumTag->save(); } } exit; }