public function autosuggestCityAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $q = strtolower($this->_getParam('term'));
     if (!$q) {
         return;
     }
     $where = "name like '%{$q}%'";
     $model = new Application_Model_City();
     $res = $model->fetchAll($where, null, 11);
     $result = array();
     foreach ($res as $row) {
         array_push($result, array("id" => $row->getId(), "value" => $row->getName()));
     }
     echo Zend_Json::encode($result);
 }
 /**
  * @Created By : Mahipal Singh Adhikari
  * @Created On : 7-Dec-2010
  * @Description: Travel guides home page content
  */
 public function indexAction()
 {
     //get destination home page CMS text
     $id = $this->_getParam('id', 1);
     $modelRes = new Application_Model_TravelGuidesHome();
     $modelRes = $modelRes->find($id);
     if (false !== $modelRes) {
         $this->view->title = $modelRes->getTitle();
         $this->view->subTitle = $modelRes->getSubTitle();
         $this->view->desription = $modelRes->getDescription();
     }
     //now retrieve travel guide slides
     $homeSlidesArr = array();
     $TravelGuidesSlidesM = new Application_Model_TravelGuidesSlides();
     $whereCond = "status=1";
     $orderBy = "weight DESC";
     $slideLimit = 10;
     $TravelGuidesSlidesRes = $TravelGuidesSlidesM->fetchAll($whereCond, $orderBy);
     if (false !== $TravelGuidesSlidesRes) {
         foreach ($TravelGuidesSlidesRes as $slides) {
             $homeSlidesArr[] = array("title" => $slides->getSlideTitle(), "type" => $slides->getSlideType(), "image" => $slides->getSlideImage(), "text" => $slides->getSlideText(), "label" => $slides->getSlideLinkLabel(), "url" => $slides->getSlideLinkUrl(), "target" => $slides->getSlideLinkTarget());
         }
         $this->view->cityImagesArr = $homeSlidesArr;
     }
     //get top featured city to display in top
     $cityM = new Application_Model_City();
     $destinationM = new Application_Model_Destination();
     //get other featured cities
     $featuredOther = array();
     $featuredOtherArr = array();
     $cityArr = array();
     $cityArr = $cityM->fetchAll("featured_top!=1 AND featured_other=1", "name ASC");
     if (count($cityArr) > 0) {
         foreach ($cityArr as $row) {
             $featuredOther['city_id'] = $row->id;
             $featuredOther['name'] = $row->name;
             //get City/place image
             $featuredOther['city_image'] = "no-image.jpg";
             $cityImagesArr = $destinationM->destinationImages($row->id);
             if (false !== $cityImagesArr) {
                 if (count($cityImagesArr) > 0) {
                     $featuredOther['city_image'] = $cityImagesArr[0]['city_image'];
                 }
             }
             //now get country in which this city exists
             $countryM = new Application_Model_Country();
             $country_id = $row->countryId;
             $countryM = $countryM->find($country_id);
             $featuredOther['country'] = "";
             if (false !== $countryM) {
                 $featuredOther['country'] = $countryM->getName();
             }
             $destinationM = new Application_Model_Destination();
             $destination = $destinationM->fetchRow("location_id='{$row->id}' AND location_type='city'");
             $featuredOther['overview'] = "";
             $featuredOther['nutshell'] = "";
             if (false !== $destination) {
                 $featuredOther['overview'] = $destination->getTitle();
                 $featuredOther['nutshell'] = $destination->getIntroduction();
                 //$destination_id = $destination->getId();
             }
             $featuredOtherArr[] = $featuredOther;
         }
         //end of foreach
     }
     $this->view->featuredOtherArr = $featuredOtherArr;
     //get featured countries
     $featuredCountry = array();
     $featuredCountryArr = array();
     $countryM = new Application_Model_Country();
     $countryArr = array();
     $countryArr = $countryM->fetchAll("featured=1", "name ASC");
     if (count($countryArr) > 0) {
         foreach ($countryArr as $row) {
             $featuredCountry['country_id'] = $row->id;
             $featuredCountry['name'] = $row->name;
             //get country image
             $featuredCountry['country_image'] = "no-image.jpg";
             $countryImagesArr = $destinationM->destinationImages($row->id, "country");
             if (false !== $countryImagesArr) {
                 if (count($countryImagesArr) > 0) {
                     $featuredCountry['country_image'] = $countryImagesArr[0]['country_image'];
                 }
             }
             //get country information
             $lonelyM = new Application_Model_LonelyPlanetCountry();
             $lonelyM = $lonelyM->fetchRow("country_id='{$row->id}'");
             $featuredCountry['overview'] = "";
             $featuredCountry['nutshell'] = "";
             if (false !== $lonelyM) {
                 $featuredCountry['overview'] = $lonelyM->getIntroMini();
                 $featuredCountry['nutshell'] = $lonelyM->getIntroShort();
             }
             $featuredCountryArr[] = $featuredCountry;
         }
         //end of foreach
     }
     $this->view->featuredCountryArr = $featuredCountryArr;
 }
 /**
  * @Created By	: Mahipal Singh Adhikari
  * @Created On	: 7-Dec-2010
  * @Description	: Manage featured plasec/cities
  */
 public function indexAction()
 {
     $this->view->title = "Manage Featured Places";
     $this->view->headTitle(" - " . $this->view->title);
     $this->view->msg = base64_decode($this->_getParam('msg', ''));
     $form = new Admin_Form_Featuredcity();
     //clear form element decorators
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('class');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     $this->view->form = $form;
     //get featured Cities
     $cityM = new Application_Model_City();
     $cityArr = $cityM->fetchAll("featured_top=1 OR featured_other=1");
     //get existing records to populate filled/selected in form
     $featuredOther = array();
     foreach ($cityArr as $row) {
         if ($row->featuredTop == 1) {
             //$options['featured_top']	=	$row->id;
         } else {
             $featuredOther[$row->id] = $row->id;
         }
     }
     //$form->getElement('featured_other')->setMultiOptions($featuredOther);
     $options['featured_other'] = $featuredOther;
     //get existing featured countries
     $countryM = new Application_Model_Country();
     $countryArr = $countryM->fetchAll("featured=1");
     $featuredCountry = array();
     foreach ($countryArr as $country) {
         $featuredCountry[$country->id] = $country->id;
     }
     $options['featured_country'] = $featuredCountry;
     $form->populate($options);
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             //re-set all values of featured_top and featured_other fileds in city table
             $resetFeaturedCity = $cityM->resetUpdateFeatured();
             $resetFeaturedCountry = $countryM->resetUpdateFeatured();
             if ($resetFeaturedCity && $resetFeaturedCountry) {
                 //update top featued city
                 //$cityM->setUpdateFeaturedTop($formData['featured_top']);
                 //update other featured cities
                 $cityM->setUpdateFeaturedOther($formData['featured_other']);
                 //update featured countries
                 $countryM->setUpdateFeatured($formData['featured_country']);
                 //set update message and redirect user
                 $this->_redirect("/admin/featured-city/index/msg/" . base64_encode("Featured places information has been updated."));
             }
         } else {
             $form->populate($formData);
         }
     }
 }
Exemple #4
0
 /**
  * @Created By	: Mahipal Singh Adhikari
  * @Created On	: 13-Jan-2011
  * @Description	: Get featured places
  * @Input		: none 
  * @Return		: array
  */
 public function selectFeaturedPlaces()
 {
     $cityM = new Application_Model_City();
     //get other featured cities
     $cityArr = array();
     $cityArr = $cityM->fetchAll("featured_top=1 OR featured_other=1", "name ASC");
     $featuredOther = array();
     $featuredOtherArr = array();
     if (count($cityArr) > 0) {
         foreach ($cityArr as $row) {
             $featuredOther['city_id'] = $row->id;
             $featuredOther['name'] = $row->name;
             //get City/place image
             $featuredOther['city_image'] = "no-image.jpg";
             $cityImagesArr = $this->destinationImages($row->id);
             if (false !== $cityImagesArr) {
                 if (count($cityImagesArr) > 0) {
                     $featuredOther['city_image'] = $cityImagesArr[0]['city_image'];
                 }
             }
             //now get country in which this city exists
             $countryM = new Application_Model_Country();
             $country_id = $row->countryId;
             $countryM = $countryM->find($country_id);
             if (false !== $countryM) {
                 $featuredOther['country'] = $countryM->getName();
             }
             $destination = $this->fetchRow("location_id='{$row->id}' AND location_type='city'");
             if (false !== $destination) {
                 $featuredOther['overview'] = $destination->getTitle();
                 $featuredOther['nutshell'] = $destination->getIntroduction();
             }
             $featuredOtherArr[] = $featuredOther;
         }
         //end of foreach
         return $featuredOtherArr;
     }
     //end if
 }