From 87ad1edcd6572515a669e4cbfd080a69a66fd47d Mon Sep 17 00:00:00 2001 From: Petr Skoda <skodak@moodle.org> Date: Sun, 7 Feb 2010 09:34:19 +0000 Subject: [PATCH] MDL-21400 JS modules now include needed strings in module description + fixed some string and icon issues in file picker --- lib/javascript-static.js | 2 +- lib/outputrequirementslib.php | 26 +++++++++++++++++- repository/filepicker.js | 19 ++++++------- repository/lib.php | 52 ----------------------------------- 4 files changed, 35 insertions(+), 64 deletions(-) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 44f00b12889..b3d79399ea6 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -30,7 +30,7 @@ M.util.image_url = function(imagename, component) { url = url + '&rev=' + M.cfg.themerev; } - if (component != '' && component != 'moodle' && component != 'core') { + if (component && component != '' && component != 'moodle' && component != 'core') { url = url + '&component=' + component; } diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 3a4adea3ecb..47d884a63a4 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -331,6 +331,7 @@ class page_requirements_manager { $module = null; + if (strpos($name, 'core_') === 0) { // must be some core stuff - list here is not complete, this is just the stuff used from multiple places // so that we do nto have to repeat the definition of these modules over and over again @@ -338,7 +339,19 @@ class page_requirements_manager { case 'core_filepicker': $module = array('name' => 'core_filepicker', 'fullpath' => '/repository/filepicker.js', - 'requires' => array('base', 'node', 'json', 'async-queue', 'io', 'yui2-button', 'yui2-container', 'yui2-layout', 'yui2-menu', 'yui2-treeview')); + 'requires' => array('base', 'node', 'json', 'async-queue', 'io', 'yui2-button', 'yui2-container', 'yui2-layout', 'yui2-menu', 'yui2-treeview'), + 'strings' => array(array('add', 'repository'), array('back', 'repository'), array('cancel', 'moodle'), array('close', 'repository'), + array('cleancache', 'repository'), array('copying', 'repository'), array('date', 'repository'), array('downloadsucc', 'repository'), + array('emptylist', 'repository'), array('error', 'repository'), array('federatedsearch', 'repository'), + array('filenotnull', 'repository'), array('getfile', 'repository'), array('help', 'moodle'), array('iconview', 'repository'), + array('invalidjson', 'repository'), array('linkexternal', 'repository'), array('listview', 'repository'), + array('loading', 'repository'), array('login', 'repository'), array('logout', 'repository'), array('noenter', 'repository'), + array('noresult', 'repository'), array('manageurl', 'repository'), array('popup', 'repository'), array('preview', 'repository'), + array('refresh', 'repository'), array('save', 'repository'), array('saveas', 'repository'), array('saved', 'repository'), + array('saving', 'repository'), array('search', 'repository'), array('searching', 'repository'), array('size', 'repository'), + array('submit', 'repository'), array('sync', 'repository'), array('title', 'repository'), array('upload', 'repository'), + array('uploading', 'repository'), array('xhtmlerror', 'repository'), + array('xhtml', 'quiz'), array('cancel'))); break; case 'core_comment': $module = array('name' => 'core_comment', @@ -413,6 +426,17 @@ class page_requirements_manager { $module['fullpath'] = $this->js_fix_url($module['fullpath'])->out(false); + // add all needed strings + if (!empty($module['strings'])) { + foreach ($module['strings'] as $string) { + $identifier = $string[0]; + $component = isset($string[1]) ? $string[1] : 'moodle'; + $a = isset($string[2]) ? $string[2] : null; + $this->string_for_js($identifier, $component, $a); + } + } + unset($module['strings']); + if ($this->headdone) { $this->extramodules[$module['name']] = $module; } else { diff --git a/repository/filepicker.js b/repository/filepicker.js index b5d16e027c8..241f81060d1 100644 --- a/repository/filepicker.js +++ b/repository/filepicker.js @@ -14,7 +14,6 @@ * * Filepicker options: * ===== - * this.options.pix, stores all images used in file picker * this.options.client_id, the instance id * this.options.contextid * this.options.itemid @@ -321,7 +320,7 @@ M.core_filepicker.init = function(Y, options) { var panel = Y.one('#panel-'+client_id); var html = '<div class="fp-rename-form">'; html += '<p><img src="'+args.thumbnail+'" /></p>'; - html += '<p><label for="newname-'+client_id+'">'+mstr.repository.saveas+'</label>'; + html += '<p><label for="newname-'+client_id+'">'+mstr.repository.saveas+':</label>'; html += '<input type="text" id="newname-'+client_id+'" value="'+args.title+'" /></p>'; var le_checked = ''; @@ -401,10 +400,10 @@ M.core_filepicker.init = function(Y, options) { var name = ''; var str = '<div style="text-align:center">'; if(type=='load') { - str += '<img src="'+this.options.pix.loading+'" />'; + str += '<img src="'+M.util.image_url('i/loading')+'" />'; str += '<p>'+mstr.repository.loading+'</p>'; }else{ - str += '<img src="'+this.options.pix.progressbar+'" />'; + str += '<img src="'+M.util.image_url('i/progressbar')+'" />'; str += '<p>'+mstr.repository.copying+' <strong>'+name+'</strong></p>'; } str += '</div>'; @@ -787,7 +786,7 @@ M.core_filepicker.init = function(Y, options) { str += '<label for="'+id+'_file">'+data.upload.label+': </label>'; str += '<input type="file" id="'+id+'_file" name="repo_upload_file" />'; str += '<input type="hidden" name="itemid" value="'+this.options.itemid+'" />'; - str += '<div class="fp-upload-btn"><a id="'+id+'_action" href="###" >'+mstr.repository.upload+'</a></div>'; + str += '<div class="fp-upload-btn"><a id="'+id+'_action" href="###" >'+mstr.repository.upload+'...</a></div>'; str += '</form>'; str += '</div>'; var upload_form = Y.Node.create(str); @@ -840,7 +839,7 @@ M.core_filepicker.init = function(Y, options) { var toolbar = Y.one('#repo-tb-'+client_id); if(!r.nosearch) { - var html = '<a href="###"><img src="'+this.options.pix.search+'" /> '+mstr.repository.search+'</a>'; + var html = '<a href="###"><img src="'+this.M.util.image_url('a/search')+'" /> '+mstr.repository.search+'</a>'; var search = Y.Node.create(html); search.on('click', function() { scope.request({ @@ -921,7 +920,7 @@ M.core_filepicker.init = function(Y, options) { } // weather we use cache for this instance, this button will reload listing anyway if(!r.norefresh) { - var html = '<a href="###"><img src="'+this.options.pix.refresh+'" /> '+mstr.repository.refresh+'</a>'; + var html = '<a href="###"><img src="'+M.util.image_url('a/refresh')+'" /> '+mstr.repository.refresh+'</a>'; var refresh = Y.Node.create(html); refresh.on('click', function() { this.list(); @@ -929,7 +928,7 @@ M.core_filepicker.init = function(Y, options) { toolbar.appendChild(refresh); } if(!r.nologin) { - var html = '<a href="###"><img src="'+this.options.pix.logout+'" /> '+mstr.repository.logout+'</a>'; + var html = '<a href="###"><img src="'+M.util.image_url('a/logout')+'" /> '+mstr.repository.logout+'</a>'; var logout = Y.Node.create(html); logout.on('click', function() { this.request({ @@ -950,14 +949,14 @@ M.core_filepicker.init = function(Y, options) { var mgr = document.createElement('A'); mgr.href = r.manage; mgr.target = "_blank"; - mgr.innerHTML = '<img src="'+this.options.pix.setting+'" /> '+mstr.repository.manageurl; + mgr.innerHTML = '<img src="'+M.util.image_url('a/setting')+'" /> '+mstr.repository.manageurl; toolbar.appendChild(mgr); } if(r.help) { var help = document.createElement('A'); help.href = r.help; help.target = "_blank"; - help.innerHTML = '<img src="'+this.options.pix.help+'" /> '+mstr.repository.help; + help.innerHTML = '<img src="'+M.util.image_url('a/help')+'" /> '+mstr.repository.help; toolbar.appendChild(help); } diff --git a/repository/lib.php b/repository/lib.php index 68d71191d87..392ab9a35b0 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -1777,50 +1777,6 @@ function initialise_filepicker($args) { } $return = new stdclass; - $PAGE->requires->string_for_js('loading', 'repository'); - $PAGE->requires->string_for_js('title', 'repository'); - $PAGE->requires->string_for_js('preview', 'repository'); - $PAGE->requires->string_for_js('add', 'repository'); - $PAGE->requires->string_for_js('back', 'repository'); - $PAGE->requires->string_for_js('cancel', 'moodle'); - $PAGE->requires->string_for_js('close', 'repository'); - $PAGE->requires->string_for_js('cleancache', 'repository'); - $PAGE->requires->string_for_js('copying', 'repository'); - $PAGE->requires->string_for_js('getfile', 'repository'); - $PAGE->requires->string_for_js('downloadsucc', 'repository'); - $PAGE->requires->string_for_js('date', 'repository').': '; - $PAGE->requires->string_for_js('error', 'repository'); - $PAGE->requires->string_for_js('emptylist', 'repository'); - $PAGE->requires->string_for_js('filenotnull', 'repository'); - $PAGE->requires->string_for_js('federatedsearch', 'repository'); - $PAGE->requires->string_for_js('help', 'moodle'); - $PAGE->requires->string_for_js('refresh', 'repository'); - $PAGE->requires->string_for_js('invalidjson', 'repository'); - $PAGE->requires->string_for_js('listview', 'repository'); - $PAGE->requires->string_for_js('linkexternal', 'repository'); - $PAGE->requires->string_for_js('login', 'repository'); - $PAGE->requires->string_for_js('logout', 'repository'); - $PAGE->requires->string_for_js('loading', 'repository'); - $PAGE->requires->string_for_js('iconview', 'repository'); - $PAGE->requires->string_for_js('title', 'repository'); - $PAGE->requires->string_for_js('noresult', 'repository'); - $PAGE->requires->string_for_js('manageurl', 'repository'); - $PAGE->requires->string_for_js('noenter', 'repository'); - $PAGE->requires->string_for_js('save', 'repository'); - $PAGE->requires->string_for_js('saveas', 'repository').': '; - $PAGE->requires->string_for_js('saved', 'repository'); - $PAGE->requires->string_for_js('saving', 'repository'); - $PAGE->requires->string_for_js('size', 'repository').': '; - $PAGE->requires->string_for_js('sync', 'repository'); - $PAGE->requires->string_for_js('search', 'repository'); - $PAGE->requires->string_for_js('searching', 'repository'); - $PAGE->requires->string_for_js('submit', 'repository'); - $PAGE->requires->string_for_js('preview', 'repository'); - $PAGE->requires->string_for_js('popup', 'repository'); - $PAGE->requires->string_for_js('upload', 'repository').'...'; - $PAGE->requires->string_for_js('uploading', 'repository'); - $PAGE->requires->string_for_js('xhtmlerror', 'repository'); - $user_context = get_context_instance(CONTEXT_USER, $USER->id); $externallink = (int)get_config(null, 'repositoryallowexternallinks'); @@ -1838,14 +1794,6 @@ function initialise_filepicker($args) { $return->externallink = true; } - $return->pix = array(); - $return->pix['loading'] = $OUTPUT->pix_url('i/loading')->out(); - $return->pix['logout'] = $OUTPUT->pix_url('a/logout')->out(); - $return->pix['help'] = $OUTPUT->pix_url('a/help')->out(); - $return->pix['progressbar'] = $OUTPUT->pix_url('i/progressbar')->out(); - $return->pix['search'] = $OUTPUT->pix_url('a/search')->out(); - $return->pix['setting'] = $OUTPUT->pix_url('a/setting')->out(); - $return->pix['refresh'] = $OUTPUT->pix_url('a/refresh')->out(); // provided by form element $return->accepted_types = $ft->get_extensions($args->accepted_types); foreach ($repositories as $repository) {