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-2008 Zend Technologies USA Inc.
|
---|
20 | * (http://www.zend.com)
|
---|
21 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
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-2008 Zend Technologies USA Inc.
|
---|
36 | * (http://www.zend.com)
|
---|
37 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
38 | */
|
---|
39 | class Zend_Gdata_Books_Extension_Viewability extends Zend_Gdata_Extension
|
---|
40 | {
|
---|
41 |
|
---|
42 | protected $_rootNamespace = 'gbs';
|
---|
43 | protected $_rootElement = 'viewability';
|
---|
44 | protected $_value = null;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Constructor for Zend_Gdata_Books_Extension_Viewability which
|
---|
48 | * Describes a viewability
|
---|
49 | *
|
---|
50 | * @param string|null $value A programmatic value representing the book's
|
---|
51 | * viewability mode.
|
---|
52 | */
|
---|
53 | public function __construct($value = null)
|
---|
54 | {
|
---|
55 | $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces);
|
---|
56 | parent::__construct();
|
---|
57 | $this->_value = $value;
|
---|
58 | }
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Retrieves DOMElement which corresponds to this element and all
|
---|
62 | * child properties. This is used to build this object back into a DOM
|
---|
63 | * and eventually XML text for sending to the server upon updates, or
|
---|
64 | * for application storage/persistance.
|
---|
65 | *
|
---|
66 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
67 | * @return DOMElement The DOMElement representing this element and all
|
---|
68 | * child properties.
|
---|
69 | */
|
---|
70 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
71 | {
|
---|
72 | $element = parent::getDOM($doc);
|
---|
73 | if ($this->_value !== null) {
|
---|
74 | $element->setAttribute('value', $this->_value);
|
---|
75 | }
|
---|
76 | return $element;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Extracts XML attributes from the DOM and converts them to the
|
---|
81 | * appropriate object members.
|
---|
82 | *
|
---|
83 | * @param DOMNode $attribute The DOMNode attribute to be handled.
|
---|
84 | */
|
---|
85 | protected function takeAttributeFromDOM($attribute)
|
---|
86 | {
|
---|
87 | switch ($attribute->localName) {
|
---|
88 | case 'value':
|
---|
89 | $this->_value = $attribute->nodeValue;
|
---|
90 | break;
|
---|
91 | default:
|
---|
92 | parent::takeAttributeFromDOM($attribute);
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Returns the programmatic value that describes the viewability of a volume
|
---|
98 | * in Google Book Search
|
---|
99 | *
|
---|
100 | * @return string The value
|
---|
101 | */
|
---|
102 | public function getValue()
|
---|
103 | {
|
---|
104 | return $this->_value;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Sets the programmatic value that describes the viewability of a volume in
|
---|
109 | * Google Book Search
|
---|
110 | *
|
---|
111 | * @param string $value programmatic value that describes the viewability
|
---|
112 | * of a volume in Googl eBook Search
|
---|
113 | * @return Zend_Gdata_Books_Extension_Viewability Provides a fluent
|
---|
114 | * interface
|
---|
115 | */
|
---|
116 | public function setValue($value)
|
---|
117 | {
|
---|
118 | $this->_value = $value;
|
---|
119 | return $this;
|
---|
120 | }
|
---|
121 |
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|