本文整理汇总了PHP中question_type::find_standard_scripts方法的典型用法代码示例。如果您正苦于以下问题:PHP question_type::find_standard_scripts方法的具体用法?PHP question_type::find_standard_scripts怎么用?PHP question_type::find_standard_scripts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_type
的用法示例。
在下文中一共展示了question_type::find_standard_scripts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find_standard_scripts
/**
* Utility method used by {@link qtype_renderer::head_code()}
* It looks for any of the files script.js or script.php that
* exist in the plugin folder and ensures they get included.
* It also includes the jquery files required for this plugin
*/
public function find_standard_scripts()
{
global $CFG, $PAGE;
// include "script.js" and/or "script.php" in the normal way
parent::find_standard_scripts();
$version = '';
$min_version = '1.11.0';
// Moodle 2.7
$search = '/jquery-([0-9.]+)(\\.min)?\\.js$/';
// make sure jQuery version is high enough
// (required if Quiz is in a popup window)
// Moodle 2.5 has jQuery 1.9.1
// Moodle 2.6 has jQuery 1.10.2
// Moodle 2.7 has jQuery 1.11.0
// Moodle 2.8 has jQuery 1.11.1
// Moodle 2.9 has jQuery 1.11.1
if (method_exists($PAGE->requires, 'jquery')) {
// Moodle >= 2.5
if ($version == '') {
include $CFG->dirroot . '/lib/jquery/plugins.php';
if (isset($plugins['jquery']['files'][0])) {
if (preg_match($search, $plugins['jquery']['files'][0], $matches)) {
$version = $matches[1];
}
}
}
if ($version == '') {
$filename = $CFG->dirroot . '/lib/jquery/jquery*.js';
foreach (glob($filename) as $filename) {
if (preg_match($search, $filename, $matches)) {
$version = $matches[1];
break;
}
}
}
if (version_compare($version, $min_version) < 0) {
$version = '';
}
}
// include jquery files
if ($version) {
// Moodle >= 2.7
$PAGE->requires->jquery();
$PAGE->requires->jquery_plugin('ui');
$PAGE->requires->jquery_plugin('ui.touch-punch', 'qtype_ordering');
} else {
// Moodle <= 2.6
$jquery = '/question/type/' . $this->name() . '/jquery';
$PAGE->requires->js($jquery . '/jquery.js', true);
$PAGE->requires->js($jquery . '/jquery-ui.js', true);
$PAGE->requires->js($jquery . '/jquery-ui.touch-punch.js', true);
}
}