Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31901 filepicker interface changes:

- fixed displaying and dragging of dialog popups;
- fixed error when repository results are filtered;
- added string for image dimensions
  • Loading branch information...
commit dd1f051e4a32becd72cea8fd012f1f082839a9ea 1 parent 55089a9
Marina Glancy marinaglancy authored
1  lang/en/repository.php
@@ -115,6 +115,7 @@
115 115 $string['choosealink'] = 'Choose a link...';
116 116 $string['chooselicense'] = 'Choose license';
117 117 $string['iconview'] = 'View as icons';
  118 +$string['imagesize'] = '{$a->width} x {$a->height} px';
118 119 $string['instance'] = 'instance';
119 120 $string['instancedeleted'] = 'Instance deleted';
120 121 $string['instances'] = 'Repository instances';
60 repository/filepicker.js
@@ -518,14 +518,6 @@ M.core_filepicker.init = function(Y, options) {
518 518 this.fpnode.one('.fp-content').setContent('');
519 519 }
520 520 return;
521   - } else if (data && data.event) {
522   - switch (data.event) {
523   - case 'fileexists':
524   - scope.process_existing_file(data);
525   - break;
526   - default:
527   - break;
528   - }
529 521 } else {
530 522 if (data.msg) {
531 523 scope.print_msg(data.msg, 'info');
@@ -593,7 +585,8 @@ M.core_filepicker.init = function(Y, options) {
593 585 var fileinfo = {'client_id':scope.options.client_id,
594 586 'url':data.existingfile.url,
595 587 'file':data.existingfile.filename};
596   - scope.options.formcallback.apply(scope, [fileinfo]);
  588 + var formcallback_scope = scope.options.magicscope ? scope.options.magicscope : scope;
  589 + scope.options.formcallback.apply(formcallback_scope, [fileinfo]);
597 590 }
598 591 }
599 592 }, true);
@@ -608,12 +601,7 @@ M.core_filepicker.init = function(Y, options) {
608 601 scope.options.editor_target.onchange();
609 602 }
610 603 scope.hide();
611   - var formcallback_scope = null;
612   - if (scope.options.magicscope) {
613   - formcallback_scope = scope.options.magicscope;
614   - } else {
615   - formcallback_scope = scope;
616   - }
  604 + var formcallback_scope = scope.options.magicscope ? scope.options.magicscope : scope;
617 605 var fileinfo = {'client_id':scope.options.client_id,
618 606 'url':data.newfile.url,
619 607 'file':data.newfile.filename};
@@ -640,8 +628,10 @@ M.core_filepicker.init = function(Y, options) {
640 628 this.selectui.hide();
641 629 }
642 630 if (!this.process_dlg) {
643   - var node = Y.Node.create(M.core_filepicker.templates.processexistingfile);
644   - this.fpnode.appendChild(node);
  631 + this.process_dlg_node = Y.Node.create(M.core_filepicker.templates.processexistingfile);
  632 + var node = this.process_dlg_node;
  633 + node.generateID();
  634 + Y.one(document.body).appendChild(node);
645 635 this.process_dlg = new Y.Panel({
646 636 srcNode : node,
647 637 headerContent: M.str.repository.fileexistsdialogheader,
@@ -652,6 +642,7 @@ M.core_filepicker.init = function(Y, options) {
652 642 render : true,
653 643 buttons : {}
654 644 });
  645 + this.process_dlg.plug(Y.Plugin.Drag,{handles:['#'+node.get('id')+' .yui3-widget-hd']});
655 646 node.one('.fp-dlg-butoverwrite').on('click', handleOverwrite, this);
656 647 node.one('.fp-dlg-butrename').on('click', handleRename, this);
657 648 node.one('.fp-dlg-butcancel').on('click', handleCancel, this);
@@ -663,7 +654,7 @@ M.core_filepicker.init = function(Y, options) {
663 654 }
664 655 this.selectnode.removeClass('loading');
665 656 this.process_dlg.dialogdata = data;
666   - this.fpnode.one('.fp-dlg .fp-dlg-butrename').setContent(M.util.get_string('renameto', 'repository', data.newfile.filename));
  657 + this.process_dlg_node.one('.fp-dlg-butrename').setContent(M.util.get_string('renameto', 'repository', data.newfile.filename));
667 658 this.process_dlg.show();
668 659 },
669 660 /** displays error instead of filepicker contents */
@@ -681,26 +672,28 @@ M.core_filepicker.init = function(Y, options) {
681 672 header = M.str.moodle.info;
682 673 }
683 674 if (!this.msg_dlg) {
684   - var node = Y.Node.create(M.core_filepicker.templates.message);
685   - this.fpnode.appendChild(node);
  675 + this.msg_dlg_node = Y.Node.create(M.core_filepicker.templates.message);
  676 + this.msg_dlg_node.generateID();
  677 + Y.one(document.body).appendChild(this.msg_dlg_node);
686 678
687 679 this.msg_dlg = new Y.Panel({
688   - srcNode : node,
  680 + srcNode : this.msg_dlg_node,
689 681 zIndex : 800000,
690 682 centered : true,
691 683 modal : true,
692 684 visible : false,
693 685 render : true
694 686 });
695   - node.one('.fp-msg-butok').on('click', function(e) {
  687 + this.msg_dlg.plug(Y.Plugin.Drag,{handles:['#'+this.msg_dlg_node.get('id')+' .yui3-widget-hd']});
  688 + this.msg_dlg_node.one('.fp-msg-butok').on('click', function(e) {
696 689 e.preventDefault();
697 690 this.msg_dlg.hide();
698 691 }, this);
699 692 }
700 693
701 694 this.msg_dlg.set('headerContent', header);
702   - this.fpnode.one('.fp-msg').removeClass('fp-msg-info').removeClass('fp-msg-error').addClass('fp-msg-'+type)
703   - this.fpnode.one('.fp-msg .fp-msg-text').setContent(msg);
  695 + this.msg_dlg_node.removeClass('fp-msg-info').removeClass('fp-msg-error').addClass('fp-msg-'+type)
  696 + this.msg_dlg_node.one('.fp-msg-text').setContent(msg);
704 697 this.msg_dlg.show();
705 698 },
706 699 view_files: function(appenditems) {
@@ -1095,12 +1088,7 @@ M.core_filepicker.init = function(Y, options) {
1095 1088 }
1096 1089 scope.hide();
1097 1090 obj.client_id = client_id;
1098   - var formcallback_scope = null;
1099   - if (args.scope.options.magicscope) {
1100   - formcallback_scope = args.scope.options.magicscope;
1101   - } else {
1102   - formcallback_scope = args.scope;
1103   - }
  1091 + var formcallback_scope = args.scope.options.magicscope ? args.scope.options.magicscope : args.scope;
1104 1092 scope.options.formcallback.apply(formcallback_scope, [obj]);
1105 1093 }
1106 1094 }, false);
@@ -1539,18 +1527,18 @@ M.core_filepicker.init = function(Y, options) {
1539 1527 scope.create_upload_form(data);
1540 1528 },
1541 1529 callback: function(id, o, args) {
  1530 + if (o.event == 'fileexists') {
  1531 + scope.create_upload_form(data);
  1532 + scope.process_existing_file(o);
  1533 + return;
  1534 + }
1542 1535 if (scope.options.editor_target&&scope.options.env=='editor') {
1543 1536 scope.options.editor_target.value=o.url;
1544 1537 scope.options.editor_target.onchange();
1545 1538 }
1546 1539 scope.hide();
1547 1540 o.client_id = client_id;
1548   - var formcallback_scope = null;
1549   - if (args.scope.options.magicscope) {
1550   - formcallback_scope = args.scope.options.magicscope;
1551   - } else {
1552   - formcallback_scope = args.scope;
1553   - }
  1541 + var formcallback_scope = args.scope.options.magicscope ? args.scope.options.magicscope : args.scope;
1554 1542 scope.options.formcallback.apply(formcallback_scope, [o]);
1555 1543 }
1556 1544 }, true);
11 repository/lib.php
@@ -1781,16 +1781,18 @@ public function get_listing($path = '', $page = '') {
1781 1781
1782 1782 /**
1783 1783 * Prepares list of files before passing it to AJAX, makes sure data is in the correct
1784   - * format and stores formatted dates.
  1784 + * format and stores formatted values.
1785 1785 *
1786 1786 * @param array|stdClass $listing result of get_listing() or search() or file_get_drafarea_files()
1787 1787 * @return array
1788 1788 */
1789 1789 public static function prepare_listing($listing) {
1790 1790 global $OUTPUT;
1791   - if (is_array($listing) && isset($listing['list'])) {
  1791 + if (is_array($listing) && isset($listing['list']) && is_array(($listing['list']))) {
  1792 + $listing['list'] = array_values($listing['list']); // convert to array
1792 1793 $files = &$listing['list'];
1793   - } else if (is_object($listing) && isset($listing->list)) {
  1794 + } else if (is_object($listing) && isset($listing->list) && is_array(($listing->list))) {
  1795 + $listing->list = array_values($listing->list); // convert to array
1794 1796 $files = &$listing->list;
1795 1797 } else {
1796 1798 return $listing;
@@ -1813,7 +1815,8 @@ public static function prepare_listing($listing) {
1813 1815 $file['license_f'] = get_string($file['license'], 'license');
1814 1816 }
1815 1817 if (isset($file['image_width']) && isset($file['image_height'])) {
1816   - $file['dimensions'] = $file['image_width'].'x'.$file['image_height'];
  1818 + $a = array('width' => $file['image_width'], 'height' => $file['image_height']);
  1819 + $file['dimensions'] = get_string('imagesize', 'repository', (object)$a);
1817 1820 }
1818 1821 foreach (array('date', 'datemodified', 'datecreated') as $key) {
1819 1822 if (!isset($file[$key]) && isset($file['date'])) {

0 comments on commit dd1f051

Please sign in to comment.
Something went wrong with that request. Please try again.