Merge branch 'MDL-33683-master-2' of git://git.luns.net.uk/moodle
authorAparup Banerjee <aparup@moodle.com>
Wed, 20 Jun 2012 11:36:22 +0000 (19:36 +0800)
committerAparup Banerjee <aparup@moodle.com>
Wed, 20 Jun 2012 11:36:22 +0000 (19:36 +0800)
15 files changed:
admin/settings/development.php
lib/csslib.php
lib/filelib.php
lib/form/filemanager.js
lib/form/filepicker.php
lib/outputrequirementslib.php
lib/tests/csslib_test.php
lib/yui/chooserdialogue/chooserdialogue.js
repository/boxnet/lib.php
repository/dropbox/lib.php
repository/filepicker.php
repository/lib.php
repository/repository_ajax.php
repository/s3/lib.php
repository/upload/lib.php

index 5c41b86..cb77515 100644 (file)
@@ -14,7 +14,10 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
     $temp->add(new admin_setting_configcheckbox('enablegroupmembersonly', new lang_string('enablegroupmembersonly', 'admin'), new lang_string('configenablegroupmembersonly', 'admin'), 0));
 
     $temp->add(new admin_setting_configcheckbox('dndallowtextandlinks', new lang_string('dndallowtextandlinks', 'admin'), new lang_string('configdndallowtextandlinks', 'admin'), 0));
-    $temp->add(new admin_setting_configcheckbox('enablecssoptimiser', new lang_string('enablecssoptimiser','admin'), new lang_string('enablecssoptimiser_desc','admin'), 0));
+    // The CSS optimiser setting. When changed we need to reset the theme caches in order to ensure they are regenerated through the optimiser.
+    $enablecssoptimiser = new admin_setting_configcheckbox('enablecssoptimiser', new lang_string('enablecssoptimiser','admin'), new lang_string('enablecssoptimiser_desc','admin'), 0);
+    $enablecssoptimiser->set_updatedcallback('theme_reset_all_caches');
+    $temp->add($enablecssoptimiser);
 
     $ADMIN->add('experimental', $temp);
 
index 3032433..2408e38 100644 (file)
@@ -3845,7 +3845,11 @@ class css_style_background extends css_style {
                 } else if ($attachment === self::NULL_VALUE && in_array($bit, $attachments)) {
                     $attachment = $bit;
                 } else if ($bit !== '') {
-                    $return[] = css_style_background_advanced::init($bit);
+                    $advanced = css_style_background_advanced::init($bit);
+                    if ($important) {
+                        $advanced->set_important();
+                    }
+                    $return[] = $advanced;
                 }
             }
         }
index 0d18cfa..45f4f7a 100644 (file)
@@ -601,7 +601,7 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
             }
             // find the file this draft file was created from and count all references in local
             // system pointing to that file
-            $source = unserialize($file->get_source());
+            $source = @unserialize($file->get_source());
             if (isset($source->original)) {
                 $item->refcount = $fs->search_references_count($source->original);
             }
@@ -679,7 +679,7 @@ function file_get_submitted_draft_itemid($elname) {
  * @return stored_file
  */
 function file_restore_source_field_from_draft_file($storedfile) {
-    $source = unserialize($storedfile->get_source());
+    $source = @unserialize($storedfile->get_source());
     if (!empty($source)) {
         if (is_object($source)) {
             $restoredsource = $source->source;
index 3918bb2..f1f88b2 100644 (file)
@@ -155,9 +155,8 @@ M.form_filemanager.init = function(Y, options) {
                         try {
                             data = Y.JSON.parse(o.responseText);
                         } catch(e) {
-                            // TODO display error
                             scope.print_msg(M.str.repository.invalidjson, 'error');
-                            //scope.display_error(M.str.repository.invalidjson+'<pre>'+stripHTML(o.responseText)+'</pre>', 'invalidjson')
+                            Y.error(M.str.repository.invalidjson+":\n"+o.responseText);
                             return;
                         }
                         if (data && data.tree && scope.set_current_tree) {
index a27f015..58253bb 100644 (file)
@@ -76,7 +76,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input {
             $fpmaxbytes = $options['maxbytes'];
         }
         $coursemaxbytes = 0;
-        if (!empty($PAGE->course)) {
+        if (!empty($PAGE->course->maxbytes)) {
             $coursemaxbytes = $PAGE->course->maxbytes;
         }
         $this->_options['maxbytes'] = get_user_max_upload_file_size($PAGE->context, $CFG->maxbytes, $coursemaxbytes, $fpmaxbytes);
index 8f95fe5..6ad4bea 100644 (file)
@@ -749,7 +749,7 @@ class page_requirements_manager {
         if (!is_array($modules)) {
             $modules = array($modules);
         }
-        if (empty($CFG->useexternalyui) || true) {
+        if (empty($CFG->useexternalyui)) {
             // We need to set the M.yui.galleryversion to the correct version
             $jscode = 'M.yui.galleryversion='.json_encode($galleryversion).';';
         } else {
index c5f1223..f00a88f 100644 (file)
@@ -213,6 +213,16 @@ class css_optimiser_testcase extends advanced_testcase {
 
         $css = '#filesskin .yui3-widget-hd{background:#CCC;background:-webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC));background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC);}';
         $this->assertEquals($css, $optimiser->process($css));
+
+        $css = '.userenrolment{background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;}';
+        $this->assertEquals($css, $optimiser->process($css));
+
+        $css = '.userenrolment{background:#CCC !important;background:-webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC)) !important;background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;}';
+        $this->assertEquals($css, $optimiser->process($css));
+
+        $cssin = '.userenrolment{background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;}.userenrolment {background: #CCCCCC!important;background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC))!important;}';
+        $cssout = '.userenrolment{background:#CCC !important;background:-moz-linear-gradient(top, #FFFFFF, #CCCCCC) !important;background:-webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#CCCCCC)) !important;}';
+        $this->assertEquals($cssout, $optimiser->process($cssin));
     }
 
     /**
index 1a499a8..e67af29 100644 (file)
@@ -249,8 +249,8 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
         },
 
         hide : function() {
-            // Detach the global keypress handler before hiding
-            Y.one('document').detach('keyup', this.handle_key_press, this);
+            // Cancel all listen events
+            this.cancel_listenevents();
 
             // Re-enable the page scrollbars
             if (Y.UA.ie > 0) {
index e26072e..a60b1f4 100644 (file)
@@ -319,7 +319,7 @@ class repository_boxnet extends repository {
         $fileid = array_pop($array);
         $fileinfo = $this->boxclient->get_file_info($fileid);
         if (!empty($fileinfo)) {
-            return 'Box:' . (string)$fileinfo->file_name;
+            return 'Box: ' . (string)$fileinfo->file_name;
         } else {
             return $url;
         }
index 7a12bb9..186e63b 100644 (file)
@@ -432,7 +432,7 @@ class repository_dropbox extends repository {
      * @return string|null
      */
     public function get_file_source_info($filepath) {
-        return 'Dropbox:' . $filepath;
+        return 'Dropbox: ' . $filepath;
     }
 
     /**
index ebd9c9f..20b67ca 100644 (file)
@@ -306,7 +306,8 @@ case 'download':
         $record->userid       = $USER->id;
         $record->contextid = $user_context->id;
 
-        $record->source = serialize((object)array('source' => $thefile['url']));
+        $sourcefield = $repo->get_file_source_info($thefile['url']);
+        $record->source = repository::build_source_field($sourcefield);
         try {
             $info = repository::move_to_filepool($thefile['path'], $record);
             redirect($home_url, get_string('downloadsucc', 'repository'));
index db4e45b..db99489 100644 (file)
@@ -1233,6 +1233,9 @@ abstract class repository {
      * @return string|null
      */
     public function get_file_source_info($url) {
+        if ($this->has_moodle_files()) {
+            return $this->get_reference_details($url, 0);
+        }
         return $url;
     }
 
index 45f0662..6919b3e 100644 (file)
@@ -241,6 +241,10 @@ switch ($action) {
                 }
             }
 
+            // {@link repository::build_source_field()}
+            $sourcefield = $repo->get_file_source_info($source);
+            $record->source = $repo::build_source_field($sourcefield);
+
             if ($usefilereference) {
                 $reference = $repo->get_file_reference($source);
                 // get reference life time from repo
@@ -266,10 +270,6 @@ switch ($action) {
                     $event['existingfile']->url      = moodle_url::make_draftfile_url($itemid, $saveas_path, $saveas_filename)->out();;
                 } else {
 
-                    // {@link repository::build_source_field()}
-                    $sourcefield = $repo->get_file_source_info($source);
-                    $record->source = $repo::build_source_field($sourcefield);
-
                     $storedfile = $fs->create_file_from_reference($record, $repo_id, $reference);
                     $event = array(
                         'url'=>moodle_url::make_draftfile_url($storedfile->get_itemid(), $storedfile->get_filepath(), $storedfile->get_filename())->out(),
@@ -307,10 +307,6 @@ switch ($action) {
                     throw new file_exception('maxbytes');
                 }
 
-                // {@link repository::build_source_field()}
-                $sourcefield = $repo->get_file_source_info($source);
-                $record->source = $repo::build_source_field($sourcefield);
-
                 $info = repository::move_to_filepool($downloadedfile['path'], $record);
                 if (empty($info)) {
                     $info['e'] = get_string('error', 'moodle');
index 5558620..c25dfc6 100644 (file)
@@ -126,7 +126,7 @@ class repository_s3 extends repository {
      * @return string
      */
     public function get_file_source_info($filepath) {
-        return 'Amazon S3:' . $filepath;
+        return 'Amazon S3: ' . $filepath;
     }
 
     /**
index d1a2512..7420230 100644 (file)
@@ -146,7 +146,8 @@ class repository_upload extends repository {
         @chmod($_FILES[$elname]['tmp_name'], $permissions);
 
         // {@link repository::build_source_field()}
-        $record->source = self::build_source_field($_FILES[$elname]['name']);
+        $sourcefield = $this->get_file_source_info($_FILES[$elname]['name']);
+        $record->source = self::build_source_field($sourcefield);
 
         if (empty($saveas_filename)) {
             $record->filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);