示例#1
0
 public function editAction()
 {
     $this->view->title = "Country - Edit";
     $this->view->headTitle($this->view->title);
     $id = $this->_getParam('id');
     $model1 = new Application_Model_Country();
     $model = $model1->find($id);
     $options['name'] = $model->getName();
     $options['continentId'] = $model->getContinentId();
     $request = $this->getRequest();
     $form = new Admin_Form_Country();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $model->setOptions($options);
             $model->save($model);
             $this->view->successMsg = "Country Id : {$model->getId()}' has been updated successfully!";
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
 /**
  * @Created By : Mahipal Singh Adhikari
  * @Created On : 7-Dec-2010
  * @Description: Display Country information under Travel guides section
  */
 public function countryAction()
 {
     $id = $this->_getParam('id');
     $countryM = new Application_Model_Country();
     $country = $countryM->find($id);
     $this->view->country_id = $id;
     //get in block
     $this->view->invalidCountry = "0";
     if (false === $country) {
         $this->view->invalidCountry = "1";
     } else {
         $this->view->countyName = $countryName = $country->getName();
         //set City Google map address
         $searchAddress = $countryName;
         $latitude = "-34.397";
         $longitude = "150.644";
         //if Lat/Lon coordinates available
         if ($country->getLatitude() != "" && $country->getLongitude() != "") {
             $latitude = $country->getLatitude();
             $longitude = $country->getLongitude();
             $searchAddress = "(" . $latitude . ", " . $longitude . ")";
         }
         $this->view->latitude = $latitude;
         $this->view->longitude = $longitude;
         $this->view->searchAddress = $searchAddress;
         $db = Zend_Registry::get("db");
         $sSQL = "SELECT * FROM lonely_planet_country WHERE country_id='{$id}'";
         $row = $db->fetchRow($sSQL);
         if (!empty($row)) {
             $this->view->countryInfo = $row;
             //get information from destination table
             $destinationM = new Application_Model_Destination();
             $destination = $destinationM->fetchRow("location_id='{$id}' AND location_type='country'");
             if (false !== $destination) {
                 $bank_breaker = unserialize($destination->getBankBreaker());
                 $this->view->bank_breaker = $bank_breaker;
                 $dontLeaveWithoutM = new Application_Model_DontLeaveWithout();
                 $this->view->dontLeaveWithout = $dontLeaveWithoutM->fetchAll("destination_id='{$destination->getId()}'", "id ASC");
             }
             //get country images
             $countryImagesArr = $destinationM->destinationImages($id, "country");
             if (false !== $countryImagesArr) {
                 if (count($countryImagesArr) > 0) {
                     $this->view->countryImagesArr = $countryImagesArr;
                 }
             }
         } else {
             $this->view->invalidCountry = "2";
         }
     }
 }