Zend_Gdata_Query

Provides a mechanism to build a query URL for Gdata services.

Defined (1)

The class is defined in the following location(s).

/inc/VideoUploader/includes/Zend/Gdata/Query.php  
  1. class Zend_Gdata_Query 
  2.  
  3. /** 
  4. * Query parameters. 
  5. * @var array 
  6. */ 
  7. protected $_params = array(); 
  8.  
  9. /** 
  10. * Default URL 
  11. * @var string 
  12. */ 
  13. protected $_defaultFeedUri = null; 
  14.  
  15. /** 
  16. * Base URL 
  17. * TODO: Add setters and getters 
  18. * @var string 
  19. */ 
  20. protected $_url = null; 
  21.  
  22. /** 
  23. * Category for the query 
  24. * @var string 
  25. */ 
  26. protected $_category = null; 
  27.  
  28. /** 
  29. * Create Gdata_Query object 
  30. */ 
  31. public function __construct($url = null) 
  32. $this->_url = $url; 
  33.  
  34. /** 
  35. * @return string querystring 
  36. */ 
  37. public function getQueryString() 
  38. $queryArray = array(); 
  39. foreach ($this->_params as $name => $value) { 
  40. if (substr($name, 0, 1) == '_') { 
  41. continue; 
  42. $queryArray[] = urlencode($name) . '=' . urlencode($value); 
  43. if (count($queryArray) > 0) { 
  44. return '?' . implode('&', $queryArray); 
  45. } else { 
  46. return ''; 
  47.  
  48. /** 
  49. */ 
  50. public function resetParameters() 
  51. $this->_params = array(); 
  52.  
  53. /** 
  54. * @return string url 
  55. */ 
  56. public function getQueryUrl() 
  57. if ($this->_url == null) { 
  58. $url = $this->_defaultFeedUri; 
  59. } else { 
  60. $url = $this->_url; 
  61. if ($this->getCategory() !== null) { 
  62. $url .= '/-/' . $this->getCategory(); 
  63. $url .= $this->getQueryString(); 
  64. return $url; 
  65.  
  66. /** 
  67. * @param string $name 
  68. * @param string $value 
  69. * @return Zend_Gdata_Query Provides a fluent interface 
  70. */ 
  71. public function setParam($name, $value) 
  72. $this->_params[$name] = $value; 
  73. return $this; 
  74.  
  75. /** 
  76. * @param string $name 
  77. */ 
  78. public function getParam($name) 
  79. return $this->_params[$name]; 
  80.  
  81. /** 
  82. * @param string $value 
  83. * @return Zend_Gdata_Query Provides a fluent interface 
  84. */ 
  85. public function setAlt($value) 
  86. if ($value != null) { 
  87. $this->_params['alt'] = $value; 
  88. } else { 
  89. unset($this->_params['alt']); 
  90. return $this; 
  91.  
  92. /** 
  93. * @param int $value 
  94. * @return Zend_Gdata_Query Provides a fluent interface 
  95. */ 
  96. public function setMaxResults($value) 
  97. if ($value != null) { 
  98. $this->_params['max-results'] = $value; 
  99. } else { 
  100. unset($this->_params['max-results']); 
  101. return $this; 
  102.  
  103. /** 
  104. * @param string $value 
  105. * @return Zend_Gdata_Query Provides a fluent interface 
  106. */ 
  107. public function setQuery($value) 
  108. if ($value != null) { 
  109. $this->_params['q'] = $value; 
  110. } else { 
  111. unset($this->_params['q']); 
  112. return $this; 
  113.  
  114. /** 
  115. * @param int $value 
  116. * @return Zend_Gdata_Query Provides a fluent interface 
  117. */ 
  118. public function setStartIndex($value) 
  119. if ($value != null) { 
  120. $this->_params['start-index'] = $value; 
  121. } else { 
  122. unset($this->_params['start-index']); 
  123. return $this; 
  124.  
  125. /** 
  126. * @param string $value 
  127. * @return Zend_Gdata_Query Provides a fluent interface 
  128. */ 
  129. public function setUpdatedMax($value) 
  130. if ($value != null) { 
  131. $this->_params['updated-max'] = Zend_Gdata_App_Util::formatTimestamp($value); 
  132. } else { 
  133. unset($this->_params['updated-max']); 
  134. return $this; 
  135.  
  136. /** 
  137. * @param string $value 
  138. * @return Zend_Gdata_Query Provides a fluent interface 
  139. */ 
  140. public function setUpdatedMin($value) 
  141. if ($value != null) { 
  142. $this->_params['updated-min'] = Zend_Gdata_App_Util::formatTimestamp($value); 
  143. } else { 
  144. unset($this->_params['updated-min']); 
  145. return $this; 
  146.  
  147. /** 
  148. * @param string $value 
  149. * @return Zend_Gdata_Query Provides a fluent interface 
  150. */ 
  151. public function setPublishedMax($value) 
  152. if ($value !== null) { 
  153. $this->_params['published-max'] = Zend_Gdata_App_Util::formatTimestamp($value); 
  154. } else { 
  155. unset($this->_params['published-max']); 
  156. return $this; 
  157.  
  158. /** 
  159. * @param string $value 
  160. * @return Zend_Gdata_Query Provides a fluent interface 
  161. */ 
  162. public function setPublishedMin($value) 
  163. if ($value != null) { 
  164. $this->_params['published-min'] = Zend_Gdata_App_Util::formatTimestamp($value); 
  165. } else { 
  166. unset($this->_params['published-min']); 
  167. return $this; 
  168.  
  169. /** 
  170. * @param string $value 
  171. * @return Zend_Gdata_Query Provides a fluent interface 
  172. */ 
  173. public function setAuthor($value) 
  174. if ($value != null) { 
  175. $this->_params['author'] = $value; 
  176. } else { 
  177. unset($this->_params['author']); 
  178. return $this; 
  179.  
  180. /** 
  181. * @return string rss or atom 
  182. */ 
  183. public function getAlt() 
  184. if (array_key_exists('alt', $this->_params)) { 
  185. return $this->_params['alt']; 
  186. } else { 
  187. return null; 
  188.  
  189. /** 
  190. * @return int maxResults 
  191. */ 
  192. public function getMaxResults() 
  193. if (array_key_exists('max-results', $this->_params)) { 
  194. return intval($this->_params['max-results']); 
  195. } else { 
  196. return null; 
  197.  
  198. /** 
  199. * @return string query 
  200. */ 
  201. public function getQuery() 
  202. if (array_key_exists('q', $this->_params)) { 
  203. return $this->_params['q']; 
  204. } else { 
  205. return null; 
  206.  
  207. /** 
  208. * @return int startIndex 
  209. */ 
  210. public function getStartIndex() 
  211. if (array_key_exists('start-index', $this->_params)) { 
  212. return intval($this->_params['start-index']); 
  213. } else { 
  214. return null; 
  215.  
  216. /** 
  217. * @return string updatedMax 
  218. */ 
  219. public function getUpdatedMax() 
  220. if (array_key_exists('updated-max', $this->_params)) { 
  221. return $this->_params['updated-max']; 
  222. } else { 
  223. return null; 
  224.  
  225. /** 
  226. * @return string updatedMin 
  227. */ 
  228. public function getUpdatedMin() 
  229. if (array_key_exists('updated-min', $this->_params)) { 
  230. return $this->_params['updated-min']; 
  231. } else { 
  232. return null; 
  233.  
  234. /** 
  235. * @return string publishedMax 
  236. */ 
  237. public function getPublishedMax() 
  238. if (array_key_exists('published-max', $this->_params)) { 
  239. return $this->_params['published-max']; 
  240. } else { 
  241. return null; 
  242.  
  243. /** 
  244. * @return string publishedMin 
  245. */ 
  246. public function getPublishedMin() 
  247. if (array_key_exists('published-min', $this->_params)) { 
  248. return $this->_params['published-min']; 
  249. } else { 
  250. return null; 
  251.  
  252. /** 
  253. * @return string author 
  254. */ 
  255. public function getAuthor() 
  256. if (array_key_exists('author', $this->_params)) { 
  257. return $this->_params['author']; 
  258. } else { 
  259. return null; 
  260.  
  261. /** 
  262. * @param string $value 
  263. * @return Zend_Gdata_Query Provides a fluent interface 
  264. */ 
  265. public function setCategory($value) 
  266. $this->_category = $value; 
  267. return $this; 
  268.  
  269. /** 
  270. * @return string id 
  271. */ 
  272. public function getCategory() 
  273. return $this->_category; 
  274.  
  275.  
  276. public function __get($name) 
  277. $method = 'get'.ucfirst($name); 
  278. if (method_exists($this, $method)) { 
  279. return call_user_func(array(&$this, $method)); 
  280. } else { 
  281. require_once 'Zend/Gdata/App/Exception.php'; 
  282. throw new Zend_Gdata_App_Exception('Property ' . $name . ' does not exist'); 
  283.  
  284. public function __set($name, $val) 
  285. $method = 'set'.ucfirst($name); 
  286. if (method_exists($this, $method)) { 
  287. return call_user_func(array(&$this, $method), $val); 
  288. } else { 
  289. require_once 'Zend/Gdata/App/Exception.php'; 
  290. throw new Zend_Gdata_App_Exception('Property ' . $name . ' does not exist'); 
  291.