|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once 'Zend/Gdata.php'; 00028 00032 require_once 'Zend/Gdata/DublinCore.php'; 00033 00037 require_once 'Zend/Gdata/Books/CollectionEntry.php'; 00038 00042 require_once 'Zend/Gdata/Books/CollectionFeed.php'; 00043 00047 require_once 'Zend/Gdata/Books/VolumeEntry.php'; 00048 00052 require_once 'Zend/Gdata/Books/VolumeFeed.php'; 00053 00063 class Zend_Gdata_Books extends Zend_Gdata 00064 { 00065 const VOLUME_FEED_URI = 'http://books.google.com/books/feeds/volumes'; 00066 const MY_LIBRARY_FEED_URI = 'http://books.google.com/books/feeds/users/me/collections/library/volumes'; 00067 const MY_ANNOTATION_FEED_URI = 'http://books.google.com/books/feeds/users/me/volumes'; 00068 const AUTH_SERVICE_NAME = 'print'; 00069 00075 public static $namespaces = array( 00076 array('gbs', 'http://schemas.google.com/books/2008', 1, 0), 00077 array('dc', 'http://purl.org/dc/terms', 1, 0) 00078 ); 00079 00087 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0') 00088 { 00089 $this->registerPackage('Zend_Gdata_Books'); 00090 $this->registerPackage('Zend_Gdata_Books_Extension'); 00091 parent::__construct($client, $applicationId); 00092 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME); 00093 } 00094 00104 public function getVolumeFeed($location = null) 00105 { 00106 if ($location == null) { 00107 $uri = self::VOLUME_FEED_URI; 00108 } else if ($location instanceof Zend_Gdata_Query) { 00109 $uri = $location->getQueryUrl(); 00110 } else { 00111 $uri = $location; 00112 } 00113 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed'); 00114 } 00115 00126 public function getVolumeEntry($volumeId = null, $location = null) 00127 { 00128 if ($volumeId !== null) { 00129 $uri = self::VOLUME_FEED_URI . "/" . $volumeId; 00130 } else if ($location instanceof Zend_Gdata_Query) { 00131 $uri = $location->getQueryUrl(); 00132 } else { 00133 $uri = $location; 00134 } 00135 return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry'); 00136 } 00137 00146 public function getUserLibraryFeed($location = null) 00147 { 00148 if ($location == null) { 00149 $uri = self::MY_LIBRARY_FEED_URI; 00150 } else { 00151 $uri = $location; 00152 } 00153 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed'); 00154 } 00155 00164 public function getUserAnnotationFeed($location = null) 00165 { 00166 if ($location == null) { 00167 $uri = self::MY_ANNOTATION_FEED_URI; 00168 } else { 00169 $uri = $location; 00170 } 00171 return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed'); 00172 } 00173 00182 public function insertVolume($entry, $location = null) 00183 { 00184 if ($location == null) { 00185 $uri = self::MY_LIBRARY_FEED_URI; 00186 } else { 00187 $uri = $location; 00188 } 00189 return parent::insertEntry( 00190 $entry, $uri, 'Zend_Gdata_Books_VolumeEntry'); 00191 } 00192 00199 public function deleteVolume($entry) 00200 { 00201 $entry->delete(); 00202 } 00203 00204 }