MDL-21403 hardcoded JS legacy code should not use new $PAGE->requires-> api, switchin...
authorPetr Skoda <skodak@moodle.org>
Tue, 26 Jan 2010 10:17:41 +0000 (10:17 +0000)
committerPetr Skoda <skodak@moodle.org>
Tue, 26 Jan 2010 10:17:41 +0000 (10:17 +0000)
lib/form/passwordunmask.php
mod/scorm/datamodels/aicclib.php
mod/scorm/loaddatamodel.php
mod/scorm/player.php

index 37f5232..b70f0d5 100644 (file)
@@ -19,14 +19,14 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
     }
 
     function toHtml() {
-        global $PAGE;
+        global $CFG;
         if ($this->_flagFrozen) {
             return $this->getFrozenHtml();
         } else {
             $id = $this->getAttribute('id');
             $unmask = get_string('unmaskpassword', 'form');
-            $unmaskjs = $PAGE->requires->data_for_js('punmask',Array('id'=>$id, 'unmaskstr'=>$unmask))->asap();
-            $unmaskjs .= $PAGE->requires->js('/lib/form/passwordunmask.js')->asap();
+            $unmaskjs = html_writer::script(js_writer::set_variable('punmask', array('id'=>$id, 'unmaskstr'=>$unmask)));
+            $unmaskjs .= html_writer::script('', $CFG->httpswwwroot.'/lib/form/passwordunmask.js');
             return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' /><div class="unmask" id="'.$id.'unmaskdiv"></div>'.$unmaskjs;
         }
     } //end func toHtml
index 150430a..7757b2d 100644 (file)
@@ -538,11 +538,11 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
     }
     $result->toc .= "\t</ul>\n";
     if ($scorm->hidetoc == 0) {
-        $result->toc .= $PAGE->requires->data_for_js('scormdata', array(
+        $result->toc .= html_writer::script(js_writer::set_variable('scormdata', array(
                 'plusicon' => $OUTPUT->pix_url('pix/plus', 'scorm'),
-                'minusicon' => $OUTPUT->pix_url('pix/minus', 'scorm')))->asap();
-        $result->toc .= $PAGE->requires->js('/lib/cookies.js')->asap();
-        $result->toc .= $PAGE->requires->js('/mod/scorm/datamodels/scorm_datamodels.js')->asap();
+                'minusicon' => $OUTPUT->pix_url('pix/minus', 'scorm'))));
+        $result->toc .= html_writer::script('', $CFG->wwwroot.'/lib/cookies.js');
+        $result->toc .= html_writer::script('', $CFG->wwwroot.'/mod/scorm/datamodels/scorm_datamodels.js');
     }
 
     $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr;
index cd07dd6..6f61066 100644 (file)
         print_error('cannotfindsco', 'scorm');
     }
     $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR));   // Just to be safe
-    $PAGE->requires->js('/lib/cookies.js')->asap();
     if (file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php')) {
-        include_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php');
+        include($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'.js.php');
     } else {
-        include_once($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php');
+        include($CFG->dirroot.'/mod/scorm/datamodels/scorm_12.js.php');
     }
 
     // set the start time of this SCO
index 30aa1fd..c3ddf33 100755 (executable)
 
     $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height))->in_head();
     $PAGE->requires->js('/mod/scorm/request.js')->in_head();
+    $PAGE->requires->js('/lib/cookies.js')->in_head();
     $PAGE->requires->js('/mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr)->in_head();
     $PAGE->requires->js('/mod/scorm/rd.js')->in_head();