diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Gdata.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Gdata.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,241 @@ +decodeRequest('GET', $uri); + $response = $app->performHttpRequest($requestData['method'], $requestData['url']); + + $feedContent = $response->getBody(); + + $feed = self::importString($feedContent, $className); + if ($client != null) { + $feed->setHttpClient($client); + } + return $feed; + } + + /** + * Retrieve feed as string or object + * + * @param mixed $location The location as string or Zend_Gdata_Query + * @param string $className The class type to use for returning the feed + * @throws Zend_Gdata_App_InvalidArgumentException + * @return string|Zend_Gdata_App_Feed Returns string only if the object + * mapping has been disabled explicitly + * by passing false to the + * useObjectMapping() function. + */ + public function getFeed($location, $className='Zend_Gdata_Feed') + { + if (is_string($location)) { + $uri = $location; + } elseif ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'You must specify the location as either a string URI ' . + 'or a child of Zend_Gdata_Query'); + } + return parent::getFeed($uri, $className); + } + + /** + * Retrieve entry as string or object + * + * @param mixed $location The location as string or Zend_Gdata_Query + * @throws Zend_Gdata_App_InvalidArgumentException + * @return string|Zend_Gdata_App_Entry Returns string only if the object + * mapping has been disabled explicitly + * by passing false to the + * useObjectMapping() function. + */ + public function getEntry($location, $className='Zend_Gdata_Entry') + { + if (is_string($location)) { + $uri = $location; + } elseif ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'You must specify the location as either a string URI ' . + 'or a child of Zend_Gdata_Query'); + } + return parent::getEntry($uri, $className); + } + + /** + * Performs a HTTP request using the specified method. + * + * Overrides the definition in the parent (Zend_Gdata_App) + * and uses the Zend_Gdata_HttpClient functionality + * to filter the HTTP requests and responses. + * + * @param string $method The HTTP method for the request - + * 'GET', 'POST', 'PUT', 'DELETE' + * @param string $url The URL to which this request is being performed, + * or null if found in $data + * @param array $headers An associative array of HTTP headers + * for this request + * @param string $body The body of the HTTP request + * @param string $contentType The value for the content type of the + * request body + * @param int $remainingRedirects Number of redirects to follow + * if requests results in one + * @return Zend_Http_Response The response object + */ + public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null) + { + if ($this->_httpClient instanceof Zend_Gdata_HttpClient) { + $filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType); + $method = $filterResult['method']; + $url = $filterResult['url']; + $body = $filterResult['body']; + $headers = $filterResult['headers']; + $contentType = $filterResult['contentType']; + return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects)); + } else { + return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects); + } + } + + /** + * Determines whether service object is authenticated. + * + * @return boolean True if service object is authenticated, false otherwise. + */ + public function isAuthenticated() + { + $client = parent::getHttpClient(); + if ($client->getClientLoginToken() || + $client->getAuthSubToken()) { + return true; + } + + return false; + } + +}