Merge branch 'MDL-38192-master' of git://github.com/sammarshallou/moodle
This commit is contained in:
@@ -330,7 +330,7 @@ abstract class base_moodleform extends moodleform {
|
||||
* Displays the form
|
||||
*/
|
||||
public function display() {
|
||||
global $PAGE;
|
||||
global $PAGE, $COURSE;
|
||||
|
||||
$this->require_definition_after_data();
|
||||
|
||||
@@ -342,8 +342,13 @@ abstract class base_moodleform extends moodleform {
|
||||
$config->closeButtonTitle = get_string('close', 'editor');
|
||||
$PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config));
|
||||
|
||||
// Get list of module types on course.
|
||||
$modinfo = get_fast_modinfo($COURSE);
|
||||
$modnames = $modinfo->get_used_module_names(true);
|
||||
$PAGE->requires->yui_module('moodle-backup-backupselectall', 'M.core_backup.select_all_init',
|
||||
array(array('select' => get_string('select'), 'all' => get_string('all'), 'none' => get_string('none'))));
|
||||
array($modnames));
|
||||
$PAGE->requires->strings_for_js(array('select', 'all', 'none'), 'moodle');
|
||||
$PAGE->requires->strings_for_js(array('showtypes', 'hidetypes'), 'backup');
|
||||
|
||||
parent::display();
|
||||
}
|
||||
|
||||
+89
-10
@@ -6,15 +6,23 @@ M.core_backup = M.core_backup || {};
|
||||
/**
|
||||
* Adds select all/none links to the top of the backup/restore/import schema page.
|
||||
*/
|
||||
M.core_backup.select_all_init = function(str) {
|
||||
M.core_backup.select_all_init = function(modnames) {
|
||||
var formid = null;
|
||||
|
||||
var helper = function(e, check, type) {
|
||||
var helper = function(e, check, type, mod) {
|
||||
e.preventDefault();
|
||||
var prefix = '';
|
||||
if (typeof mod !== 'undefined') {
|
||||
prefix = 'setting_activity_' + mod + '_';
|
||||
}
|
||||
|
||||
var len = type.length;
|
||||
Y.all('input[type="checkbox"]').each(function(checkbox) {
|
||||
var name = checkbox.get('name');
|
||||
// If a prefix has been set, ignore checkboxes which don't have that prefix.
|
||||
if (prefix && name.substring(0, prefix.length) !== prefix) {
|
||||
return;
|
||||
}
|
||||
if (name.substring(name.length - len) == type) {
|
||||
checkbox.set('checked', check);
|
||||
}
|
||||
@@ -28,13 +36,17 @@ M.core_backup.select_all_init = function(str) {
|
||||
}
|
||||
};
|
||||
|
||||
var html_generator = function(classname, idtype) {
|
||||
var html_generator = function(classname, idtype, heading, extra) {
|
||||
if (typeof extra === 'undefined') {
|
||||
extra = '';
|
||||
}
|
||||
return '<div class="' + classname + '">' +
|
||||
'<div class="fitem fitem_fcheckbox">' +
|
||||
'<div class="fitemtitle">' + str.select + '</div>' +
|
||||
'<div class="fitem fitem_fcheckbox backup_selector">' +
|
||||
'<div class="fitemtitle">' + heading + '</div>' +
|
||||
'<div class="felement">' +
|
||||
'<a id="backup-all-' + idtype + '" href="#">' + str.all + '</a> / ' +
|
||||
'<a id="backup-none-' + idtype + '" href="#">' + str.none + '</a>' +
|
||||
'<a id="backup-all-' + idtype + '" href="#">' + M.util.get_string('all', 'moodle') + '</a> / ' +
|
||||
'<a id="backup-none-' + idtype + '" href="#">' + M.util.get_string('none', 'moodle') + '</a>' +
|
||||
extra +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
@@ -62,13 +74,80 @@ M.core_backup.select_all_init = function(str) {
|
||||
}
|
||||
});
|
||||
|
||||
var html = html_generator('include_setting section_level', 'included');
|
||||
// Add global select all/none options.
|
||||
var html = html_generator('include_setting section_level', 'included', M.util.get_string('select', 'moodle'),
|
||||
' (<a id="backup-bytype" href="#">' + M.util.get_string('showtypes', 'backup') + '</a>)');
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata');
|
||||
html += html_generator('normal_setting', 'userdata', M.util.get_string('select', 'moodle'));
|
||||
}
|
||||
var links = Y.Node.create('<div class="grouped_settings section_level">' + html + '</div>');
|
||||
firstsection.insert(links, 'before');
|
||||
|
||||
// Add select all/none for each module type.
|
||||
var initlinks = function(links, mod) {
|
||||
Y.one('#backup-all-mod_' + mod).on('click', function(e) { helper(e, true, '_included', mod); });
|
||||
Y.one('#backup-none-mod_' + mod).on('click', function(e) { helper(e, false, '_included', mod); });
|
||||
if (withuserdata) {
|
||||
Y.one('#backup-all-userdata-mod_' + mod).on('click', function(e) { helper(e, true, withuserdata, mod); });
|
||||
Y.one('#backup-none-userdata-mod_' + mod).on('click', function(e) { helper(e, false, withuserdata, mod); });
|
||||
}
|
||||
};
|
||||
|
||||
// For each module type on the course, add hidden select all/none options.
|
||||
var modlist = Y.Node.create('<div id="mod_select_links">');
|
||||
modlist.hide();
|
||||
modlist.currentlyshown = false;
|
||||
links.appendChild(modlist);
|
||||
for (var mod in modnames) {
|
||||
// Only include actual values from the list.
|
||||
if (!modnames.hasOwnProperty(mod)) {
|
||||
continue;
|
||||
}
|
||||
var html = html_generator('include_setting section_level', 'mod_' + mod, modnames[mod]);
|
||||
if (withuserdata) {
|
||||
html += html_generator('normal_setting', 'userdata-mod_' + mod, modnames[mod]);
|
||||
}
|
||||
var modlinks = Y.Node.create(
|
||||
'<div class="grouped_settings section_level">' + html + '</div>');
|
||||
modlist.appendChild(modlinks);
|
||||
initlinks(modlinks, mod);
|
||||
}
|
||||
|
||||
// Toggles the display of the hidden module select all/none links.
|
||||
var toggletypes = function() {
|
||||
// Change text of type toggle link.
|
||||
var link = Y.one('#backup-bytype');
|
||||
if (modlist.currentlyshown) {
|
||||
link.setHTML(M.util.get_string('showtypes', 'backup'));
|
||||
} else {
|
||||
link.setHTML(M.util.get_string('hidetypes', 'backup'));
|
||||
}
|
||||
|
||||
// The link has now been toggled (from show to hide, or vice-versa).
|
||||
modlist.currentlyshown = !modlist.currentlyshown;
|
||||
|
||||
// Either hide or show the links.
|
||||
var animcfg = { node: modlist, duration: 0.2 };
|
||||
if (modlist.currentlyshown) {
|
||||
// Animate reveal of the module links.
|
||||
modlist.show();
|
||||
animcfg.to = { maxHeight: modlist.get('clientHeight') + 'px' };
|
||||
modlist.setStyle('maxHeight', '0px');
|
||||
var anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() { modlist.setStyle('maxHeight', 'none'); });
|
||||
anim.run();
|
||||
} else {
|
||||
// Animate hide of the module links.
|
||||
animcfg.to = { maxHeight: '0px' };
|
||||
modlist.setStyle('maxHeight', modlist.get('clientHeight') + 'px');
|
||||
var anim = new Y.Anim(animcfg);
|
||||
anim.on('end', function() { modlist.hide(); modlist.setStyle('maxHeight', 'none'); });
|
||||
anim.run();
|
||||
}
|
||||
|
||||
};
|
||||
Y.one('#backup-bytype').on('click', function(e) { toggletypes(); });
|
||||
|
||||
Y.one('#backup-all-included').on('click', function(e) { helper(e, true, '_included'); });
|
||||
Y.one('#backup-none-included').on('click', function(e) { helper(e, false, '_included'); });
|
||||
if (withuserdata) {
|
||||
@@ -77,4 +156,4 @@ M.core_backup.select_all_init = function(str) {
|
||||
}
|
||||
}
|
||||
|
||||
}, '@VERSION@', {'requires':['base','node','event', 'node-event-simulate']});
|
||||
}, '@VERSION@', {'requires':['base', 'node', 'event', 'node-event-simulate', 'anim']});
|
||||
|
||||
@@ -140,6 +140,7 @@ $string['generalroleassignments'] = 'Include role assignments';
|
||||
$string['generalsettings'] = 'General backup settings';
|
||||
$string['generaluserscompletion'] = 'Include user completion information';
|
||||
$string['generalusers'] = 'Include users';
|
||||
$string['hidetypes'] = 'Hide type options';
|
||||
$string['importgeneralsettings'] = 'General import defaults';
|
||||
$string['importgeneralmaxresults'] = 'Maximum number of courses listed for import';
|
||||
$string['importgeneralmaxresults_desc'] = 'This controls the number of courses that are listed during the first step of the import process';
|
||||
@@ -246,6 +247,7 @@ $string['setting_course_shortname'] = 'Course short name';
|
||||
$string['setting_course_startdate'] = 'Course start date';
|
||||
$string['setting_keep_roles_and_enrolments'] = 'Keep current roles and enrolments';
|
||||
$string['setting_keep_groups_and_groupings'] = 'Keep current groups and groupings';
|
||||
$string['showtypes'] = 'Show type options';
|
||||
$string['skiphidden'] = 'Skip hidden courses';
|
||||
$string['skiphiddenhelp'] = 'Choose whether or not to skip hidden courses';
|
||||
$string['skipmodifdays'] = 'Skip courses not modified since';
|
||||
|
||||
@@ -529,6 +529,7 @@ body.tag .managelink {padding: 5px;}
|
||||
.path-backup .mform .grouped_settings .fitem .fitemtitle {width:40%;padding-right:10px;}
|
||||
.path-backup.dir-rtl .mform .grouped_settings .fitem .fitemtitle {width: 60%;}
|
||||
.path-backup .mform .grouped_settings .fitem .felement {width:50%;}
|
||||
.path-backup .mform .grouped_settings .fitem.backup_selector .felement {width:100%;}
|
||||
.path-backup.dir-rtl .mform .grouped_settings .fitem .felement {width: 99%;}
|
||||
.path-backup .mform .grouped_settings.section_level .include_setting {width:50%;margin:0;float:left;clear:left;font-weight:bold;}
|
||||
.path-backup.dir-rtl .mform .grouped_settings.section_level .include_setting {float: right; clear: right;}
|
||||
|
||||
Reference in New Issue
Block a user