]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14731 Improved Bryce's patch and applied. YUI version number is kept in a simple...
authornicolasconnault <nicolasconnault>
Thu, 24 Jul 2008 13:37:05 +0000 (13:37 +0000)
committernicolasconnault <nicolasconnault>
Thu, 24 Jul 2008 13:37:05 +0000 (13:37 +0000)
admin/settings/appearance.php
lang/en_utf8/admin.php
lib/ajax/ajaxlib.php
lib/yui/version.php [new file with mode: 0644]
version.php

index 041230844cb2a946c71daac751e9c96a40b33bfa..436157e013088003e3f3505048243d866be1bda2 100644 (file)
@@ -95,6 +95,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
 
     $temp = new admin_settingpage('ajax', get_string('ajaxuse'));
     $temp->add(new admin_setting_configcheckbox('enableajax', get_string('enableajax', 'admin'), get_string('configenableajax', 'admin'), 1));
+    $temp->add(new admin_setting_configcheckbox('useexternalyui', get_string('useexternalyui', 'admin'), get_string('configuseexternalyui', 'admin'), 1));
     $temp->add(new admin_setting_configcheckbox('disablecourseajax', get_string('disablecourseajax', 'admin'), get_string('configdisablecourseajax', 'admin'),
                                                 isset($CFG->disablecourseajax) ? 1 : empty($CFG->enableajax)));
     $ADMIN->add('appearance', $temp);
index 081d3ab642992d9b8d5dc51ac1bd8c8dd4d17fcb..f6bfa2fb1ffef68868aa4a0d2e0b51cd0f845e73 100644 (file)
@@ -242,6 +242,7 @@ $string['configthemelist'] = 'Leave this blank to allow any valid theme to be us
 For example:  standard,orangewhite.';
 $string['configtimezone'] = 'You can set the default timezone here.  This is the only the DEFAULT timezone for displaying dates - each user can override this by setting their own in their profile. \"Server time\" here will make Moodle default to the server\'s operating system setting, but \"Server time\" in the user profile will make the user default to this timezone setting.  Cronjobs that depend on a time of day to run will use this timezone.';
 $string['configunzip'] = 'Indicate the location of your unzip program (Unix only, optional).  If specified, this will be used to unpack zip archives on the server.  If you leave this blank, then Moodle will use internal routines.';
+$string['configuseexternalyui'] = 'Instead of using local files, use online files available on Yahoo&#145;s servers.';
 $string['configusetags'] = 'Should tags functionality across the site be enabled?';
 $string['configvariables'] = 'Variables';
 $string['configwarning'] = 'Be careful modifying these settings - strange values could cause problems.';
@@ -732,6 +733,7 @@ $string['upgradinglogs'] = 'Upgrading logs';
 $string['uploaduserspreview'] = 'Upload users preview';
 $string['uploadusersresult'] = 'Upload users results';
 $string['upwards'] = 'upwards';
+$string['useexternalyui'] = 'Use online YUI libraries';
 $string['usehtmleditor'] = 'Use HTML editor';
 $string['useraccountupdated'] = 'User updated';
 $string['userbulk'] = 'Bulk user actions';
index f7109f3dd07da288719402b77aea86d53a8d446a..0636b82e2a9a0aa0fcf163f2bd298947e0b147e2 100644 (file)
@@ -12,6 +12,7 @@ function ajax_get_lib($libname) {
 
     global $CFG;
     $libpath = '';
+    $external_yui = false;
 
     $translatelist = array(
             'yui_yahoo' => '/lib/yui/yahoo/yahoo-min.js',
@@ -58,14 +59,26 @@ function ajax_get_lib($libname) {
             );
 
     if (array_key_exists($libname, $translatelist)) {
-        $libpath = $CFG->wwwroot . $translatelist[$libname];
+        // If this is a YUI file and we are using external libraries
+        if (substr($libname, 0, 3) == 'yui' && $CFG->useexternalyui) {
+            $external_yui = true;
+            // Get current version
+            include($CFG->libdir.'/yui/version.php');
+            $libpath = 'http://yui.yahooapis.com/'.$yuiversion.'/build/'.substr($translatelist[$libname], 9);
+        } else {
+            $libpath = $CFG->wwwroot . $translatelist[$libname];
+        }
+
     } else {
         $libpath = $libname;
     }
 
-    $testpath = str_replace($CFG->wwwroot, $CFG->dirroot, $libpath);
-    if (!file_exists($testpath)) {
-        print_error('require_js: '.$libpath.' - file not found.');
+    // Make sure the file exists if it is local.
+    if ($external_yui === false) {
+        $testpath = str_replace($CFG->wwwroot, $CFG->dirroot, $libpath);
+        if (!file_exists($testpath)) {
+            error('require_js: '.$libpath.' - file not found.');
+        }
     }
 
     return $libpath;
diff --git a/lib/yui/version.php b/lib/yui/version.php
new file mode 100644 (file)
index 0000000..3e962a2
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+$yuiversion = '2.5.0';
+?>
index 792ceb80fbd85f2cc5aee45ee08aae98c00024b4..60227c57a3f993f2b928507c32f3c776dffa7352 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2008072401;  // YYYYMMDD   = date of the last version bump
+    $version = 2008072402;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20080724)';  // Human-friendly version name