[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/Zend/Gdata/Contacts/Extension/ -> StructuredPostalAddress.php (source)

   1  <?php
   2  
   3  /**
   4   * https://github.com/prasad83/Zend-Gdata-Contacts
   5   * @author prasad
   6   * 
   7   * LICENSE
   8   *
   9   * This source file is subject to the new BSD license that is bundled
  10   * with this package in the file LICENSE.txt.
  11   * It is also available through the world-wide-web at this URL:
  12   * http://framework.zend.com/license/new-bsd
  13   * If you did not receive a copy of the license and are unable to
  14   * obtain it through the world-wide-web, please send an email
  15   * to [email protected] so we can send you a copy immediately.
  16   *
  17   * @category   Zend
  18   * @package    Zend_Gdata
  19   * @subpackage Contacts
  20   */
  21  require_once  'Zend/Gdata/Contacts/Extension.php';
  22  
  23  require_once  'Zend/Gdata/Contacts/Extension/FormattedAddress.php';
  24  require_once  'Zend/Gdata/Contacts/Extension/Street.php';
  25  require_once  'Zend/Gdata/Contacts/Extension/Postcode.php';
  26  require_once  'Zend/Gdata/Contacts/Extension/Region.php';
  27  require_once  'Zend/Gdata/Contacts/Extension/Country.php';
  28  require_once  'Zend/Gdata/Contacts/Extension/City.php';
  29  require_once  'Zend/Gdata/Contacts/Extension/Pobox.php';
  30  
  31  class Zend_Gdata_Contacts_Extension_StructuredPostalAddress extends Zend_Gdata_Contacts_Extension {
  32      protected $_rootElement = 'structuredPostalAddress';
  33      
  34      protected $_rel;
  35      protected $_formattedAddress, $_street,$_postcode,$_city,$_pobox,$_region,$_country; 
  36      
  37  	public function __construct($value = null, $rel = 'work') {
  38          parent::__construct();
  39          $this->_rel = $rel;
  40          $this->_formattedAddress = new Zend_Gdata_Contacts_Extension_FormattedAddress($value);
  41                  $this->_city = new Zend_Gdata_Contacts_Extension_City($value);
  42                  $this->_country = new Zend_Gdata_Contacts_Extension_Country($value);
  43                  $this->_pobox = new Zend_Gdata_Contacts_Extension_Pobox($value);
  44                  $this->_postcode = new Zend_Gdata_Contacts_Extension_Postcode($value);
  45                  $this->_region = new Zend_Gdata_Contacts_Extension_Region($value);
  46      }
  47      
  48  	public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) {
  49          $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  50          $element->setAttribute("rel", $this->lookupNamespace("gd").'#'.$this->_rel);
  51          if ($this->_formattedAddress != null) {
  52              $element->appendChild($this->_formattedAddress->getDOM($element->ownerDocument));
  53          }
  54          if ($this->_street != null) {
  55              $element->appendChild($this->_street->getDOM($element->ownerDocument));
  56          }
  57                  if ($this->_postcode != null) {
  58                      
  59              $element->appendChild($this->_postcode->getDOM($element->ownerDocument));
  60          }
  61                  if ($this->_pobox!= null) {
  62              $element->appendChild($this->_pobox->getDOM($element->ownerDocument));
  63          }
  64                  if ($this->_city != null) {
  65              $element->appendChild($this->_city->getDOM($element->ownerDocument));
  66          }
  67                  if ($this->_region != null) {
  68              $element->appendChild($this->_region->getDOM($element->ownerDocument));
  69          }
  70                  if ($this->_country != null) {
  71              $element->appendChild($this->_country->getDOM($element->ownerDocument));
  72          }
  73          return $element;
  74      }
  75      
  76      /**
  77       * Creates individual Entry objects of the appropriate type and
  78       * stores them as members of this entry based upon DOM data.
  79       *
  80       * @param DOMNode $child The DOMNode to process
  81       */
  82      protected function takeChildFromDOM($child) {
  83          $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  84          $gdNamespacePrefix = $this->lookupNamespace('gd') . ':';
  85  
  86          switch ($absoluteNodeName) {
  87              case $gdNamespacePrefix . 'formattedAddress';
  88                  $formattedAddress = new Zend_Gdata_Contacts_Extension_FormattedAddress();
  89                  $formattedAddress->transferFromDOM($child);
  90                  $this->_formattedAddress = $formattedAddress;
  91                  break;
  92              case $gdNamespacePrefix . 'street';
  93                  $street = new Zend_Gdata_Contacts_Extension_Street();
  94                  $street->transferFromDOM($child);
  95                  $this->_street = $street;
  96                  break;
  97              case $gdNamespacePrefix . 'pobox';
  98                  $pobox = new Zend_Gdata_Contacts_Extension_Pobox();
  99                  $pobox->transferFromDOM($child);
 100                  $this->_pobox = $pobox;
 101                  break;
 102              case $gdNamespacePrefix . 'city';
 103                  $city = new Zend_Gdata_Contacts_Extension_City();
 104                  $city->transferFromDOM($child);
 105                  $this->_city = $city;
 106                  break;
 107              case $gdNamespacePrefix . 'country';
 108                  $country = new Zend_Gdata_Contacts_Extension_Country();
 109                  $country->transferFromDOM($child);
 110                  $this->_country = $country;
 111                  break;
 112              case $gdNamespacePrefix . 'region';
 113                  $region = new Zend_Gdata_Contacts_Extension_Region();
 114                  $region->transferFromDOM($child);
 115                  $this->_region = $region;
 116                  break;
 117              case $gdNamespacePrefix . 'postcode';
 118                  $postcode = new Zend_Gdata_Contacts_Extension_Postcode();
 119                  $postcode->transferFromDOM($child);
 120                  $this->_postcode = $postcode;
 121                  break;
 122          }
 123      }
 124      
 125  	public function getValue() {
 126          return $this->_formattedAddress->getValue();
 127      }
 128      
 129  	public function __toString() {
 130          $string = $this->_formattedAddress->__toString();
 131          if ($this->_street != null) $string .= "\n" . $this->_street->__toString();
 132          return trim($string);
 133      }
 134  
 135  
 136  	public function setFormattedAddress($value) {
 137          $this->_formattedAddress = $value;
 138          return $this;
 139      }
 140      
 141  	public function getFormattedAddress() {
 142          return $this->_formattedAddress;
 143      }
 144      
 145  	public function setStreet($value) {
 146          $this->_street = $value;
 147          return $this;
 148      }
 149      
 150  	public function getStreet() {
 151          return $this->_street;
 152      }
 153          
 154          public function getPobox() {
 155          return $this->_pobox;
 156      }
 157          public function setCity($value) {
 158          $this->_city = $value;
 159          return $this;
 160      }
 161      
 162  	public function getCity() {
 163          return $this->_city;
 164      }
 165          public function setCountry($value) {
 166          $this->_country = $value;
 167          return $this;
 168      }
 169      
 170  	public function getCountry() {
 171          return $this->_country;
 172      }
 173           public function setRegion($value) {
 174          $this->_region = $value;
 175          return $this;
 176      }
 177      
 178  	public function getRegion() {
 179          return $this->_region;
 180      }
 181           public function setPostCode($value) {
 182          $this->_postcode = $value;
 183          return $this;
 184      }
 185      
 186  	public function getPostCode() {
 187          return $this->_postcode;
 188      }
 189  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1