File indexing completed on 2024-12-22 05:36:44
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Docs 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * Zend_Gdata_Query 0026 */ 0027 // require_once('Zend/Gdata/Query.php'); 0028 0029 /** 0030 * Assists in constructing queries for Google Document List documents 0031 * 0032 * @link http://code.google.com/apis/gdata/spreadsheets/ 0033 * 0034 * @category Zend 0035 * @package Zend_Gdata 0036 * @subpackage Docs 0037 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0038 * @license http://framework.zend.com/license/new-bsd New BSD License 0039 */ 0040 class Zend_Gdata_Docs_Query extends Zend_Gdata_Query 0041 { 0042 0043 /** 0044 * The base URL for retrieving a document list 0045 * 0046 * @var string 0047 */ 0048 const DOCUMENTS_LIST_FEED_URI = 'https://docs.google.com/feeds/documents'; 0049 0050 /** 0051 * The generic base URL used by some inherited methods 0052 * 0053 * @var string 0054 */ 0055 protected $_defaultFeedUri = self::DOCUMENTS_LIST_FEED_URI; 0056 0057 /** 0058 * The visibility to be used when querying for the feed. A request for a 0059 * feed with private visbility requires the user to be authenricated. 0060 * Private is the only avilable visibility for the documents list. 0061 * 0062 * @var string 0063 */ 0064 protected $_visibility = 'private'; 0065 0066 /** 0067 * The projection determines how much detail should be given in the 0068 * result of the query. Full is the only valid projection for the 0069 * documents list. 0070 * 0071 * @var string 0072 */ 0073 protected $_projection = 'full'; 0074 0075 /** 0076 * Constructs a new instance of a Zend_Gdata_Docs_Query object. 0077 */ 0078 public function __construct() 0079 { 0080 parent::__construct(); 0081 } 0082 0083 /** 0084 * Sets the projection for this query. Common values for projection 0085 * include 'full'. 0086 * 0087 * @param string $value 0088 * @return Zend_Gdata_Docs_Query Provides a fluent interface 0089 */ 0090 public function setProjection($value) 0091 { 0092 $this->_projection = $value; 0093 return $this; 0094 } 0095 0096 /** 0097 * Sets the visibility for this query. Common values for visibility 0098 * include 'private'. 0099 * 0100 * @return Zend_Gdata_Docs_Query Provides a fluent interface 0101 */ 0102 public function setVisibility($value) 0103 { 0104 $this->_visibility = $value; 0105 return $this; 0106 } 0107 0108 /** 0109 * Gets the projection for this query. 0110 * 0111 * @return string projection 0112 */ 0113 public function getProjection() 0114 { 0115 return $this->_projection; 0116 } 0117 0118 /** 0119 * Gets the visibility for this query. 0120 * 0121 * @return string visibility 0122 */ 0123 public function getVisibility() 0124 { 0125 return $this->_visibility; 0126 } 0127 0128 /** 0129 * Sets the title attribute for this query. The title parameter is used 0130 * to restrict the results to documents whose titles either contain or 0131 * completely match the title. 0132 * 0133 * @param string $value 0134 * @return Zend_Gdata_Docs_Query Provides a fluent interface 0135 */ 0136 public function setTitle($value) 0137 { 0138 if ($value !== null) { 0139 $this->_params['title'] = $value; 0140 } else { 0141 unset($this->_params['title']); 0142 } 0143 return $this; 0144 } 0145 0146 /** 0147 * Gets the title attribute for this query. 0148 * 0149 * @return string title 0150 */ 0151 public function getTitle() 0152 { 0153 if (array_key_exists('title', $this->_params)) { 0154 return $this->_params['title']; 0155 } else { 0156 return null; 0157 } 0158 } 0159 0160 /** 0161 * Sets the title-exact attribute for this query. 0162 * If title-exact is set to true, the title query parameter will be used 0163 * in an exact match. Only documents with a title identical to the 0164 * title parameter will be returned. 0165 * 0166 * @param boolean $value Use either true or false 0167 * @return Zend_Gdata_Docs_Query Provides a fluent interface 0168 */ 0169 public function setTitleExact($value) 0170 { 0171 if ($value) { 0172 $this->_params['title-exact'] = $value; 0173 } else { 0174 unset($this->_params['title-exact']); 0175 } 0176 return $this; 0177 } 0178 0179 /** 0180 * Gets the title-exact attribute for this query. 0181 * 0182 * @return string title-exact 0183 */ 0184 public function getTitleExact() 0185 { 0186 if (array_key_exists('title-exact', $this->_params)) { 0187 return $this->_params['title-exact']; 0188 } else { 0189 return false; 0190 } 0191 } 0192 0193 /** 0194 * Gets the full query URL for this query. 0195 * 0196 * @return string url 0197 */ 0198 public function getQueryUrl() 0199 { 0200 $uri = $this->_defaultFeedUri; 0201 0202 if ($this->_visibility !== null) { 0203 $uri .= '/' . $this->_visibility; 0204 } else { 0205 // require_once 'Zend/Gdata/App/Exception.php'; 0206 throw new Zend_Gdata_App_Exception( 0207 'A visibility must be provided for cell queries.'); 0208 } 0209 0210 if ($this->_projection !== null) { 0211 $uri .= '/' . $this->_projection; 0212 } else { 0213 // require_once 'Zend/Gdata/App/Exception.php'; 0214 throw new Zend_Gdata_App_Exception( 0215 'A projection must be provided for cell queries.'); 0216 } 0217 0218 $uri .= $this->getQueryString(); 0219 return $uri; 0220 } 0221 0222 }