2
0

ProfileEntry.php 4.0 KB

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