Skip to content

Commit

Permalink
MDL-21420 finally moving old global mstr to new M.str.
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 7, 2010
1 parent 87ad1ed commit 2b728cb
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 84 deletions.
12 changes: 6 additions & 6 deletions admin/report/spamcleaner/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ M.report_spamcleaner = {
del_all: function() {
var context = M.report_spamcleaner;

var yes = confirm(mstr.report_spamcleaner.spamdeleteallconfirm);
var yes = confirm(M.str.report_spamcleaner.spamdeleteallconfirm);
if (yes) {
var cfg = {
method: "POST",
Expand All @@ -15,7 +15,7 @@ M.report_spamcleaner = {
try {
var resp = context.Y.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
alert(M.str.report_spamcleaner.spaminvalidresult);
return;
}
if (resp == true) {
Expand All @@ -36,7 +36,7 @@ M.report_spamcleaner = {
return;
}

var yes = confirm(mstr.report_spamcleaner.spamdeleteconfirm);
var yes = confirm(M.str.report_spamcleaner.spamdeleteconfirm);
if (yes) {
context.row = obj;
var cfg = {
Expand All @@ -46,7 +46,7 @@ M.report_spamcleaner = {
try {
var resp = context.Y.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
alert(M.str.report_spamcleaner.spaminvalidresult);
return;
}
if (context.row) {
Expand All @@ -57,7 +57,7 @@ M.report_spamcleaner = {
context.row.parentNode.removeChild(context.row);
context.row = null;
} else {
alert(mstr.report_spamcleaner.spamcannotdelete);
alert(M.str.report_spamcleaner.spamcannotdelete);
}
}
}
Expand All @@ -83,7 +83,7 @@ M.report_spamcleaner = {
try {
var resp = context.Y.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
alert(M.str.report_spamcleaner.spaminvalidresult);
return;
}
if (context.row) {
Expand Down
12 changes: 6 additions & 6 deletions blocks/dock.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ M.core_dock = {
this.node.setStyle('height', this.node.get('winHeight')+'px');
}
var dockcontrol = this.Y.Node.create('<div class="'+M.core_dock.cfg.css.controls+'"></div>');
var removeall = this.Y.Node.create('<img src="'+this.cfg.display.removeallicon+'" alt="'+mstr.block.undockall+'" title="'+mstr.block.undockall+'" />');
var removeall = this.Y.Node.create('<img src="'+this.cfg.display.removeallicon+'" alt="'+M.str.block.undockall+'" title="'+M.str.block.undockall+'" />');
removeall.on('removeall|click', this.remove_all, this);
dockcontrol.appendChild(removeall);
this.node.appendChild(dockcontrol);
Expand Down Expand Up @@ -336,7 +336,7 @@ M.core_dock = {
}

var moveto = this.Y.Node.create('<a class="moveto customcommand requiresjs"></a>');
moveto.append(this.Y.Node.create('<img src="'+M.util.image_url('t/dock_to_block', 'moodle')+'" alt="'+mstr.block.undockitem+'" title="'+mstr.block.undockitem+'" />'));
moveto.append(this.Y.Node.create('<img src="'+M.util.image_url('t/dock_to_block', 'moodle')+'" alt="'+M.str.block.undockitem+'" title="'+M.str.block.undockitem+'" />'));
if (location.href.match(/\?/)) {
moveto.set('href', location.href+'&dock='+this.id);
} else {
Expand Down Expand Up @@ -381,8 +381,8 @@ M.core_dock = {
if (moveto.hasClass('customcommand')) {
moveto.all('img').each(function(movetoimg){
movetoimg.setAttribute('src', M.util.image_url('t/dock_to_block', 'moodle'));
movetoimg.setAttribute('alt', mstr.block.undockitem);
movetoimg.setAttribute('title', mstr.block.undockitem);
movetoimg.setAttribute('alt', M.str.block.undockitem);
movetoimg.setAttribute('title', M.str.block.undockitem);
}, this);
}
}, this);
Expand Down Expand Up @@ -489,8 +489,8 @@ M.core_dock = {
if (moveto.hasClass('customcommand')) {
moveto.all('img').each(function(movetoimg){
movetoimg.setAttribute('src', M.util.image_url('t/block_to_dock', 'moodle'));
movetoimg.setAttribute('alt', mstr.block.addtodock);
movetoimg.setAttribute('title', mstr.block.addtodock);
movetoimg.setAttribute('alt', M.str.block.addtodock);
movetoimg.setAttribute('title', M.str.block.addtodock);
}, this);
}
}, this);
Expand Down
12 changes: 6 additions & 6 deletions comment/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ M.core_comment = {
var ta = Y.one('#dlg-content-'+this.client_id);
var scope = this;
var value = ta.get('value');
if (value && value != mstr.moodle.addcomment) {
if (value && value != M.str.moodle.addcomment) {
var params = {'content': value};
this.request({
action: 'add',
Expand All @@ -73,7 +73,7 @@ M.core_comment = {
container.appendChild(newcomment);
var ids = result.ids;
var linktext = Y.one('#comment-link-text-'+cid);
linktext.set('innerHTML', mstr.moodle.comments + ' ('+obj.count+')');
linktext.set('innerHTML', M.str.moodle.comments + ' ('+obj.count+')');
for(var i in ids) {
var attributes = {
color: { to: '#06e' },
Expand Down Expand Up @@ -158,7 +158,7 @@ M.core_comment = {
var val = template.get('innerHTML');
val = val.replace('___name___', list[i].username);
if (list[i]['delete']||newcmt) {
list[i].content = '<div class="comment-delete"><a href="###" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+mstr.moodle.deletecomment+'"><img src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + list[i].content;
list[i].content = '<div class="comment-delete"><a href="###" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+M.str.moodle.deletecomment+'"><img src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + list[i].content;
}
val = val.replace('___time___', list[i].time);
val = val.replace('___picture___', list[i].avatar);
Expand All @@ -181,7 +181,7 @@ M.core_comment = {
params: params,
callback: function(id, ret, args) {
var linktext = Y.one('#comment-link-text-'+scope.client_id);
linktext.set('innerHTML', mstr.moodle.comments + ' ('+ret.count+')');
linktext.set('innerHTML', M.str.moodle.comments + ' ('+ret.count+')');
var container = Y.one('#comment-list-'+scope.client_id);
var pagination = Y.one('#comment-pagination-'+scope.client_id);
if (ret.pagination) {
Expand Down Expand Up @@ -305,13 +305,13 @@ M.core_comment = {
toggle_textarea: function(focus) {
var t = Y.one('#dlg-content-'+this.client_id);
if (focus) {
if (t.get('value') == mstr.moodle.addcomment) {
if (t.get('value') == M.str.moodle.addcomment) {
t.set('value', '');
t.setStyle('color', 'black');
}
}else{
if (t.get('value') == '') {
t.set('value', mstr.moodle.addcomment);
t.set('value', M.str.moodle.addcomment);
t.setStyle('color','grey');
t.set('rows', 1);
}
Expand Down
8 changes: 4 additions & 4 deletions course/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ M.core_completion.init = function(Y) {
if (current == 1) {
args.state.set('value', 0);
args.image.set('src', M.util.image_url('i/completion-manual-y', 'moodle'));
args.image.set('alt', mstr.completion['completion-alt-manual-y']);
args.image.set('title', mstr.completion['completion-title-manual-y']);
args.image.set('alt', M.str.completion['completion-alt-manual-y']);
args.image.set('title', M.str.completion['completion-title-manual-y']);
} else {
args.state.set('value', 1);
args.image.set('src', M.util.image_url('i/completion-manual-n', 'moodle'));
args.image.set('alt', mstr.completion['completion-alt-manual-n']);
args.image.set('title', mstr.completion['completion-title-manual-n']);
args.image.set('alt', M.str.completion['completion-alt-manual-n']);
args.image.set('title', M.str.completion['completion-title-manual-n']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion grade/export/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function print_continue() {
$sep = '&';
}

$link = $CFG->wwwroot.'/grade/export/'.$this->plugin.'/dump.php'.$paramstr.'&key='.$this->userkey;
$link = $CFG->wwwroot.'/grade/export/'.$this->plugin.'/dump.php'.$paraM.str.'&key='.$this->userkey;

echo get_string('download', 'admin').': ' . $OUTPUT->link($link, $link);
}
Expand Down
38 changes: 19 additions & 19 deletions lib/form/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ M.form_filemanager.init = function(Y, options) {
});
}
if (!Y.one('#fm-mkdir-dlg')) {
var dialog = Y.Node.create('<div id="fm-mkdir-dlg"><div class="hd">'+mstr.repository.entername+'</div><div class="bd"><input type="text" id="fm-newname" /></div></div>');
var dialog = Y.Node.create('<div id="fm-mkdir-dlg"><div class="hd">'+M.str.repository.entername+'</div><div class="bd"><input type="text" id="fm-newname" /></div></div>');
Y.one(document.body).appendChild(dialog);
this.mkdir_dialog = new YAHOO.widget.Dialog("fm-mkdir-dlg", {
width: "300px",
Expand All @@ -189,8 +189,8 @@ M.form_filemanager.init = function(Y, options) {
});

}
var buttons = [ { text:mstr.moodle.ok, handler:perform_action, isDefault:true },
{ text:mstr.moodle.cancel, handler:function(){this.cancel();}}];
var buttons = [ { text:M.str.moodle.ok, handler:perform_action, isDefault:true },
{ text:M.str.moodle.cancel, handler:function(){this.cancel();}}];

this.mkdir_dialog.cfg.queueProperty("buttons", buttons);
this.mkdir_dialog.render();
Expand All @@ -212,7 +212,7 @@ M.form_filemanager.init = function(Y, options) {
scope.refresh(obj.filepath);
var win = window.open(obj.fileurl, 'fm-download-folder');
if (!win) {
alert(mstr.repository.popupblockeddownload);
alert(M.str.repository.popupblockeddownload);
}
}
});
Expand All @@ -231,7 +231,7 @@ M.form_filemanager.init = function(Y, options) {
for(var p in path) {
var arrow = '';
if (count==0) {
arrow = Y.Node.create('<span>'+mstr.moodle.path + ': </span>');
arrow = Y.Node.create('<span>'+M.str.moodle.path + ': </span>');
} else {
arrow = Y.Node.create('<span> ▶ </span>');
}
Expand Down Expand Up @@ -400,7 +400,7 @@ M.form_filemanager.init = function(Y, options) {
var file = data[node.get('id')];

var menuitems = [
{text: mstr.moodle.download, url:file.url}
{text: M.str.moodle.download, url:file.url}
];
this.create_menu(e, 'filemenu', menuitems, file, data);
},
Expand All @@ -423,7 +423,7 @@ M.form_filemanager.init = function(Y, options) {
});
}
var menuitems = [
{text: mstr.editor.zip, onclick: {fn: archive_folder, obj: data, scope: this}},
{text: M.str.editor.zip, onclick: {fn: archive_folder, obj: data, scope: this}},
];
this.create_menu(e, 'foldermenu', menuitems, fileinfo, data);
},
Expand All @@ -446,8 +446,8 @@ M.form_filemanager.init = function(Y, options) {
});
}
var menuitems = [
{text: mstr.moodle.download, url:fileinfo.url},
{text: mstr.moodle.unzip, onclick: {fn: unzip, obj: data, scope: this}}
{text: M.str.moodle.download, url:fileinfo.url},
{text: M.str.moodle.unzip, onclick: {fn: unzip, obj: data, scope: this}}
];
this.create_menu(e, 'zipmenu', menuitems, fileinfo, data);
},
Expand All @@ -457,7 +457,7 @@ M.form_filemanager.init = function(Y, options) {
function remove(type, ev, obj) {
var dialog_options = {};
var params = {};
dialog_options.message = mstr.repository.confirmdeletefile;
dialog_options.message = M.str.repository.confirmdeletefile;
dialog_options.scope = this;
var filename = '';
var filepath = '';
Expand Down Expand Up @@ -519,7 +519,7 @@ M.form_filemanager.init = function(Y, options) {

var dialog = Y.one('#fm-rename-dlg');
if (!dialog) {
dialog = Y.Node.create('<div id="fm-rename-dlg"><div class="hd">'+mstr.repository.enternewname+'</div><div class="bd"><input type="text" id="fm-rename-input" /></div></div>');
dialog = Y.Node.create('<div id="fm-rename-dlg"><div class="hd">'+M.str.repository.enternewname+'</div><div class="bd"><input type="text" id="fm-rename-input" /></div></div>');
Y.one(document.body).appendChild(dialog);
this.rename_dialog = new YAHOO.widget.Dialog("fm-rename-dlg", {
width: "300px",
Expand All @@ -529,8 +529,8 @@ M.form_filemanager.init = function(Y, options) {
});

}
var buttons = [ { text:mstr.moodle.rename, handler:perform, isDefault:true},
{ text:mstr.moodle.cancel, handler:function(){this.cancel();}}];
var buttons = [ { text:M.str.moodle.rename, handler:perform, isDefault:true},
{ text:M.str.moodle.cancel, handler:function(){this.cancel();}}];

this.rename_dialog.cfg.queueProperty('buttons', buttons);
this.rename_dialog.render();
Expand All @@ -551,7 +551,7 @@ M.form_filemanager.init = function(Y, options) {
dialog = Y.one('#fm-move-dlg');
}

dialog.set('innerHTML', '<div class="hd">Moving</div><div class="bd"><div id="fm-move-div">'+mstr.repository.nopathselected+'</div><div id="fm-tree"></div></div>');
dialog.set('innerHTML', '<div class="hd">Moving</div><div class="bd"><div id="fm-move-div">'+M.str.repository.nopathselected+'</div><div id="fm-tree"></div></div>');

this.movefile_dialog = new YAHOO.widget.Dialog("fm-move-dlg", {
width : "600px",
Expand Down Expand Up @@ -591,8 +591,8 @@ M.form_filemanager.init = function(Y, options) {
});
}

var buttons = [ { text:mstr.moodle.move, handler:_move, isDefault:true },
{ text:mstr.moodle.cancel, handler:function(){this.cancel();}}];
var buttons = [ { text:M.str.moodle.move, handler:_move, isDefault:true },
{ text:M.str.moodle.cancel, handler:function(){this.cancel();}}];

this.movefile_dialog.cfg.queueProperty("buttons", buttons);
this.movefile_dialog.render();
Expand Down Expand Up @@ -640,10 +640,10 @@ M.form_filemanager.init = function(Y, options) {
this.movefile_dialog.show();
}
var shared_items = [
{text: mstr.moodle.rename+'...', onclick: {fn: rename, obj: options, scope: this}},
{text: mstr.moodle.move+'...', onclick: {fn: move, obj: options, scope: this}},
{text: M.str.moodle.rename+'...', onclick: {fn: rename, obj: options, scope: this}},
{text: M.str.moodle.move+'...', onclick: {fn: move, obj: options, scope: this}},
// delete is reserve word in Javascript
{text: mstr.moodle['delete']+'...', onclick: {fn: remove, obj: options, scope: this}}
{text: M.str.moodle['delete']+'...', onclick: {fn: remove, obj: options, scope: this}}
];
var menu = new YAHOO.widget.Menu(menuid, {xy:position, clicktohide:true});
menu.clearContent();
Expand Down
15 changes: 10 additions & 5 deletions lib/javascript-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ M.yui.add_module = function(modules) {
*/
M.util = {};

/**
* Language strings - initialised from page footer.
*/
M.str = {};

/**
* Returns url for images.
* @param {String} imagename
Expand Down Expand Up @@ -271,7 +276,7 @@ M.util.show_confirm_dialog = function(e, args) {
}
);

simpledialog.setHeader(mstr.admin.confirmation);
simpledialog.setHeader(M.str.admin.confirmation);
simpledialog.setBody(args.message);
simpledialog.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN);

Expand Down Expand Up @@ -320,8 +325,8 @@ M.util.show_confirm_dialog = function(e, args) {
}
};

var buttons = [ { text: mstr.moodle.cancel, handler: handle_cancel, isDefault: true },
{ text: mstr.moodle.yes, handler: handle_yes } ];
var buttons = [ { text: M.str.moodle.cancel, handler: handle_cancel, isDefault: true },
{ text: M.str.moodle.yes, handler: handle_yes } ];

simpledialog.cfg.queueProperty('buttons', buttons);

Expand Down Expand Up @@ -779,8 +784,8 @@ function showAdvancedInit(addBefore, nameAttr, buttonLabel, hideText, showText)
showHideButton.value = buttonLabel;
showHideButton.name = nameAttr;
showHideButton.moodle = {
hideLabel: mstr.form.hideadvanced,
showLabel: mstr.form.showadvanced
hideLabel: M.str.form.hideadvanced,
showLabel: M.str.form.showadvanced
};
YAHOO.util.Event.addListener(showHideButton, 'click', showAdvancedOnClick);
el = document.getElementById(addBefore);
Expand Down
6 changes: 3 additions & 3 deletions lib/outputrequirementslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ public function js_init_code($jscode, $ondomready = false, array $module = null)
/**
* Make a language string available to JavaScript.
*
* All the strings will be available in a mstr object in the global namespace.
* All the strings will be available in a M.str object in the global namespace.
* So, for example, after a call to $PAGE->requires->string_for_js('course', 'moodle');
* then the JavaScript variable mstr.moodle.course will be 'Course', or the
* then the JavaScript variable M.str.moodle.course will be 'Course', or the
* equivalent in the current language.
*
* The arguments to this function are just like the arguments to get_string
Expand Down Expand Up @@ -934,7 +934,7 @@ public function get_end_code() {

// add all needed strings
if (!empty($this->stringsforjs)) {
$output .= html_writer::script(js_writer::set_variable('mstr', $this->stringsforjs));
$output .= html_writer::script(js_writer::set_variable('M.str', $this->stringsforjs));
}

// add variables
Expand Down
Loading

0 comments on commit 2b728cb

Please sign in to comment.