From a9ec9031498b857ffb254f94d04e3410b8a2c838 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Wed, 18 Nov 2009 17:33:19 +0000 Subject: [PATCH] portfolio: MDL-20897 Add additional format types Added new specific formats for PDF, Document, Presentation and Spreadsheet Allow the googledocs plugin to support all these formats --- lib/portfolio/constants.php | 19 +++++++++++++ lib/portfolio/formats.php | 53 ++++++++++++++++++++++++++++++++++++ lib/portfoliolib.php | 16 +++++++---- portfolio/googledocs/lib.php | 10 ++++++- 4 files changed, 91 insertions(+), 7 deletions(-) diff --git a/lib/portfolio/constants.php b/lib/portfolio/constants.php index 22d7901662..f21dfebb57 100644 --- a/lib/portfolio/constants.php +++ b/lib/portfolio/constants.php @@ -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 diff --git a/lib/portfolio/formats.php b/lib/portfolio/formats.php index 3ba6c7d8ff..e97b823ed3 100644 --- a/lib/portfolio/formats.php +++ b/lib/portfolio/formats.php @@ -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); + } +} diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index 3ff296fa6f..2a1fe809b5 100644 --- a/lib/portfoliolib.php +++ b/lib/portfoliolib.php @@ -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 ); diff --git a/portfolio/googledocs/lib.php b/portfolio/googledocs/lib.php index db02fd1313..8201836a7e 100644 --- a/portfolio/googledocs/lib.php +++ b/portfolio/googledocs/lib.php @@ -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() { -- 2.39.5