示例#1
0
 /**
  * Test for core_media::get_filename.
  */
 public function test_get_filename()
 {
     $this->assertSame('frog.mp4', core_media::get_filename(new moodle_url('/pluginfile.php/312/mod_page/content/7/frog.mp4')));
     // This should work even though slasharguments is true, because we want
     // it to support 'legacy' links if somebody toggles the option later.
     $this->assertSame('frog.mp4', core_media::get_filename(new moodle_url('/pluginfile.php?file=/312/mod_page/content/7/frog.mp4')));
 }
示例#2
0
 public function embed($urls, $name, $width, $height, $options)
 {
     // If link is turned off, return empty.
     if (!empty($options[core_media::OPTION_NO_LINK])) {
         return '';
     }
     // Build up link content.
     $output = '';
     foreach ($urls as $url) {
         $title = core_media::get_filename($url);
         $printlink = html_writer::link($url, $title, array('class' => 'mediafallbacklink'));
         if ($output) {
             // Where there are multiple available formats, there are fallback links
             // for all formats, separated by /.
             $output .= ' / ';
         }
         $output .= $printlink;
     }
     return $output;
 }