MediaTitle.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 Media
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Gdata_App_Extension
  24. */
  25. require_once 'Zend/Gdata/App/Extension.php';
  26. /**
  27. * Represents the media:title element in MediaRSS
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Media
  32. * @copyright Copyright (c) 2005-2015 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_Media_Extension_MediaTitle extends Zend_Gdata_Extension
  36. {
  37. protected $_rootElement = 'title';
  38. protected $_rootNamespace = 'media';
  39. /**
  40. * @var string
  41. */
  42. protected $_type = null;
  43. /**
  44. * Constructs a MediaTitle element
  45. *
  46. * @param string $text
  47. * @param string $type
  48. */
  49. public function __construct($text = null, $type = null)
  50. {
  51. $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
  52. parent::__construct();
  53. $this->_type = $type;
  54. $this->_text = $text;
  55. }
  56. /**
  57. * Retrieves a DOMElement which corresponds to this element and all
  58. * child properties. This is used to build an entry back into a DOM
  59. * and eventually XML text for sending to the server upon updates, or
  60. * for application storage/persistence.
  61. *
  62. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  63. * @return DOMElement The DOMElement representing this element and all
  64. * child properties.
  65. */
  66. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  67. {
  68. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  69. if ($this->_type !== null) {
  70. $element->setAttribute('type', $this->_type);
  71. }
  72. return $element;
  73. }
  74. /**
  75. * Given a DOMNode representing an attribute, tries to map the data into
  76. * instance members. If no mapping is defined, the name and value are
  77. * stored in an array.
  78. *
  79. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  80. */
  81. protected function takeAttributeFromDOM($attribute)
  82. {
  83. switch ($attribute->localName) {
  84. case 'type':
  85. $this->_type = $attribute->nodeValue;
  86. break;
  87. default:
  88. parent::takeAttributeFromDOM($attribute);
  89. }
  90. }
  91. /**
  92. * @return string
  93. */
  94. public function getType()
  95. {
  96. return $this->_type;
  97. }
  98. /**
  99. * @param string $value
  100. * @return Zend_Gdata_Media_Extension_MediaTitle Provides a fluent interface
  101. */
  102. public function setType($value)
  103. {
  104. $this->_type = $value;
  105. return $this;
  106. }
  107. }