~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/Books.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
23
require_once 'Zend/Gdata.php';
 
24
 
 
25
/**
 
26
 * @see Zend_Gdata_DublinCore
 
27
 */
 
28
require_once 'Zend/Gdata/DublinCore.php';
 
29
 
 
30
/**
 
31
 * @see Zend_Gdata_Books_CollectionEntry
 
32
 */
 
33
require_once 'Zend/Gdata/Books/CollectionEntry.php';
 
34
 
 
35
/**
 
36
 * @see Zend_Gdata_Books_CollectionFeed
 
37
 */
 
38
require_once 'Zend/Gdata/Books/CollectionFeed.php';
 
39
 
 
40
/**
 
41
 * @see Zend_Gdata_Books_VolumeEntry
 
42
 */
 
43
require_once 'Zend/Gdata/Books/VolumeEntry.php';
 
44
 
 
45
/**
 
46
 * @see Zend_Gdata_Books_VolumeFeed
 
47
 */
 
48
require_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
 * @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
 
57
 */
 
58
class Zend_Gdata_Books extends Zend_Gdata
 
59
{
 
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';
 
64
 
 
65
    public static $namespaces = array(
 
66
            'gbs' => 'http://schemas.google.com/books/2008',
 
67
            'dc' => 'http://purl.org/dc/terms'
 
68
    );
 
69
 
 
70
    /**
 
71
     * Create Zend_Gdata_Books object
 
72
     *
 
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
 
76
     */
 
77
    public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')
 
78
    {
 
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);
 
83
     }
 
84
 
 
85
    /**
 
86
     * Retrieves a feed of volumes.
 
87
     *
 
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
 
90
     *        determined.
 
91
     * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
 
92
     *         specified URL.
 
93
     */
 
94
    public function getVolumeFeed($location = null)
 
95
    {
 
96
        if ($location == null) {
 
97
            $uri = self::VOLUME_FEED_URI;
 
98
        } else if ($location instanceof Zend_Gdata_Query) {
 
99
            $uri = $location->getQueryUrl();
 
100
        } else {
 
101
            $uri = $location;
 
102
        }
 
103
        return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
 
104
    }
 
105
 
 
106
    /**
 
107
     * Retrieves a specific volume entry.
 
108
     *
 
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
 
112
     *        determined.
 
113
     * @return Zend_Gdata_Books_VolumeEntry The feed of volumes found at the
 
114
     *         specified URL.
 
115
     */
 
116
    public function getVolumeEntry($volumeId = null, $location = null)
 
117
    {
 
118
        if ($volumeId !== null) {
 
119
            $uri = self::VOLUME_FEED_URI . "/" . $volumeId;
 
120
        } else if ($location instanceof Zend_Gdata_Query) {
 
121
            $uri = $location->getQueryUrl();
 
122
        } else {
 
123
            $uri = $location;
 
124
        }
 
125
        return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
 
126
    }
 
127
 
 
128
    /**
 
129
     * Retrieves a feed of volumes, by default the User library feed.
 
130
     *
 
131
     * @param Zend_Gdata_Query|string|null $location (optional) The URL to
 
132
     *        query.
 
133
     * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
 
134
     *         specified URL.
 
135
     */
 
136
    public function getUserLibraryFeed($location = null)
 
137
    {
 
138
        if ($location == null) {
 
139
            $uri = self::MY_LIBRARY_FEED_URI;
 
140
        } else {
 
141
            $uri = $location;
 
142
        }
 
143
        return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
 
144
    }
 
145
 
 
146
    /**
 
147
     * Retrieves a feed of volumes, by default the User annotation feed 
 
148
     *
 
149
     * @param Zend_Gdata_Query|string|null $location (optional) The URL to
 
150
     *        query.
 
151
     * @return Zend_Gdata_Books_VolumeFeed The feed of volumes found at the
 
152
     *         specified URL.
 
153
     */
 
154
    public function getUserAnnotationFeed($location = null)
 
155
    {
 
156
        if ($location == null) {
 
157
            $uri = self::MY_ANNOTATION_FEED_URI;
 
158
        } else {
 
159
            $uri = $location;
 
160
        }
 
161
        return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed');
 
162
    }
 
163
 
 
164
    /**
 
165
     * Insert a Volume / Annotation
 
166
     *
 
167
     * @param Zend_Gdata_Books_VolumeEntry $entry
 
168
     * @param Zend_Gdata_Query|string|null $location (optional) The URL to
 
169
     *        query
 
170
     * @return Zend_Gdata_Books_VolumeEntry The inserted volume entry.
 
171
     */
 
172
    public function insertVolume($entry, $location = null)
 
173
    {
 
174
        if ($location == null) {
 
175
            $uri = self::MY_LIBRARY_FEED_URI;
 
176
        } else {
 
177
            $uri = $location;
 
178
        }
 
179
        return parent::insertEntry(
 
180
            $entry, $uri, 'Zend_Gdata_Books_VolumeEntry');
 
181
    }
 
182
 
 
183
    /**
 
184
     * Delete a Volume 
 
185
     *
 
186
     * @param Zend_Gdata_Books_VolumeEntry $entry
 
187
     * @return void
 
188
     */
 
189
    public function deleteVolume($entry)
 
190
    {
 
191
        $entry->delete();
 
192
    }
 
193
 
 
194
}