예제 #1
0
파일: city.php 프로젝트: nemein/openpsa
 /**
  * @return org_routamc_positioning_country_dba Country the city is in
  */
 function get_parent_guid_uncached()
 {
     if ($this->country) {
         $qb = org_routamc_positioning_country_dba::new_query_builder();
         $qb->add_constraint('code', '=', $this->country);
         $countries = $qb->execute();
         if (count($countries) == 0) {
             debug_add("Could not load Country ID {$this->country} from the database, aborting.", MIDCOM_LOG_INFO);
             return null;
         }
         return $countries[0]->guid;
     }
     return null;
 }
예제 #2
0
파일: country.php 프로젝트: nemein/openpsa
 static function get_by_name($name)
 {
     // Seek by strict city name first
     $qb = org_routamc_positioning_country_dba::new_query_builder();
     $qb->add_constraint('name', 'LIKE', $name);
     $qb->set_limit(1);
     $matches = $qb->execute_unchecked();
     if (count($matches) > 0) {
         return $matches[0];
     }
     // Strict name didn't match, seek by alternate names
     $qb = org_routamc_positioning_country_dba::new_query_builder();
     $qb->add_constraint('alternatenames', 'LIKE', "%{$name}%");
     // Most likely we're interested in the biggest city that matches
     $qb->add_order('population', 'DESC');
     $qb->set_limit(1);
     $matches = $qb->execute_unchecked();
     if (count($matches) > 0) {
         return $matches[0];
     }
     return false;
 }
예제 #3
0
 public function __construct($args)
 {
     $this->_component = 'org.routamc.positioning';
     parent::__construct();
     $this->_data = array();
     if (isset($args['start_message'])) {
         if (is_bool($args['start_message']) && $args['start_message']) {
             $this->_data[''] = $this->_l10n->get('select your country');
         } else {
             if (is_string($args['start_message'])) {
                 $this->_data[''] = $args['start_message'];
             }
         }
     }
     $qb = org_routamc_positioning_country_dba::new_query_builder();
     $qb->add_constraint('code', '<>', '');
     $qb->add_order('name', 'ASC');
     $countries = $qb->execute_unchecked();
     if (count($countries) == 0) {
         debug_add('No countries found. You have to use org.routamc.positioning to import countries to database.');
     }
     $this->_populate_data($countries);
 }
예제 #4
0
파일: widget.php 프로젝트: nemein/openpsa
 function _get_country_list()
 {
     $this->_countrylist = array('' => midcom::get('i18n')->get_string('select your country', 'org.routamc.positioning'));
     $qb = org_routamc_positioning_country_dba::new_query_builder();
     $qb->add_constraint('code', '<>', '');
     $qb->add_order('name', 'ASC');
     $countries = $qb->execute_unchecked();
     if (count($countries) == 0) {
         debug_add('Cannot render country list: No countries found. You have to use org.routamc.positioning to import countries to database.');
     }
     foreach ($countries as $country) {
         $this->_countrylist[$country->code] = $country->name;
     }
 }
예제 #5
0
파일: manual.php 프로젝트: nemein/openpsa
 /**
  * Modify country to conform to ISO standards
  */
 function normalize_country($country)
 {
     if (strlen($country) == 2) {
         // Probably an ISO code
         return $country;
     }
     $qb = org_routamc_positioning_country_dba::new_query_builder();
     $qb->add_constraint('name', '=', $country);
     $countries = $qb->execute();
     if (count($countries) > 0) {
         return $countries[0]->code;
     }
     return '';
 }