PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

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

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