]> git.mjollnir.org Git - moodle.git/commitdiff
Reverted require_js() in lib/ajax/ajaxlib.php. Last changes broke backwards compatibi...
authorvyshane <vyshane>
Mon, 12 Feb 2007 06:01:49 +0000 (06:01 +0000)
committervyshane <vyshane>
Mon, 12 Feb 2007 06:01:49 +0000 (06:01 +0000)
Small change in lib/weblib.php to allow require_js() to be used from themes. To use it, just call the function from themedir/meta.php.

lib/ajax/ajaxlib.php
lib/weblib.php

index 689f7a7e65957e75fef1b6f3d4b6800eb25adf96..22194c8cbdc9787fb54d6bb9af0165eae360d394 100644 (file)
@@ -4,7 +4,6 @@
  */
 
 
-
 /**
  * Used to include JavaScript libraries.
  *
  * @param $lib - string or array of strings
  *               string(s) should be the shortname for the library or the
  *               full path to the library file.
- *        $add - 1 to return the libraries in lib
- *               not already loaded.
  * @return string or false or nothing.
  */
-function require_js($lib='', $add = 0) {
+function require_js($lib='') {
     global $CFG;
     static $loadlibs = array();
 
     if (!ajaxenabled()) {
-        return false;
+        //return false;
     }
 
     if (!empty($lib)) {
         // Add the lib to the list of libs to be loaded, if it isn't already
         // in the list.
-        // if (is_array($lib)) {
-            // array_map('require_js', $lib);
-        // } else {
-        foreach ($lib as $lib1)  {
-            // $libpath = ajax_get_lib($lib);
-            $libpath = ajax_get_lib($lib1);
+        if (is_array($lib)) {
+            array_map('require_js', $lib);
+        } else {
+            $libpath = ajax_get_lib($lib);
             if (array_search($libpath, $loadlibs) === false) {
-                // array_push($loadlibs, $libpath);
-                // array_push($addedlibs, $libpath);
                 $loadlibs[] = $libpath;
-                $addedlibs[] = $libpath;
             }
         }
-    }
-    // } else {
-    if (empty($lib) || ((!empty($addedlibs)) && ($add != 0))) {
+    } else {
         // Return the html needed to load the JavaScript files defined in
         // our list of libs to be loaded.
         $output = '';
 
-        $thelibs = (!empty($addedlibs)) ? $addedlibs : $loadlibs;
-        // foreach ($loadlibs as $loadlib) {
-        foreach ($thelibs as $loadlib) {
+        foreach ($loadlibs as $loadlib) {
             $output .= '<script type="text/javascript" ';
             $output .= " src=\"$loadlib\"></script>\n";
             if ($loadlib == $CFG->wwwroot.'/lib/yui/logger/logger-min.js') {
index 0f1a841702ecb14ef9319f2b5fdd8f96e1397d61..a282f3a520231dbc3ce9f8f95b5dd76fbbf9f2a4 100644 (file)
@@ -1961,10 +1961,6 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
     }
     $meta = $stylesheetshtml.$meta;
 
-
-/// Add the required JavaScript Libraries
-    $meta .= "\n".require_js();
-
         
 /// Add the meta page from the themes if any were requested
 
@@ -1998,6 +1994,9 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
     $meta = $meta."\n".$metapage;
 
 
+/// Add the required JavaScript Libraries
+    $meta .= "\n".require_js();
+
 
     if ($navigation == 'home') {
         $home = true;