portfolio: MDL-20897 Add additional format types
authorDan Poltawski <dan.poltawski@lancaster.ac.uk>
Wed, 18 Nov 2009 17:33:19 +0000 (17:33 +0000)
committerDan Poltawski <dan.poltawski@lancaster.ac.uk>
Wed, 18 Nov 2009 17:33:19 +0000 (17:33 +0000)
Added new specific formats for PDF, Document, Presentation and Spreadsheet

Allow the googledocs plugin to support all these formats

lib/portfolio/constants.php
lib/portfolio/formats.php
lib/portfoliolib.php
portfolio/googledocs/lib.php

index 22d7901..f21dfeb 100644 (file)
@@ -122,6 +122,25 @@ define('PORTFOLIO_FORMAT_VIDEO', 'video');
 */
 define('PORTFOLIO_FORMAT_TEXT', 'text');
 
+/**
+* pdf - subtype of file
+*/
+define('PORTFOLIO_FORMAT_PDF', 'pdf');
+
+/**
+* document - subtype of file
+*/
+define('PORTFOLIO_FORMAT_DOCUMENT', 'document');
+
+/**
+* document - subtype of file
+*/
+define('PORTFOLIO_FORMAT_SPREADSHEET', 'spreadsheet');
+
+/**
+* document - subtype of file
+*/
+define('PORTFOLIO_FORMAT_PRESENTATION', 'presentation');
 
 // ************************************************** //
 //  EXPORT TIME LEVELS
index 3ba6c7d..e97b823 100644 (file)
@@ -141,3 +141,56 @@ class portfolio_format_leap extends portfolio_format_rich { }
 * it's commented out in portfolio_supported_formats so cannot currently be used.
 */
 class portfolio_format_mbkp extends portfolio_format_rich {}
+
+/**
+* 'PDF format', subtype of file.
+*
+* for portfolio plugins that support PDFs specifically
+*/
+class portfolio_format_pdf extends portfolio_format_file {
+    public static function mimetypes() {
+        return array('application/pdf');
+    }
+}
+
+/**
+* 'Document format', subtype of file.
+*
+* for portfolio plugins that support documents specifically
+*/
+class portfolio_format_document extends portfolio_format_file {
+    public static function mimetypes() {
+        return array_merge(
+            array('text/plain', 'text/rtf'),
+            mimeinfo_from_icon('type', 'word.gif', true),
+            mimeinfo_from_icon('type', 'docx.gif', true),
+            mimeinfo_from_icon('type', 'odt.gif', true)
+        );
+    }
+}
+
+/**
+* 'Spreadsheet format', subtype of file.
+*
+* for portfolio plugins that support spreadsheets specifically
+*/
+class portfolio_format_spreadsheet extends portfolio_format_file {
+    public static function mimetypes() {
+        return array_merge(
+            mimeinfo_from_icon('type', 'excel.gif', true),
+            mimeinfo_from_icon('type', 'xlsm.gif', true),
+            mimeinfo_from_icon('type', 'ods.gif', true)
+        );
+    }
+}
+
+/**
+* 'Presentation format', subtype of file.
+*
+* for portfolio plugins that support presentation specifically
+*/
+class portfolio_format_presentation extends portfolio_format_file {
+    public static function mimetypes() {
+        return mimeinfo_from_icon('type', 'powerpoint.gif', true);
+    }
+}
index 3ff296f..2a1fe80 100644 (file)
@@ -465,12 +465,16 @@ function portfolio_instances($visibleonly=true, $useronly=true) {
 */
 function portfolio_supported_formats() {
     return array(
-        PORTFOLIO_FORMAT_FILE       => 'portfolio_format_file',
-        PORTFOLIO_FORMAT_IMAGE      => 'portfolio_format_image',
-        PORTFOLIO_FORMAT_RICHHTML   => 'portfolio_format_richhtml',
-        PORTFOLIO_FORMAT_PLAINHTML  => 'portfolio_format_plainhtml',
-        PORTFOLIO_FORMAT_TEXT       => 'portfolio_format_text',
-        PORTFOLIO_FORMAT_VIDEO      => 'portfolio_format_video',
+        PORTFOLIO_FORMAT_FILE         => 'portfolio_format_file',
+        PORTFOLIO_FORMAT_IMAGE        => 'portfolio_format_image',
+        PORTFOLIO_FORMAT_RICHHTML     => 'portfolio_format_richhtml',
+        PORTFOLIO_FORMAT_PLAINHTML    => 'portfolio_format_plainhtml',
+        PORTFOLIO_FORMAT_TEXT         => 'portfolio_format_text',
+        PORTFOLIO_FORMAT_VIDEO        => 'portfolio_format_video',
+        PORTFOLIO_FORMAT_PDF          => 'portfolio_format_pdf',
+        PORTFOLIO_FORMAT_DOCUMENT     => 'portfolio_format_document',
+        PORTFOLIO_FORMAT_SPREADSHEET  => 'portfolio_format_spreadsheet',
+        PORTFOLIO_FORMAT_PRESENTATION => 'portfolio_format_presentation',
         /*PORTFOLIO_FORMAT_MBKP, */ // later
         /*PORTFOLIO_FORMAT_LEAP, */ // also later
     );
index db02fd1..8201836 100644 (file)
@@ -11,7 +11,15 @@ class portfolio_plugin_googledocs extends portfolio_plugin_push_base {
     private $sessiontoken;
 
     public static function supported_formats() {
-        return array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_IMAGE, PORTFOLIO_FORMAT_TEXT);
+        return array(
+            PORTFOLIO_FORMAT_PLAINHTML,
+            PORTFOLIO_FORMAT_IMAGE,
+            PORTFOLIO_FORMAT_TEXT,
+            PORTFOLIO_FORMAT_PDF,
+            PORTFOLIO_FORMAT_DOCUMENT,
+            PORTFOLIO_FORMAT_PRESENTATION,
+            PORTFOLIO_FORMAT_SPREADSHEET
+        );
     }
 
     public static function get_name() {