/** * Test for the sort feature of country list */ public function testFetchTranslatedNamesSort() { $translatedCountriesList = array( 'FR' => 'France', 'GB' => 'Royaume-uni', 'DE' => 'Allemagne', 'NO' => 'Norvège' ); ezpINIHelper::setINISetting( array( 'fre-FR.ini', 'share/locale' ), 'CountryNames', 'Countries', $translatedCountriesList ); ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'Locale', 'fre-FR' ); $countries = eZCountryType::fetchCountryList(); $this->assertInternalType( 'array', $countries, "eZCountryType::fetchCountryList() didn't return an array" ); $countryListIsSorted = true; foreach( $countries as $country ) { if ( !isset( $previousCountry ) ) { $previousCountry = $country; continue; } if ( strcoll( $previousCountry['Name'], $country['Name'] ) > 0 ) { $countryListIsSorted = false; break; } } ezpINIHelper::restoreINISettings(); $this->assertTrue( $countryListIsSorted, "Country list isn't sorted" ); }
function getCountryList($ret = false, $debug = false) { /* if ( $debug ) ezDebug::writeNotice( 'call', 'getCountryList:fetch' ); */ $countryType = new eZCountryType(); $countries = $countryType->fetchCountryList(); /* include_once( 'extension/ezdbug/autoloads/ezdbug.php' ); $d = new eZDBugOperators(); $d->ezdbugDump( $countries ); */ $ret =& $countries; if ($debug) { ezDebug::writeNotice($ret, 'getXMLString:ret'); } return $ret; }
public static function fetchCountryList($filter, $value) { // Fetch country list if (!$filter and !$value) { $country = eZCountryType::fetchCountryList(); } else { $country = eZCountryType::fetchCountry($value, $filter); } return array('result' => $country); }
function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute ) { if ( $http->hasPostVariable( $base . '_country_' . $contentObjectAttribute->attribute( 'id' ) ) ) { $data = $http->postVariable( $base . '_country_' . $contentObjectAttribute->attribute( 'id' ) ); $defaultList = array(); if ( is_array( $data ) ) { foreach ( $data as $alpha2 ) { if ( trim( $alpha2 ) == '' ) continue; $eZCountry = eZCountryType::fetchCountry( $alpha2, 'Alpha2' ); if ( $eZCountry ) $defaultList[$alpha2] = $eZCountry; } } else { $countries = eZCountryType::fetchCountryList(); foreach ( $countries as $country ) { if ( $country['Name'] == $data ) { $defaultList[$country['Alpha2']] = $country['Name']; } } } $content = array( 'value' => $defaultList ); $contentObjectAttribute->setContent( $content ); } else { $content = array( 'value' => array() ); $contentObjectAttribute->setContent( $content ); } return true; }
$script = eZScript::instance( array( 'description' => ( "eZ Publish Country update script\n\n" . "Upgrades db table in addition with upgrade from 3.9.2 to 3.9.3\n" . "Fixes bug with aplying VAT rules" ), 'use-session' => false, 'use-modules' => true, 'use-extensions' => true ) ); $script->startup(); $options = $script->getOptions( ); $script->initialize(); $db = eZDB::instance(); $countries = $db->arrayQuery( "SELECT country_code from ezvatrule;" ); $iniCountries = eZCountryType::fetchCountryList(); $updatedRules = 0; foreach ( $countries as $country ) { foreach ( $iniCountries as $iniCountry ) { if ( $iniCountry['Name'] == $country['country_code'] ) { $countryName = $country['country_code']; $countryCode = $iniCountry['Alpha2']; $db->query( "UPDATE ezvatrule SET country_code='" . $db->escapeString( $countryCode ) . "' WHERE country_code='" . $db->escapeString( $countryName ) . "'" ); $updatedRules++; } }