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-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
27 require_once('Zend/Gdata/App/Util.php');
32 require_once('Zend/Gdata/Query.php');
35 * Assists in constructing queries for Google Spreadsheets lists
37 * @link http://code.google.com/apis/gdata/calendar/
41 * @subpackage Spreadsheets
42 * @copyright Copyright (c) 2005-2010 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_ListQuery extends Zend_Gdata_Query
48 const SPREADSHEETS_LIST_FEED_URI = 'http://spreadsheets.google.com/feeds/list';
50 protected $_defaultFeedUri = self::SPREADSHEETS_LIST_FEED_URI;
51 protected $_visibility = 'private';
52 protected $_projection = 'full';
53 protected $_spreadsheetKey = null;
54 protected $_worksheetId = 'default';
55 protected $_rowId = null;
58 * Constructs a new Zend_Gdata_Spreadsheets_ListQuery object.
60 public function __construct()
62 parent::__construct();
66 * Sets the spreadsheet key for the query.
67 * @param string $value
68 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
70 public function setSpreadsheetKey($value)
72 $this->_spreadsheetKey = $value;
77 * Gets the spreadsheet key for the query.
78 * @return string spreadsheet key
80 public function getSpreadsheetKey()
82 return $this->_spreadsheetKey;
86 * Sets the worksheet id for the query.
87 * @param string $value
88 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
90 public function setWorksheetId($value)
92 $this->_worksheetId = $value;
97 * Gets the worksheet id for the query.
98 * @return string worksheet id
100 public function getWorksheetId()
102 return $this->_worksheetId;
106 * Sets the row id for the query.
107 * @param string $value row id
108 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
110 public function setRowId($value)
112 $this->_rowId = $value;
117 * Gets the row id for the query.
118 * @return string row id
120 public function getRowId()
122 return $this->_rowId;
126 * Sets the projection for the query.
127 * @param string $value Projection
128 * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface
130 public function setProjection($value)
132 $this->_projection = $value;
137 * Sets the visibility for this query.
138 * @param string $value visibility
139 * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface
141 public function setVisibility($value)
143 $this->_visibility = $value;
148 * Gets the projection for this query.
149 * @return string projection
151 public function getProjection()
153 return $this->_projection;
157 * Gets the visibility for this query.
158 * @return string visibility
160 public function getVisibility()
162 return $this->_visibility;
166 * Sets the spreadsheet key for this query.
167 * @param string $value
168 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
170 public function setSpreadsheetQuery($value)
172 if ($value != null) {
173 $this->_params['sq'] = $value;
175 unset($this->_params['sq']);
181 * Gets the spreadsheet key for this query.
182 * @return string spreadsheet query
184 public function getSpreadsheetQuery()
186 if (array_key_exists('sq', $this->_params)) {
187 return $this->_params['sq'];
194 * Sets the orderby attribute for this query.
195 * @param string $value
196 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
198 public function setOrderBy($value)
200 if ($value != null) {
201 $this->_params['orderby'] = $value;
203 unset($this->_params['orderby']);
209 * Gets the orderby attribute for this query.
210 * @return string orderby
212 public function getOrderBy()
214 if (array_key_exists('orderby', $this->_params)) {
215 return $this->_params['orderby'];
222 * Sets the reverse attribute for this query.
223 * @param string $value
224 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
226 public function setReverse($value)
228 if ($value != null) {
229 $this->_params['reverse'] = $value;
231 unset($this->_params['reverse']);
237 * Gets the reverse attribute for this query.
238 * @return string reverse
240 public function getReverse()
244 if (array_key_exists('reverse', $this->_params)) {
245 return $this->_params['reverse'];
252 * Gets the full query URL for this query.
255 public function getQueryUrl()
258 $uri = $this->_defaultFeedUri;
260 if ($this->_spreadsheetKey != null) {
261 $uri .= '/'.$this->_spreadsheetKey;
263 require_once 'Zend/Gdata/App/Exception.php';
264 throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for list queries.');
267 if ($this->_worksheetId != null) {
268 $uri .= '/'.$this->_worksheetId;
270 require_once 'Zend/Gdata/App/Exception.php';
271 throw new Zend_Gdata_App_Exception('A worksheet id must be provided for list queries.');
274 if ($this->_visibility != null) {
275 $uri .= '/'.$this->_visibility;
277 require_once 'Zend/Gdata/App/Exception.php';
278 throw new Zend_Gdata_App_Exception('A visibility must be provided for list queries.');
281 if ($this->_projection != null) {
282 $uri .= '/'.$this->_projection;
284 require_once 'Zend/Gdata/App/Exception.php';
285 throw new Zend_Gdata_App_Exception('A projection must be provided for list queries.');
288 if ($this->_rowId != null) {
289 $uri .= '/'.$this->_rowId;
292 $uri .= $this->getQueryString();
297 * Gets the attribute query string for this query.
298 * @return string query string
300 public function getQueryString()
302 return parent::getQueryString();