ExtendedProperty.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 Gdata
  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 gd:extendedProperty element, used by some Gdata
  27. * services to implement arbitrary name/value pair storage
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Gdata
  32. * @copyright Copyright (c) 2005-2008 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_Extension_ExtendedProperty extends Zend_Gdata_Extension
  36. {
  37. protected $_rootElement = 'extendedProperty';
  38. protected $_name = null;
  39. protected $_value = null;
  40. public function __construct($name = null, $value = null)
  41. {
  42. parent::__construct();
  43. $this->_name = $name;
  44. $this->_value = $value;
  45. }
  46. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  47. {
  48. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  49. if ($this->_name !== null) {
  50. $element->setAttribute('name', $this->_name);
  51. }
  52. if ($this->_value !== null) {
  53. $element->setAttribute('value', $this->_value);
  54. }
  55. return $element;
  56. }
  57. protected function takeAttributeFromDOM($attribute)
  58. {
  59. switch ($attribute->localName) {
  60. case 'name':
  61. $this->_name = $attribute->nodeValue;
  62. break;
  63. case 'value':
  64. $this->_value = $attribute->nodeValue;
  65. break;
  66. default:
  67. parent::takeAttributeFromDOM($attribute);
  68. }
  69. }
  70. public function __toString()
  71. {
  72. return $this->getName() . '=' . $this->getValue();
  73. }
  74. public function getName()
  75. {
  76. return $this->_name;
  77. }
  78. public function setName($value)
  79. {
  80. $this->_name = $value;
  81. return $this;
  82. }
  83. public function getValue()
  84. {
  85. return $this->_value;
  86. }
  87. public function setValue($value)
  88. {
  89. $this->_value = $value;
  90. return $this;
  91. }
  92. }