Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

This file contains all the class definitions of the export formats. They are implemented in php classes rather than just a simpler hash Because it provides an easy way to do subtyping using php inheritance.

Copyright: 2008 Penny Leach <penny@catalyst.net.nz>,
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 607 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 13 classes

portfolio_format:: (5 methods):
  mimetypes()
  get_file_directory()
  file_output()
  make_tag()
  conflicts()

portfolio_format_file:: (3 methods):
  mimetypes()
  get_file_directory()
  file_output()

portfolio_format_image:: (2 methods):
  mimetypes()
  conflicts()

portfolio_format_plainhtml:: (2 methods):
  mimetypes()
  conflicts()

portfolio_format_video:: (1 method):
  mimetypes()

portfolio_format_text:: (2 methods):
  mimetypes()
  conflicts()

portfolio_format_rich:: (1 method):
  mimetypes()

portfolio_format_richhtml:: (3 methods):
  get_file_directory()
  file_output()
  conflicts()

portfolio_format_leap2a:: (5 methods):
  get_file_directory()
  file_id_prefix()
  file_output()
  leap2a_writer()
  manifest_name()

portfolio_format_pdf:: (1 method):
  mimetypes()

portfolio_format_document:: (1 method):
  mimetypes()

portfolio_format_spreadsheet:: (1 method):
  mimetypes()

portfolio_format_presentation:: (1 method):
  mimetypes()


Class: portfolio_format  - X-Ref

Base class to inherit from.

Do not use this anywhere in supported_formats

mimetypes()   X-Ref
Array of mimetypes this format supports


get_file_directory()   X-Ref
For multipart formats, eg html with attachments,
we need to have a directory to place associated files from
inside the zip file. This is the name of that directory


file_output($file, $options=null)   X-Ref
Given a file, return a snippet of markup in whatever format
to link to that file.
Usually involves the path given by get_file_directory.
This is not supported in subclasses of portfolio_format_file
since they're all just single files.

param: stored_file $file file information object
param: array $options array of options to pass. can contain:

make_tag($file, $path, $attributes)   X-Ref
Create portfolio tag

return: string
param: stored_file $file file information object
param: string $path file path
param: array $attributes portfolio attributes

conflicts($format)   X-Ref
Whether this format conflicts with the given format.
This is used for the case where an export location
"generally" supports something like FORMAT_PLAINHTML
but then in a specific export case, must add attachments,
which means that FORMAT_RICHHTML is supported in that case,
which implies removing support for FORMAT_PLAINHTML.
Note that conflicts don't have to be bi-directional
(eg FORMAT_PLAINHTML conflicts with FORMAT_RICHHTML
but not the other way around) and things within the class hierarchy
are resolved automatically anyway.
This is really just between subclasses of format_rich
and subclasses of format_file.

return: bool
param: string $format one of the FORMAT_XX constants

Class: portfolio_format_file  - X-Ref

The most basic type - pretty much everything is a subtype

mimetypes()   X-Ref
Array of mimetypes this format supports

return: array

get_file_directory()   X-Ref
For multipart formats, eg html with attachments,
we need to have a directory to place associated files from
inside the zip file. This is the name of that directory

return: bool

file_output($file, $options=null)   X-Ref
Given a file, return a snippet of markup in whatever format
to link to that file.
Usually involves the path given by get_file_directory.
This is not supported in subclasses of portfolio_format_file
since they're all just single files.

param: stored_file $file informations object
param: array $options array of options to pass. can contain:

Class: portfolio_format_image  - X-Ref

Image format, subtype of file.

mimetypes()   X-Ref
Return all mimetypes that use image.gif (eg all images)

return: string

conflicts($format)   X-Ref
Whether this format conflicts with the given format.
This is used for the case where an export location
"generally" supports something like FORMAT_PLAINHTML
but then in a specific export case, must add attachments,
which means that FORMAT_RICHHTML is supported in that case,
which implies removing support for FORMAT_PLAINHTML.
Note that conflicts don't have to be bi-directional
(eg FORMAT_PLAINHTML conflicts with FORMAT_RICHHTML
but not the other way around) and things within the class hierarchy
are resolved automatically anyway.
This is really just between subclasses of format_rich
and subclasses of format_file.

return: bool
param: string $format one of the FORMAT_XX constants

Class: portfolio_format_plainhtml  - X-Ref

HTML format

Could be used for an external cms or something in case we want to be really specific.

mimetypes()   X-Ref
Return html mimetype

return: array

conflicts($format)   X-Ref
Whether this format conflicts with the given format.
This is used for the case where an export location
"generally" supports something like FORMAT_PLAINHTML
but then in a specific export case, must add attachments,
which means that FORMAT_RICHHTML is supported in that case,
which implies removing support for FORMAT_PLAINHTML.
Note that conflicts don't have to be bi-directional
(eg FORMAT_PLAINHTML conflicts with FORMAT_RICHHTML
but not the other way around) and things within the class hierarchy
are resolved automatically anyway.
This is really just between subclasses of format_rich
and subclasses of format_file.

return: bool
param: string $format one of the FORMAT_XX constants

Class: portfolio_format_video  - X-Ref

Video format

For portfolio plugins that support videos specifically

mimetypes()   X-Ref
Return video mimetypes

return: array

Class: portfolio_format_text  - X-Ref

Class for plain text format.

Not sure why we would need this yet,
but since resource module wants to export it... we can

mimetypes()   X-Ref
Return plain text mimetypes

return: array

conflicts($format )   X-Ref
Whether this format conflicts with the given format.
This is used for the case where an export location
"generally" supports something like FORMAT_PLAINHTML
but then in a specific export case, must add attachments,
which means that FORMAT_RICHHTML is supported in that case,
which implies removing support for FORMAT_PLAINHTML.
Note that conflicts don't have to be bi-directional
(eg FORMAT_PLAINHTML conflicts with FORMAT_RICHHTML
but not the other way around) and things within the class hierarchy
are resolved automatically anyway.
This is really just between subclasses of format_rich
and subclasses of format_file.

return: bool
param: string $format one of the FORMAT_XX constants

Class: portfolio_format_rich  - X-Ref

Base class for rich formats.

These are multipart - eg things with attachments

mimetypes()   X-Ref
Return rich text mimetypes

return: array

Class: portfolio_format_richhtml  - X-Ref

Richhtml - html with attachments.

The most commonly used rich format
eg inline images

get_file_directory()   X-Ref
For multipart formats, eg html with attachments,
we need to have a directory to place associated files from
inside the zip file. this is the name of that directory

return: string

file_output($file, $options=null)   X-Ref
Given a file, return a snippet of markup in whatever format
to link to that file.
Usually involves the path given by get_file_directory.
This is not supported in subclasses of portfolio_format_file
since they're all just single files.

return: string
param: stored_file $file information for existing file
param: array $options array of options to pass. can contain:

conflicts($format)   X-Ref
Whether this format conflicts with the given format.
This is used for the case where an export location
"generally" supports something like FORMAT_PLAINHTML
but then in a specific export case, must add attachments,
which means that FORMAT_RICHHTML is supported in that case,
which implies removing support for FORMAT_PLAINHTML.
Note that conflicts don't have to be bi-directional
(eg FORMAT_PLAINHTML conflicts with FORMAT_RICHHTML
but not the other way around) and things within the class hierarchy
are resolved automatically anyway.
This is really just between subclasses of format_rich
and subclasses of format_file.

return: bool
param: string $format one of the FORMAT_XX constants

Class: portfolio_format_leap2a  - X-Ref

Class used for leap2a format

get_file_directory()   X-Ref
For multipart formats, eg html with attachments,
we need to have a directory to place associated files from
inside the zip file. this is the name of that directory

return: string

file_id_prefix()   X-Ref
Return the file prefix

return: string

file_output($file, $options=null)   X-Ref
Return the link to a file

return: string
param: stored_file $file information for existing file
param: array $options array of options to pass. can contain:

leap2a_writer(stdclass $user=null)   X-Ref
Generate portfolio_format_leap2a

return: portfolio_format_leap2a_writer
param: stdclass $user user information object

manifest_name()   X-Ref
Return the manifest name

return: string

Class: portfolio_format_pdf  - X-Ref

'PDF format', subtype of file.

For portfolio plugins that support PDFs specifically.

mimetypes()   X-Ref
Return pdf mimetypes

return: array

Class: portfolio_format_document  - X-Ref

'Document format', subtype of file.

For portfolio plugins that support documents specifically.

mimetypes()   X-Ref
Return documents mimetypes

return: array of documents mimetypes

Class: portfolio_format_spreadsheet  - X-Ref

'Spreadsheet format', subtype of file.

For portfolio plugins that support spreadsheets specifically.

mimetypes()   X-Ref
Return spreadsheet spreadsheet mimetypes

return: array of documents mimetypes

Class: portfolio_format_presentation  - X-Ref

'Presentation format', subtype of file.

For portfolio plugins that support presentation specifically.

mimetypes()   X-Ref
Return presentation documents mimetypes

return: array presentation document mimetypes