Skip to content

Commit

Permalink
portfolio: MDL-20897 Add additional format types
Browse files Browse the repository at this point in the history
Added new specific formats for PDF, Document, Presentation and Spreadsheet

Allow the googledocs plugin to support all these formats
  • Loading branch information
danpoltawski committed Nov 18, 2009
1 parent 887160c commit a9ec903
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 7 deletions.
19 changes: 19 additions & 0 deletions lib/portfolio/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@
*/
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
Expand Down
53 changes: 53 additions & 0 deletions lib/portfolio/formats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
16 changes: 10 additions & 6 deletions lib/portfoliolib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
10 changes: 9 additions & 1 deletion portfolio/googledocs/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a9ec903

Please sign in to comment.