~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/Query.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @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
 
20
 */
 
21
 
 
22
/**
 
23
 * Zend_Gdata_App_Util
 
24
 */
 
25
require_once 'Zend/Gdata/App/Util.php';
 
26
 
 
27
/**
 
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
 
30
 * as an extension.
 
31
 *
 
32
 * @category   Zend
 
33
 * @package    Zend_Gdata
 
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
 
36
 */
 
37
class Zend_Gdata_Query
 
38
{
 
39
 
 
40
    /**
 
41
     * Query parameters.
 
42
     *
 
43
     * @var array
 
44
     */
 
45
    protected $_params = array();
 
46
 
 
47
    /**
 
48
     * Default URL
 
49
     *
 
50
     * @var string
 
51
     */
 
52
    protected $_defaultFeedUri = null;
 
53
 
 
54
    /**
 
55
     * Base URL
 
56
     * TODO: Add setters and getters
 
57
     *
 
58
     * @var string
 
59
     */
 
60
    protected $_url = null;
 
61
 
 
62
    /**
 
63
     * Category for the query
 
64
     *
 
65
     * @var string
 
66
     */
 
67
    protected $_category = null;
 
68
 
 
69
    /**
 
70
     * Create Gdata_Query object
 
71
     */
 
72
    public function __construct($url = null)
 
73
    {
 
74
        $this->_url = $url;
 
75
    }
 
76
 
 
77
    /**
 
78
     * @return string querystring
 
79
     */
 
80
    public function getQueryString()
 
81
    {
 
82
        $queryArray = array();
 
83
        foreach ($this->_params as $name => $value) {
 
84
            if (substr($name, 0, 1) == '_') {
 
85
                continue;
 
86
            }
 
87
            $queryArray[] = urlencode($name) . '=' . urlencode($value);
 
88
        }
 
89
        if (count($queryArray) > 0) {
 
90
            return '?' . implode('&', $queryArray);
 
91
        } else {
 
92
            return '';
 
93
        }
 
94
    }
 
95
 
 
96
    /**
 
97
     *
 
98
     */
 
99
    public function resetParameters()
 
100
    {
 
101
        $this->_params = array();
 
102
    }
 
103
 
 
104
    /**
 
105
     * @return string url
 
106
     */
 
107
    public function getQueryUrl()
 
108
    {
 
109
        if ($this->_url == null) {
 
110
            $url = $this->_defaultFeedUri;
 
111
        } else {
 
112
            $url = $this->_url;
 
113
        }
 
114
        if ($this->getCategory() !== null) {
 
115
            $url .= '/-/' . $this->getCategory();
 
116
        }
 
117
        $url .= $this->getQueryString();
 
118
        return $url;
 
119
    }
 
120
 
 
121
    /**
 
122
     * @param string $name
 
123
     * @param string $value
 
124
     * @return Zend_Gdata_Query Provides a fluent interface
 
125
     */
 
126
    public function setParam($name, $value)
 
127
    {
 
128
        $this->_params[$name] = $value;
 
129
        return $this;
 
130
    }
 
131
 
 
132
    /**
 
133
     * @param string $name
 
134
     */
 
135
    public function getParam($name)
 
136
    {
 
137
        return $this->_params[$name];
 
138
    }
 
139
 
 
140
    /**
 
141
     * @param string $value
 
142
     * @return Zend_Gdata_Query Provides a fluent interface
 
143
     */
 
144
    public function setAlt($value)
 
145
    {
 
146
        if ($value != null) {
 
147
            $this->_params['alt'] = $value;
 
148
        } else {
 
149
            unset($this->_params['alt']);
 
150
        }
 
151
        return $this;
 
152
    }
 
153
 
 
154
    /**
 
155
     * @param int $value
 
156
     * @return Zend_Gdata_Query Provides a fluent interface
 
157
     */
 
158
    public function setMaxResults($value)
 
159
    {
 
160
        if ($value != null) {
 
161
            $this->_params['max-results'] = $value;
 
162
        } else {
 
163
            unset($this->_params['max-results']);
 
164
        }
 
165
        return $this;
 
166
    }
 
167
 
 
168
    /**
 
169
     * @param string $value
 
170
     * @return Zend_Gdata_Query Provides a fluent interface
 
171
     */
 
172
    public function setQuery($value)
 
173
    {
 
174
        if ($value != null) {
 
175
            $this->_params['q'] = $value;
 
176
        } else {
 
177
            unset($this->_params['q']);
 
178
        }
 
179
        return $this;
 
180
    }
 
181
 
 
182
    /**
 
183
     * @param int $value
 
184
     * @return Zend_Gdata_Query Provides a fluent interface
 
185
     */
 
186
    public function setStartIndex($value)
 
187
    {
 
188
        if ($value != null) {
 
189
            $this->_params['start-index'] = $value;
 
190
        } else {
 
191
            unset($this->_params['start-index']);
 
192
        }
 
193
        return $this;
 
194
    }
 
195
 
 
196
    /**
 
197
     * @param string $value
 
198
     * @return Zend_Gdata_Query Provides a fluent interface
 
199
     */
 
200
    public function setUpdatedMax($value)
 
201
    {
 
202
        if ($value != null) {
 
203
            $this->_params['updated-max'] = Zend_Gdata_App_Util::formatTimestamp($value);
 
204
        } else {
 
205
            unset($this->_params['updated-max']);
 
206
        }
 
207
        return $this;
 
208
    }
 
209
 
 
210
    /**
 
211
     * @param string $value
 
212
     * @return Zend_Gdata_Query Provides a fluent interface
 
213
     */
 
214
    public function setUpdatedMin($value)
 
215
    {
 
216
        if ($value != null) {
 
217
            $this->_params['updated-min'] = Zend_Gdata_App_Util::formatTimestamp($value);
 
218
        } else {
 
219
            unset($this->_params['updated-min']);
 
220
        }
 
221
        return $this;
 
222
    }
 
223
 
 
224
    /**
 
225
     * @param string $value
 
226
     * @return Zend_Gdata_Query Provides a fluent interface
 
227
     */
 
228
    public function setPublishedMax($value)
 
229
    {
 
230
        if ($value !== null) {
 
231
            $this->_params['published-max'] = Zend_Gdata_App_Util::formatTimestamp($value);
 
232
        } else {
 
233
            unset($this->_params['published-max']);
 
234
        }
 
235
        return $this;
 
236
    }
 
237
 
 
238
    /**
 
239
     * @param string $value
 
240
     * @return Zend_Gdata_Query Provides a fluent interface
 
241
     */
 
242
    public function setPublishedMin($value)
 
243
    {
 
244
        if ($value != null) {
 
245
            $this->_params['published-min'] = Zend_Gdata_App_Util::formatTimestamp($value);
 
246
        } else {
 
247
            unset($this->_params['published-min']);
 
248
        }
 
249
        return $this;
 
250
    }
 
251
 
 
252
    /**
 
253
     * @param string $value
 
254
     * @return Zend_Gdata_Query Provides a fluent interface
 
255
     */
 
256
    public function setAuthor($value)
 
257
    {
 
258
        if ($value != null) {
 
259
            $this->_params['author'] = $value;
 
260
        } else {
 
261
            unset($this->_params['author']);
 
262
        }
 
263
        return $this;
 
264
    }
 
265
 
 
266
    /**
 
267
     * @return string rss or atom
 
268
     */
 
269
    public function getAlt()
 
270
    {
 
271
        if (array_key_exists('alt', $this->_params)) {
 
272
            return $this->_params['alt'];
 
273
        } else {
 
274
            return null;
 
275
        }
 
276
    }
 
277
 
 
278
    /**
 
279
     * @return int maxResults
 
280
     */
 
281
    public function getMaxResults()
 
282
    {
 
283
        if (array_key_exists('max-results', $this->_params)) {
 
284
            return intval($this->_params['max-results']);
 
285
        } else {
 
286
            return null;
 
287
        }
 
288
    }
 
289
 
 
290
    /**
 
291
     * @return string query
 
292
     */
 
293
    public function getQuery()
 
294
    {
 
295
        if (array_key_exists('q', $this->_params)) {
 
296
            return $this->_params['q'];
 
297
        } else {
 
298
            return null;
 
299
        }
 
300
    }
 
301
 
 
302
    /**
 
303
     * @return int startIndex
 
304
     */
 
305
    public function getStartIndex()
 
306
    {
 
307
        if (array_key_exists('start-index', $this->_params)) {
 
308
            return intval($this->_params['start-index']);
 
309
        } else {
 
310
            return null;
 
311
        }
 
312
    }
 
313
 
 
314
    /**
 
315
     * @return string updatedMax
 
316
     */
 
317
    public function getUpdatedMax()
 
318
    {
 
319
        if (array_key_exists('updated-max', $this->_params)) {
 
320
            return $this->_params['updated-max'];
 
321
        } else {
 
322
            return null;
 
323
        }
 
324
    }
 
325
 
 
326
    /**
 
327
     * @return string updatedMin
 
328
     */
 
329
    public function getUpdatedMin()
 
330
    {
 
331
        if (array_key_exists('updated-min', $this->_params)) {
 
332
            return $this->_params['updated-min'];
 
333
        } else {
 
334
            return null;
 
335
        }
 
336
    }
 
337
 
 
338
    /**
 
339
     * @return string publishedMax
 
340
     */
 
341
    public function getPublishedMax()
 
342
    {
 
343
        if (array_key_exists('published-max', $this->_params)) {
 
344
            return $this->_params['published-max'];
 
345
        } else {
 
346
            return null;
 
347
        }
 
348
    }
 
349
 
 
350
    /**
 
351
     * @return string publishedMin
 
352
     */
 
353
    public function getPublishedMin()
 
354
    {
 
355
        if (array_key_exists('published-min', $this->_params)) {
 
356
            return $this->_params['published-min'];
 
357
        } else {
 
358
            return null;
 
359
        }
 
360
    }
 
361
 
 
362
    /**
 
363
     * @return string author
 
364
     */
 
365
    public function getAuthor()
 
366
    {
 
367
        if (array_key_exists('author', $this->_params)) {
 
368
            return $this->_params['author'];
 
369
        } else {
 
370
            return null;
 
371
        }
 
372
    }
 
373
 
 
374
    /**
 
375
     * @param string $value
 
376
     * @return Zend_Gdata_Query Provides a fluent interface
 
377
     */
 
378
    public function setCategory($value)
 
379
    {
 
380
        $this->_category = $value;
 
381
        return $this;
 
382
    }
 
383
 
 
384
    /*
 
385
     * @return string id
 
386
     */
 
387
    public function getCategory()
 
388
    {
 
389
        return $this->_category;
 
390
    }
 
391
 
 
392
 
 
393
    public function __get($name)
 
394
    {
 
395
        $method = 'get'.ucfirst($name);
 
396
        if (method_exists($this, $method)) {
 
397
            return call_user_func(array(&$this, $method));
 
398
        } else {
 
399
            require_once 'Zend/Gdata/App/Exception.php';
 
400
            throw new Zend_Gdata_App_Exception('Property ' . $name . '  does not exist');
 
401
        }
 
402
    }
 
403
 
 
404
    public function __set($name, $val)
 
405
    {
 
406
        $method = 'set'.ucfirst($name);
 
407
        if (method_exists($this, $method)) {
 
408
            return call_user_func(array(&$this, $method), $val);
 
409
        } else {
 
410
            require_once 'Zend/Gdata/App/Exception.php';
 
411
            throw new Zend_Gdata_App_Exception('Property ' . $name . '  does not exist');
 
412
        }
 
413
    }
 
414
 
 
415
}