source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Books.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 6.1 KB
Line 
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. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 */
22
23require_once 'Zend/Gdata.php';
24
25/**
26 * @see Zend_Gdata_DublinCore
27 */
28require_once 'Zend/Gdata/DublinCore.php';
29
30/**
31 * @see Zend_Gdata_Books_CollectionEntry
32 */
33require_once 'Zend/Gdata/Books/CollectionEntry.php';
34
35/**
36 * @see Zend_Gdata_Books_CollectionFeed
37 */
38require_once 'Zend/Gdata/Books/CollectionFeed.php';
39
40/**
41 * @see Zend_Gdata_Books_VolumeEntry
42 */
43require_once 'Zend/Gdata/Books/VolumeEntry.php';
44
45/**
46 * @see Zend_Gdata_Books_VolumeFeed
47 */
48require_once 'Zend/Gdata/Books/VolumeFeed.php';
49
50/**
51 * Service class for interacting with the Books service
52 *
53 * @category Zend
54 * @package Zend_Gdata
55 * @subpackage Books
56 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
57 * @license http://framework.zend.com/license/new-bsd New BSD License
58 */
59class Zend_Gdata_Books extends Zend_Gdata
60{
61 const VOLUME_FEED_URI = 'http://books.google.com/books/feeds/volumes';
62 const MY_LIBRARY_FEED_URI = 'http://books.google.com/books/feeds/users/me/collections/library/volumes';
63 const MY_ANNOTATION_FEED_URI = 'http://books.google.com/books/feeds/users/me/volumes';
64 const AUTH_SERVICE_NAME = 'print';
65
66 /**
67 * Namespaces used for Zend_Gdata_Books
68 *
69 * @var array
70 */
71 public static $namespaces = array(
72 array('gbs', 'http://schemas.google.com/books/2008', 1, 0),
73 array('dc', 'http://purl.org/dc/terms', 1, 0)
74 );
75
76 /**
77 * Create Zend_Gdata_Books object
78 *
79 * @param Zend_Http_Client $client (optional) The HTTP client to use when
80 * when communicating with the Google servers.
81 * @param string $applicationId The identity of the app in the form of Company-AppName-Version
82 */
83 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
84 {
85 $this->registerPackage('Zend_Gdata_Books');
86 $this->registerPackage('Zend_Gdata_Books_Extension');
87 parent::__construct($client, $applicationId);
88 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);
89 }
90
91 /**
92 * Retrieves a feed of volumes.
93 *
94 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
95 * query or a Zend_Gdata_Query object from which a URL can be
96 * determined.
97 * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
98 * specified URL.
99 */
100 public function getVolumeFeed($location = null)
101 {
102 if ($location == null) {
103 $uri = self::VOLUME_FEED_URI;
104 } else if ($location instanceof Zend_Gdata_Query) {
105 $uri = $location->getQueryUrl();
106 } else {
107 $uri = $location;
108 }
109 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
110 }
111
112 /**
113 * Retrieves a specific volume entry.
114 *
115 * @param string|null $volumeId The volumeId of interest.
116 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
117 * query or a Zend_Gdata_Query object from which a URL can be
118 * determined.
119 * @return Zend_Gdata_Books_VolumeEntry The feed of volumes found at the
120 * specified URL.
121 */
122 public function getVolumeEntry($volumeId = null, $location = null)
123 {
124 if ($volumeId !== null) {
125 $uri = self::VOLUME_FEED_URI . "/" . $volumeId;
126 } else if ($location instanceof Zend_Gdata_Query) {
127 $uri = $location->getQueryUrl();
128 } else {
129 $uri = $location;
130 }
131 return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
132 }
133
134 /**
135 * Retrieves a feed of volumes, by default the User library feed.
136 *
137 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
138 * query.
139 * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
140 * specified URL.
141 */
142 public function getUserLibraryFeed($location = null)
143 {
144 if ($location == null) {
145 $uri = self::MY_LIBRARY_FEED_URI;
146 } else {
147 $uri = $location;
148 }
149 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
150 }
151
152 /**
153 * Retrieves a feed of volumes, by default the User annotation feed
154 *
155 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
156 * query.
157 * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
158 * specified URL.
159 */
160 public function getUserAnnotationFeed($location = null)
161 {
162 if ($location == null) {
163 $uri = self::MY_ANNOTATION_FEED_URI;
164 } else {
165 $uri = $location;
166 }
167 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
168 }
169
170 /**
171 * Insert a Volume / Annotation
172 *
173 * @param Zend_Gdata_Books_VolumeEntry $entry
174 * @param Zend_Gdata_Query|string|null $location (optional) The URL to
175 * query
176 * @return Zend_Gdata_Books_VolumeEntry The inserted volume entry.
177 */
178 public function insertVolume($entry, $location = null)
179 {
180 if ($location == null) {
181 $uri = self::MY_LIBRARY_FEED_URI;
182 } else {
183 $uri = $location;
184 }
185 return parent::insertEntry(
186 $entry, $uri, 'Zend_Gdata_Books_VolumeEntry');
187 }
188
189 /**
190 * Delete a Volume
191 *
192 * @param Zend_Gdata_Books_VolumeEntry $entry
193 * @return void
194 */
195 public function deleteVolume($entry)
196 {
197 $entry->delete();
198 }
199
200}
Note: See TracBrowser for help on using the repository browser.