예제 #1
0
 private function setModel($row)
 {
     $model = new Application_Model_LonelyPlanetCountry();
     $model->setId($row->id)->setNodeId($row->node_id)->setDestinationName($row->destination_name)->setFullDestinationName($row->full_destination_name)->setIntroMini($row->intro_mini)->setIntroShort($row->intro_short)->setWarningTitle($row->warning_title)->setWarningText($row->warning_text)->setWarningPosition($row->warning_position)->setWarningSeverity($row->warning_severity)->setTimezones($row->timezones)->setWeightsMeasuresSystem($row->weights_measures_system)->setCapitalCity($row->capital_city)->setLeaders($row->leaders)->setGovernmentType($row->government_type)->setAreaSqkm($row->area_sqkm)->setPopulation($row->population)->setLanguageSpokens($row->language_spokens)->setReligion($row->religion)->setCurrencyCode($row->currency_code)->setCurrencyName($row->currency_name)->setCurrencySymbol($row->currency_symbol)->setCurrencyUnit($row->currency_unit)->setRelativeCostRooms($row->relative_cost_rooms)->setRelativeCostMeals($row->relative_cost_meals)->setWhenToGo($row->when_to_go)->setVisasOverview($row->visas_overview)->setElectricalPlugs($row->electrical_plugs)->setElectricityVoltage($row->electricity_voltage)->setElectricityHz($row->electricity_hz)->setDangersAndAnnoyances($row->dangers_and_annoyances)->setHealthConditions($row->health_conditions)->setWeatherOverview($row->weather_overview)->setCountryDiallingCode($row->country_dialling_code)->setTransport($row->transport)->setHistoryPre20c($row->history_pre_20c)->setHistoryModern($row->history_modern)->setHistoryRecent($row->history_recent)->setProductInfo($row->product_info)->setImages($row->images)->setMap($row->map)->setPois($row->pois)->setAttractions($row->attractions)->setCopyright($row->copyright)->setCountryId($row->country_id)->setAddedon($row->addedon);
     return $model;
 }
예제 #2
0
 public function addCountryAction()
 {
     //get request variables and set to view
     $id = $this->_getParam("id");
     $page = $this->_getParam("page");
     $selTab = $this->_getParam("tab", "tabs-1");
     $this->view->id = $id;
     $this->view->page = $page;
     $this->view->selTab = $selTab;
     $errorMsg = "";
     $request = $this->getRequest();
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($options["update_action"] == "overview") {
             $node_id = 0;
             $destination_name = "";
             $full_destination_name = "";
             $intro_mini = "";
             $intro_short = $options["introShort"];
             $timezones = array("0" => array("gmt_utc" => ""));
             $leaders = array(0 => array("leader_name" => "", "leader_type" => "", "leader_title" => ""));
             $religion = "";
             $currency_code = "";
             $currency_name = "";
             $currency_symbol = "";
             $currency_unit = "";
             $electrical_plugs = array(0 => array("image_filename" => "/images/plug_types/elec_4.gif", "electrical_plug_description" => ""));
             $health_conditions = array("cholera" => "", "dengue fever" => "", "hepatitis" => "", "malaria" => "", "meningococcal meningitis" => "", "typhoid" => "");
             $transport = array("getting there and away" => "", "getting around" => "");
             //$images				= array ("0"=> array("image_caption"=>"", "image_photographer"=>"Administrator", "image_filename"=>"", "image_thumbnail_filename"=>""));
             $images = array();
             $map = array("map_name" => "N/A", "map_filename" => "/maps/", "map_thumbnail_filename" => "/maps/thumbs/");
             $pois = array("0" => array("poi_name" => "", "address_parts" => array("0" => array("address_type" => "street", "address_text" => "")), "address_postcode" => "", "poi_web" => "", "review_summary" => "", "review_full" => "", "keywords" => array("keyword" => array("0" => "NA"))));
             $attractions = array("0" => array("destination_name" => "", "full_destination_name" => "", "intro_short" => "", "intro_medium" => ""));
             $country_id = $options["countryId"];
             $area_sqkm = 0;
             $population = 0;
             $language_spokens = array(0 => array("language_spoken_type" => "official", "language_spoken_name" => "N/A", "language_spoken_description" => "N/A"));
             //get Country name
             $countryM = new Application_Model_Country();
             $countryM = $countryM->find($options["countryId"]);
             if ($countryM !== false) {
                 $destination_name = $countryM->getName();
                 $full_destination_name = $countryM->getName();
             }
             $params["nodeId"] = $node_id;
             $params["destinationName"] = $destination_name;
             $params["fullDestinationName"] = $full_destination_name;
             $params["introMini"] = $intro_mini;
             $params["introShort"] = $intro_short;
             $params["timezones"] = serialize($timezones);
             $params["leaders"] = serialize($leaders);
             $params["areaSqkm"] = $area_sqkm;
             $params["population"] = $population;
             $params["languageSpokens"] = serialize($language_spokens);
             $params["religion"] = $religion;
             $params["currencyCode"] = $currency_code;
             $params["currencyName"] = $currency_name;
             $params["currencySymbol"] = $currency_symbol;
             $params["currencyUnit"] = $currency_unit;
             $params["electricalPlugs"] = serialize($electrical_plugs);
             $params["healthConditions"] = serialize($health_conditions);
             $params["transport"] = serialize($transport);
             $params["images"] = serialize($images);
             $params["map"] = serialize($map);
             $params["pois"] = serialize($pois);
             $params["attractions"] = serialize($attractions);
             $params["countryId"] = $country_id;
             $lonelyPlanetCountryM = new Application_Model_LonelyPlanetCountry($params);
             $res = $lonelyPlanetCountryM->save();
             if ($res) {
                 //save destination information into DB
                 $title = "A guide to " . $destination_name;
                 $introduction = "";
                 $location_id = $country_id;
                 $location_type = "country";
                 $bankBreakerAllArr = array();
                 $bankBreakerArr1 = array();
                 $bankBreakerArr2 = array();
                 for ($item = 0; $item < count($options["bankBreakerItem"]); $item++) {
                     $bankBreakerArr1[$options["bankBreakerItem"][$item]] = $options["bankBreakerRating"][$item];
                 }
                 $bankBreakerArr2["amount"] = $options["bankBreakerAmount"];
                 $bankBreakerArr2["currency"] = $options["bankBreakerCurrency"];
                 $bankBreakerArr2["rate"] = $options["bankBreakerRate"];
                 $bankBreakerAllArr["bankBreaker"] = $bankBreakerArr1;
                 $bankBreakerAllArr["dailyBudget"] = $bankBreakerArr2;
                 $bank_breaker = serialize($bankBreakerAllArr);
                 $knowledgeArr = array(0 => array("title" => "", "copy" => ""));
                 $knowledge = serialize($knowledgeArr);
                 $destination["title"] = $title;
                 $destination["introduction"] = $introduction;
                 $destination["locationId"] = $location_id;
                 $destination["locationType"] = $location_type;
                 $destination["bankBreaker"] = $bank_breaker;
                 $destination["knowledge"] = $knowledge;
                 //if Destination information is already exists then update table record else insert new record
                 $destinationM = new Application_Model_Destination($destination);
                 $destinationM = $destinationM->fetchRow("location_id={$location_id} AND location_type='country'");
                 if (false !== $destinationM) {
                     $destinationM->setTitle($title);
                     $destinationM->setIntroduction($introduction);
                     $destinationM->setLocationId($location_id);
                     $destinationM->setLocationType($location_type);
                     $destinationM->setBankBreaker($bank_breaker);
                     $destinationM->setKnowledge($knowledge);
                     $destinationM->save();
                     $destination_id = $destinationM->getId();
                 } else {
                     $destinationM = new Application_Model_Destination($destination);
                     $destination_id = $destinationM->save();
                 }
                 if ($destination_id) {
                     //save Don't leave Without information
                     for ($dont = 0; $dont < count($options["pracTitle"]); $dont++) {
                         if (trim($options["pracTitle"][$dont]) != "") {
                             $pracTitle = $options["pracTitle"][$dont];
                             $pracCopy = $options["pracCopy"][$dont];
                             $newItem["title"] = $pracTitle;
                             $newItem["copy"] = $pracCopy;
                             $newItem["destinationId"] = $destination_id;
                             $dontLeaveWithoutM = new Application_Model_DontLeaveWithout($newItem);
                             $dontId = $dontLeaveWithoutM->save();
                         }
                         //end if
                     }
                     //end for
                     //$_SESSION['errorMsg'] = "Overview has been saved.";
                     $this->_helper->redirector("edit-country", "featured-city", "admin", array("id" => $id, "page" => $page, "tab" => "tabs-1"));
                 } else {
                     $errorMsg = "Error occured, unable to save data into destination.";
                 }
             } else {
                 $errorMsg = "Error occured, unable to save data into Lonely Planet country.";
             }
         }
         //end if
     }
     //end if
     $this->view->errorMsg = $errorMsg;
 }