Commit | Line | Data |
---|---|---|
fab11235 MG |
1 | <?php |
2 | // This file is part of Moodle - http://moodle.org/ | |
3 | // | |
4 | // Moodle is free software: you can redistribute it and/or modify | |
5 | // it under the terms of the GNU General Public License as published by | |
6 | // the Free Software Foundation, either version 3 of the License, or | |
7 | // (at your option) any later version. | |
8 | // | |
9 | // Moodle is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License | |
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | /** | |
18 | * Main class for plugin 'media_swf' | |
19 | * | |
20 | * @package media_swf | |
21 | * @copyright 2016 Marina Glancy | |
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
23 | */ | |
24 | ||
25 | defined('MOODLE_INTERNAL') || die(); | |
26 | ||
27 | /** | |
28 | * Media player for Flash SWF files. | |
29 | * | |
30 | * This player contains additional security restriction: it will only be used | |
31 | * if you add option core_media_player_swf::ALLOW = true. | |
32 | * | |
33 | * Code should only set this option if it has verified that the data was | |
34 | * embedded by a trusted user (e.g. in trust text). | |
35 | * | |
36 | * @package media_swf | |
37 | * @copyright 2016 Marina Glancy | |
38 | * @author 2011 The Open University | |
39 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
40 | */ | |
41 | class media_swf_plugin extends core_media_player { | |
42 | public function embed($urls, $name, $width, $height, $options) { | |
43 | self::pick_video_size($width, $height); | |
44 | ||
45 | $firsturl = reset($urls); | |
46 | $url = $firsturl->out(true); | |
47 | ||
48 | $fallback = core_media_player::PLACEHOLDER; | |
49 | $output = <<<OET | |
50 | <span class="mediaplugin mediaplugin_swf"> | |
51 | <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="$width" height="$height"> | |
52 | <param name="movie" value="$url" /> | |
53 | <param name="autoplay" value="true" /> | |
54 | <param name="loop" value="false" /> | |
55 | <param name="controller" value="true" /> | |
56 | <param name="scale" value="aspect" /> | |
57 | <param name="base" value="." /> | |
58 | <param name="allowscriptaccess" value="never" /> | |
59 | <param name="allowfullscreen" value="true" /> | |
60 | <!--[if !IE]><!--> | |
61 | <object type="application/x-shockwave-flash" data="$url" width="$width" height="$height"> | |
62 | <param name="controller" value="true" /> | |
63 | <param name="autoplay" value="true" /> | |
64 | <param name="loop" value="false" /> | |
65 | <param name="scale" value="aspect" /> | |
66 | <param name="base" value="." /> | |
67 | <param name="allowscriptaccess" value="never" /> | |
68 | <param name="allowfullscreen" value="true" /> | |
69 | <!--<![endif]--> | |
70 | $fallback | |
71 | <!--[if !IE]><!--> | |
72 | </object> | |
73 | <!--<![endif]--> | |
74 | </object> | |
75 | </span> | |
76 | OET; | |
77 | ||
78 | return $output; | |
79 | } | |
80 | ||
81 | public function get_supported_extensions() { | |
82 | return array('.swf'); | |
83 | } | |
84 | ||
85 | public function list_supported_urls(array $urls, array $options = array()) { | |
86 | // Not supported unless the creator is trusted. | |
87 | if (empty($options[core_media_manager::OPTION_TRUSTED])) { | |
88 | return array(); | |
89 | } | |
90 | return parent::list_supported_urls($urls, $options); | |
91 | } | |
92 | ||
93 | /** | |
94 | * Default rank | |
95 | * @return int | |
96 | */ | |
97 | public function get_rank() { | |
98 | return 30; | |
99 | } | |
100 | } |