source: extensions/Google2Piwigo/include/Zend/Gdata/Books.php @ 17475

Revision 17475, 6.2 KB checked in by mistic100, 7 years ago (diff)

new extension: Google2Piwigo

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