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.
18 * @subpackage Spreadsheets
19 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: CellQuery.php 16971 2009-07-22 18:05:45Z mikaelkael $
27 require_once('Zend/Gdata/App/Util.php');
32 require_once('Zend/Gdata/Query.php');
35 * Assists in constructing queries for Google Spreadsheets cells
37 * @link http://code.google.com/apis/gdata/spreadsheets/
41 * @subpackage Spreadsheets
42 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
43 * @license http://framework.zend.com/license/new-bsd New BSD License
45 class Zend_Gdata_Spreadsheets_CellQuery
extends Zend_Gdata_Query
48 const SPREADSHEETS_CELL_FEED_URI
= 'http://spreadsheets.google.com/feeds/cells';
50 protected $_defaultFeedUri = self
::SPREADSHEETS_CELL_FEED_URI
;
51 protected $_visibility = 'private';
52 protected $_projection = 'full';
53 protected $_spreadsheetKey = null;
54 protected $_worksheetId = 'default';
55 protected $_cellId = null;
58 * Constructs a new Zend_Gdata_Spreadsheets_CellQuery object.
60 * @param string $url Base URL to use for queries
62 public function __construct($url = null)
64 parent
::__construct($url);
68 * Sets the spreadsheet key for this query.
70 * @param string $value
71 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
73 public function setSpreadsheetKey($value)
75 $this->_spreadsheetKey
= $value;
80 * Gets the spreadsheet key for this query.
82 * @return string spreadsheet key
84 public function getSpreadsheetKey()
86 return $this->_spreadsheetKey
;
90 * Sets the worksheet id for this query.
92 * @param string $value
93 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
95 public function setWorksheetId($value)
97 $this->_worksheetId
= $value;
102 * Gets the worksheet id for this query.
104 * @return string worksheet id
106 public function getWorksheetId()
108 return $this->_worksheetId
;
112 * Sets the cell id for this query.
114 * @param string $value
115 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
117 public function setCellId($value)
119 $this->_cellId
= $value;
124 * Gets the cell id for this query.
126 * @return string cell id
128 public function getCellId()
130 return $this->_cellId
;
134 * Sets the projection for this query.
136 * @param string $value
137 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
139 public function setProjection($value)
141 $this->_projection
= $value;
146 * Sets the visibility for this query.
148 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
150 public function setVisibility($value)
152 $this->_visibility
= $value;
157 * Gets the projection for this query.
159 * @return string projection
161 public function getProjection()
163 return $this->_projection
;
167 * Gets the visibility for this query.
169 * @return string visibility
171 public function getVisibility()
173 return $this->_visibility
;
177 * Sets the min-row attribute for this query.
179 * @param string $value
180 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
182 public function setMinRow($value)
184 if ($value != null) {
185 $this->_params
['min-row'] = $value;
187 unset($this->_params
['min-row']);
193 * Gets the min-row attribute for this query.
195 * @return string min-row
197 public function getMinRow()
199 if (array_key_exists('min-row', $this->_params
)) {
200 return $this->_params
['min-row'];
207 * Sets the max-row attribute for this query.
209 * @param string $value
210 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
212 public function setMaxRow($value)
214 if ($value != null) {
215 $this->_params
['max-row'] = $value;
217 unset($this->_params
['max-row']);
223 * Gets the max-row attribute for this query.
225 * @return string max-row
227 public function getMaxRow()
229 if (array_key_exists('max-row', $this->_params
)) {
230 return $this->_params
['max-row'];
237 * Sets the min-col attribute for this query.
239 * @param string $value
240 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
242 public function setMinCol($value)
244 if ($value != null) {
245 $this->_params
['min-col'] = $value;
247 unset($this->_params
['min-col']);
253 * Gets the min-col attribute for this query.
255 * @return string min-col
257 public function getMinCol()
259 if (array_key_exists('min-col', $this->_params
)) {
260 return $this->_params
['min-col'];
267 * Sets the max-col attribute for this query.
269 * @param string $value
270 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
272 public function setMaxCol($value)
274 if ($value != null) {
275 $this->_params
['max-col'] = $value;
277 unset($this->_params
['max-col']);
283 * Gets the max-col attribute for this query.
285 * @return string max-col
287 public function getMaxCol()
289 if (array_key_exists('max-col', $this->_params
)) {
290 return $this->_params
['max-col'];
297 * Sets the range attribute for this query.
299 * @param string $value
300 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
302 public function setRange($value)
304 if ($value != null) {
305 $this->_params
['range'] = $value;
307 unset($this->_params
['range']);
313 * Gets the range attribute for this query.
315 * @return string range
317 public function getRange()
319 if (array_key_exists('range', $this->_params
)) {
320 return $this->_params
['range'];
327 * Sets the return-empty attribute for this query.
329 * @param mixed $value String or bool value for whether to return empty cells
330 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
332 public function setReturnEmpty($value)
334 if (is_bool($value)) {
335 $this->_params
['return-empty'] = ($value?
'true':'false');
336 } else if ($value != null) {
337 $this->_params
['return-empty'] = $value;
339 unset($this->_params
['return-empty']);
345 * Gets the return-empty attribute for this query.
347 * @return string return-empty
349 public function getReturnEmpty()
351 if (array_key_exists('return-empty', $this->_params
)) {
352 return $this->_params
['return-empty'];
359 * Gets the full query URL for this query.
363 public function getQueryUrl()
365 if ($this->_url
== null) {
366 $uri = $this->_defaultFeedUri
;
368 if ($this->_spreadsheetKey
!= null) {
369 $uri .= '/'.$this->_spreadsheetKey
;
371 require_once 'Zend/Gdata/App/Exception.php';
372 throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for cell queries.');
375 if ($this->_worksheetId
!= null) {
376 $uri .= '/'.$this->_worksheetId
;
378 require_once 'Zend/Gdata/App/Exception.php';
379 throw new Zend_Gdata_App_Exception('A worksheet id must be provided for cell queries.');
382 if ($this->_visibility
!= null) {
383 $uri .= '/'.$this->_visibility
;
385 require_once 'Zend/Gdata/App/Exception.php';
386 throw new Zend_Gdata_App_Exception('A visibility must be provided for cell queries.');
389 if ($this->_projection
!= null) {
390 $uri .= '/'.$this->_projection
;
392 require_once 'Zend/Gdata/App/Exception.php';
393 throw new Zend_Gdata_App_Exception('A projection must be provided for cell queries.');
396 if ($this->_cellId
!= null) {
397 $uri .= '/'.$this->_cellId
;
403 $uri .= $this->getQueryString();
408 * Gets the attribute query string for this query.
410 * @return string query string
412 public function getQueryString()
414 return parent
::getQueryString();