MDL-62202 privacy: fix behat tests to point to new location under users
[moodle.git] / lib / medialib.php
blob3c51122c765153aa8cd6ed00d346f7f9fa79aa57
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.
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/>.
17 /**
18 * Deprecated classes and constants.
20 * DO NOT INCLUDE THIS FILE
22 * use $CFG->media_default_width instead of CORE_MEDIA_VIDEO_WIDTH,
23 * $CFG->media_default_height instead of CORE_MEDIA_VIDEO_HEIGHT,
24 * core_media_manager::instance() instead of static methods in core_media,
25 * core_media_manager::OPTION_zzz instead of core_media::OPTION_zzz
27 * New syntax to include media files:
29 * $mediamanager = core_media_manager::instance();
30 * echo $mediamanager->embed_url(new moodle_url('http://example.org/a.mp3'));
32 * @package core_media
33 * @copyright 2012 The Open University
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 defined('MOODLE_INTERNAL') || die();
39 if (!defined('CORE_MEDIA_VIDEO_WIDTH')) {
40 // Default video width if no width is specified; some players may do something
41 // more intelligent such as use real video width.
42 // May be defined in config.php if required.
43 define('CORE_MEDIA_VIDEO_WIDTH', 400);
45 if (!defined('CORE_MEDIA_VIDEO_HEIGHT')) {
46 // Default video height. May be defined in config.php if required.
47 define('CORE_MEDIA_VIDEO_HEIGHT', 300);
49 if (!defined('CORE_MEDIA_AUDIO_WIDTH')) {
50 // Default audio width if no width is specified.
51 // May be defined in config.php if required.
52 define('CORE_MEDIA_AUDIO_WIDTH', 300);
55 debugging('Do not include lib/medialib.php, use $CFG->media_default_width instead of CORE_MEDIA_VIDEO_WIDTH, ' .
56 '$CFG->media_default_height instead of CORE_MEDIA_VIDEO_HEIGHT, ' .
57 'core_media_manager::instance() instead of static methods in core_media, ' .
58 'core_media_manager::OPTION_zzz instead of core_media::OPTION_zzz',
59 DEBUG_DEVELOPER);
61 /**
62 * Constants and static utility functions for use with core_media_renderer.
64 * @deprecated since Moodle 3.2
66 * @copyright 2011 The Open University
67 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
69 abstract class core_media {
70 /**
71 * Option: Disable text link fallback.
73 * Use this option if you are going to print a visible link anyway so it is
74 * pointless to have one as fallback.
76 * To enable, set value to true.
78 const OPTION_NO_LINK = 'nolink';
80 /**
81 * Option: When embedding, if there is no matching embed, do not use the
82 * default link fallback player; instead return blank.
84 * This is different from OPTION_NO_LINK because this option still uses the
85 * fallback link if there is some kind of embedding. Use this option if you
86 * are going to check if the return value is blank and handle it specially.
88 * To enable, set value to true.
90 const OPTION_FALLBACK_TO_BLANK = 'embedorblank';
92 /**
93 * Option: Enable players which are only suitable for use when we trust the
94 * user who embedded the content.
96 * At present, this option enables the SWF player.
98 * To enable, set value to true.
100 const OPTION_TRUSTED = 'trusted';
103 * Option: Put a div around the output (if not blank) so that it displays
104 * as a block using the 'resourcecontent' CSS class.
106 * To enable, set value to true.
108 const OPTION_BLOCK = 'block';
111 * Given a string containing multiple URLs separated by #, this will split
112 * it into an array of moodle_url objects suitable for using when calling
113 * embed_alternatives.
115 * Note that the input string should NOT be html-escaped (i.e. if it comes
116 * from html, call html_entity_decode first).
118 * @param string $combinedurl String of 1 or more alternatives separated by #
119 * @param int $width Output variable: width (will be set to 0 if not specified)
120 * @param int $height Output variable: height (0 if not specified)
121 * @return array Array of 1 or more moodle_url objects
123 public static function split_alternatives($combinedurl, &$width, &$height) {
124 return core_media_manager::instance()->split_alternatives($combinedurl, $width, $height);
128 * Returns the file extension for a URL.
129 * @param moodle_url $url URL
131 public static function get_extension(moodle_url $url) {
132 return core_media_manager::instance()->get_extension($url);
136 * Obtains the filename from the moodle_url.
137 * @param moodle_url $url URL
138 * @return string Filename only (not escaped)
140 public static function get_filename(moodle_url $url) {
141 return core_media_manager::instance()->get_filename($url);
145 * Guesses MIME type for a moodle_url based on file extension.
146 * @param moodle_url $url URL
147 * @return string MIME type
149 public static function get_mimetype(moodle_url $url) {
150 return core_media_manager::instance()->get_mimetype($url);