public function setCountriesFromOldConfigFile() { $countriesConfigFile = new CountriesConfigFile(); try { $countries = $countriesConfigFile->read(); } catch (Gpf_Exception $e) { Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED); return; } if ($countries == '') { Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED); return; } Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_DISABLED); $countriesCodesArray = preg_split('/,/', $countries); foreach ($countriesCodesArray as $countryCode) { $country = new Gpf_Db_Country(); $country->setCountryCode($countryCode); $country->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); try { $country->loadFromData(array(Gpf_Db_Table_Countries::COUNTRY_CODE, Gpf_Db_Table_Countries::ACCOUNTID)); $country->setStatus(Gpf_Db_Country::STATUS_ENABLED); $country->save(); } catch (Gpf_Exception $e) { } } }
private function resolveCountryNames($countryArray) { $out = ''; if (count($countryArray) == 0) { return $out; } foreach ($countryArray as $code) { $out .= $this->_localize(Gpf_Country_Countries::getCountryName($code)) . ', '; } return substr($out, 0, -2); }
private function setupCountries() { Gpf_Country_Countries::insertCountriesToDB(Gpf_Db_Country::STATUS_ENABLED); Gpf_Settings::set(Gpf_Settings_Gpf::DEFAULT_COUNTRY, "US"); }
/** * @param $countryStatus (E - Enabled, D - Disabled, defined in Gpf_Db_Country) */ public static function insertCountriesToDB($countryStatus) { if (self::$countries == null) { self::$countries = self::createCountries(); } foreach (self::$countries as $code => $name) { $country = new Gpf_Db_Country(); $country->setCountryCode($code); $country->setCountry($name); $country->setStatus($countryStatus); $country->setAccountId(Gpf_Session::getAuthUser()->getAccountId()); try { $country->save(); } catch (Gpf_DbEngine_Row_ConstraintException $e) { } } }