Skip to content

Commit

Permalink
MDL-23407, the advlink plugin of tinymce should use external reposito…
Browse files Browse the repository at this point in the history
…ries only
  • Loading branch information
Dongsheng Cai committed Jul 27, 2010
1 parent 9c954e8 commit 766514a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 15 deletions.
10 changes: 8 additions & 2 deletions lib/editor/tinymce/module.js
Expand Up @@ -51,11 +51,17 @@ M.editor_tinymce.filepicker = function(target_id, url, type, win) {
YUI(M.yui.loader).use('core_filepicker', function (Y) {
var editor_id = tinyMCE.selectedInstance.editorId;
var options = null;
alert(type);
if (type == 'media') {
// when mediaw button clicked
options = M.editor_tinymce.filepicker_options[editor_id]['media'];
} else {
} else if (type == 'file') {
// when link button clicked
options = M.editor_tinymce.filepicker_options[editor_id]['link'];
} else if (type == 'image') {
// when image button clicked
options = M.editor_tinymce.filepicker_options[editor_id]['image'];
}
}

options.formcallback = M.editor_tinymce.filepicker_callback;
options.editor_target = win.document.getElementById(target_id);
Expand Down
25 changes: 16 additions & 9 deletions lib/form/editor.php
Expand Up @@ -167,26 +167,33 @@ function toHtml() {
$args->return_types = (FILE_INTERNAL | FILE_EXTERNAL);
$args->context = $ctx;
$args->env = 'filepicker';

$image_options = initialise_filepicker($args);
$image_options->context = $ctx;
$image_options->client_id = uniqid();
$image_options->maxbytes = $this->_options['maxbytes'];
$image_options->env = 'editor';
$image_options->itemid = $draftitemid;

$args->accepted_types = array('video', 'audio');
$media_options = initialise_filepicker($args);

$image_options->context = $ctx;
$media_options->context = $ctx;
$image_options->client_id = uniqid();
$media_options->client_id = uniqid();
$image_options->maxbytes = $this->_options['maxbytes'];
$media_options->maxbytes = $this->_options['maxbytes'];
$image_options->maxfiles = 1;
$media_options->maxfiles = 1;
$image_options->env = 'editor';
$media_options->env = 'editor';
$image_options->itemid = $draftitemid;
$media_options->itemid = $draftitemid;

$args->return_types = FILE_EXTERNAL;
$args->accepted_types = '*';
$link_options = initialise_filepicker($args);
$link_options->context = $ctx;
$link_options->client_id = uniqid();
$link_options->maxbytes = $this->_options['maxbytes'];
$link_options->env = 'editor';
$link_options->itemid = $draftitemid;

$fpoptions['image'] = $image_options;
$fpoptions['media'] = $media_options;
$fpoptions['link'] = $link_options;
}

/// print text area - TODO: add on-the-fly switching, size configuration, etc.
Expand Down
16 changes: 12 additions & 4 deletions repository/filepicker.js
Expand Up @@ -462,7 +462,7 @@ M.core_filepicker.init = function(Y, options) {
// support internal files only
le_style = ' style="display:none;"';
}
if ((this.options.externallink && this.options.env == 'editor')) {
if ((this.options.externallink && this.options.env == 'editor' && this.options.return_types != 1)) {
html += '<tr'+le_style+'><td></td><td class="mdl-left"><input type="checkbox" id="linkexternal-'+client_id+'" value="" '+le_checked+' />'+M.str.repository.linkexternal+'</td></tr>';
}

Expand Down Expand Up @@ -523,11 +523,19 @@ M.core_filepicker.init = function(Y, options) {
if (this.options.env == 'editor') {
// in editor, images are stored in '/' only
params.savepath = '/';
var linkexternal = Y.one('#linkexternal-'+client_id).get('checked');
if (linkexternal) {
// when image or media button is clicked
if ( this.options.return_types != 1 ) {
var linkexternal = Y.one('#linkexternal-'+client_id).get('checked');
if (linkexternal) {
params['linkexternal'] = 'yes';
}
} else {
// when link button in editor clicked
params['linkexternal'] = 'yes';
}
} if (this.options.env == 'url') {
}

if (this.options.env == 'url') {
params['linkexternal'] = 'yes';
}

Expand Down
1 change: 1 addition & 0 deletions repository/lib.php
Expand Up @@ -1764,6 +1764,7 @@ function initialise_filepicker($args) {

// provided by form element
$return->accepted_types = $ft->get_extensions($args->accepted_types);
$return->return_types = $args->return_types;
foreach ($repositories as $repository) {
$meta = $repository->get_meta();
$return->repositories[$repository->id] = $meta;
Expand Down

0 comments on commit 766514a

Please sign in to comment.