當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。