]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-21187 brand new yui2 lib loading now using the official YAHOO oholoaders which...
authorPetr Skoda <skodak@moodle.org>
Fri, 25 Dec 2009 15:27:47 +0000 (15:27 +0000)
committerPetr Skoda <skodak@moodle.org>
Fri, 25 Dec 2009 15:27:47 +0000 (15:27 +0000)
14 files changed:
comment/index.php
course/view.php
lib/ajax/ajaxlib.php
lib/commentlib.php
lib/deprecatedlib.php
lib/outputrenderers.php
lib/resourcelib.php
mod/chat/gui_ajax/index.php
mod/imscp/view.php
mod/quiz/attemptlib.php
mod/resource/locallib.php
mod/url/locallib.php
repository/lib.php
theme/lines/meta.php

index 9b7f2f618974f58558584352d1522687da5d96b8..a9d9ec056419634808d997c421c7eccbc8876b35 100644 (file)
@@ -28,13 +28,13 @@ admin_externalpage_setup('comments');
 $context = get_context_instance(CONTEXT_SYSTEM);
 require_capability('moodle/comment:delete', $context);
 
-$PAGE->requires->yui2_lib('yahoo')->in_head();
-$PAGE->requires->yui2_lib('dom')->in_head();
-$PAGE->requires->yui2_lib('event')->in_head();
-$PAGE->requires->yui2_lib('animation')->in_head();
-$PAGE->requires->yui2_lib('json')->in_head();
-$PAGE->requires->yui2_lib('connection')->in_head();
-$PAGE->requires->js('comment/admin.js')->in_head();
+$PAGE->requires->yui2_lib('yahoo');
+$PAGE->requires->yui2_lib('dom');
+$PAGE->requires->yui2_lib('event');
+$PAGE->requires->yui2_lib('animation');
+$PAGE->requires->yui2_lib('json');
+$PAGE->requires->yui2_lib('connection');
+$PAGE->requires->js('comment/admin.js');
 
 $action     = optional_param('action', '', PARAM_ALPHA);
 $commentid  = optional_param('commentid', 0, PARAM_INT);
index 2e3a1ad0c62156155ef2dcfb490c46663ef9d4f2..fb7319da74613cbc67da83c175971cac529736b8 100644 (file)
                                                              // Course-based switches
 
             if (ajaxenabled($CFG->ajaxtestedbrowsers)) {     // Browser, user and site-based switches
-                $PAGE->requires->yui2_lib('dragdrop')->asap();
-                $PAGE->requires->yui2_lib('connection')->asap();
-                $PAGE->requires->yui2_lib('selector')->asap();
-                $PAGE->requires->js('lib/ajax/block_classes.js')->asap();
-                $PAGE->requires->js('lib/ajax/section_classes.js')->asap();
+                $PAGE->requires->yui2_lib('dragdrop');
+                $PAGE->requires->yui2_lib('connection');
+                $PAGE->requires->yui2_lib('selector');
+                $PAGE->requires->js('lib/ajax/block_classes.js');
+                $PAGE->requires->js('lib/ajax/section_classes.js');
 
                 // Okay, global variable alert. VERY UGLY. We need to create
                 // this object here before the <blockname>_print_block()
 
     $completion = new completion_info($course);
     if ($completion->is_enabled() && ajaxenabled()) {
-        $PAGE->requires->yui2_lib('connection')->asap();
-        $PAGE->requires->js('course/completion.js')->asap();
+        $PAGE->requires->yui2_lib('connection');
+        $PAGE->requires->js('course/completion.js')->in_head();
         $PAGE->requires->js_function_call('completion_init')->on_dom_ready();
         $PAGE->requires->data_for_js('completion_strsaved', get_string('saved', 'completion'));
         $PAGE->requires->data_for_js('completion_strtitley', get_string('completion-title-manual-y', 'completion'));
index 48758670eb1d2603ca5f7cf7f6f2fac960802913..9f6de99d4b3a390a9d10a7eed7272f451047d659 100644 (file)
@@ -110,8 +110,10 @@ class page_requirements_manager {
     protected $headdone = false;
     protected $topofbodydone = false;
 
-    /** YUI PHPLoader instance responsible for YUI3 laoding in HEAD */
+    /** YUI PHPLoader instance responsible for YUI3 laoding in page head only */
     protected $yui3loader;
+    /** YUI PHPLoader instance responsible for YUI2 laoding */
+    protected $yui2loader;
 
     /**
      * Page requirements constructor.
@@ -121,23 +123,27 @@ class page_requirements_manager {
         require_once("$CFG->libdir/yui/phploader/phploader/loader.php");
 
         $this->yui3loader = new YAHOO_util_Loader($CFG->yui3version);
+        $this->yui2loader = new YAHOO_util_Loader($CFG->yui2version);
 
         // set up some loader options
-        $this->yui3loader->loadOptional = false;
         if (debugging('', DEBUG_DEVELOPER)) {
             $this->yui3loader->filter = YUI_DEBUG; // alternatively we could use just YUI_RAW here
+            $this->yui2loader->filter = YUI_DEBUG; // alternatively we could use just YUI_RAW here
         } else {
             $this->yui3loader->filter = null;
+            $this->yui2loader->filter = null;
         }
         if (!empty($CFG->useexternalyui)) {
             $this->yui3loader->base = 'http://yui.yahooapis.com/' . $CFG->yui3version . '/build/';
+            $this->yui2loader->base = 'http://yui.yahooapis.com/' . $CFG->yui2version . '/build/';
         } else {
             $this->yui3loader->base = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui3version . '/';
-            $libpath = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui2version;
+            $this->yui2loader->base = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui2version . '/';
         }
 
         // This file helps to minimise number of http requests
         //$this->yui3loader->comboBase = $CFG->httpswwwroot . '/theme/yuicomboloader.php?';
+        //$this->yui2loader->comboBase = $CFG->httpswwwroot . '/theme/yuicomboloader.php?';
     }
 
     /**
@@ -188,22 +194,23 @@ class page_requirements_manager {
      * Even if a particular library is requested more than once (perhaps as a dependancy
      * of other libraries) it will only be linked to once.
      *
-     * @param $libname the name of the YUI2 library you require. For example 'autocomplete'.
-     * @return required_yui2_lib A required_yui2_lib object. This allows you to control when the
-     *      link to the script is output by calling methods like {@link required_yui2_lib::asap()} or
-     *      {@link required_yui2_lib::in_head()}.
+     * The library is leaded as soon as possible, if $OUTPUT->header() not used yet it
+     * is put into the page header, otherwise it is loaded in the page footer. 
+     *
+     * @param string|array $libname the name of the YUI2 library you require. For example 'autocomplete'.
+     * @return void
      */
     public function yui2_lib($libname) {
-        $key = 'yui:' . $libname;
-        if (!isset($this->linkedrequirements[$key])) {
-            $this->linkedrequirements[$key] = new required_yui2_lib($this, $libname);
+        $libnames = (array)$libname;
+        foreach ($libnames as $lib) {
+            $this->yui2loader->load($lib);
         }
-        return $this->linkedrequirements[$key];
     }
 
     /**
      * Ensure that the specified YUI3 library file, and all its required dependancies,
      * are laoded automatically on this page.
+     *
      * @param string|array $libname the name of the YUI3 library you require. For example 'overlay'.
      * @return void
      */
@@ -424,7 +431,7 @@ class page_requirements_manager {
     public function event_handler($id, $event, $function, $arguments=array()) {
         $requirement = new required_event_handler($this, $id, $event, $function, $arguments);
         $this->requiredjscode[] = $requirement;
-        $this->linkedrequirements[] = new required_yui2_lib($this, 'event');
+        $this->yui2_lib('event');
         return $requirement;
     }
 
@@ -462,13 +469,27 @@ class page_requirements_manager {
 
     /**
      * Returns basic YUI3 JS loading code.
-     *
-     * Please note this can be used only from WHEN_IN_HEAD.
+     * YUI3 is using autoloading of both CSS and JS code.
      *
      * @return string
      */
-    protected function get_yui3lib_code() {
-        return $this->yui3loader->css().$this->yui3loader->script();
+    protected function get_yui3lib_headcode() {
+        return $this->yui3loader->css() . $this->yui3loader->script();
+    }
+
+    /**
+     * Returns basic YUI2 JS loading code.
+     * It can be called manually at any time.
+     *
+     * @return string JS embedding code
+     */
+    public function get_yui2lib_code() {
+        // All YUI2 CSS is loaded automatically
+        if ($this->headdone) {
+            return $this->yui2loader->script_embed();
+        } else {
+            return $this->yui2loader->script();
+        }
     }
 
     /**
@@ -481,7 +502,8 @@ class page_requirements_manager {
      */
     public function get_head_code() {
         setup_core_javascript($this);
-        $output = $this->get_yui3lib_code();
+        $output = $this->get_yui3lib_headcode();
+        $output .= $this->get_yui2lib_code();
         $output .= $this->get_linked_resources_code(self::WHEN_IN_HEAD);
         $js = $this->get_javascript_code(self::WHEN_IN_HEAD);
         $output .= ajax_generate_script_tag($js);
@@ -515,7 +537,8 @@ class page_requirements_manager {
      * @return string the HTML code to to at the end of the page.
      */
     public function get_end_code() {
-        $output = $this->get_linked_resources_code(self::WHEN_AT_END);
+        $output = $this->get_yui2lib_code();
+        $output .= $this->get_linked_resources_code(self::WHEN_AT_END);
 
         if (!empty($this->stringsforjs)) {
             array_unshift($this->requiredjscode, new required_data_for_js($this, 'mstr', $this->stringsforjs));
@@ -745,127 +768,6 @@ class required_js extends linked_requirement {
     }
 }
 
-/**
- * A subclass of {@link linked_requirement} to represent a requried YUI library.
- *
- * You should not create instances of this class directly. Instead you should
- * work with a {@link page_requirements_manager} - and probably the only
- * page_requirements_manager you will ever need is the one at $PAGE->requires.
- *
- * The methods {@link asap()}, {@link in_head()} and {@link at_top_of_body()}
- * are indented to be used as a fluid API, so you can say things like
- *     $PAGE->requires->yui2_lib('autocomplete')->in_head();
- *
- * This class (with the help of {@link ajax_resolve_yui2_lib()}) knows about the
- * dependancies between the different YUI libraries, and will include all the
- * other libraries required by the one you ask for.
- *
- * By default JavaScript files are included at the end of the HTML.
- * This is recommended practice because it means that the web browser will only
- * start loading the javascript files after the rest of the page is loaded, and
- * that gives the best performance for users.
- *
- * @copyright 2009 Tim Hunt
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 2.0
- */
-class required_yui2_lib extends linked_requirement {
-    protected $jss = array();
-
-    /**
-     * Constructor. Normally instances of this class should not be created
-     * directly. Client code should create them via the page_requirements_manager
-     * method {@link page_requirements_manager::yui2_lib()}.
-     *
-     * @param page_requirements_manager $manager the page_requirements_manager we are associated with.
-     * @param string $libname The name of the YUI library you want. See the array
-     * defined in {@link ajax_resolve_yui2_lib()} for a list of known libraries.
-     */
-    public function __construct(page_requirements_manager $manager, $libname) {
-        parent::__construct($manager, '');
-        $this->when = page_requirements_manager::WHEN_AT_END;
-
-        $jsurls = ajax_resolve_yui2_lib($libname);
-        foreach ($jsurls as $jsurl) {
-            $this->jss[] = $manager->js($jsurl, true);
-        }
-    }
-
-    public function get_html() {
-        // Since we create a required_js for each of our files, that will generate the HTML.
-        return '';
-    }
-
-    /**
-     * Indicate that the link to this YUI library file should be output as soon as
-     * possible. The comment above {@link required_js::asap()} applies to this method too.
-     *
-     * @return string The HTML required to include this JavaScript file. The caller
-     * is responsible for outputting this HTML promptly. For example, a good way to
-     * call this method is like
-     * <pre>
-     *     echo $PAGE->requires->yui2_lib(...)->asap();
-     * </pre>
-     */
-    public function asap() {
-        if ($this->is_done()) {
-            return;
-        }
-
-        if (!$this->manager->is_head_done()) {
-            $this->in_head();
-            return '';
-        }
-
-        $output = '';
-        foreach ($this->jss as $requiredjs) {
-            $output .= $requiredjs->asap();
-        }
-        $this->mark_done();
-        return $output;
-    }
-
-    /**
-     * Indicate that the links to this  YUI library should be output in the
-     * <head> section of the HTML. If it too late for this request to be
-     * satisfied, an exception is thrown.
-     */
-    public function in_head() {
-        if ($this->is_done() || $this->when <= page_requirements_manager::WHEN_IN_HEAD) {
-            return;
-        }
-
-        if ($this->manager->is_head_done()) {
-            throw new coding_exception('Too late to ask for a YUI library to be linked to from &lt;head>.');
-        }
-
-        $this->when = page_requirements_manager::WHEN_IN_HEAD;
-        foreach ($this->jss as $requiredjs) {
-            $requiredjs->in_head();
-        }
-    }
-
-    /**
-     * Indicate that the links to this YUI library should be output in the
-     * <head> section of the HTML. If it too late for this request to be
-     * satisfied, an exception is thrown.
-     */
-    public function at_top_of_body() {
-        if ($this->is_done() || $this->when <= page_requirements_manager::WHEN_TOP_OF_BODY) {
-            return;
-        }
-
-        if ($this->manager->is_top_of_body_done()) {
-            throw new coding_exception('Too late to ask for a YUI library to be linked to from the top of &lt;body>.');
-        }
-
-        $this->when = page_requirements_manager::WHEN_TOP_OF_BODY;
-        foreach ($this->jss as $requiredjs) {
-            $output .= $requiredjs->at_top_of_body();
-        }
-    }
-}
-
 
 /**
  * A subclass of {@link linked_requirement} to represent a required CSS file.
@@ -1203,114 +1105,6 @@ function ajax_generate_script_tag($js) {
 }
 
 
-/**
- * Given the name of a YUI library, return a list of the .js that it requries.
- *
- * This method takes note of the $CFG->useexternalyui setting.
- *
- * If $CFG->debug is set to DEBUG_DEVELOPER then this method will return links to
- * the -debug version of the YUI files, otherwise it will return links to the -min versions.
- *
- * @param string $libname the name of a YUI library, for example 'autocomplete'.
- * @return an array of the JavaScript URLs that must be loaded to make this library work,
- *      in the order they should be loaded.
- */
-function ajax_resolve_yui2_lib($libname) {
-    global $CFG;
-
-    // Note, we always use yahoo-dom-event, even if we are only asked for part of it.
-    // because another part of the code may later ask for other bits. It is easier, and
-    // not very inefficient, just to always use (and get browsers to cache) the combined file.
-    static $translatelist = array(
-        'animation'        => array('yahoo-dom-event', 'animation'),
-        'autocomplete'     => array('yahoo-dom-event', 'datasource', 'autocomplete'),
-        'button'           => array('yahoo-dom-event', 'element', 'button'),
-        'calendar'         => array('yahoo-dom-event', 'calendar'),
-        'carousel'         => array('yahoo-dom-event', 'element', 'carousel'),
-        'charts'           => array('yahoo-dom-event', 'element', 'datasource', 'json', 'charts'),
-        'colorpicker'      => array('yahoo-dom-event', 'dragdrop', 'element', 'slider', 'colorpicker'),
-        'connection'       => array('yahoo-dom-event', 'connection'),
-        'container'        => array('yahoo-dom-event', 'container'),
-        'cookie'           => array('yahoo-dom-event', 'cookie'),
-        'datasource'       => array('yahoo-dom-event', 'datasource'),
-        'datatable'        => array('yahoo-dom-event', 'element', 'datasource', 'datatable'),
-        'datemath'         => array('yahoo-dom-event', 'datemath'),
-        'dom'              => array('yahoo-dom-event'),
-        'dom-event'        => array('yahoo-dom-event'),
-        'dragdrop'         => array('yahoo-dom-event', 'dragdrop'),
-        'editor'           => array('yahoo-dom-event', 'element', 'container', 'menu', 'button', 'editor'),
-        'element'          => array('yahoo-dom-event', 'element'),
-        'element-delegate' => array('yahoo-dom-event', 'element', 'element-delegate'),
-        'event'            => array('yahoo-dom-event'),
-        'event-delegate'   => array('yahoo-dom-event', 'event-delegate'),
-        'event-mouseenter' => array('yahoo-dom-event', 'event-mouseenter'),
-        'event-simulate'   => array('yahoo-dom-event', 'event-simulate'),
-        'get'              => array('yahoo-dom-event', 'get'),
-        'history'          => array('yahoo-dom-event', 'history'),
-        'imagecropper'     => array('yahoo-dom-event', 'dragdrop', 'element', 'resize', 'imagecropper'),
-        'imageloader'      => array('yahoo-dom-event', 'imageloader'),
-        'json'             => array('yahoo-dom-event', 'json'),
-        'layout'           => array('yahoo-dom-event', 'dragdrop', 'element', 'layout'),
-        'logger'           => array('yahoo-dom-event', 'logger'),
-        'menu'             => array('yahoo-dom-event', 'container', 'menu'),
-        'paginator'        => array('yahoo-dom-event', 'element', 'paginator'),
-        'profiler'         => array('yahoo-dom-event', 'profiler'),
-        'profilerviewer'   => array('yuiloader-dom-event', 'element', 'profiler', 'profilerviewer'),
-        'progressbar'      => array('yahoo-dom-event', 'progressbar'),
-        'resize'           => array('yahoo-dom-event', 'dragdrop', 'element', 'resize'),
-        'selector'         => array('yahoo-dom-event', 'selector'),
-        'simpleeditor'     => array('yahoo-dom-event', 'element', 'container', 'simpleeditor'),
-        'slider'           => array('yahoo-dom-event', 'gragdrop', 'slider'),
-        'storage'          => array('yahoo-dom-event', 'cookie', 'storage'),
-        'stylesheet'       => array('yahoo-dom-event', 'stylesheet'),
-        'swf'              => array('yahoo-dom-event', 'swf'),
-        'swfdetect'        => array('yahoo-dom-event', 'swfdetect'),
-        'swfstore'         => array('yahoo-dom-event', 'cookie', 'swfstore'),
-        'tabview'          => array('yahoo-dom-event', 'element', 'tabview'),
-        'treeview'         => array('yahoo-dom-event', 'treeview'),
-        'uploader'         => array('yahoo-dom-event', 'element', 'uploader'),
-        'utilities'        => array('yahoo-dom-event', 'connection', 'animation', 'dragdrop', 'element', 'get'),
-        'yahoo'            => array('yahoo-dom-event'),
-        'yuiloader'        => array('yuiloader'),
-        'yuitest'          => array('yahoo-dom-event', 'logger', 'yuitest'),
-    );
-    if (!isset($translatelist[$libname])) {
-        throw new coding_exception('Unknown YUI2 library ' . $libname);
-    }
-
-    $jsnames = $translatelist[$libname];
-
-    $debugging = debugging('', DEBUG_DEVELOPER);
-    if ($debugging) {
-        $suffix = '-debug.js';
-    } else {
-        $suffix = '-min.js';
-    }
-
-    if (!empty($CFG->useexternalyui)) {
-        $libpath = 'http://yui.yahooapis.com/' . $CFG->yui2version . '/build';
-    } else {
-        $libpath = $CFG->httpswwwroot . '/lib/yui/'. $CFG->yui2version;
-    }
-
-    $jsurls = array();
-    foreach ($jsnames as $js) {
-        if ($js == 'yahoo-dom-event') {
-            if ($debugging) {
-                $jsurls[] = $libpath . '/yahoo/yahoo' . $suffix;
-                $jsurls[] = $libpath . '/dom/dom' . $suffix;
-                $jsurls[] = $libpath . '/event/event' . $suffix;
-            } else {
-                $jsurls[] = $libpath . '/'. $js . '/' . $js . '.js';
-            }
-        } else {
-            $jsurls[] = $libpath . '/' . $js . '/' . $js . $suffix;
-        }
-    }
-
-    return $jsurls;
-}
-
 /**
  * Return the HTML required to link to a JavaScript file.
  * @param $url the URL of a JavaScript file.
index deafc233b7970eb434223fba84edd9856bad9f41..47c5a8c70bc26f919510de41c4ac4ced82f250ac 100644 (file)
@@ -178,12 +178,12 @@ EOD;
         self::$comment_context = optional_param('comment_context', '', PARAM_INT);
         self::$comment_area    = optional_param('comment_area',    '', PARAM_ALPHAEXT);
 
-        $PAGE->requires->yui2_lib('yahoo')->in_head();
-        $PAGE->requires->yui2_lib('dom')->in_head();
-        $PAGE->requires->yui2_lib('event')->in_head();
-        $PAGE->requires->yui2_lib('animation')->in_head();
-        $PAGE->requires->yui2_lib('json')->in_head();
-        $PAGE->requires->yui2_lib('connection')->in_head();
+        $PAGE->requires->yui2_lib('yahoo');
+        $PAGE->requires->yui2_lib('dom');
+        $PAGE->requires->yui2_lib('event');
+        $PAGE->requires->yui2_lib('animation');
+        $PAGE->requires->yui2_lib('json');
+        $PAGE->requires->yui2_lib('connection');
         $PAGE->requires->js('comment/comment.js')->in_head();
         $PAGE->requires->string_for_js('addcomment', 'moodle');
         $PAGE->requires->string_for_js('deletecomment', 'moodle');
index a91755aef3d1a0f03039f2da0546b1b7b0058e03..3a4d47b7516aeae79a1972a7a6879d4bf9b095f7 100644 (file)
@@ -1676,7 +1676,7 @@ function use_html_editor($name='', $editorhidebuttons='', $id='') {
  *
  * @param mixed $lib The library or libraries to load (a string or array of strings)
  *      There are three way to specify the library:
- *      1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui2_lib('yahoo')->asap();
+ *      1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui2_lib('yahoo');
  *      2. the path to the library relative to wwwroot, for example 'lib/javascript-static.js'
  *      3. (legacy) a full URL like $CFG->wwwroot . '/lib/javascript-static.js'.
  *      2. and 3. lead to a call $PAGE->requires->js('/lib/javascript-static.js').
@@ -1696,7 +1696,7 @@ function require_js($lib) {
               'or $PAGE->requires->yui2_lib() instead.', DEBUG_DEVELOPER);
 
     if (strpos($lib, 'yui_') === 0) {
-        echo $PAGE->requires->yui2_lib(substr($lib, 4))->asap();
+        $PAGE->requires->yui2_lib(substr($lib, 4));
     } else if (preg_match('/^https?:/', $lib)) {
         echo $PAGE->requires->js(str_replace($CFG->wwwroot, '', $lib))->asap();
     } else {
index 6c971bf32288b674e0a42adb977a67e4e22b0fda..b66c0b319c92db95d7d16aaca712be0ad9797919 100644 (file)
@@ -371,8 +371,8 @@ class core_renderer extends renderer_base {
 
         // Perform a browser environment check for the flash version.  Should only run once per login session.
         if (isloggedin() && !empty($CFG->excludeoldflashclients) && empty($SESSION->flashversion)) {
-            $this->page->requires->yui2_lib('event')->in_head();
-            $this->page->requires->yui2_lib('connection')->in_head();
+            $this->page->requires->yui2_lib('event');
+            $this->page->requires->yui2_lib('connection');
             $this->page->requires->js('lib/swfobject/swfobject.js')->in_head();
             $this->page->requires->js('lib/flashdetect/flashdetect.js')->in_head();
             $this->page->requires->js_function_call('setflashversiontosession', array($CFG->wwwroot, sesskey()));
index 336942ab67ff2edd1d4ca208cd129015ebb1e69b..858c2c3dc81806ece68a2bef30fa6d170635ede9 100644 (file)
@@ -167,7 +167,7 @@ function resourcelib_embed_mp3($fullurl, $title, $clicktoopen) {
 </div>
 OET;
 
-    $PAGE->requires->yui2_lib('dom')->in_head();
+    $PAGE->requires->yui2_lib('dom');
     $PAGE->requires->js('lib/ufo.js')->in_head();
     $PAGE->requires->js('lib/resourcelib.js')->in_head();
     $code .= $PAGE->requires->data_for_js('FO', $ufoargs)->asap();
@@ -213,7 +213,7 @@ function resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen) {
 </div>
 EOT;
 
-    $PAGE->requires->yui2_lib('dom')->in_head();
+    $PAGE->requires->yui2_lib('dom');
     $PAGE->requires->js('lib/ufo.js')->in_head();
     $PAGE->requires->js('lib/resourcelib.js')->in_head();
     $code .= $PAGE->requires->data_for_js('FO', $ufoargs)->asap();
index ae792edcf041a07641a7b2eb6078e9f70988b77d..47d7f51abec2976c0b1292913a02a58b00d77f06 100644 (file)
@@ -91,7 +91,7 @@ $PAGE->requires->string_for_js('beep', 'chat');
 $PAGE->requires->string_for_js('talk', 'chat');
 
 $PAGE->requires->js('mod/chat/gui_ajax/script.js');
-$PAGE->requires->yui2_lib('animation')->in_head();
+$PAGE->requires->yui2_lib('animation');
 
 $PAGE->add_body_class('yui-skin-sam');
 $PAGE->set_pagelayout('embedded');
index 4cb7f94138289dd68cef1b7d3f4a12933dfbc627..925cc03d9c13228d0e418b2b595aa221b9b0c1f2 100644 (file)
@@ -46,14 +46,14 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 add_to_log($course->id, 'imscp', 'view', 'view.php?id='.$cm->id, $imscp->id, $cm->id);
 
 $PAGE->set_url('mod/imscp/view.php', array('id' => $cm->id));
-$PAGE->requires->yui2_lib('json')->in_head();
-$PAGE->requires->yui2_lib('event')->in_head();
-$PAGE->requires->yui2_lib('treeview')->in_head();
-$PAGE->requires->yui2_lib('layout')->in_head();
-$PAGE->requires->yui2_lib('button')->in_head();
-$PAGE->requires->yui2_lib('container')->in_head();
-$PAGE->requires->yui2_lib('dragdrop')->in_head();
-$PAGE->requires->yui2_lib('resize')->in_head();
+$PAGE->requires->yui2_lib('json');
+$PAGE->requires->yui2_lib('event');
+$PAGE->requires->yui2_lib('treeview');
+$PAGE->requires->yui2_lib('layout');
+$PAGE->requires->yui2_lib('button');
+$PAGE->requires->yui2_lib('container');
+$PAGE->requires->yui2_lib('dragdrop');
+$PAGE->requires->yui2_lib('resize');
 $PAGE->requires->js('mod/imscp/functions.js')->in_head();
 
 $PAGE->requires->string_for_js('navigation', 'imscp');
index 4d8631a4cb253dcaf91caf9a0a1f146f9787355d..00209a244047058ffeb4deeeed72ebd0baf5d9ee 100644 (file)
@@ -722,8 +722,8 @@ class quiz_attempt extends quiz {
         global $PAGE;
         // The JS does important things like navigation and so must be initialised
         // as seen as possible, particularly if the page is loading slowly.
-        $PAGE->requires->yui2_lib('dom')->in_head();
-        $PAGE->requires->yui2_lib('event')->in_head();
+        $PAGE->requires->yui2_lib('dom');
+        $PAGE->requires->yui2_lib('event');
         $PAGE->requires->js('mod/quiz/quiz.js')->in_head();
         get_html_head_contributions($this->get_question_ids($page), $this->questions, $this->states);
     }
index 169f414f4050e4be1377fcbe5735b8e1ae0baa76..90e8d48243554aad4178ab906fd46975b8a264fd 100644 (file)
@@ -104,7 +104,7 @@ function resource_display_embed($resource, $cm, $course, $file) {
     } else {
         // anything else - just try object tag enlarged as much as possible
         $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
-        $PAGE->requires->yui2_lib('dom')->in_head();
+        $PAGE->requires->yui2_lib('dom');
         $PAGE->requires->js('mod/url/functions.js')->in_head();
         $PAGE->requires->js_function_call('url_init_object');
     }
index ca7dffc520e5ff933fe44b382a746384cb6b1400..a4a42678ac5230516523b241029562cf28bade0b 100644 (file)
@@ -265,7 +265,7 @@ function url_display_embed($url, $cm, $course) {
     } else {
         // anything else - just try object tag enlarged as much as possible
         $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
-        $PAGE->requires->yui2_lib('dom')->in_head();
+        $PAGE->requires->yui2_lib('dom');
         $PAGE->requires->js('mod/url/functions.js')->in_head();
         $PAGE->requires->js_function_call('url_init_object');
     }
index 321f135eefd11ad4c0f993e71f0cc1548c2f615c..beefe30ea0ca66a39dc5600df6f0fc1838a3ea86 100644 (file)
@@ -1763,19 +1763,19 @@ function repository_setup_default_plugins() {
 function repository_head_setup() {
     global $PAGE;
 
-    $PAGE->requires->yui2_lib('yahoo')->in_head();
-    $PAGE->requires->yui2_lib('dom')->in_head();
-    $PAGE->requires->yui2_lib('element')->in_head();
-    $PAGE->requires->yui2_lib('event')->in_head();
-    $PAGE->requires->yui2_lib('json')->in_head();
-    $PAGE->requires->yui2_lib('treeview')->in_head();
-    $PAGE->requires->yui2_lib('dragdrop')->in_head();
-    $PAGE->requires->yui2_lib('container')->in_head();
-    $PAGE->requires->yui2_lib('resize')->in_head();
-    $PAGE->requires->yui2_lib('layout')->in_head();
-    $PAGE->requires->yui2_lib('connection')->in_head();
-    $PAGE->requires->yui2_lib('button')->in_head();
-    $PAGE->requires->yui2_lib('selector')->in_head();
+    $PAGE->requires->yui2_lib('yahoo');
+    $PAGE->requires->yui2_lib('dom');
+    $PAGE->requires->yui2_lib('element');
+    $PAGE->requires->yui2_lib('event');
+    $PAGE->requires->yui2_lib('json');
+    $PAGE->requires->yui2_lib('treeview');
+    $PAGE->requires->yui2_lib('dragdrop');
+    $PAGE->requires->yui2_lib('container');
+    $PAGE->requires->yui2_lib('resize');
+    $PAGE->requires->yui2_lib('layout');
+    $PAGE->requires->yui2_lib('connection');
+    $PAGE->requires->yui2_lib('button');
+    $PAGE->requires->yui2_lib('selector');
 
     //TODO: remove the ->in_head() once we refactor the inline script tags in repo code
     $PAGE->requires->js('repository/repository.src.js')->in_head();
index f1713a35924c8be128e6e64d0cb3c50914932871..fffd9b06fcc6dcc0dbd823a6e2681d1c73258ea8 100755 (executable)
@@ -1,6 +1,7 @@
 <?php
 
-echo $PAGE->requires->yui2_lib('animation')->asap(); ?>
+$PAGE->requires->yui2_lib('animation');
+echo $PAGE->requires->get_yui2lib_code(); ?>
 
 <!--[if IE 7]>
     <link rel="stylesheet" type="text/css" href="<?php echo $CFG->httpsthemewww ?>/lines/styles_ie7.css" />