/** * Load all countries * * @return array */ public static function getAllCountries() { if (self::$completeLoad == false) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('*')->from($db->qn('#__redcore_country')); $db->setQuery($query); $items = $db->loadObjectList(); foreach ($items as $item) { $item->code = $item->alpha2; self::$countries[$item->alpha2] = $item; } self::$completeLoad = true; } return self::$countries; }
/** * Return supported currencies from http://www.currency-iso.org * * @return array */ protected static function get_iso_codes() { if (!self::$codes) { // Xml file was pulled from http://www.currency-iso.org/dam/downloads/table_a1.xml. Should be refreshed sometimes ! $xml = file_get_contents(dirname(__FILE__) . '/countries_iso_3166_alpha_2_table.xml'); $obj = new SimpleXMLElement($xml); $codes = array(); foreach ($obj->children() as $country) { $code = (string) $country->{'ISO_3166-1_Alpha-2_Code_element'}; if ($code && !isset($currencies[$code])) { $obj = new stdclass(); $obj->name = (string) $country->{'ISO_3166-1_Country_name'}; $obj->code = (string) $country->{'ISO_3166-1_Alpha-2_Code_element'}; $codes[$code] = $obj; } } self::$codes = $codes; } return self::$codes; }
/** * Method to get the options to populate list * * @return array The field option objects. * * @since 1.0 */ protected function getOptions() { $options = array_merge(parent::getOptions(), RHelperCountry::getOptions()); return $options; }