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
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
* @license http://framework.zend.com/license/new-bsd New BSD License
25
require_once 'Zend/Gdata/App/Util.php';
28
* Provides a mechanism to build a query URL for Gdata services.
29
* Queries are not defined for APP, but are provided by Gdata services
34
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
35
* @license http://framework.zend.com/license/new-bsd New BSD License
37
class Zend_Gdata_Query
45
protected $_params = array();
52
protected $_defaultFeedUri = null;
56
* TODO: Add setters and getters
60
protected $_url = null;
63
* Category for the query
67
protected $_category = null;
70
* Create Gdata_Query object
72
public function __construct($url = null)
78
* @return string querystring
80
public function getQueryString()
82
$queryArray = array();
83
foreach ($this->_params as $name => $value) {
84
if (substr($name, 0, 1) == '_') {
87
$queryArray[] = urlencode($name) . '=' . urlencode($value);
89
if (count($queryArray) > 0) {
90
return '?' . implode('&', $queryArray);
99
public function resetParameters()
101
$this->_params = array();
107
public function getQueryUrl()
109
if ($this->_url == null) {
110
$url = $this->_defaultFeedUri;
114
if ($this->getCategory() !== null) {
115
$url .= '/-/' . $this->getCategory();
117
$url .= $this->getQueryString();
122
* @param string $name
123
* @param string $value
124
* @return Zend_Gdata_Query Provides a fluent interface
126
public function setParam($name, $value)
128
$this->_params[$name] = $value;
133
* @param string $name
135
public function getParam($name)
137
return $this->_params[$name];
141
* @param string $value
142
* @return Zend_Gdata_Query Provides a fluent interface
144
public function setAlt($value)
146
if ($value != null) {
147
$this->_params['alt'] = $value;
149
unset($this->_params['alt']);
156
* @return Zend_Gdata_Query Provides a fluent interface
158
public function setMaxResults($value)
160
if ($value != null) {
161
$this->_params['max-results'] = $value;
163
unset($this->_params['max-results']);
169
* @param string $value
170
* @return Zend_Gdata_Query Provides a fluent interface
172
public function setQuery($value)
174
if ($value != null) {
175
$this->_params['q'] = $value;
177
unset($this->_params['q']);
184
* @return Zend_Gdata_Query Provides a fluent interface
186
public function setStartIndex($value)
188
if ($value != null) {
189
$this->_params['start-index'] = $value;
191
unset($this->_params['start-index']);
197
* @param string $value
198
* @return Zend_Gdata_Query Provides a fluent interface
200
public function setUpdatedMax($value)
202
if ($value != null) {
203
$this->_params['updated-max'] = Zend_Gdata_App_Util::formatTimestamp($value);
205
unset($this->_params['updated-max']);
211
* @param string $value
212
* @return Zend_Gdata_Query Provides a fluent interface
214
public function setUpdatedMin($value)
216
if ($value != null) {
217
$this->_params['updated-min'] = Zend_Gdata_App_Util::formatTimestamp($value);
219
unset($this->_params['updated-min']);
225
* @param string $value
226
* @return Zend_Gdata_Query Provides a fluent interface
228
public function setPublishedMax($value)
230
if ($value !== null) {
231
$this->_params['published-max'] = Zend_Gdata_App_Util::formatTimestamp($value);
233
unset($this->_params['published-max']);
239
* @param string $value
240
* @return Zend_Gdata_Query Provides a fluent interface
242
public function setPublishedMin($value)
244
if ($value != null) {
245
$this->_params['published-min'] = Zend_Gdata_App_Util::formatTimestamp($value);
247
unset($this->_params['published-min']);
253
* @param string $value
254
* @return Zend_Gdata_Query Provides a fluent interface
256
public function setAuthor($value)
258
if ($value != null) {
259
$this->_params['author'] = $value;
261
unset($this->_params['author']);
267
* @return string rss or atom
269
public function getAlt()
271
if (array_key_exists('alt', $this->_params)) {
272
return $this->_params['alt'];
279
* @return int maxResults
281
public function getMaxResults()
283
if (array_key_exists('max-results', $this->_params)) {
284
return intval($this->_params['max-results']);
291
* @return string query
293
public function getQuery()
295
if (array_key_exists('q', $this->_params)) {
296
return $this->_params['q'];
303
* @return int startIndex
305
public function getStartIndex()
307
if (array_key_exists('start-index', $this->_params)) {
308
return intval($this->_params['start-index']);
315
* @return string updatedMax
317
public function getUpdatedMax()
319
if (array_key_exists('updated-max', $this->_params)) {
320
return $this->_params['updated-max'];
327
* @return string updatedMin
329
public function getUpdatedMin()
331
if (array_key_exists('updated-min', $this->_params)) {
332
return $this->_params['updated-min'];
339
* @return string publishedMax
341
public function getPublishedMax()
343
if (array_key_exists('published-max', $this->_params)) {
344
return $this->_params['published-max'];
351
* @return string publishedMin
353
public function getPublishedMin()
355
if (array_key_exists('published-min', $this->_params)) {
356
return $this->_params['published-min'];
363
* @return string author
365
public function getAuthor()
367
if (array_key_exists('author', $this->_params)) {
368
return $this->_params['author'];
375
* @param string $value
376
* @return Zend_Gdata_Query Provides a fluent interface
378
public function setCategory($value)
380
$this->_category = $value;
387
public function getCategory()
389
return $this->_category;
393
public function __get($name)
395
$method = 'get'.ucfirst($name);
396
if (method_exists($this, $method)) {
397
return call_user_func(array(&$this, $method));
399
require_once 'Zend/Gdata/App/Exception.php';
400
throw new Zend_Gdata_App_Exception('Property ' . $name . ' does not exist');
404
public function __set($name, $val)
406
$method = 'set'.ucfirst($name);
407
if (method_exists($this, $method)) {
408
return call_user_func(array(&$this, $method), $val);
410
require_once 'Zend/Gdata/App/Exception.php';
411
throw new Zend_Gdata_App_Exception('Property ' . $name . ' does not exist');