web/lib/Zend/Gdata/Health/ProfileEntry.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * Zend Framework
       
     5  *
       
     6  * LICENSE
       
     7  *
       
     8  * This source file is subject to the new BSD license that is bundled
       
     9  * with this package in the file LICENSE.txt.
       
    10  * It is also available through the world-wide-web at this URL:
       
    11  * http://framework.zend.com/license/new-bsd
       
    12  * If you did not receive a copy of the license and are unable to
       
    13  * obtain it through the world-wide-web, please send an email
       
    14  * to license@zend.com so we can send you a copy immediately.
       
    15  *
       
    16  * @category   Zend
       
    17  * @package    Zend_Gdata
       
    18  * @subpackage Health
       
    19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    21  * @version    $Id: ProfileEntry.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_Entry
       
    26  */
       
    27 require_once 'Zend/Gdata/Entry.php';
       
    28 
       
    29 /**
       
    30  * @see Zend_Gdata_Health_Extension_Ccr
       
    31  */
       
    32 require_once 'Zend/Gdata/Health/Extension/Ccr.php';
       
    33 
       
    34 /**
       
    35  * Concrete class for working with Health profile entries.
       
    36  *
       
    37  * @link http://code.google.com/apis/health/
       
    38  *
       
    39  * @category   Zend
       
    40  * @package    Zend_Gdata
       
    41  * @subpackage Health
       
    42  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    43  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    44  */
       
    45 class Zend_Gdata_Health_ProfileEntry extends Zend_Gdata_Entry
       
    46 {
       
    47     /**
       
    48      * The classname for individual profile entry elements.
       
    49      *
       
    50      * @var string
       
    51      */
       
    52     protected $_entryClassName = 'Zend_Gdata_Health_ProfileEntry';
       
    53 
       
    54     /**
       
    55      * Google Health CCR data
       
    56      *
       
    57      * @var Zend_Gdata_Health_Extension_Ccr
       
    58      */
       
    59     protected $_ccrData = null;
       
    60 
       
    61     /**
       
    62      * Constructs a new Zend_Gdata_Health_ProfileEntry object.
       
    63      * @param DOMElement $element (optional) The DOMElement on which to base this object.
       
    64      */
       
    65     public function __construct($element = null)
       
    66     {
       
    67         foreach (Zend_Gdata_Health::$namespaces as $nsPrefix => $nsUri) {
       
    68             $this->registerNamespace($nsPrefix, $nsUri);
       
    69         }
       
    70         parent::__construct($element);
       
    71     }
       
    72 
       
    73     /**
       
    74      * Retrieves a DOMElement which corresponds to this element and all
       
    75      * child properties.  This is used to build an entry back into a DOM
       
    76      * and eventually XML text for application storage/persistence.
       
    77      *
       
    78      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    79      * @return DOMElement The DOMElement representing this element and all
       
    80      *          child properties.
       
    81      */
       
    82     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
    83     {
       
    84         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
    85         if ($this->_ccrData !== null) {
       
    86           $element->appendChild($this->_ccrData->getDOM($element->ownerDocument));
       
    87         }
       
    88 
       
    89         return $element;
       
    90     }
       
    91 
       
    92     /**
       
    93      * Creates individual Entry objects of the appropriate type and
       
    94      * stores them as members of this entry based upon DOM data.
       
    95      *
       
    96      * @param DOMNode $child The DOMNode to process
       
    97      */
       
    98     protected function takeChildFromDOM($child)
       
    99     {
       
   100         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
       
   101 
       
   102         if (strstr($absoluteNodeName, $this->lookupNamespace('ccr') . ':')) {
       
   103             $ccrElement = new Zend_Gdata_Health_Extension_Ccr();
       
   104             $ccrElement->transferFromDOM($child);
       
   105             $this->_ccrData = $ccrElement;
       
   106         } else {
       
   107             parent::takeChildFromDOM($child);
       
   108 
       
   109         }
       
   110     }
       
   111 
       
   112     /**
       
   113      * Sets the profile entry's CCR data
       
   114      * @param string $ccrXMLStr The CCR as an xml string
       
   115      * @return Zend_Gdata_Health_Extension_Ccr
       
   116      */
       
   117     public function setCcr($ccrXMLStr) {
       
   118         $ccrElement = null;
       
   119         if ($ccrXMLStr != null) {
       
   120           $ccrElement = new Zend_Gdata_Health_Extension_Ccr();
       
   121           $ccrElement->transferFromXML($ccrXMLStr);
       
   122           $this->_ccrData = $ccrElement;
       
   123         }
       
   124         return $ccrElement;
       
   125     }
       
   126 
       
   127 
       
   128     /**
       
   129      * Returns all the CCR data in a profile entry
       
   130      * @return Zend_Gdata_Health_Extension_Ccr
       
   131      */
       
   132     public function getCcr() {
       
   133         return $this->_ccrData;
       
   134     }
       
   135 }