[44] | 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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
| 20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | * @see Zend_Gdata_Entry
|
---|
| 25 | */
|
---|
| 26 | require_once 'Zend/Gdata/Entry.php';
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * @see Zend_Gdata_Health_Extension_Ccr
|
---|
| 30 | */
|
---|
| 31 | require_once 'Zend/Gdata/Health/Extension/Ccr.php';
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * Concrete class for working with Health profile entries.
|
---|
| 35 | *
|
---|
| 36 | * @link http://code.google.com/apis/health/
|
---|
| 37 | *
|
---|
| 38 | * @category Zend
|
---|
| 39 | * @package Zend_Gdata
|
---|
| 40 | * @subpackage Health
|
---|
| 41 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
| 42 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
| 43 | */
|
---|
| 44 | class Zend_Gdata_Health_ProfileEntry extends Zend_Gdata_Entry
|
---|
| 45 | {
|
---|
| 46 | /**
|
---|
| 47 | * The classname for individual profile entry elements.
|
---|
| 48 | *
|
---|
| 49 | * @var string
|
---|
| 50 | */
|
---|
| 51 | protected $_entryClassName = 'Zend_Gdata_Health_ProfileEntry';
|
---|
| 52 |
|
---|
| 53 | /**
|
---|
| 54 | * Google Health CCR data
|
---|
| 55 | *
|
---|
| 56 | * @var Zend_Gdata_Health_Extension_Ccr
|
---|
| 57 | */
|
---|
| 58 | protected $_ccrData = null;
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | * Constructs a new Zend_Gdata_Health_ProfileEntry object.
|
---|
| 62 | * @param DOMElement $element (optional) The DOMElement on which to base this object.
|
---|
| 63 | */
|
---|
| 64 | public function __construct($element = null)
|
---|
| 65 | {
|
---|
| 66 | foreach (Zend_Gdata_Health::$namespaces as $nsPrefix => $nsUri) {
|
---|
| 67 | $this->registerNamespace($nsPrefix, $nsUri);
|
---|
| 68 | }
|
---|
| 69 | parent::__construct($element);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | /**
|
---|
| 73 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
| 74 | * child properties. This is used to build an entry back into a DOM
|
---|
| 75 | * and eventually XML text for application storage/persistence.
|
---|
| 76 | *
|
---|
| 77 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
| 78 | * @return DOMElement The DOMElement representing this element and all
|
---|
| 79 | * child properties.
|
---|
| 80 | */
|
---|
| 81 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
| 82 | {
|
---|
| 83 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
| 84 | if ($this->_ccrData !== null) {
|
---|
| 85 | $element->appendChild($this->_ccrData->getDOM($element->ownerDocument));
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | return $element;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | /**
|
---|
| 92 | * Creates individual Entry objects of the appropriate type and
|
---|
| 93 | * stores them as members of this entry based upon DOM data.
|
---|
| 94 | *
|
---|
| 95 | * @param DOMNode $child The DOMNode to process
|
---|
| 96 | */
|
---|
| 97 | protected function takeChildFromDOM($child)
|
---|
| 98 | {
|
---|
| 99 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
|
---|
| 100 |
|
---|
| 101 | if (strstr($absoluteNodeName, $this->lookupNamespace('ccr') . ':')) {
|
---|
| 102 | $ccrElement = new Zend_Gdata_Health_Extension_Ccr();
|
---|
| 103 | $ccrElement->transferFromDOM($child);
|
---|
| 104 | $this->_ccrData = $ccrElement;
|
---|
| 105 | } else {
|
---|
| 106 | parent::takeChildFromDOM($child);
|
---|
| 107 |
|
---|
| 108 | }
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /**
|
---|
| 112 | * Sets the profile entry's CCR data
|
---|
| 113 | * @param string $ccrXMLStr The CCR as an xml string
|
---|
| 114 | * @return Zend_Gdata_Health_Extension_Ccr
|
---|
| 115 | */
|
---|
| 116 | public function setCcr($ccrXMLStr) {
|
---|
| 117 | $ccrElement = null;
|
---|
| 118 | if ($ccrXMLStr != null) {
|
---|
| 119 | $ccrElement = new Zend_Gdata_Health_Extension_Ccr();
|
---|
| 120 | $ccrElement->transferFromXML($ccrXMLStr);
|
---|
| 121 | $this->_ccrData = $ccrElement;
|
---|
| 122 | }
|
---|
| 123 | return $ccrElement;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | /**
|
---|
| 128 | * Returns all the CCR data in a profile entry
|
---|
| 129 | * @return Zend_Gdata_Health_Extension_Ccr
|
---|
| 130 | */
|
---|
| 131 | public function getCcr() {
|
---|
| 132 | return $this->_ccrData;
|
---|
| 133 | }
|
---|
| 134 | }
|
---|