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.
19
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
20
* @license http://framework.zend.com/license/new-bsd New BSD License
23
require_once 'Zend/Gdata.php';
26
* @see Zend_Gdata_DublinCore
28
require_once 'Zend/Gdata/DublinCore.php';
31
* @see Zend_Gdata_Books_CollectionEntry
33
require_once 'Zend/Gdata/Books/CollectionEntry.php';
36
* @see Zend_Gdata_Books_CollectionFeed
38
require_once 'Zend/Gdata/Books/CollectionFeed.php';
41
* @see Zend_Gdata_Books_VolumeEntry
43
require_once 'Zend/Gdata/Books/VolumeEntry.php';
46
* @see Zend_Gdata_Books_VolumeFeed
48
require_once 'Zend/Gdata/Books/VolumeFeed.php';
51
* Service class for interacting with the Books service
55
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
56
* @license http://framework.zend.com/license/new-bsd New BSD License
58
class Zend_Gdata_Books extends Zend_Gdata
60
const VOLUME_FEED_URI = 'http://books.google.com/books/feeds/volumes';
61
const MY_LIBRARY_FEED_URI = 'http://books.google.com/books/feeds/users/me/collections/library/volumes';
62
const MY_ANNOTATION_FEED_URI = 'http://books.google.com/books/feeds/users/me/volumes';
63
const AUTH_SERVICE_NAME = 'print';
65
public static $namespaces = array(
66
'gbs' => 'http://schemas.google.com/books/2008',
67
'dc' => 'http://purl.org/dc/terms'
71
* Create Zend_Gdata_Books object
73
* @param Zend_Http_Client $client (optional) The HTTP client to use when
74
* when communicating with the Google servers.
75
* @param string $applicationId The identity of the app in the form of Company-AppName-Version
77
public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
79
$this->registerPackage('Zend_Gdata_Books');
80
$this->registerPackage('Zend_Gdata_Books_Extension');
81
parent::__construct($client, $applicationId);
82
$this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
86
* Retrieves a feed of volumes.
88
* @param Zend_Gdata_Query|string|null $location (optional) The URL to
89
* query or a Zend_Gdata_Query object from which a URL can be
91
* @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
94
public function getVolumeFeed($location = null)
96
if ($location == null) {
97
$uri = self::VOLUME_FEED_URI;
98
} else if ($location instanceof Zend_Gdata_Query) {
99
$uri = $location->getQueryUrl();
103
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
107
* Retrieves a specific volume entry.
109
* @param string|null $volumeId The volumeId of interest.
110
* @param Zend_Gdata_Query|string|null $location (optional) The URL to
111
* query or a Zend_Gdata_Query object from which a URL can be
113
* @return Zend_Gdata_Books_VolumeEntry The feed of volumes found at the
116
public function getVolumeEntry($volumeId = null, $location = null)
118
if ($volumeId !== null) {
119
$uri = self::VOLUME_FEED_URI . "/" . $volumeId;
120
} else if ($location instanceof Zend_Gdata_Query) {
121
$uri = $location->getQueryUrl();
125
return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
129
* Retrieves a feed of volumes, by default the User library feed.
131
* @param Zend_Gdata_Query|string|null $location (optional) The URL to
133
* @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
136
public function getUserLibraryFeed($location = null)
138
if ($location == null) {
139
$uri = self::MY_LIBRARY_FEED_URI;
143
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
147
* Retrieves a feed of volumes, by default the User annotation feed
149
* @param Zend_Gdata_Query|string|null $location (optional) The URL to
151
* @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
154
public function getUserAnnotationFeed($location = null)
156
if ($location == null) {
157
$uri = self::MY_ANNOTATION_FEED_URI;
161
return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
165
* Insert a Volume / Annotation
167
* @param Zend_Gdata_Books_VolumeEntry $entry
168
* @param Zend_Gdata_Query|string|null $location (optional) The URL to
170
* @return Zend_Gdata_Books_VolumeEntry The inserted volume entry.
172
public function insertVolume($entry, $location = null)
174
if ($location == null) {
175
$uri = self::MY_LIBRARY_FEED_URI;
179
return parent::insertEntry(
180
$entry, $uri, 'Zend_Gdata_Books_VolumeEntry');
186
* @param Zend_Gdata_Books_VolumeEntry $entry
189
public function deleteVolume($entry)