|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once('Zend/Gdata/App/Util.php'); 00028 00032 require_once('Zend/Gdata/Query.php'); 00033 00045 class Zend_Gdata_Spreadsheets_DocumentQuery extends Zend_Gdata_Query 00046 { 00047 00048 const SPREADSHEETS_FEED_URI = 'http://spreadsheets.google.com/feeds'; 00049 00050 protected $_defaultFeedUri = self::SPREADSHEETS_FEED_URI; 00051 protected $_documentType; 00052 protected $_visibility = 'private'; 00053 protected $_projection = 'full'; 00054 protected $_spreadsheetKey = null; 00055 protected $_worksheetId = null; 00056 00060 public function __construct() 00061 { 00062 parent::__construct(); 00063 } 00064 00070 public function setSpreadsheetKey($value) 00071 { 00072 $this->_spreadsheetKey = $value; 00073 return $this; 00074 } 00075 00080 public function getSpreadsheetKey() 00081 { 00082 return $this->_spreadsheetKey; 00083 } 00084 00090 public function setWorksheetId($value) 00091 { 00092 $this->_worksheetId = $value; 00093 return $this; 00094 } 00095 00100 public function getWorksheetId() 00101 { 00102 return $this->_worksheetId; 00103 } 00104 00110 public function setDocumentType($value) 00111 { 00112 $this->_documentType = $value; 00113 return $this; 00114 } 00115 00120 public function getDocumentType() 00121 { 00122 return $this->_documentType; 00123 } 00124 00130 public function setProjection($value) 00131 { 00132 $this->_projection = $value; 00133 return $this; 00134 } 00135 00140 public function setVisibility($value) 00141 { 00142 $this->_visibility = $value; 00143 return $this; 00144 } 00145 00150 public function getProjection() 00151 { 00152 return $this->_projection; 00153 } 00154 00159 public function getVisibility() 00160 { 00161 return $this->_visibility; 00162 } 00163 00169 public function setTitle($value) 00170 { 00171 if ($value != null) { 00172 $this->_params['title'] = $value; 00173 } else { 00174 unset($this->_params['title']); 00175 } 00176 return $this; 00177 } 00178 00184 public function setTitleExact($value) 00185 { 00186 if ($value != null) { 00187 $this->_params['title-exact'] = $value; 00188 } else { 00189 unset($this->_params['title-exact']); 00190 } 00191 return $this; 00192 } 00193 00198 public function getTitle() 00199 { 00200 if (array_key_exists('title', $this->_params)) { 00201 return $this->_params['title']; 00202 } else { 00203 return null; 00204 } 00205 } 00206 00211 public function getTitleExact() 00212 { 00213 if (array_key_exists('title-exact', $this->_params)) { 00214 return $this->_params['title-exact']; 00215 } else { 00216 return null; 00217 } 00218 } 00219 00220 private function appendVisibilityProjection() 00221 { 00222 $uri = ''; 00223 00224 if ($this->_visibility != null) { 00225 $uri .= '/'.$this->_visibility; 00226 } else { 00227 require_once 'Zend/Gdata/App/Exception.php'; 00228 throw new Zend_Gdata_App_Exception('A visibility must be provided for document queries.'); 00229 } 00230 00231 if ($this->_projection != null) { 00232 $uri .= '/'.$this->_projection; 00233 } else { 00234 require_once 'Zend/Gdata/App/Exception.php'; 00235 throw new Zend_Gdata_App_Exception('A projection must be provided for document queries.'); 00236 } 00237 00238 return $uri; 00239 } 00240 00241 00246 public function getQueryUrl() 00247 { 00248 $uri = $this->_defaultFeedUri; 00249 00250 if ($this->_documentType != null) { 00251 $uri .= '/'.$this->_documentType; 00252 } else { 00253 require_once 'Zend/Gdata/App/Exception.php'; 00254 throw new Zend_Gdata_App_Exception('A document type must be provided for document queries.'); 00255 } 00256 00257 if ($this->_documentType == 'spreadsheets') { 00258 $uri .= $this->appendVisibilityProjection(); 00259 if ($this->_spreadsheetKey != null) { 00260 $uri .= '/'.$this->_spreadsheetKey; 00261 } 00262 } else if ($this->_documentType == 'worksheets') { 00263 if ($this->_spreadsheetKey != null) { 00264 $uri .= '/'.$this->_spreadsheetKey; 00265 } else { 00266 require_once 'Zend/Gdata/App/Exception.php'; 00267 throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for worksheet document queries.'); 00268 } 00269 $uri .= $this->appendVisibilityProjection(); 00270 if ($this->_worksheetId != null) { 00271 $uri .= '/'.$this->_worksheetId; 00272 } 00273 } 00274 00275 $uri .= $this->getQueryString(); 00276 return $uri; 00277 } 00278 00283 public function getQueryString() 00284 { 00285 return parent::getQueryString(); 00286 } 00287 00288 }