]> git.mjollnir.org Git - moodle.git/commitdiff
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 22d79016626035c8df693209f6a165a71ea42420..f21dfebb576d4bef82d12e13b8e7514ce39e7682 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 3ba6c7d8ff934af66eb159e13bdda03e39eccd18..e97b823ed3c8060fb2b6d3c200084e1630e5e561 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 3ff296fa6f4d09b436909c47e5a26cd264473443..2a1fe809b52ea01517c8182f0818026dc919aaa9 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 db02fd1313bdb35828fd5c27edbdb0a5f18ed796..8201836a7e3ba6d2f4816cdc17b26e6d5e55858a 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() {