Person.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 App
  18. * @copyright Copyright (c) 2005-2015 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_App_Extension
  24. */
  25. require_once 'Zend/Gdata/App/Extension.php';
  26. /**
  27. * @see Zend_Gdata_App_Extension_Name
  28. */
  29. require_once 'Zend/Gdata/App/Extension/Name.php';
  30. /**
  31. * @see Zend_Gdata_App_Extension_Email
  32. */
  33. require_once 'Zend/Gdata/App/Extension/Email.php';
  34. /**
  35. * @see Zend_Gdata_App_Extension_Uri
  36. */
  37. require_once 'Zend/Gdata/App/Extension/Uri.php';
  38. /**
  39. * Base class for people (currently used by atom:author, atom:contributor)
  40. *
  41. * @category Zend
  42. * @package Zend_Gdata
  43. * @subpackage App
  44. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  45. * @license http://framework.zend.com/license/new-bsd New BSD License
  46. */
  47. abstract class Zend_Gdata_App_Extension_Person extends Zend_Gdata_App_Extension
  48. {
  49. protected $_rootElement = null;
  50. protected $_name = null;
  51. protected $_email = null;
  52. protected $_uri = null;
  53. public function __construct($name = null, $email = null, $uri = null)
  54. {
  55. parent::__construct();
  56. $this->_name = $name;
  57. $this->_email = $email;
  58. $this->_uri = $uri;
  59. }
  60. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  61. {
  62. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  63. if ($this->_name != null) {
  64. $element->appendChild($this->_name->getDOM($element->ownerDocument));
  65. }
  66. if ($this->_email != null) {
  67. $element->appendChild($this->_email->getDOM($element->ownerDocument));
  68. }
  69. if ($this->_uri != null) {
  70. $element->appendChild($this->_uri->getDOM($element->ownerDocument));
  71. }
  72. return $element;
  73. }
  74. protected function takeChildFromDOM($child)
  75. {
  76. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  77. switch ($absoluteNodeName) {
  78. case $this->lookupNamespace('atom') . ':' . 'name':
  79. $name = new Zend_Gdata_App_Extension_Name();
  80. $name->transferFromDOM($child);
  81. $this->_name = $name;
  82. break;
  83. case $this->lookupNamespace('atom') . ':' . 'email':
  84. $email = new Zend_Gdata_App_Extension_Email();
  85. $email->transferFromDOM($child);
  86. $this->_email = $email;
  87. break;
  88. case $this->lookupNamespace('atom') . ':' . 'uri':
  89. $uri = new Zend_Gdata_App_Extension_Uri();
  90. $uri->transferFromDOM($child);
  91. $this->_uri = $uri;
  92. break;
  93. default:
  94. parent::takeChildFromDOM($child);
  95. break;
  96. }
  97. }
  98. /**
  99. * @return Zend_Gdata_App_Extension_Name
  100. */
  101. public function getName()
  102. {
  103. return $this->_name;
  104. }
  105. /**
  106. * @param Zend_Gdata_App_Extension_Name $value
  107. * @return Zend_Gdata_App_Entry Provides a fluent interface
  108. */
  109. public function setName($value)
  110. {
  111. $this->_name = $value;
  112. return $this;
  113. }
  114. /**
  115. * @return Zend_Gdata_App_Extension_Email
  116. */
  117. public function getEmail()
  118. {
  119. return $this->_email;
  120. }
  121. /**
  122. * @param Zend_Gdata_App_Extension_Email $value
  123. * @return Zend_Gdata_App_Extension_Person Provides a fluent interface
  124. */
  125. public function setEmail($value)
  126. {
  127. $this->_email = $value;
  128. return $this;
  129. }
  130. /**
  131. * @return Zend_Gdata_App_Extension_Uri
  132. */
  133. public function getUri()
  134. {
  135. return $this->_uri;
  136. }
  137. /**
  138. * @param Zend_Gdata_App_Extension_Uri $value
  139. * @return Zend_Gdata_App_Extension_Person Provides a fluent interface
  140. */
  141. public function setUri($value)
  142. {
  143. $this->_uri = $value;
  144. return $this;
  145. }
  146. }