added elfinder module

This commit is contained in:
2018-12-04 20:35:06 +01:00
parent 1b53514906
commit ccab226e12
223 changed files with 97254 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?php
/**
* @file
* BUEditor integration plugin
*/
/**
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
*/
function elfinder_bueditor_elfinder_editor_plugin($options) {
drupal_add_js(array('elfinder' => array('moduleUrl' => url('elfinder'))), 'setting');
drupal_add_js(array('elfinder' => array('moduleUrl' => url('elfinder'))), 'setting');
drupal_add_js($options['plugin_url_base'] . '/bueditor.js');
return array(
'elfinder' => array(
'extensions' => array('elfinder' => t('elFinder')),
'url' => $options['homepage_url'],
'options' => array(),
'load' => FALSE,
),
);
}

View File

@@ -0,0 +1,12 @@
// $Id: elfinder.bueditor.js,v 1.1 2010/10/06 09:44:51 ph0enix Exp $
Drupal.elfinder.editor.bueditor = {
fn : {
attach: Drupal.wysiwyg.editor.attach.bueditor
}
}
Drupal.wysiwyg.editor.attach.bueditor = function(context, params, settings) {
Drupal.settings.BUE.imceURL = Drupal.settings.elfinder.moduleUrl;
Drupal.elfinder.editor.bueditor.fn.attach.apply(this, arguments);
}

View File

@@ -0,0 +1,30 @@
function elfinder_ckeditor_callback(arg1) {
var url = arg1;
if (typeof arg1 == 'object') {
url = arg1.url;
}
funcNum = window.location.search.replace(/^.*CKEditorFuncNum=(\d+).*$/, "$1");
window.opener.CKEDITOR.tools.callFunction(funcNum, url, function() {
// adapted from http://docs.ckeditor.com/#!/guide/dev_file_browser_api
var dialog = this.getDialog();
if (dialog.getName() == 'link' ) {
var element = dialog.getContentElement('info', 'linkDisplayText');
var display_text = element.getValue();
// If display text is blank, insert the filename.
if (element && !display_text) {
element.setValue(arg1.name);
}
}
});
// Avoid beforeunload event when selecting an image.
// See https://github.com/Studio-42/elFinder/issues/1340
// Maybe remove this when elfinder js library gets updated.
$(window).off('beforeunload');
window.close();
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* @file
* CKeditor integration plugin
*/
/**
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
*/
function elfinder_ckeditor_elfinder_editor_plugin($options) {
return array(
'elfinder' => array(
'extensions' => array('elfinder' => t('elFinder')),
'url' => $options['homepage_url'],
'options' => array(
'filebrowserBrowseUrl' => $options['elfinder_url'],
'filebrowserUploadUrl' => url('elfinder/upload/ckeditor'),
'filebrowserImageUploadUrl' => url('elfinder/upload/ckeditor'),
'filebrowserFlashUploadUrl' => url('elfinder/upload/ckeditor'),
),
'load' => FALSE,
),
);
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* @file
*
* CKeditor Upload tab support
*/
function elfinder_editor_upload_ckeditor() {
$p = elfinder_get_user_profile();
$dest = file_build_uri('');
if (!strpos($p->settings['ckeditor_upload_directory'], '://')) {
$dest .= $p->settings['ckeditor_upload_directory'];
} else {
$dest = $p->settings['ckeditor_upload_directory'];
}
$dest = elfinder_parse_path_tokens($dest);
$destabs = drupal_realpath($dest);
if (!file_prepare_directory($destabs, FILE_CREATE_DIRECTORY)) {
drupal_set_message(t('Error. Cannot initialize directory %dir', array('%dir' => $destabs)), 'error');
}
$tmpf = $_FILES;
foreach (array_keys($_FILES['upload']) as $key) {
$tmpf['files'][$key]['upload'] = $_FILES['upload'][$key];
}
$_FILES = $tmpf;
$file = file_save_upload('upload', array(), $dest);
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
header('Content-Type: text/html');
print '<script type="text/javascript">';
if ($file) {
print "window.parent.CKEDITOR.tools.callFunction(2, '" . file_create_url($file->uri) . "', '');";
} else {
print "window.parent.CKEDITOR.tools.callFunction(2, '', '" . t('Error uploading file!') . "');";
}
print '</script>';
exit();
}

View File

@@ -0,0 +1,5 @@
// $Id$
function elfinder_drupalnodeattach_callback(url) {
parent.jQuery('input#edit-attach-url').val(url);
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* @file
* FCKeditor integration plugin
*/
/**
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
*/
function elfinder_fckeditor_elfinder_editor_plugin($options) {
return array(
'elfinder' => array(
'extensions' => array('elfinder' => t('elFinder')),
'url' => $options['homepage_url'],
'options' => array(
'LinkBrowser' => TRUE,
'LinkBrowserURL' => $options['elfinder_url'],
'ImageBrowser' => TRUE,
'ImageBrowserURL' => $options['elfinder_url'],
'FlashBrowser' => TRUE,
'FlashBrowserURL' => $options['elfinder_url'],
'ImageUpload' => TRUE,
'ImageUploadURL' => url('elfinder/upload/fckeditor'),
'FlashUpload' => TRUE,
// 'FlashUploadURL' => $options['elfinder_connector_url'],
'LinkUpload' => TRUE,
// 'LinkUploadURL' => $options['elfinder_connector_url'],
),
'load' => FALSE,
),
);
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* @file
*
* FCKeditor Upload tab support
*/
function elfinder_editor_upload_fckeditor() {
$p = elfinder_get_user_profile();
$dest = file_build_uri('');
if (!strpos($p->settings['ckeditor_upload_directory'], '://')) {
$dest .= $p->settings['ckeditor_upload_directory'];
} else {
$dest = $p->settings['ckeditor_upload_directory'];
}
$dest = elfinder_parse_path_tokens($dest);
$destabs = drupal_realpath($dest);
if (!file_prepare_directory($destabs, FILE_CREATE_DIRECTORY)) {
drupal_set_message(t('Error. Cannot initialize directory %dir', array('%dir' => $destabs)), 'error');
}
$tmpf = $_FILES;
foreach (array_keys($_FILES['NewFile']) as $key) {
$tmpf['files'][$key]['NewFile'] = $_FILES['NewFile'][$key];
}
$_FILES = $tmpf;
$file = file_save_upload('NewFile', array(), $dest);
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
header('Content-Type: text/html');
print '<script type="text/javascript">';
if ($file) {
print "window.parent.OnUploadCompleted(0, '" . file_create_url($file->uri) . "', '" . $file->filename . "', '') ;";
} else {
print 'window.parent.OnUploadCompleted(1,"","", "' . t('Error uploading file!') . '") ;';
}
print '</script>';
exit();
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @file
* jWYSIWYG integration plugin
*/
/**
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
*/
function elfinder_jwysiwyg_elfinder_editor_plugin($options) {
if (module_exists('jquery_update') && module_exists('jquery_ui')) {
drupal_add_css(JQUERY_UI_PATH . '/themes/base/ui.all.css');
jquery_ui_add(array('ui.dialog', 'ui.accordion', 'ui.draggable', 'ui.droppable', 'ui.selectable'));
} else {
drupal_set_message(t('elFinder requires jQuery 1.3+ and jQuery UI 1.7+ for jWYSIWYG support. Please install and enable <a href="http://drupal.org/project/jquery_update">jquery_update</a> and <a href="http://drupal.org/project/jquery_ui">jquery_ui</a> modules.'), 'error');
}
drupal_add_js(array('elfinder' => array('file_browser_url' => $options['elfinder_url'])), 'setting');
drupal_add_js($options['plugin_url_base'] . '/jwysiwyg.js');
return array(
'elfinder' => array(
'extensions' => array('elfinder' => t('elFinder')),
'url' => $options['homepage_url'],
'options' => array(),
'load' => FALSE,
),
);
}

View File

@@ -0,0 +1,34 @@
// $Id: elfinder.jwysiwyg.js,v 1.1 2010/10/06 09:44:51 ph0enix Exp $
(function($) {
Drupal.elfinder.editor.jwysiwyg = {
fn : {
attach: Drupal.wysiwyg.editor.attach.jwysiwyg
}
}
Drupal.wysiwyg.editor.attach.jwysiwyg = function(context, params, settings) {
var imgHtml = null;
if (jQuery.fn.wysiwyg.defaults) {
imgHtml = jQuery.fn.wysiwyg.defaults.formImageHtml;
}
var oImgHtml = $('<div>'+imgHtml+'</div>');
var oUrl = $("input[name=url]", oImgHtml);
var browsebutton = $('<input type="button">');
browsebutton.attr('value', Drupal.t('Browse Server'));
browsebutton.attr('onclick', 'var w = window; w.open("' + Drupal.settings.elfinder.file_browser_url + '","","toolbar=no,menubar=no,width=600,height=600")');
browsebutton.insertAfter(oUrl);
if (jQuery.fn.wysiwyg.defaults) {
jQuery.fn.wysiwyg.defaults.formImageHtml = oImgHtml.html();
}
Drupal.elfinder.editor.jwysiwyg.fn.attach.apply(this, arguments);
}
})(jQuery);

View File

@@ -0,0 +1,24 @@
<?php
/**
* @file
* TinyMCE integration plugin
*/
/**
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
*/
function elfinder_tinymce_elfinder_editor_plugin($options) {
drupal_add_js($options['plugin_url_base'] . '/tinymce.js');
return array(
'elfinder' => array(
'extensions' => array('elfinder' => t('elFinder')),
'url' => $options['homepage_url'],
'options' => array(
'file_browser_callback' => 'elfinder_tinymce_browse_callback',
'file_browser_url' => $options['elfinder_url'], // non standard TinyMCE configuration variable to pass source application to elFinder
'inline_styles' => TRUE,
),
'load' => FALSE,
),
);
}

View File

@@ -0,0 +1,27 @@
function elfinder_tinymce_browse_callback(field_name, url, type, win) {
var cmsURL = tinymce.settings.file_browser_url; // script URL - use an absolute path!
if (cmsURL.indexOf("?") < 0) {
//add the type as the only query parameter
cmsURL = cmsURL + "?type=" + type;
} else {
//add the type as an additional query parameter
// (PHP session ID is now included if there is one at all)
cmsURL = cmsURL + "&type=" + type;
}
tinyMCE.activeEditor.windowManager.open({
file: cmsURL,
title: 'File Manager',
width: 900,
height: 450,
resizable: "yes",
inline: "yes", // This parameter only has an effect if you use the inlinepopups plugin!
popup_css: false, // Disable TinyMCE's default popup CSS
close_previous: "no"
}, {
window: win,
input: field_name
});
return false;
}

View File

@@ -0,0 +1,4 @@
function elfinder_wymeditor_callback(url) {
window.opener.jQuery('input.wym_src').val(url);
window.close();
}

View File

@@ -0,0 +1,23 @@
<?php
// $Id$
/**
* @file
* WYMeditor integration plugin
*/
/**
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
*/
function elfinder_wymeditor_elfinder_editor_plugin($options) {
drupal_add_js($options['plugin_url_base'] . '/wymeditor.js');
drupal_add_js(array('elfinder' => array('file_browser_url' => $options['elfinder_url'])), 'setting');
return array(
'elfinder' => array(
'extensions' => array('elfinder' => t('elFinder')),
'url' => $options['homepage_url'],
'options' => array(),
'load' => FALSE,
),
);
}

View File

@@ -0,0 +1,52 @@
// $Id: elfinder.wymeditor.js,v 1.1.2.2 2010/12/11 11:53:49 ph0enix Exp $
(function($) {
Drupal.elfinder.editor.wymeditor = {
fn : {
attach: Drupal.wysiwyg.editor.attach.wymeditor
}
}
Drupal.wysiwyg.editor.attach.wymeditor = function(context, params, settings) {
Drupal.elfinder.editor.wymeditor.fn.attach.apply(this, arguments);
var $field = $('#' + params.field);
var index = $field.data(WYMeditor.WYM_INDEX);
if (typeof index != 'undefined') {
var instance = WYMeditor.INSTANCES[index];
var imgHtml = instance._options.dialogImageHtml;
var oImgHtml = $('<div>'+imgHtml+'</div>');
var oUrl = $("input.wym_src", oImgHtml);
var browsebutton = $('<input type="button">');
browsebutton.attr('value', Drupal.t('Browse Server'));
/* FIXME: url parameters duplicates for some reason */
var tmp = Drupal.settings.elfinder.file_browser_url;
var bugpos = tmp.indexOf(",");
var elfinderUrl = '';
if (bugpos != -1) {
elfinderUrl = tmp.slice(0, bugpos);
}
else {
elfinderUrl = tmp;
}
browsebutton.attr('onclick', 'var w = window; w.open("' + elfinderUrl + '","","toolbar=no,menubar=no,width=600,height=600")');
browsebutton.insertAfter(oUrl);
ImgHtml = '<body class="wym_dialog wym_dialog_image" onload="WYMeditor.INIT_DIALOG(' + index + ')">' + oImgHtml.html() + '</body>';
instance._options.dialogImageHtml = ImgHtml;
}
}
})(jQuery);

View File

@@ -0,0 +1,5 @@
function elfinder_yui_callback(url) {
var editorId = window.opener.Drupal.wysiwyg.activeId;
window.opener.jQuery('input#' + editorId + '_insertimage_url').val(url);
window.close();
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* @file
* YUI editor integration plugin
*/
/**
* Pseudo-hook for elfinder hook_wysiwyg_plugin implementation
*/
function elfinder_yui_elfinder_editor_plugin($options) {
drupal_add_js($options['plugin_url_base'] . '/yui.js');
drupal_add_js(array('elfinder' => array('file_browser_url' => $options['elfinder_url'])), 'setting');
return array(
'elfinder' => array(
'extensions' => array('elfinder' => t('elFinder')),
'url' => $options['homepage_url'],
'options' => array(),
'load' => FALSE,
),
);
}

View File

@@ -0,0 +1,33 @@
// $Id: elfinder.yui.js,v 1.1 2010/10/06 09:44:51 ph0enix Exp $
(function($) {
Drupal.elfinder.editor.yui = {
fn : {
attach: Drupal.wysiwyg.editor.attach.yui
}
}
Drupal.wysiwyg.editor.attach.yui = function(context, params, settings) {
$('#' + params.field).parent().addClass('yui-skin-' + settings.theme);
// Attach editor.
var editor = new YAHOO.widget.Editor(params.field, settings);
editor.on('windowInsertImageRender', function(e) {
var dialogcode = $('#' + params.field + '-panel');
var oUrl = $('input#' + params.field + '_insertimage_url');
var browsebutton = $('<input type="button">');
browsebutton.attr('value', Drupal.t('Browse Server'));
browsebutton.attr('onclick', 'var w = window; w.open("' + Drupal.settings.elfinder.file_browser_url + '","","toolbar=no,menubar=no,width=600,height=600")');
browsebutton.insertAfter(oUrl);
}, editor, true);
editor.render();
}
})(jQuery);