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 Spreadsheets
|
---|
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_App_util
|
---|
25 | */
|
---|
26 | require_once('Zend/Gdata/App/Util.php');
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Zend_Gdata_Query
|
---|
30 | */
|
---|
31 | require_once('Zend/Gdata/Query.php');
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Assists in constructing queries for Google Spreadsheets lists
|
---|
35 | *
|
---|
36 | * @link http://code.google.com/apis/gdata/calendar/
|
---|
37 | *
|
---|
38 | * @category Zend
|
---|
39 | * @package Zend_Gdata
|
---|
40 | * @subpackage Spreadsheets
|
---|
41 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
42 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
43 | */
|
---|
44 | class Zend_Gdata_Spreadsheets_ListQuery extends Zend_Gdata_Query
|
---|
45 | {
|
---|
46 |
|
---|
47 | const SPREADSHEETS_LIST_FEED_URI = 'http://spreadsheets.google.com/feeds/list';
|
---|
48 |
|
---|
49 | protected $_defaultFeedUri = self::SPREADSHEETS_LIST_FEED_URI;
|
---|
50 | protected $_visibility = 'private';
|
---|
51 | protected $_projection = 'full';
|
---|
52 | protected $_spreadsheetKey = null;
|
---|
53 | protected $_worksheetId = 'default';
|
---|
54 | protected $_rowId = null;
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Constructs a new Zend_Gdata_Spreadsheets_ListQuery object.
|
---|
58 | */
|
---|
59 | public function __construct()
|
---|
60 | {
|
---|
61 | parent::__construct();
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Sets the spreadsheet key for the query.
|
---|
66 | * @param string $value
|
---|
67 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
68 | */
|
---|
69 | public function setSpreadsheetKey($value)
|
---|
70 | {
|
---|
71 | $this->_spreadsheetKey = $value;
|
---|
72 | return $this;
|
---|
73 | }
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Gets the spreadsheet key for the query.
|
---|
77 | * @return string spreadsheet key
|
---|
78 | */
|
---|
79 | public function getSpreadsheetKey()
|
---|
80 | {
|
---|
81 | return $this->_spreadsheetKey;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Sets the worksheet id for the query.
|
---|
86 | * @param string $value
|
---|
87 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
88 | */
|
---|
89 | public function setWorksheetId($value)
|
---|
90 | {
|
---|
91 | $this->_worksheetId = $value;
|
---|
92 | return $this;
|
---|
93 | }
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Gets the worksheet id for the query.
|
---|
97 | * @return string worksheet id
|
---|
98 | */
|
---|
99 | public function getWorksheetId()
|
---|
100 | {
|
---|
101 | return $this->_worksheetId;
|
---|
102 | }
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Sets the row id for the query.
|
---|
106 | * @param string $value row id
|
---|
107 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
108 | */
|
---|
109 | public function setRowId($value)
|
---|
110 | {
|
---|
111 | $this->_rowId = $value;
|
---|
112 | return $this;
|
---|
113 | }
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Gets the row id for the query.
|
---|
117 | * @return string row id
|
---|
118 | */
|
---|
119 | public function getRowId()
|
---|
120 | {
|
---|
121 | return $this->_rowId;
|
---|
122 | }
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * Sets the projection for the query.
|
---|
126 | * @param string $value Projection
|
---|
127 | * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface
|
---|
128 | */
|
---|
129 | public function setProjection($value)
|
---|
130 | {
|
---|
131 | $this->_projection = $value;
|
---|
132 | return $this;
|
---|
133 | }
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Sets the visibility for this query.
|
---|
137 | * @param string $value visibility
|
---|
138 | * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface
|
---|
139 | */
|
---|
140 | public function setVisibility($value)
|
---|
141 | {
|
---|
142 | $this->_visibility = $value;
|
---|
143 | return $this;
|
---|
144 | }
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Gets the projection for this query.
|
---|
148 | * @return string projection
|
---|
149 | */
|
---|
150 | public function getProjection()
|
---|
151 | {
|
---|
152 | return $this->_projection;
|
---|
153 | }
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * Gets the visibility for this query.
|
---|
157 | * @return string visibility
|
---|
158 | */
|
---|
159 | public function getVisibility()
|
---|
160 | {
|
---|
161 | return $this->_visibility;
|
---|
162 | }
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * Sets the spreadsheet key for this query.
|
---|
166 | * @param string $value
|
---|
167 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
168 | */
|
---|
169 | public function setSpreadsheetQuery($value)
|
---|
170 | {
|
---|
171 | if ($value != null) {
|
---|
172 | $this->_params['sq'] = $value;
|
---|
173 | } else {
|
---|
174 | unset($this->_params['sq']);
|
---|
175 | }
|
---|
176 | return $this;
|
---|
177 | }
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Gets the spreadsheet key for this query.
|
---|
181 | * @return string spreadsheet query
|
---|
182 | */
|
---|
183 | public function getSpreadsheetQuery()
|
---|
184 | {
|
---|
185 | if (array_key_exists('sq', $this->_params)) {
|
---|
186 | return $this->_params['sq'];
|
---|
187 | } else {
|
---|
188 | return null;
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * Sets the orderby attribute for this query.
|
---|
194 | * @param string $value
|
---|
195 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
196 | */
|
---|
197 | public function setOrderBy($value)
|
---|
198 | {
|
---|
199 | if ($value != null) {
|
---|
200 | $this->_params['orderby'] = $value;
|
---|
201 | } else {
|
---|
202 | unset($this->_params['orderby']);
|
---|
203 | }
|
---|
204 | return $this;
|
---|
205 | }
|
---|
206 |
|
---|
207 | /**
|
---|
208 | * Gets the orderby attribute for this query.
|
---|
209 | * @return string orderby
|
---|
210 | */
|
---|
211 | public function getOrderBy()
|
---|
212 | {
|
---|
213 | if (array_key_exists('orderby', $this->_params)) {
|
---|
214 | return $this->_params['orderby'];
|
---|
215 | } else {
|
---|
216 | return null;
|
---|
217 | }
|
---|
218 | }
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * Sets the reverse attribute for this query.
|
---|
222 | * @param string $value
|
---|
223 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
224 | */
|
---|
225 | public function setReverse($value)
|
---|
226 | {
|
---|
227 | if ($value != null) {
|
---|
228 | $this->_params['reverse'] = $value;
|
---|
229 | } else {
|
---|
230 | unset($this->_params['reverse']);
|
---|
231 | }
|
---|
232 | return $this;
|
---|
233 | }
|
---|
234 |
|
---|
235 | /**
|
---|
236 | * Gets the reverse attribute for this query.
|
---|
237 | * @return string reverse
|
---|
238 | */
|
---|
239 | public function getReverse()
|
---|
240 | {
|
---|
241 |
|
---|
242 |
|
---|
243 | if (array_key_exists('reverse', $this->_params)) {
|
---|
244 | return $this->_params['reverse'];
|
---|
245 | } else {
|
---|
246 | return null;
|
---|
247 | }
|
---|
248 | }
|
---|
249 |
|
---|
250 | /**
|
---|
251 | * Gets the full query URL for this query.
|
---|
252 | * @return string url
|
---|
253 | */
|
---|
254 | public function getQueryUrl()
|
---|
255 | {
|
---|
256 |
|
---|
257 | $uri = $this->_defaultFeedUri;
|
---|
258 |
|
---|
259 | if ($this->_spreadsheetKey != null) {
|
---|
260 | $uri .= '/'.$this->_spreadsheetKey;
|
---|
261 | } else {
|
---|
262 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
263 | throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for list queries.');
|
---|
264 | }
|
---|
265 |
|
---|
266 | if ($this->_worksheetId != null) {
|
---|
267 | $uri .= '/'.$this->_worksheetId;
|
---|
268 | } else {
|
---|
269 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
270 | throw new Zend_Gdata_App_Exception('A worksheet id must be provided for list queries.');
|
---|
271 | }
|
---|
272 |
|
---|
273 | if ($this->_visibility != null) {
|
---|
274 | $uri .= '/'.$this->_visibility;
|
---|
275 | } else {
|
---|
276 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
277 | throw new Zend_Gdata_App_Exception('A visibility must be provided for list queries.');
|
---|
278 | }
|
---|
279 |
|
---|
280 | if ($this->_projection != null) {
|
---|
281 | $uri .= '/'.$this->_projection;
|
---|
282 | } else {
|
---|
283 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
284 | throw new Zend_Gdata_App_Exception('A projection must be provided for list queries.');
|
---|
285 | }
|
---|
286 |
|
---|
287 | if ($this->_rowId != null) {
|
---|
288 | $uri .= '/'.$this->_rowId;
|
---|
289 | }
|
---|
290 |
|
---|
291 | $uri .= $this->getQueryString();
|
---|
292 | return $uri;
|
---|
293 | }
|
---|
294 |
|
---|
295 | /**
|
---|
296 | * Gets the attribute query string for this query.
|
---|
297 | * @return string query string
|
---|
298 | */
|
---|
299 | public function getQueryString()
|
---|
300 | {
|
---|
301 | return parent::getQueryString();
|
---|
302 | }
|
---|
303 |
|
---|
304 | }
|
---|