当前位置: 首页>>代码示例>>PHP>>正文


PHP question_type::find_standard_scripts方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:Kathrin84,项目名称:moodle-qtype_ordering,代码行数:59,代码来源:questiontype.php


注:本文中的question_type::find_standard_scripts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。