web/lib/Zend/Gdata/Books/Extension/Viewability.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * Zend Framework
       
     5  *
       
     6  * LICENSE
       
     7  *
       
     8  * This source file is subject to the new BSD license that is bundled
       
     9  * with this package in the file LICENSE.txt.
       
    10  * It is also available through the world-wide-web at this URL:
       
    11  * http://framework.zend.com/license/new-bsd
       
    12  * If you did not receive a copy of the license and are unable to
       
    13  * obtain it through the world-wide-web, please send an email
       
    14  * to license@zend.com so we can send you a copy immediately.
       
    15  *
       
    16  * @category   Zend
       
    17  * @package    Zend_Gdata
       
    18  * @subpackage Books
       
    19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    21  * @version    $Id: Viewability.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_Extension
       
    26  */
       
    27 require_once 'Zend/Gdata/Extension.php';
       
    28 
       
    29 /**
       
    30  * Describes a viewability
       
    31  *
       
    32  * @category   Zend
       
    33  * @package    Zend_Gdata
       
    34  * @subpackage Books
       
    35  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    37  */
       
    38 class Zend_Gdata_Books_Extension_Viewability extends Zend_Gdata_Extension
       
    39 {
       
    40 
       
    41     protected $_rootNamespace = 'gbs';
       
    42     protected $_rootElement = 'viewability';
       
    43     protected $_value = null;
       
    44 
       
    45     /**
       
    46      * Constructor for Zend_Gdata_Books_Extension_Viewability which
       
    47      * Describes a viewability
       
    48      *
       
    49      * @param string|null $value A programmatic value representing the book's
       
    50      *        viewability mode.
       
    51      */
       
    52     public function __construct($value = null)
       
    53     {
       
    54         $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
       
    55         parent::__construct();
       
    56         $this->_value = $value;
       
    57     }
       
    58 
       
    59     /**
       
    60      * Retrieves DOMElement which corresponds to this element and all
       
    61      * child properties. This is used to build this object back into a DOM
       
    62      * and eventually XML text for sending to the server upon updates, or
       
    63      * for application storage/persistance.
       
    64      *
       
    65      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    66      * @return DOMElement The DOMElement representing this element and all
       
    67      * child properties.
       
    68      */
       
    69     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
    70     {
       
    71         $element = parent::getDOM($doc);
       
    72         if ($this->_value !== null) {
       
    73             $element->setAttribute('value', $this->_value);
       
    74         }
       
    75         return $element;
       
    76     }
       
    77 
       
    78     /**
       
    79      * Extracts XML attributes from the DOM and converts them to the
       
    80      * appropriate object members.
       
    81      *
       
    82      * @param DOMNode $attribute The DOMNode attribute to be handled.
       
    83      */
       
    84     protected function takeAttributeFromDOM($attribute)
       
    85     {
       
    86         switch ($attribute->localName) {
       
    87         case 'value':
       
    88             $this->_value = $attribute->nodeValue;
       
    89             break;
       
    90         default:
       
    91             parent::takeAttributeFromDOM($attribute);
       
    92         }
       
    93     }
       
    94 
       
    95     /**
       
    96      * Returns the programmatic value that describes the viewability of a volume
       
    97      * in Google Book Search
       
    98      *
       
    99      * @return string The value
       
   100      */
       
   101     public function getValue()
       
   102     {
       
   103         return $this->_value;
       
   104     }
       
   105 
       
   106     /**
       
   107      * Sets the programmatic value that describes the viewability of a volume in
       
   108      * Google Book Search
       
   109      *
       
   110      * @param string $value programmatic value that describes the viewability
       
   111      *     of a volume in Googl eBook Search
       
   112      * @return Zend_Gdata_Books_Extension_Viewability Provides a fluent
       
   113      *     interface
       
   114      */
       
   115     public function setValue($value)
       
   116     {
       
   117         $this->_value = $value;
       
   118         return $this;
       
   119     }
       
   120 
       
   121 
       
   122 }
       
   123