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

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 5.7 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 Docs
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/**
24 * Zend_Gdata_Query
25 */
26require_once('Zend/Gdata/Query.php');
27
28/**
29 * Assists in constructing queries for Google Document List documents
30 *
31 * @link http://code.google.com/apis/gdata/spreadsheets/
32 *
33 * @category Zend
34 * @package Zend_Gdata
35 * @subpackage Docs
36 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
37 * @license http://framework.zend.com/license/new-bsd New BSD License
38 */
39class Zend_Gdata_Docs_Query extends Zend_Gdata_Query
40{
41
42 /**
43 * The base URL for retrieving a document list
44 *
45 * @var string
46 */
47 const DOCUMENTS_LIST_FEED_URI = 'http://docs.google.com/feeds/documents';
48
49 /**
50 * The generic base URL used by some inherited methods
51 *
52 * @var string
53 */
54 protected $_defaultFeedUri = self::DOCUMENTS_LIST_FEED_URI;
55
56 /**
57 * The visibility to be used when querying for the feed. A request for a
58 * feed with private visbility requires the user to be authenricated.
59 * Private is the only avilable visibility for the documents list.
60 *
61 * @var string
62 */
63 protected $_visibility = 'private';
64
65 /**
66 * The projection determines how much detail should be given in the
67 * result of the query. Full is the only valid projection for the
68 * documents list.
69 *
70 * @var string
71 */
72 protected $_projection = 'full';
73
74 /**
75 * Constructs a new instance of a Zend_Gdata_Docs_Query object.
76 */
77 public function __construct()
78 {
79 parent::__construct();
80 }
81
82 /**
83 * Sets the projection for this query. Common values for projection
84 * include 'full'.
85 *
86 * @param string $value
87 * @return Zend_Gdata_Docs_Query Provides a fluent interface
88 */
89 public function setProjection($value)
90 {
91 $this->_projection = $value;
92 return $this;
93 }
94
95 /**
96 * Sets the visibility for this query. Common values for visibility
97 * include 'private'.
98 *
99 * @return Zend_Gdata_Docs_Query Provides a fluent interface
100 */
101 public function setVisibility($value)
102 {
103 $this->_visibility = $value;
104 return $this;
105 }
106
107 /**
108 * Gets the projection for this query.
109 *
110 * @return string projection
111 */
112 public function getProjection()
113 {
114 return $this->_projection;
115 }
116
117 /**
118 * Gets the visibility for this query.
119 *
120 * @return string visibility
121 */
122 public function getVisibility()
123 {
124 return $this->_visibility;
125 }
126
127 /**
128 * Sets the title attribute for this query. The title parameter is used
129 * to restrict the results to documents whose titles either contain or
130 * completely match the title.
131 *
132 * @param string $value
133 * @return Zend_Gdata_Docs_Query Provides a fluent interface
134 */
135 public function setTitle($value)
136 {
137 if ($value !== null) {
138 $this->_params['title'] = $value;
139 } else {
140 unset($this->_params['title']);
141 }
142 return $this;
143 }
144
145 /**
146 * Gets the title attribute for this query.
147 *
148 * @return string title
149 */
150 public function getTitle()
151 {
152 if (array_key_exists('title', $this->_params)) {
153 return $this->_params['title'];
154 } else {
155 return null;
156 }
157 }
158
159 /**
160 * Sets the title-exact attribute for this query.
161 * If title-exact is set to true, the title query parameter will be used
162 * in an exact match. Only documents with a title identical to the
163 * title parameter will be returned.
164 *
165 * @param boolean $value Use either true or false
166 * @return Zend_Gdata_Docs_Query Provides a fluent interface
167 */
168 public function setTitleExact($value)
169 {
170 if ($value) {
171 $this->_params['title-exact'] = $value;
172 } else {
173 unset($this->_params['title-exact']);
174 }
175 return $this;
176 }
177
178 /**
179 * Gets the title-exact attribute for this query.
180 *
181 * @return string title-exact
182 */
183 public function getTitleExact()
184 {
185 if (array_key_exists('title-exact', $this->_params)) {
186 return $this->_params['title-exact'];
187 } else {
188 return false;
189 }
190 }
191
192 /**
193 * Gets the full query URL for this query.
194 *
195 * @return string url
196 */
197 public function getQueryUrl()
198 {
199 $uri = $this->_defaultFeedUri;
200
201 if ($this->_visibility !== null) {
202 $uri .= '/' . $this->_visibility;
203 } else {
204 require_once 'Zend/Gdata/App/Exception.php';
205 throw new Zend_Gdata_App_Exception(
206 'A visibility must be provided for cell queries.');
207 }
208
209 if ($this->_projection !== null) {
210 $uri .= '/' . $this->_projection;
211 } else {
212 require_once 'Zend/Gdata/App/Exception.php';
213 throw new Zend_Gdata_App_Exception(
214 'A projection must be provided for cell queries.');
215 }
216
217 $uri .= $this->getQueryString();
218 return $uri;
219 }
220
221}
Note: See TracBrowser for help on using the repository browser.