Link.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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_Extension
  23. */
  24. require_once 'Zend/Gdata/Extension.php';
  25. /**
  26. * Data model for representing an atom:link element
  27. *
  28. * @category Zend
  29. * @package Zend_Gdata
  30. * @subpackage App
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Gdata_App_Extension_Link extends Zend_Gdata_App_Extension
  35. {
  36. protected $_rootElement = 'link';
  37. protected $_href = null;
  38. protected $_rel = null;
  39. protected $_type = null;
  40. protected $_hrefLang = null;
  41. protected $_title = null;
  42. protected $_length = null;
  43. public function __construct($href = null, $rel = null, $type = null,
  44. $hrefLang = null, $title = null, $length = null)
  45. {
  46. parent::__construct();
  47. $this->_href = $href;
  48. $this->_rel = $rel;
  49. $this->_type = $type;
  50. $this->_hrefLang = $hrefLang;
  51. $this->_title = $title;
  52. $this->_length = $length;
  53. }
  54. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  55. {
  56. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  57. if ($this->_href !== null) {
  58. $element->setAttribute('href', $this->_href);
  59. }
  60. if ($this->_rel !== null) {
  61. $element->setAttribute('rel', $this->_rel);
  62. }
  63. if ($this->_type !== null) {
  64. $element->setAttribute('type', $this->_type);
  65. }
  66. if ($this->_hrefLang !== null) {
  67. $element->setAttribute('hreflang', $this->_hrefLang);
  68. }
  69. if ($this->_title !== null) {
  70. $element->setAttribute('title', $this->_title);
  71. }
  72. if ($this->_length !== null) {
  73. $element->setAttribute('length', $this->_length);
  74. }
  75. return $element;
  76. }
  77. protected function takeAttributeFromDOM($attribute)
  78. {
  79. switch ($attribute->localName) {
  80. case 'href':
  81. $this->_href = $attribute->nodeValue;
  82. break;
  83. case 'rel':
  84. $this->_rel = $attribute->nodeValue;
  85. break;
  86. case 'type':
  87. $this->_type = $attribute->nodeValue;
  88. break;
  89. case 'hreflang':
  90. $this->_hrefLang = $attribute->nodeValue;
  91. break;
  92. case 'title':
  93. $this->_title = $attribute->nodeValue;
  94. break;
  95. case 'length':
  96. $this->_length = $attribute->nodeValue;
  97. break;
  98. default:
  99. parent::takeAttributeFromDOM($attribute);
  100. }
  101. }
  102. /**
  103. * @return string|null
  104. */
  105. public function getHref()
  106. {
  107. return $this->_href;
  108. }
  109. /**
  110. * @param string|null $value
  111. * @return Zend_Gdata_App_Entry Provides a fluent interface
  112. */
  113. public function setHref($value)
  114. {
  115. $this->_href = $value;
  116. return $this;
  117. }
  118. /**
  119. * @return string|null
  120. */
  121. public function getRel()
  122. {
  123. return $this->_rel;
  124. }
  125. /**
  126. * @param string|null $value
  127. * @return Zend_Gdata_App_Entry Provides a fluent interface
  128. */
  129. public function setRel($value)
  130. {
  131. $this->_rel = $value;
  132. return $this;
  133. }
  134. /**
  135. * @return string|null
  136. */
  137. public function getType()
  138. {
  139. return $this->_type;
  140. }
  141. /**
  142. * @param string|null $value
  143. * @return Zend_Gdata_App_Entry Provides a fluent interface
  144. */
  145. public function setType($value)
  146. {
  147. $this->_type = $value;
  148. return $this;
  149. }
  150. /**
  151. * @return string|null
  152. */
  153. public function getHrefLang()
  154. {
  155. return $this->_hrefLang;
  156. }
  157. /**
  158. * @param string|null $value
  159. * @return Zend_Gdata_App_Entry Provides a fluent interface
  160. */
  161. public function setHrefLang($value)
  162. {
  163. $this->_hrefLang = $value;
  164. return $this;
  165. }
  166. /**
  167. * @return string|null
  168. */
  169. public function getTitle()
  170. {
  171. return $this->_title;
  172. }
  173. /**
  174. * @param string|null $value
  175. * @return Zend_Gdata_App_Entry Provides a fluent interface
  176. */
  177. public function setTitle($value)
  178. {
  179. $this->_title = $value;
  180. return $this;
  181. }
  182. /**
  183. * @return string|null
  184. */
  185. public function getLength()
  186. {
  187. return $this->_length;
  188. }
  189. /**
  190. * @param string|null $value
  191. * @return Zend_Gdata_App_Entry Provides a fluent interface
  192. */
  193. public function setLength($value)
  194. {
  195. $this->_length = $value;
  196. return $this;
  197. }
  198. }