PageRenderTime 35ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Zend/Gdata/App/Extension/Link.php

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