mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-21403 hardcoded JS legacy code should not use new $PAGE->requires-> api, switching to html_writer instead + improved ufo embedding
This commit is contained in:
parent
5668690321
commit
10eaeca808
4 changed files with 21 additions and 22 deletions
|
@ -148,9 +148,7 @@ function mediaplugin_filter_mp3_callback($link) {
|
||||||
$args['flashvars'] = $c;
|
$args['flashvars'] = $c;
|
||||||
$args['quality'] = 'high';
|
$args['quality'] = 'high';
|
||||||
|
|
||||||
$jsoutput = $PAGE->requires->js('/lib/ufo.js')->asap();
|
$jsoutput = create_ufo_inline($id, $args);
|
||||||
$jsoutput .= $PAGE->requires->data_for_js('FO', $args)->asap();
|
|
||||||
$jsoutput .= $PAGE->requires->js_function_call('create_UFO_object', Array($id))->asap();
|
|
||||||
|
|
||||||
$output = $link[0].'<span class="mediaplugin mediaplugin_mp3" id="'.$id.'">('.get_string('mp3audio', 'mediaplugin').')</span>'.$jsoutput;
|
$output = $link[0].'<span class="mediaplugin mediaplugin_mp3" id="'.$id.'">('.get_string('mp3audio', 'mediaplugin').')</span>'.$jsoutput;
|
||||||
|
|
||||||
|
@ -175,9 +173,8 @@ function mediaplugin_filter_swf_callback($link) {
|
||||||
$args['build'] = 40;
|
$args['build'] = 40;
|
||||||
$args['allowscriptaccess'] = 'never';
|
$args['allowscriptaccess'] = 'never';
|
||||||
$args['quality'] = 'high';
|
$args['quality'] = 'high';
|
||||||
$jsoutput = $PAGE->requires->js('/lib/ufo.js')->asap();
|
|
||||||
$jsoutput .= $PAGE->requires->data_for_js('FO', $args)->asap();
|
$jsoutput = create_ufo_inline($id, $args);
|
||||||
$jsoutput .= $PAGE->requires->js_function_call('create_UFO_object', Array($id))->asap();
|
|
||||||
|
|
||||||
$output = $link[0].'<span class="mediaplugin mediaplugin_swf" id="'.$id.'">('.get_string('flashanimation', 'mediaplugin').')</span>'.$jsoutput;
|
$output = $link[0].'<span class="mediaplugin mediaplugin_swf" id="'.$id.'">('.get_string('flashanimation', 'mediaplugin').')</span>'.$jsoutput;
|
||||||
|
|
||||||
|
@ -204,9 +201,7 @@ function mediaplugin_filter_flv_callback($link) {
|
||||||
$args['allowscriptaccess'] = 'never';
|
$args['allowscriptaccess'] = 'never';
|
||||||
$args['quality'] = 'high';
|
$args['quality'] = 'high';
|
||||||
$args['allowfullscreen'] = 'true';
|
$args['allowfullscreen'] = 'true';
|
||||||
$jsoutput = $PAGE->requires->js('/lib/ufo.js')->asap();
|
$jsoutput = create_ufo_inline($id, $args);
|
||||||
$jsoutput .= $PAGE->requires->data_for_js('FO', $args)->asap();
|
|
||||||
$jsoutput .= $PAGE->requires->js_function_call('create_UFO_object', Array($id))->asap();
|
|
||||||
|
|
||||||
$output = $link[0].'<span class="mediaplugin mediaplugin_flv" id="'.$id.'">('.get_string('flashvideo', 'mediaplugin').')</span>'.$jsoutput;
|
$output = $link[0].'<span class="mediaplugin mediaplugin_flv" id="'.$id.'">('.get_string('flashvideo', 'mediaplugin').')</span>'.$jsoutput;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,10 @@ M.util.image_url = function(imagename, component) {
|
||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
M.util.create_UFO_object = function (eid, FO) {
|
||||||
|
UFO.create(FO, eid);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init a collapsible region, see print_collapsible_region in weblib.php
|
* Init a collapsible region, see print_collapsible_region in weblib.php
|
||||||
* @param Object YUI3 instance with all libraries loaded
|
* @param Object YUI3 instance with all libraries loaded
|
||||||
|
@ -1218,9 +1222,6 @@ function old_onload_focus(formid, controlname) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_UFO_object(eid) {
|
|
||||||
UFO.create(FO, eid);
|
|
||||||
}
|
|
||||||
function build_querystring(obj) {
|
function build_querystring(obj) {
|
||||||
if (typeof obj !== 'object') {
|
if (typeof obj !== 'object') {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -167,11 +167,8 @@ function resourcelib_embed_mp3($fullurl, $title, $clicktoopen) {
|
||||||
</div>
|
</div>
|
||||||
OET;
|
OET;
|
||||||
|
|
||||||
$PAGE->requires->yui2_lib('dom');
|
$PAGE->requires->js('/lib/ufo.js');
|
||||||
$PAGE->requires->js('/lib/ufo.js')->in_head();
|
$code .= $PAGE->requires->js_function_call('M.util.create_UFO_object', array($id, $ufoargs));
|
||||||
$PAGE->requires->js('/lib/resourcelib.js')->in_head();
|
|
||||||
$code .= $PAGE->requires->data_for_js('FO', $ufoargs)->asap();
|
|
||||||
$code .= $PAGE->requires->js_function_call('resourcelib_create_UFO_object', array($id))->asap();
|
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,11 +210,8 @@ function resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen) {
|
||||||
</div>
|
</div>
|
||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
$PAGE->requires->yui2_lib('dom');
|
$PAGE->requires->js('/lib/ufo.js');
|
||||||
$PAGE->requires->js('/lib/ufo.js')->in_head();
|
$code .= $PAGE->requires->js_function_call('M.util.create_UFO_object', array($id, $ufoargs));
|
||||||
$PAGE->requires->js('/lib/resourcelib.js')->in_head();
|
|
||||||
$code .= $PAGE->requires->data_for_js('FO', $ufoargs)->asap();
|
|
||||||
$code .= $PAGE->requires->js_function_call('resourcelib_create_UFO_object', array($id))->asap();
|
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3411,3 +3411,12 @@ function print_password_policy() {
|
||||||
}
|
}
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_ufo_inline($id, $args) {
|
||||||
|
global $CFG;
|
||||||
|
// must not use $PAGE, $THEME, $COURSE etc. because the result is cached!
|
||||||
|
|
||||||
|
$jsoutput = html_writer::script('', $CFG->wwwroot.'/lib/ufo.js');
|
||||||
|
$jsoutput .= html_writer::script(js_writer::function_call('M.util.create_UFO_object', array($id, $args)));
|
||||||
|
return $jsoutput;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue