oxaddress.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxAddress extends oxBase
00007 {
00008 
00014     protected $_sClassName = 'oxaddress';
00015 
00021     protected $_blSelected = false;
00022 
00026     protected $_oStateObject = null;
00027 
00033     protected function _getStateObject()
00034     {
00035         if (is_null($this->_oStateObject)) {
00036             $this->_oStateObject = oxNew('oxState');
00037         }
00038 
00039         return $this->_oStateObject;
00040     }
00041 
00047     public function __construct()
00048     {
00049         parent::__construct();
00050         $this->init('oxaddress');
00051     }
00052 
00058     public function __toString()
00059     {
00060         return $this->toString();
00061     }
00062 
00068     public function toString()
00069     {
00070         $sFirstName = $this->oxaddress__oxfname->value;
00071         $sLastName = $this->oxaddress__oxlname->value;
00072         $sStreet = $this->oxaddress__oxstreet->value;
00073         $sStreetNr = $this->oxaddress__oxstreetnr->value;
00074         $sCity = $this->oxaddress__oxcity->value;
00075 
00076         //format it
00077         $sAddress = "";
00078         if ($sFirstName || $sLastName) {
00079             $sAddress = $sFirstName . ($sFirstName ? " " : "") . "$sLastName, ";
00080         }
00081         $sAddress .= "$sStreet $sStreetNr $sCity";
00082 
00083         $sAddress = trim($sAddress);
00084 
00085         return $sAddress;
00086     }
00087 
00093     public function getEncodedDeliveryAddress()
00094     {
00095         return md5($this->_getMergedAddressFields());
00096     }
00097 
00105     public function getState()
00106     {
00107         return $this->getStateId();
00108     }
00109 
00115     public function getStateId()
00116     {
00117         return $this->oxaddress__oxstateid->value;
00118     }
00119 
00120 
00128     public function getStateTitle($sId = null)
00129     {
00130         $oState = $this->_getStateObject();
00131 
00132         if (is_null($sId)) {
00133             $sId = $this->getStateId();
00134         }
00135 
00136         return $oState->getTitleById($sId);
00137     }
00138 
00144     public function isSelected()
00145     {
00146         return $this->_blSelected;
00147     }
00148 
00152     public function setSelected()
00153     {
00154         $this->_blSelected = true;
00155     }
00156 
00162     protected function _getMergedAddressFields()
00163     {
00164         $sDelAddress = '';
00165         $sDelAddress .= $this->oxaddress__oxcompany;
00166         $sDelAddress .= $this->oxaddress__oxfname;
00167         $sDelAddress .= $this->oxaddress__oxlname;
00168         $sDelAddress .= $this->oxaddress__oxstreet;
00169         $sDelAddress .= $this->oxaddress__oxstreetnr;
00170         $sDelAddress .= $this->oxaddress__oxaddinfo;
00171         $sDelAddress .= $this->oxaddress__oxcity;
00172         $sDelAddress .= $this->oxaddress__oxcountryid;
00173         $sDelAddress .= $this->oxaddress__oxstateid;
00174         $sDelAddress .= $this->oxaddress__oxzip;
00175         $sDelAddress .= $this->oxaddress__oxfon;
00176         $sDelAddress .= $this->oxaddress__oxfax;
00177         $sDelAddress .= $this->oxaddress__oxsal;
00178 
00179         return $sDelAddress;
00180     }
00181 }