oxcountry.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00008 class oxCountry extends oxI18n
00009 {
00015     protected $_sClassName = 'oxcountry';
00016 
00022     protected $_aStates = null;
00023 
00027     public function __construct()
00028     {
00029         parent::__construct();
00030         $this->init( 'oxcountry' );
00031     }
00032 
00038     public function isForeignCountry()
00039     {
00040         return !in_array($this->getId(), $this->getConfig()->getConfigParam( 'aHomeCountry' ));
00041     }
00042 
00048     public function isInEU()
00049     {
00050         return (bool) ($this->oxcountry__oxvatstatus->value == 1);
00051     }
00052 
00058     public function getStates()
00059     {
00060         if (!is_null($this->_aStates))
00061             return $this->_aStates;
00062 
00063         $sCountryId = $this->getId();
00064         $sViewName = getViewName( "oxstates", $this->getLanguage() );
00065         $sQ = "select * from {$sViewName} where `oxcountryid` = '$sCountryId' order by `oxtitle`  ";
00066         $this->_aStates = oxNew("oxlist");
00067         $this->_aStates->init("oxstate");
00068         $this->_aStates->selectString($sQ);
00069 
00070         return $this->_aStates;
00071     }
00072 
00080     public function getIdByCode( $sCode )
00081     {
00082         $oDb = oxDb::getDb();
00083         return $oDb->getOne( "select oxid from oxcountry where oxisoalpha2 = " . $oDb->quote( $sCode ) );
00084     }
00085 
00086 }