Merge branch 'MDL-33640_23' of git://github.com/MaxThrax/moodle into MOODLE_23_STABLE

This commit is contained in:
Sam Hemelryk
2012-08-15 11:48:27 +12:00
2 changed files with 16 additions and 6 deletions
+3 -1
View File
@@ -1618,7 +1618,9 @@ M.core_filepicker.init = function(Y, options) {
var client_id = this.options.client_id;
var id = data.upload.id+'_'+client_id;
var content = this.fpnode.one('.fp-content');
content.setContent(M.core_filepicker.templates.uploadform);
var template_name = 'uploadform_'+this.options.repositories[data.repo_id].type;
var template = M.core_filepicker.templates[template_name] || M.core_filepicker.templates['uploadform'];
content.setContent(template);
content.all('.fp-file,.fp-saveas,.fp-setauthor,.fp-setlicense').each(function (node) {
node.all('label').set('for', node.one('input,select').generateID());
+13 -5
View File
@@ -2614,7 +2614,7 @@ final class repository_type_form extends moodleform {
*/
function initialise_filepicker($args) {
global $CFG, $USER, $PAGE, $OUTPUT;
static $templatesinitialized;
static $templatesinitialized = array();
require_once($CFG->libdir . '/licenselib.php');
$return = new stdClass();
@@ -2684,18 +2684,26 @@ function initialise_filepicker($args) {
// provided by form element
$return->accepted_types = file_get_typegroup('extension', $args->accepted_types);
$return->return_types = $args->return_types;
$templates = array();
foreach ($repositories as $repository) {
$meta = $repository->get_meta();
// Please note that the array keys for repositories are used within
// JavaScript a lot, the key NEEDS to be the repository id.
$return->repositories[$repository->id] = $meta;
// Register custom repository template if it has one
if(method_exists($repository, 'get_upload_template') && !array_key_exists('uploadform_' . $meta->type, $templatesinitialized)) {
$templates['uploadform_' . $meta->type] = $repository->get_upload_template();
$templatesinitialized['uploadform_' . $meta->type] = true;
}
}
if (!$templatesinitialized) {
// we need to send filepicker templates to the browser just once
if (!array_key_exists('core', $templatesinitialized)) {
// we need to send each filepicker template to the browser just once
$fprenderer = $PAGE->get_renderer('core', 'files');
$templates = $fprenderer->filepicker_js_templates();
$templates = array_merge($templates, $fprenderer->filepicker_js_templates());
$templatesinitialized['core'] = true;
}
if (sizeof($templates)) {
$PAGE->requires->js_init_call('M.core_filepicker.set_templates', array($templates), true);
$templatesinitialized = true;
}
return $return;
}