]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/Docs/Query.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Gdata / Docs / Query.php
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 Docs
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
21
22  */
23
24 /**
25  * Modifications by SugarCRM
26  * 
27  * March 14, 2011 - asandberg: Changed DOCUMENTS_LIST_FEED_URI to work with v3 of Docs API.
28  */
29
30 /**
31  * Zend_Gdata_Query
32  */
33 require_once('Zend/Gdata/Query.php');
34
35 /**
36  * Assists in constructing queries for Google Document List documents
37  *
38  * @link http://code.google.com/apis/gdata/spreadsheets/
39  *
40  * @category   Zend
41  * @package    Zend_Gdata
42  * @subpackage Docs
43  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
44  * @license    http://framework.zend.com/license/new-bsd     New BSD License
45  */
46 class Zend_Gdata_Docs_Query extends Zend_Gdata_Query
47 {
48
49     /**
50      * The base URL for retrieving a document list
51      *
52      * @var string
53      */
54     const DOCUMENTS_LIST_FEED_URI = 'https://docs.google.com/feeds/default';
55
56     /**
57      * The generic base URL used by some inherited methods
58      *
59      * @var string
60      */
61     protected $_defaultFeedUri = self::DOCUMENTS_LIST_FEED_URI;
62
63     /**
64      * The visibility to be used when querying for the feed. A request for a
65      * feed with private visbility requires the user to be authenricated.
66      * Private is the only avilable visibility for the documents list.
67      *
68      * @var string
69      */
70     protected $_visibility = 'private';
71
72     /**
73      * The projection determines how much detail should be given in the
74      * result of the query. Full is the only valid projection for the
75      * documents list.
76      *
77      * @var string
78      */
79     protected $_projection = 'full';
80
81     /**
82      * Constructs a new instance of a Zend_Gdata_Docs_Query object.
83      */
84     public function __construct()
85     {
86         parent::__construct();
87     }
88
89     /**
90      * Sets the projection for this query. Common values for projection
91      * include 'full'.
92      *
93      * @param string $value
94      * @return Zend_Gdata_Docs_Query Provides a fluent interface
95      */
96     public function setProjection($value)
97     {
98         $this->_projection = $value;
99         return $this;
100     }
101
102     /**
103      * Sets the visibility for this query. Common values for visibility
104      * include 'private'.
105      *
106      * @return Zend_Gdata_Docs_Query Provides a fluent interface
107      */
108     public function setVisibility($value)
109     {
110         $this->_visibility = $value;
111         return $this;
112     }
113
114     /**
115      * Gets the projection for this query.
116      *
117      * @return string projection
118      */
119     public function getProjection()
120     {
121         return $this->_projection;
122     }
123
124     /**
125      * Gets the visibility for this query.
126      *
127      * @return string visibility
128      */
129     public function getVisibility()
130     {
131         return $this->_visibility;
132     }
133
134     /**
135      * Sets the title attribute for this query. The title parameter is used
136      * to restrict the results to documents whose titles either contain or
137      * completely match the title.
138      *
139      * @param string $value
140      * @return Zend_Gdata_Docs_Query Provides a fluent interface
141      */
142     public function setTitle($value)
143     {
144         if ($value !== null) {
145             $this->_params['title'] = $value;
146         } else {
147             unset($this->_params['title']);
148         }
149         return $this;
150     }
151
152     /**
153      * Gets the title attribute for this query.
154      *
155      * @return string title
156      */
157     public function getTitle()
158     {
159         if (array_key_exists('title', $this->_params)) {
160             return $this->_params['title'];
161         } else {
162             return null;
163         }
164     }
165
166     /**
167      * Sets the title-exact attribute for this query.
168      * If title-exact is set to true, the title query parameter will be used
169      * in an exact match. Only documents with a title identical to the
170      * title parameter will be returned.
171      *
172      * @param boolean $value Use either true or false
173      * @return Zend_Gdata_Docs_Query Provides a fluent interface
174      */
175     public function setTitleExact($value)
176     {
177         if ($value) {
178             $this->_params['title-exact'] = $value;
179         } else {
180             unset($this->_params['title-exact']);
181         }
182         return $this;
183     }
184
185     /**
186      * Gets the title-exact attribute for this query.
187      *
188      * @return string title-exact
189      */
190     public function getTitleExact()
191     {
192         if (array_key_exists('title-exact', $this->_params)) {
193             return $this->_params['title-exact'];
194         } else {
195             return false;
196         }
197     }
198
199     /**
200      * Gets the full query URL for this query.
201      *
202      * @return string url
203      */
204     public function getQueryUrl()
205     {
206         $uri = $this->_defaultFeedUri;
207
208         if ($this->_visibility !== null) {
209             $uri .= '/' . $this->_visibility;
210         } else {
211             require_once 'Zend/Gdata/App/Exception.php';
212             throw new Zend_Gdata_App_Exception(
213                 'A visibility must be provided for cell queries.');
214         }
215
216         if ($this->_projection !== null) {
217             $uri .= '/' . $this->_projection;
218         } else {
219             require_once 'Zend/Gdata/App/Exception.php';
220             throw new Zend_Gdata_App_Exception(
221                 'A projection must be provided for cell queries.');
222         }
223
224         $uri .= $this->getQueryString();
225         return $uri;
226     }
227
228 }