--- Docs.php (revision 20086)
+++ Docs.php (working copy)
@@ -37,6 +37,12 @@
require_once 'Zend/Gdata/Docs/DocumentListEntry.php';
/**
+ * App Extensions
+ */
! Because of the way phpdoc works, using this style of comment to group
! require_once statements doesn't work. Please stick with the existing
! convention, namely an @see $CLASS_NAME for each require_once.
+require_once 'Zend/Gdata/App/Extension/Category.php';
+require_once 'Zend/Gdata/App/Extension/Title.php';
+
+/**
* Service class for interacting with the Google Document List data API
* @link http: *
@@ -50,19 +56,29 @@
{
const DOCUMENTS_LIST_FEED_URI = 'http:+ const DOCUMENTS_FOLDER_FEED_URI = 'http:+ const DOCUMENTS_CATEGORY_SCHEMA = 'http:+ const DOCUMENTS_CATEGORY_TERM = 'http: const AUTH_SERVICE_NAME = 'writely';
protected $_defaultPostUri = self::DOCUMENTS_LIST_FEED_URI;
private static $SUPPORTED_FILETYPES = array(
+ 'TXT'=>'text/plain',
'CSV'=>'text/csv',
+ 'TSV'=>'text/tab-separated-values',
+ 'TAB'=>'text/tab-separated-values',
+ 'HTML'=>'text/html',
+ 'HTM'=>'text/html',
'DOC'=>'application/msword',
'ODS'=>'application/vnd.oasis.opendocument.spreadsheet',
'ODT'=>'application/vnd.oasis.opendocument.text',
'RTF'=>'application/rtf',
'SXW'=>'application/vnd.sun.xml.writer',
- 'TXT'=>'text/plain',
- 'XLS'=>'application/vnd.ms-excel');
+ 'XLS'=>'application/vnd.ms-excel',
+ 'XLSX'=>'application/vnd.ms-excel',
+ 'PPT'=>'application/vnd.ms-powerpoint',
+ 'PPS'=>'application/vnd.ms-powerpoint');
/**
* Create Gdata_Docs object
@@ -235,6 +251,31 @@
}
/**
+ * Creates a new folder in Google Docs
+ *
+ * @param string $folderName The folder name to create
+ * @param string $folderResourceId The parent folder to create it in ("folder%3Amy_parent_folder")
! This actually accepts string|null.
+ *
! Remove extra newline here.
+ * @return boolean
+ */
+ public function createFolder($folderName, $folderResourceId=null) {
+ $category = new Zend_Gdata_App_Extension_Category(self::DOCUMENTS_CATEGORY_TERM,
+ self::DOCUMENTS_CATEGORY_SCHEMA);
+ $title = new Zend_Gdata_App_Extension_Title($folderName);
+ $entry = new Zend_Gdata_Entry();
+
+ $entry->setCategory(array($category));
+ $entry->setTitle($title);
+
+ $uri = self::DOCUMENTS_LIST_FEED_URI;
+ if ($folderResourceId != null) {
+ $uri = self::DOCUMENTS_FOLDER_FEED_URI . '/' . $folderResourceId;
+ }
+
+ return $this->insertEntry($entry, $uri);
+ }
+
+ /**
* Inserts an entry to a given URI and returns the response as an Entry.
*
* @param mixed $data The Zend_Gdata_Docs_DocumentListEntry or media
Here's an initial patch that adds folder creation support.
Once you patch this in, you can also move and delete folders relatively easily with code outside the Gdata library.