File indexing completed on 2024-06-16 05:30:07

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_Gdata
0018  * @subpackage Gdata
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * @see Zend_Gdata_Extension
0026  */
0027 // require_once 'Zend/Gdata/Extension.php';
0028 
0029 /**
0030  * Data model class to represent an entry's visibility
0031  *
0032  * @category   Zend
0033  * @package    Zend_Gdata
0034  * @subpackage Gdata
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  */
0038 class Zend_Gdata_Extension_Visibility extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootElement = 'visibility';
0042     protected $_value = null;
0043 
0044     /**
0045      * Constructs a new Zend_Gdata_Extension_Visibility object.
0046      * @param bool $value (optional) Visibility value as URI.
0047      */
0048     public function __construct($value = null)
0049     {
0050         parent::__construct();
0051         $this->_value = $value;
0052     }
0053 
0054     /**
0055      * Retrieves a DOMElement which corresponds to this element and all
0056      * child properties.  This is used to build an entry back into a DOM
0057      * and eventually XML text for sending to the server upon updates, or
0058      * for application storage/persistence.
0059      *
0060      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0061      * @return DOMElement The DOMElement representing this element and all
0062      * child properties.
0063      */
0064     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0065     {
0066         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0067         if ($this->_value !== null) {
0068             $element->setAttribute('value', $this->_value);
0069         }
0070         return $element;
0071     }
0072 
0073     /**
0074      * Given a DOMNode representing an attribute, tries to map the data into
0075      * instance members.  If no mapping is defined, the name and value are
0076      * stored in an array.
0077      *
0078      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0079      */
0080     protected function takeAttributeFromDOM($attribute)
0081     {
0082         switch ($attribute->localName) {
0083         case 'value':
0084             $this->_value = $attribute->nodeValue;
0085             break;
0086         default:
0087             parent::takeAttributeFromDOM($attribute);
0088         }
0089     }
0090 
0091     /**
0092      * Get the value for this element's Value attribute.
0093      *
0094      * @return bool The requested attribute.
0095      */
0096     public function getValue()
0097     {
0098         return $this->_value;
0099     }
0100 
0101     /**
0102      * Set the value for this element's Value attribute.
0103      *
0104      * @param bool $value The desired value for this attribute.
0105      * @return Zend_Gdata_Extension_Visibility The element being modified.
0106      */
0107     public function setValue($value)
0108     {
0109         $this->_value = $value;
0110         return $this;
0111     }
0112 
0113     /**
0114      * Magic toString method allows using this directly via echo
0115      * Works best in PHP >= 4.2.0
0116      */
0117     public function __toString()
0118     {
0119         return $this->getValue();
0120     }
0121 
0122 }
0123