2
0

Person.php 4.3 KB

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