/zf/library/Zend/Gdata/Extension/Visibility.php

http://github.com/eryx/php-framework-benchmark · PHP · 123 lines · 43 code · 12 blank · 68 comment · 2 complexity · 71331d1aa2ce7bd84a029ff62d901f6c 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 Gdata
  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: Visibility.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 class to represent an entry's visibility
  28. *
  29. * @category Zend
  30. * @package Zend_Gdata
  31. * @subpackage Gdata
  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_Extension_Visibility extends Zend_Gdata_Extension
  36. {
  37. protected $_rootElement = 'visibility';
  38. protected $_value = null;
  39. /**
  40. * Constructs a new Zend_Gdata_Extension_Visibility object.
  41. * @param bool $value (optional) Visibility value as URI.
  42. */
  43. public function __construct($value = null)
  44. {
  45. parent::__construct();
  46. $this->_value = $value;
  47. }
  48. /**
  49. * Retrieves a DOMElement which corresponds to this element and all
  50. * child properties. This is used to build an entry back into a DOM
  51. * and eventually XML text for sending to the server upon updates, or
  52. * for application storage/persistence.
  53. *
  54. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  55. * @return DOMElement The DOMElement representing this element and all
  56. * child properties.
  57. */
  58. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  59. {
  60. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  61. if ($this->_value !== null) {
  62. $element->setAttribute('value', $this->_value);
  63. }
  64. return $element;
  65. }
  66. /**
  67. * Given a DOMNode representing an attribute, tries to map the data into
  68. * instance members. If no mapping is defined, the name and value are
  69. * stored in an array.
  70. *
  71. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  72. */
  73. protected function takeAttributeFromDOM($attribute)
  74. {
  75. switch ($attribute->localName) {
  76. case 'value':
  77. $this->_value = $attribute->nodeValue;
  78. break;
  79. default:
  80. parent::takeAttributeFromDOM($attribute);
  81. }
  82. }
  83. /**
  84. * Get the value for this element's Value attribute.
  85. *
  86. * @return bool The requested attribute.
  87. */
  88. public function getValue()
  89. {
  90. return $this->_value;
  91. }
  92. /**
  93. * Set the value for this element's Value attribute.
  94. *
  95. * @param bool $value The desired value for this attribute.
  96. * @return Zend_Gdata_Extension_Visibility The element being modified.
  97. */
  98. public function setValue($value)
  99. {
  100. $this->_value = $value;
  101. return $this;
  102. }
  103. /**
  104. * Magic toString method allows using this directly via echo
  105. * Works best in PHP >= 4.2.0
  106. */
  107. public function __toString()
  108. {
  109. return $this->getValue();
  110. }
  111. }