enrol/database MDL-19445 Fixed infinite loops and removed superfluous objects and...
[moodle.git] / lib / portfolio / formats.php
CommitLineData
87fcac8d 1<?php
2/**
3 * Moodle - Modular Object-Oriented Dynamic Learning Environment
4 * http://moodle.org
5 * Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * @package moodle
21 * @subpackage portfolio
22 * @author Penny Leach <penny@catalyst.net.nz>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
24 * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
25 *
26 * This file contains all the class definitions of the export formats.
27 * They are implemented in php classes rather than just a simpler hash
28 * Because it provides an easy way to do subtyping using php inheritance.
29 */
30
31/**
32* the most basic type - pretty much everything is a subtype
33*/
34class portfolio_format_file {
35 public static function mimetypes() {
36 return array(null);
37 }
6be1dcae 38
39 public static function get_file_directory() {
40 return null;
41 }
42
43 public static function file_output($file) {
44 return '';
45 }
87fcac8d 46}
47
48/**
49* image format, subtype of file.
50*/
51class portfolio_format_image extends portfolio_format_file {
52 public static function mimetypes() {
53 return mimeinfo_from_icon('type', 'image.gif', true);
54 }
55}
56
57/**
58* html format - could be used for an external cms or something
59*
60* in case we want to be really specific.
61*/
6be1dcae 62class portfolio_format_plainhtml extends portfolio_format_file {
87fcac8d 63 public static function mimetypes() {
64 return array('text/html');
65 }
66}
67
68/**
69* video format, subtype of file.
70*
71* I guess there could be a youtube/google video plugin
72* and anyway, the flickr plugin can support it already
73*/
74class portfolio_format_video extends portfolio_format_file {
75 public static function mimetypes() {
d02b207a 76 return array_merge(
77 mimeinfo_from_icon('type', 'video.gif', true),
78 mimeinfo_from_icon('type', 'avi.gif', true)
79 );
87fcac8d 80 }
81}
82
83/**
84* class for plain text format.. not sure why we would need this yet
85* but since resource module wants to export it... we can
86*/
87class portfolio_format_text extends portfolio_format_file {
88 public static function mimetypes() {
89 return array('text/plain');
90 }
91}
92
6be1dcae 93class portfolio_format_rich {
94 public static function mimetypes() {
95 return array(null);
96 }
97}
98
99class portfolio_format_richhtml extends portfolio_format_rich {
100 public static function get_file_directory() {
101 return 'site_files';
102 }
103 public static function file_output($file) {
104 $path = self::get_file_directory() . '/' . $file->get_filename();
105 if (in_array($file->get_mimetype(), portfolio_format_image::mimetypes())) {
106 return '<img src="' . $path . '" alt="' . $file->get_filename() . '" />';
107 }
108 return '<a href="' . $path . '">' . $file->get_filename() . '</a>';
109 }
110}
111
112class portfolio_format_leap extends portfolio_format_rich { }
113
114
87fcac8d 115/**
116* later.... a moodle plugin might support this.
117* it's commented out in portfolio_supported_formats so cannot currently be used.
118*/
6be1dcae 119class portfolio_format_mbkp extends portfolio_format_rich {}