File indexing completed on 2025-05-04 05:27:55

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 Books
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  * User-provided review
0031  *
0032  * @category   Zend
0033  * @package    Zend_Gdata
0034  * @subpackage Books
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_Books_Extension_Review extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootNamespace = 'gbs';
0042     protected $_rootElement = 'review';
0043     protected $_lang = null;
0044     protected $_type = null;
0045 
0046     /**
0047      * Constructor for Zend_Gdata_Books_Extension_Review which
0048      * User-provided review
0049      *
0050      * @param string|null $lang Review language.
0051      * @param string|null $type Type of text construct (typically text, html,
0052      *        or xhtml).
0053      * @param string|null $value Text content of the review.
0054      */
0055     public function __construct($lang = null, $type = null, $value = null)
0056     {
0057         $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
0058         parent::__construct();
0059         $this->_lang = $lang;
0060         $this->_type = $type;
0061         $this->_text = $value;
0062     }
0063 
0064     /**
0065      * Retrieves DOMElement which corresponds to this element and all
0066      * child properties. This is used to build this object back into a DOM
0067      * and eventually XML text for sending to the server upon updates, or
0068      * for application storage/persistance.
0069      *
0070      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0071      * @return DOMElement The DOMElement representing this element and all
0072      * child properties.
0073      */
0074     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0075     {
0076         $element = parent::getDOM($doc);
0077         if ($this->_lang !== null) {
0078             $element->setAttribute('lang', $this->_lang);
0079         }
0080         if ($this->_type !== null) {
0081             $element->setAttribute('type', $this->_type);
0082         }
0083         return $element;
0084     }
0085 
0086     /**
0087      * Extracts XML attributes from the DOM and converts them to the
0088      * appropriate object members.
0089      *
0090      * @param DOMNode $attribute The DOMNode attribute to be handled.
0091      */
0092     protected function takeAttributeFromDOM($attribute)
0093     {
0094         switch ($attribute->localName) {
0095         case 'lang':
0096             $this->_lang = $attribute->nodeValue;
0097             break;
0098         case 'type':
0099             $this->_type = $attribute->nodeValue;
0100             break;
0101         default:
0102             parent::takeAttributeFromDOM($attribute);
0103         }
0104     }
0105 
0106     /**
0107      * Returns the language of link title
0108      *
0109      * @return string The lang
0110      */
0111     public function getLang()
0112     {
0113         return $this->_lang;
0114     }
0115 
0116     /**
0117      * Returns the type of text construct (typically 'text', 'html' or 'xhtml')
0118      *
0119      * @return string The type
0120      */
0121     public function getType()
0122     {
0123         return $this->_type;
0124     }
0125 
0126     /**
0127      * Sets the language of link title
0128      *
0129      * @param string $lang language of link title
0130      * @return Zend_Gdata_Books_Extension_Review Provides a fluent interface
0131      */
0132     public function setLang($lang)
0133     {
0134         $this->_lang = $lang;
0135         return $this;
0136     }
0137 
0138     /**
0139      * Sets the type of text construct (typically 'text', 'html' or 'xhtml')
0140      *
0141      * @param string $type type of text construct (typically 'text', 'html' or 'xhtml')
0142      * @return Zend_Gdata_Books_Extension_Review Provides a fluent interface
0143      */
0144     public function setType($type)
0145     {
0146         $this->_type = $type;
0147         return $this;
0148     }
0149 
0150 
0151 }
0152