2
0

Link.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 YouTube
  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_Link
  23. */
  24. require_once 'Zend/Gdata/App/Extension/Link.php';
  25. /**
  26. * @see Zend_Gdata_YouTube_Extension_Token
  27. */
  28. require_once 'Zend/Gdata/YouTube/Extension/Token.php';
  29. /**
  30. * Specialized Link class for use with YouTube. Enables use of yt extension elements.
  31. *
  32. * @category Zend
  33. * @package Zend_Gdata
  34. * @subpackage YouTube
  35. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Gdata_YouTube_Extension_Link extends Zend_Gdata_App_Extension_Link
  39. {
  40. protected $_token = null;
  41. /**
  42. * Constructs a new Zend_Gdata_Calendar_Extension_Link object.
  43. * @see Zend_Gdata_App_Extension_Link#__construct
  44. * @param Zend_Gdata_YouTube_Extension_Token $token
  45. */
  46. public function __construct($href = null, $rel = null, $type = null,
  47. $hrefLang = null, $title = null, $length = null, $token = null)
  48. {
  49. $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
  50. parent::__construct($href, $rel, $type, $hrefLang, $title, $length);
  51. $this->_token = $token;
  52. }
  53. /**
  54. * Retrieves a DOMElement which corresponds to this element and all
  55. * child properties. This is used to build an entry back into a DOM
  56. * and eventually XML text for sending to the server upon updates, or
  57. * for application storage/persistence.
  58. *
  59. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  60. * @return DOMElement The DOMElement representing this element and all
  61. * child properties.
  62. */
  63. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  64. {
  65. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  66. if ($this->_token != null) {
  67. $element->appendChild($this->_token->getDOM($element->ownerDocument));
  68. }
  69. return $element;
  70. }
  71. /**
  72. * Creates individual Entry objects of the appropriate type and
  73. * stores them as members of this entry based upon DOM data.
  74. *
  75. * @param DOMNode $child The DOMNode to process
  76. */
  77. protected function takeChildFromDOM($child)
  78. {
  79. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  80. switch ($absoluteNodeName) {
  81. case $this->lookupNamespace('yt') . ':' . 'token':
  82. $token = new Zend_Gdata_YouTube_Extension_Token();
  83. $token->transferFromDOM($child);
  84. $this->_token = $token;
  85. break;
  86. default:
  87. parent::takeChildFromDOM($child);
  88. break;
  89. }
  90. }
  91. /**
  92. * Get the value for this element's token attribute.
  93. *
  94. * @return Zend_Gdata_YouTube_Extension_Token The token element.
  95. */
  96. public function getToken()
  97. {
  98. return $this->_token;
  99. }
  100. /**
  101. * Set the value for this element's token attribute.
  102. *
  103. * @param Zend_Gdata_YouTube_Extension_Token $value The desired value for this attribute.
  104. * @return Zend_YouTube_Extension_Link The element being modified.
  105. */
  106. public function setToken($value)
  107. {
  108. $this->_token = $value;
  109. return $this;
  110. }
  111. /**
  112. * Get the value of this element's token attribute.
  113. *
  114. * @return string The token's text value
  115. */
  116. public function getTokenValue()
  117. {
  118. return $this->getToken()->getText();
  119. }
  120. }