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.
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
25 * Modifications by SugarCRM
27 * March 14, 2011 - asandberg: Changed DOCUMENTS_LIST_FEED_URI to work with v3 of Docs API.
33 require_once('Zend/Gdata/Query.php');
36 * Assists in constructing queries for Google Document List documents
38 * @link http://code.google.com/apis/gdata/spreadsheets/
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
46 class Zend_Gdata_Docs_Query extends Zend_Gdata_Query
50 * The base URL for retrieving a document list
54 const DOCUMENTS_LIST_FEED_URI = 'https://docs.google.com/feeds/default';
57 * The generic base URL used by some inherited methods
61 protected $_defaultFeedUri = self::DOCUMENTS_LIST_FEED_URI;
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.
70 protected $_visibility = 'private';
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
79 protected $_projection = 'full';
82 * Constructs a new instance of a Zend_Gdata_Docs_Query object.
84 public function __construct()
86 parent::__construct();
90 * Sets the projection for this query. Common values for projection
93 * @param string $value
94 * @return Zend_Gdata_Docs_Query Provides a fluent interface
96 public function setProjection($value)
98 $this->_projection = $value;
103 * Sets the visibility for this query. Common values for visibility
106 * @return Zend_Gdata_Docs_Query Provides a fluent interface
108 public function setVisibility($value)
110 $this->_visibility = $value;
115 * Gets the projection for this query.
117 * @return string projection
119 public function getProjection()
121 return $this->_projection;
125 * Gets the visibility for this query.
127 * @return string visibility
129 public function getVisibility()
131 return $this->_visibility;
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.
139 * @param string $value
140 * @return Zend_Gdata_Docs_Query Provides a fluent interface
142 public function setTitle($value)
144 if ($value !== null) {
145 $this->_params['title'] = $value;
147 unset($this->_params['title']);
153 * Gets the title attribute for this query.
155 * @return string title
157 public function getTitle()
159 if (array_key_exists('title', $this->_params)) {
160 return $this->_params['title'];
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.
172 * @param boolean $value Use either true or false
173 * @return Zend_Gdata_Docs_Query Provides a fluent interface
175 public function setTitleExact($value)
178 $this->_params['title-exact'] = $value;
180 unset($this->_params['title-exact']);
186 * Gets the title-exact attribute for this query.
188 * @return string title-exact
190 public function getTitleExact()
192 if (array_key_exists('title-exact', $this->_params)) {
193 return $this->_params['title-exact'];
200 * Gets the full query URL for this query.
204 public function getQueryUrl()
206 $uri = $this->_defaultFeedUri;
208 if ($this->_visibility !== null) {
209 $uri .= '/' . $this->_visibility;
211 require_once 'Zend/Gdata/App/Exception.php';
212 throw new Zend_Gdata_App_Exception(
213 'A visibility must be provided for cell queries.');
216 if ($this->_projection !== null) {
217 $uri .= '/' . $this->_projection;
219 require_once 'Zend/Gdata/App/Exception.php';
220 throw new Zend_Gdata_App_Exception(
221 'A projection must be provided for cell queries.');
224 $uri .= $this->getQueryString();