oxaddress.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxAddress extends oxBase
00008 {
00014     protected $_sClassName = 'oxaddress';
00015 
00021     protected $_blSelected = false;
00022 
00028     public function __construct()
00029     {
00030         parent::__construct();
00031         $this->init( 'oxaddress' );
00032     }
00033 
00039     public function __toString()
00040     {
00041         return $this->toString();
00042     }
00043 
00049     public function toString()
00050     {
00051         $sFirstName = $this->oxaddress__oxfname->value;
00052         $sLastName  = $this->oxaddress__oxlname->value;
00053         $sStreet    = $this->oxaddress__oxstreet->value;
00054         $sStreetNr  = $this->oxaddress__oxstreetnr->value;
00055         $sCity      = $this->oxaddress__oxcity->value;
00056 
00057         //format it
00058         $sAddress = "";
00059         if ($sFirstName || $sLastName) {
00060             $sAddress = $sFirstName. ($sFirstName?" ":"") . "$sLastName, ";
00061         }
00062         $sAddress .= "$sStreet $sStreetNr $sCity";
00063 
00064         $sAddress = trim($sAddress);
00065 
00066         return $sAddress;
00067     }
00068 
00074     public function getEncodedDeliveryAddress()
00075     {
00076         return md5($this->_getMergedAddressFields());
00077     }
00078 
00084     public function getState()
00085     {
00086         return $this->oxaddress__oxstateid->value;
00087     }
00088 
00094     public function isSelected()
00095     {
00096         return $this->_blSelected;
00097     }
00098 
00104     public function setSelected()
00105     {
00106         $this->_blSelected = true;
00107     }
00108 
00114     protected function _getMergedAddressFields()
00115     {
00116         $sDelAddress = '';
00117         $sDelAddress .= $this->oxaddress__oxcompany;
00118         $sDelAddress .= $this->oxaddress__oxfname;
00119         $sDelAddress .= $this->oxaddress__oxlname;
00120         $sDelAddress .= $this->oxaddress__oxstreet;
00121         $sDelAddress .= $this->oxaddress__oxstreetnr;
00122         $sDelAddress .= $this->oxaddress__oxaddinfo;
00123         $sDelAddress .= $this->oxaddress__oxcity;
00124         $sDelAddress .= $this->oxaddress__oxcountryid;
00125         $sDelAddress .= $this->oxaddress__oxstateid;
00126         $sDelAddress .= $this->oxaddress__oxzip;
00127         $sDelAddress .= $this->oxaddress__oxfon;
00128         $sDelAddress .= $this->oxaddress__oxfax;
00129         $sDelAddress .= $this->oxaddress__oxsal;
00130 
00131         return $sDelAddress;
00132     }
00133 }