2
0

ProfileEntry.php 4.0 KB

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