Skip to content

Commit

Permalink
MDL-19927 - add media plugins support for ogg and ogv files.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwijaya committed Sep 20, 2010
1 parent 0b9e4fd commit ce5dc36
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 103 deletions.
48 changes: 48 additions & 0 deletions filter/mediaplugin/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ function filter($text) {
$newtext = preg_replace_callback($search, 'filter_mediaplugin_mp3_callback', $newtext);
}

if ($CFG->filter_mediaplugin_enable_ogg) {
$search = '/<a[^>]*?href="([^<]+\.ogg)"[^>]*>.*?<\/a>/is';
$newtext = preg_replace_callback($search, 'filter_mediaplugin_ogg_callback', $newtext);
}

if ($CFG->filter_mediaplugin_enable_ogv) {
$search = '/<a[^>]*?href="([^<]+\.ogv)"[^>]*>.*?<\/a>/is';
$newtext = preg_replace_callback($search, 'filter_mediaplugin_ogv_callback', $newtext);
}

if ($CFG->filter_mediaplugin_enable_swf) {
$search = '/<a[^>]*?href="([^<]+\.swf)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
$newtext = preg_replace_callback($search, 'filter_mediaplugin_swf_callback', $newtext);
Expand Down Expand Up @@ -195,6 +205,44 @@ function filter_mediaplugin_mp3_callback($link) {
return $output;
}

function filter_mediaplugin_ogg_callback($link) {
global $CFG, $OUTPUT, $PAGE;

static $count = 0;
$count++;
$id = 'filter_ogg_'.time().$count; //we need something unique because it might be stored in text cache

$url = addslashes_js($link[1]);
$printlink = html_writer::link($url, get_string('oggaudio', 'filter_mediaplugin'));
$unsupportedplugins = get_string('unsupportedplugins', 'filter_mediaplugin', $printlink);
$output = <<<OET
<audio id="$id" src="$url" controls="true" width="100">
$unsupportedplugins
</audio>
OET;

return $output;
}

function filter_mediaplugin_ogv_callback($link) {
global $CFG, $OUTPUT, $PAGE;

static $count = 0;
$count++;
$id = 'filter_ogv_'.time().$count; //we need something unique because it might be stored in text cache

$url = addslashes_js($link[1]);
$printlink = html_writer::link($url, get_string('ogvvideo', 'filter_mediaplugin'));
$unsupportedplugins = get_string('unsupportedplugins', 'filter_mediaplugin', $printlink);
$output = <<<OET
<video id="$id" src="$url" controls="true" width="600" >
$unsupportedplugins
</video>
OET;

return $output;
}

function filter_mediaplugin_swf_callback($link) {
global $PAGE;
static $count = 0;
Expand Down
4 changes: 4 additions & 0 deletions filter/mediaplugin/filtersettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@

$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_youtube', get_string('mediapluginyoutube','admin'), '', 1));

$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_ogg', get_string('mediapluginogg','admin'), '', 1));

$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_ogv', get_string('mediapluginogv','admin'), '', 1));

$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_img', get_string('mediapluginimg','admin'), '', 1));
}
3 changes: 3 additions & 0 deletions filter/mediaplugin/lang/en/filter_mediaplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@
$string['flashanimation'] = 'Flash animation';
$string['flashvideo'] = 'Flash video';
$string['mp3audio'] = 'MP3 audio';
$string['oggaudio'] = 'OGG audio';
$string['ogvvideo'] = 'OGV video';
$string['unsupportedplugins'] = '(The browser does not support this type of file. {$a})';
2 changes: 2 additions & 0 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@
$string['mediapluginmov'] = 'Enable .mov filter';
$string['mediapluginmpg'] = 'Enable .mpg filter';
$string['mediapluginmp3'] = 'Enable .mp3 filter';
$string['mediapluginogg'] = 'Enable .ogg filter';
$string['mediapluginogv'] = 'Enable .ogv filter';
$string['mediapluginram'] = 'Enable .ram filter';
$string['mediapluginrm'] = 'Enable .rm filter';
$string['mediapluginrpm'] = 'Enable .rpm filter';
Expand Down
2 changes: 2 additions & 0 deletions lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,8 @@ function get_mimetypes_array() {
'odf' => array ('type'=>'application/vnd.oasis.opendocument.formula', 'icon'=>'odf'),
'odb' => array ('type'=>'application/vnd.oasis.opendocument.database', 'icon'=>'odb'),
'odi' => array ('type'=>'application/vnd.oasis.opendocument.image', 'icon'=>'odi'),
'ogg' => array ('type'=>'audio/ogg', 'icon'=>'audio'),
'ogv' => array ('type'=>'video/ogg', 'icon'=>'video'),

'pct' => array ('type'=>'image/pict', 'icon'=>'image'),
'pdf' => array ('type'=>'application/pdf', 'icon'=>'pdf'),
Expand Down
207 changes: 104 additions & 103 deletions lib/filestorage/file_types.mm
Original file line number Diff line number Diff line change
@@ -1,106 +1,107 @@
<map version="0.8.1">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1228443713170" ID="Freemind_Link_1016958583" MODIFIED="1228360017495" TEXT="Root">
<node CREATED="1228443713170" MODIFIED="1228443713170" POSITION="right" TEXT="image">
<node CREATED="1228443713170" MODIFIED="1228443713170" TEXT="web_image">
<node CREATED="1228443713170" ID="Freemind_Link_750128103" MODIFIED="1228360048650" TEXT=".jpg"/>
<node CREATED="1228443713170" ID="Freemind_Link_1840944189" MODIFIED="1228360051100" TEXT=".png"/>
<node CREATED="1228443713170" ID="Freemind_Link_1710862996" MODIFIED="1228360052949" TEXT=".gif"/>
</node>
<node CREATED="1228443713170" MODIFIED="1228443713170" TEXT="non_web_image">
<node CREATED="1228443713171" ID="Freemind_Link_481322493" MODIFIED="1228360054120" TEXT=".bmp"/>
<node CREATED="1228443713171" ID="Freemind_Link_1948466853" MODIFIED="1228360055879" TEXT=".svg"/>
<node CREATED="1228443713171" ID="Freemind_Link_82277447" MODIFIED="1228360058609" TEXT=".psd"/>
</node>
</node>
<node CREATED="1228443713172" MODIFIED="1228443713172" POSITION="left" TEXT="audio">
<node CREATED="1228443713172" ID="Freemind_Link_606456130" MODIFIED="1228444641257" TEXT="web_audio">
<node CREATED="1228443713172" ID="Freemind_Link_59286792" MODIFIED="1228360024405" TEXT=".wav"/>
<node CREATED="1228443713172" ID="Freemind_Link_618796935" MODIFIED="1228360026345" TEXT=".mp3"/>
<node CREATED="1228443713172" ID="Freemind_Link_313976796" MODIFIED="1228360027884" TEXT=".ra"/>
<node CREATED="1278653459728" ID="Freemind_Link_709595453" MODIFIED="1278653462003" TEXT=".wma"/>
</node>
<node CREATED="1228443713172" ID="Freemind_Link_1800832653" MODIFIED="1228444710126" TEXT="non_web_audio">
<node CREATED="1228443713172" ID="Freemind_Link_1772266185" MODIFIED="1228360029556" TEXT=".ape"/>
<node CREATED="1278653424877" ID="Freemind_Link_964578090" MODIFIED="1278653427194" TEXT=".au"/>
<node CREATED="1278653500298" ID="Freemind_Link_1295244579" MODIFIED="1278653502718" TEXT=".mid"/>
</node>
</node>
<node CREATED="1228443713171" ID="Freemind_Link_70165685" MODIFIED="1228443713171" POSITION="right" TEXT="video">
<node CREATED="1228443713171" ID="Freemind_Link_164412832" MODIFIED="1228444732485" TEXT="web_video">
<node CREATED="1228443713171" ID="Freemind_Link_1674188247" MODIFIED="1228360059808" TEXT=".flv"/>
<node CREATED="1228443713171" ID="Freemind_Link_1109951130" MODIFIED="1228360062108" TEXT=".swf"/>
<node CREATED="1228444776020" ID="Freemind_Link_441200481" MODIFIED="1228360063599" TEXT=".mov"/>
<node CREATED="1228443713171" ID="Freemind_Link_1073677924" MODIFIED="1228360067059" TEXT=".rm"/>
<node CREATED="1284371299850" ID="Freemind_Link_810187762" MODIFIED="1284371303151" TEXT=".wmv"/>
<node CREATED="1284371308695" ID="Freemind_Link_763870397" MODIFIED="1284371311440" TEXT=".asf"/>
</node>
<node CREATED="1228443713171" ID="Freemind_Link_1019644700" MODIFIED="1228444740884" TEXT="non_web_video">
<node CREATED="1228443713171" ID="Freemind_Link_190589975" MODIFIED="1228360068448" TEXT=".avi"/>
<node CREATED="1228444761093" ID="Freemind_Link_1728963308" MODIFIED="1228360070547" TEXT=".mpg"/>
<node CREATED="1280716374302" ID="Freemind_Link_761274675" MODIFIED="1280716376777" TEXT=".mp4"/>
</node>
</node>
<node CREATED="1228443713171" ID="Freemind_Link_1159259702" MODIFIED="1228443713171" POSITION="left" TEXT="document">
<node CREATED="1228443713171" ID="Freemind_Link_395227081" MODIFIED="1228443713171" TEXT="msoffice">
<node CREATED="1228443713171" ID="Freemind_Link_1480546733" MODIFIED="1228360031084" TEXT=".doc"/>
<node CREATED="1228443713171" ID="Freemind_Link_983591781" MODIFIED="1228360032344" TEXT=".ppt"/>
<node CREATED="1228444842809" ID="Freemind_Link_922920573" MODIFIED="1228360034493" TEXT=".xls"/>
</node>
<node CREATED="1228443713171" MODIFIED="1228443713171" TEXT="openoffice">
<node CREATED="1228443713171" ID="Freemind_Link_368708997" MODIFIED="1228360035753" TEXT=".odt"/>
<node CREATED="1228443713171" ID="Freemind_Link_725490871" MODIFIED="1228360037712" TEXT=".odp"/>
</node>
<node CREATED="1228445046926" ID="Freemind_Link_1253224142" MODIFIED="1228445305915" TEXT="other">
<node CREATED="1228445331815" ID="Freemind_Link_1202332406" MODIFIED="1228360039820" TEXT=".pdf"/>
<node CREATED="1228445541872" ID="Freemind_Link_1229438606" MODIFIED="1228445547473" TEXT=".ps"/>
</node>
</node>
<node CREATED="1228443713171" ID="Freemind_Link_525709024" MODIFIED="1228444608956" POSITION="right" TEXT="text">
<node CREATED="1228443713171" ID="Freemind_Link_1252355401" MODIFIED="1228444954730" TEXT="source">
<node CREATED="1228443713171" ID="Freemind_Link_1783454794" MODIFIED="1228360071977" TEXT=".c"/>
<node CREATED="1228443713171" ID="Freemind_Link_603295666" MODIFIED="1228360073187" TEXT=".cpp"/>
<node CREATED="1228443713171" ID="Freemind_Link_1939719884" MODIFIED="1228360075564" TEXT=".java"/>
</node>
<node CREATED="1228443713171" MODIFIED="1228443713171" TEXT="script">
<node CREATED="1228443713171" ID="Freemind_Link_567551283" MODIFIED="1228360078936" TEXT=".php"/>
<node CREATED="1228443713171" ID="Freemind_Link_829963573" MODIFIED="1228360081186" TEXT=".py"/>
<node CREATED="1228443713171" ID="Freemind_Link_699741325" MODIFIED="1228360082595" TEXT=".lua"/>
<node CREATED="1228443713171" ID="Freemind_Link_841176112" MODIFIED="1228360083825" TEXT=".rb"/>
</node>
<node CREATED="1228443713171" ID="Freemind_Link_466282865" MODIFIED="1228443713171" TEXT="markup">
<node CREATED="1228443713171" ID="Freemind_Link_776860364" MODIFIED="1228360085205" TEXT=".xml"/>
<node CREATED="1228443713171" ID="Freemind_Link_428374654" MODIFIED="1228360086825" TEXT=".html"/>
<node CREATED="1228443713171" ID="Freemind_Link_1636201602" MODIFIED="1228360088364" TEXT=".xhtml"/>
</node>
<node CREATED="1228443713171" MODIFIED="1228443713171" TEXT="plaintext">
<node CREATED="1228443713171" ID="Freemind_Link_304679617" MODIFIED="1228360090384" TEXT=".txt"/>
<node CREATED="1228443713171" ID="Freemind_Link_988584709" MODIFIED="1228360091764" TEXT=".log"/>
<node CREATED="1228443713171" ID="Freemind_Link_778232964" MODIFIED="1228360093272" TEXT=".csv"/>
</node>
</node>
<node CREATED="1228444010861" ID="Freemind_Link_329759178" MODIFIED="1228444605452" POSITION="left" TEXT="moodle">
<node CREATED="1228444424511" ID="Freemind_Link_864349088" MODIFIED="1228444427093" TEXT=".mb.zip"/>
<node CREATED="1228444437566" ID="Freemind_Link_1509389480" MODIFIED="1228444447148" TEXT=".ld.zip"/>
</node>
<node CREATED="1228443713172" ID="Freemind_Link_907467024" MODIFIED="1228443933119" POSITION="right" TEXT="archive">
<node CREATED="1228443713172" ID="Freemind_Link_637157755" MODIFIED="1228360096144" TEXT=".rar"/>
<node CREATED="1228443713172" ID="Freemind_Link_628673054" MODIFIED="1228360097913" TEXT=".cab"/>
<node CREATED="1228443713172" ID="Freemind_Link_1141513740" MODIFIED="1228360100154" TEXT=".iso"/>
<node CREATED="1228443713172" ID="Freemind_Link_1269400334" MODIFIED="1228360101353" TEXT=".img"/>
<node CREATED="1228443713172" ID="Freemind_Link_1973736841" MODIFIED="1228360102583" TEXT=".tar.gz"/>
<node CREATED="1228444535473" ID="Freemind_Link_1525022758" MODIFIED="1228360105150" TEXT=".zip"/>
</node>
<node CREATED="1228443713172" ID="Freemind_Link_1332471247" MODIFIED="1228443713172" POSITION="left" TEXT="application">
<node CREATED="1228443713172" MODIFIED="1228443713172" TEXT="windows">
<node CREATED="1228443713172" ID="Freemind_Link_1154060414" MODIFIED="1228360041512" TEXT=".exe"/>
<node CREATED="1228443713172" ID="Freemind_Link_1578063867" MODIFIED="1228360043052" TEXT=".dll"/>
</node>
<node CREATED="1228443713172" MODIFIED="1228443713172" TEXT="linux">
<node CREATED="1228443713172" ID="Freemind_Link_68848485" MODIFIED="1228360045021" TEXT=".bin"/>
</node>
<node CREATED="1228443713172" ID="Freemind_Link_317684862" MODIFIED="1228443713172" TEXT="mac">
<node CREATED="1228443920469" ID="_" MODIFIED="1228443922520" TEXT=".app"/>
<map version="0.7.1">
<node ID="_Freemind_Link_1016958583" TEXT="Root">
<node TEXT="image" POSITION="right">
<node TEXT="web_image">
<node ID="_Freemind_Link_750128103" TEXT=".jpg"/>
<node ID="_Freemind_Link_1840944189" TEXT=".png"/>
<node ID="_Freemind_Link_1710862996" TEXT=".gif"/>
</node>
<node TEXT="non_web_image">
<node ID="_Freemind_Link_481322493" TEXT=".bmp"/>
<node ID="_Freemind_Link_1948466853" TEXT=".svg"/>
<node ID="_Freemind_Link_82277447" TEXT=".psd"/>
</node>
</node>
<node TEXT="audio" POSITION="left">
<node ID="_Freemind_Link_606456130" TEXT="web_audio">
<node ID="_Freemind_Link_59286792" TEXT=".wav"/>
<node ID="_Freemind_Link_618796935" TEXT=".mp3"/>
<node ID="_Freemind_Link_313976796" TEXT=".ra"/>
<node ID="_Freemind_Link_709595453" TEXT=".wma"/>
<node TEXT=".ogg"/>
</node>
<node ID="_Freemind_Link_1800832653" TEXT="non_web_audio">
<node ID="_Freemind_Link_1772266185" TEXT=".ape"/>
<node ID="_Freemind_Link_964578090" TEXT=".au"/>
<node ID="_Freemind_Link_1295244579" TEXT=".mid"/>
</node>
</node>
<node ID="_Freemind_Link_70165685" TEXT="video" POSITION="right">
<node ID="_Freemind_Link_164412832" TEXT="web_video">
<node ID="_Freemind_Link_1674188247" TEXT=".flv"/>
<node ID="_Freemind_Link_1109951130" TEXT=".swf"/>
<node ID="_Freemind_Link_441200481" TEXT=".mov"/>
<node ID="_Freemind_Link_1073677924" TEXT=".rm"/>
<node ID="_Freemind_Link_810187762" TEXT=".wmv"/>
<node ID="_Freemind_Link_763870397" TEXT=".asf"/>
<node TEXT=".ogv"/>
</node>
<node ID="_Freemind_Link_1019644700" TEXT="non_web_video">
<node ID="_Freemind_Link_190589975" TEXT=".avi"/>
<node ID="_Freemind_Link_1728963308" TEXT=".mpg"/>
<node ID="_Freemind_Link_761274675" TEXT=".mp4"/>
</node>
</node>
<node ID="_Freemind_Link_1159259702" TEXT="document" POSITION="left">
<node ID="_Freemind_Link_395227081" TEXT="msoffice">
<node ID="_Freemind_Link_1480546733" TEXT=".doc"/>
<node ID="_Freemind_Link_983591781" TEXT=".ppt"/>
<node ID="_Freemind_Link_922920573" TEXT=".xls"/>
</node>
<node TEXT="openoffice">
<node ID="_Freemind_Link_368708997" TEXT=".odt"/>
<node ID="_Freemind_Link_725490871" TEXT=".odp"/>
</node>
<node ID="_Freemind_Link_1253224142" TEXT="other">
<node ID="_Freemind_Link_1202332406" TEXT=".pdf"/>
<node ID="_Freemind_Link_1229438606" TEXT=".ps"/>
</node>
</node>
<node ID="_Freemind_Link_525709024" TEXT="text" POSITION="right">
<node ID="_Freemind_Link_1252355401" TEXT="source">
<node ID="_Freemind_Link_1783454794" TEXT=".c"/>
<node ID="_Freemind_Link_603295666" TEXT=".cpp"/>
<node ID="_Freemind_Link_1939719884" TEXT=".java"/>
</node>
<node TEXT="script">
<node ID="_Freemind_Link_567551283" TEXT=".php"/>
<node ID="_Freemind_Link_829963573" TEXT=".py"/>
<node ID="_Freemind_Link_699741325" TEXT=".lua"/>
<node ID="_Freemind_Link_841176112" TEXT=".rb"/>
</node>
<node ID="_Freemind_Link_466282865" TEXT="markup">
<node ID="_Freemind_Link_776860364" TEXT=".xml"/>
<node ID="_Freemind_Link_428374654" TEXT=".html"/>
<node ID="_Freemind_Link_1636201602" TEXT=".xhtml"/>
</node>
<node TEXT="plaintext">
<node ID="_Freemind_Link_304679617" TEXT=".txt"/>
<node ID="_Freemind_Link_988584709" TEXT=".log"/>
<node ID="_Freemind_Link_778232964" TEXT=".csv"/>
</node>
</node>
<node ID="_Freemind_Link_329759178" TEXT="moodle" POSITION="left">
<node ID="_Freemind_Link_864349088" TEXT=".mb.zip"/>
<node ID="_Freemind_Link_1509389480" TEXT=".ld.zip"/>
</node>
<node ID="_Freemind_Link_907467024" TEXT="archive" POSITION="right">
<node ID="_Freemind_Link_637157755" TEXT=".rar"/>
<node ID="_Freemind_Link_628673054" TEXT=".cab"/>
<node ID="_Freemind_Link_1141513740" TEXT=".iso"/>
<node ID="_Freemind_Link_1269400334" TEXT=".img"/>
<node ID="_Freemind_Link_1973736841" TEXT=".tar.gz"/>
<node ID="_Freemind_Link_1525022758" TEXT=".zip"/>
</node>
<node ID="_Freemind_Link_1332471247" TEXT="application" POSITION="left">
<node TEXT="windows">
<node ID="_Freemind_Link_1154060414" TEXT=".exe"/>
<node ID="_Freemind_Link_1578063867" TEXT=".dll"/>
</node>
<node TEXT="linux">
<node ID="_Freemind_Link_68848485" TEXT=".bin"/>
</node>
<node ID="_Freemind_Link_317684862" TEXT="mac">
<node ID="_" TEXT=".app"/>
</node>
</node>
</node>
Expand Down

0 comments on commit ce5dc36

Please sign in to comment.