Countries
A set of countries and their relationships. More...
Classes |
|
class | Countries |
Facade class for countries. More... |
|
class | DAOContinents |
Model class for continetns. More... |
|
class | DAOCountries |
Model class for countries. More... |
|
class | DAOCountries2countriesgroups |
Model class for assigning countries to
groups. More... |
|
class | DAOCountriesgroups |
Model class for country groups. More... |
|
class | DAOCountriestranslations |
Model class for translation of country
names. More... |
|
Functions |
|
countries_load_translations ($languages) | |
Load translation for countries.
|
Detailed Description
A set of countries and their relationships.
Usage
This module offers the following models:
- countries: All countries that are listed in ISO 3166: http://www.iso.org/iso/english_country_names_and_code_elements
- continents: All continents. Each country is assigend to one continent
- countriesgroups: Groups of countries, currently implemented are European Union, Dependend Territories and Sovereign States.
- countriestranslations: Translation of country names is done using DB, not files. Currently, only German translations are maintained (based upon http://www.auswaertiges-amt.de/diplo/de/Infoservice/Terminologie/Staatennamen.pdf)
The ID space of countriesgroups is divided into three segments:
- 1-99: Reserved for use by this module
- 100-999: Reserved for use by other contributions.
- 1000-: May be used by applications. Autoincrement pointer is set to 1000, so your application can insert groups without setting a fixed ID
Function Documentation
countries_load_translations | ( | $ | languages | ) |
Load translation for countries.
This is an example of how to use DB based translations
Definition at line 10 of file countries.translations.php.
00010 { 00011 $ret = array( 00012 'Africa' => array( 00013 'de' => 'Afrika' 00014 ), 00015 'Antartica' => array( 00016 'de' => 'Antarktis' 00017 ), 00018 'Asia' => array( 00019 'de' => 'Asien' 00020 ), 00021 'Europe' => array( 00022 'de' => 'Europa' 00023 ), 00024 'North America' => array( 00025 'de' => 'Nordamerika' 00026 ), 00027 'Oceania' => array( 00028 'de' => 'Ozeanien' 00029 ), 00030 'South America' => array( 00031 'de' => 'Südamerika' 00032 ), 00033 'European Union' => array( 00034 'de' => 'Europäische Union' 00035 ), 00036 'NONE' => array( 00037 'en' => 'None', 00038 'de' => 'Kein' 00039 ), 00040 'GEOGRAPHICAL' => array( 00041 'en' => 'Geographical', 00042 'de' => 'Geografisch' 00043 ), 00044 'POLITICAL' => array( 00045 'en' => 'Political', 00046 'de' => 'Politisch' 00047 ), 00048 'CULTURAL' => array( 00049 'en' => 'Cutural', 00050 'de' => 'Kulturell' 00051 ) 00052 ); 00053 // Load translations for countries 00054 Load::models('countries', 'countriestranslations'); 00055 $dao_c = new DAOCountries(); 00056 $dao_t = new DAOCountriestranslations(); 00057 $dao_t->add_where('lang', DBWhere::OP_IN, $languages); 00058 $dao_c->join($dao_t); 00059 00060 $query = $dao_c->create_select_query(); 00061 $query->set_fields(array('countries.name' => 'source', 'countriestranslations.lang' => 'lang', 'countriestranslations.name' => 'translation')); 00062 00063 $countries = array(); 00064 $result = DB::query($query->get_sql(), $dao_c->get_table_driver()); 00065 while($data = $result->fetch()) { 00066 $countries[$data['source']][$data['lang']] = $data['translation']; 00067 } 00068 00069 $ret = array_merge($ret, $countries); 00070 return $ret; 00071 }