Based on #153623: FCK Integration I made an integration for wysiwyg - tinymce
Add the following to webfmpopup.module
/**
* Implementation of hook_wysiwyg_plugin().
*/
function webfmpopup_wysiwyg_plugin($editor) {
static $integrated;
switch ($editor) {
case 'tinymce':
/*
if (!imce_access()) {
return;
}
*/
if (!isset($integrated)) {
$integrated = TRUE;
$settings = array(
'webfmpopup' => array(
'url' => url('webfm'),
'appname' => t('editor'),
'wysiwyg_module' => true,
),
);
drupal_add_js($settings, 'setting');
drupal_add_js(drupal_get_path('module', 'webfmpopup') .'/webfmpopup.js');
}
return array(
'webfmpopup' => array(
'extensions' => array('webfmpopup' => t('webfmpopup')),
'url' => 'http://drupal.org/project/webfmpopup',
'options' => array(
'file_browser_callback' => 'webfmImageBrowser',
'inline_styles' => TRUE,
),
'load' => FALSE,
),
);
}
}
Replace content of webfmpopup.js with
/* $Id$ */
function webfmpopup() {}
if (Drupal.jsEnabled) {
$(window).load(webfmpopupGetMenusAjax);
}
// Add the send to rich text editor link to the right click menu of files.
function webfmpopupGetMenusAjax() {
Webfm.menuHT.put('file', new Webfm.menuElement("Send to rich text editor", webfmpopup.sendtocaller, ""));
}
// Send the selected file tot he rich text editor.
webfmpopup.sendtocaller = function(obj) {
// the window this popup was called from
var doc = $(window.opener.document);
// put the file url in the input with the id specified in the url
var fpath = obj.filepath;
var url_id = '#'+get_url_param('url');
doc.find(url_id).val(Drupal.settings.basePath + Drupal.settings.webfmpopup.fileDirectory + fpath);
doc.find(url_id).change();
// put the webfm file-id in the input with the id specified in the url
var fid = $('#'+obj.row_id).find('td').eq(1).find('a').attr('title');
console.log(fid);
var webfm_id = '#'+get_url_param('webfmid');
// ATTIKS doc.find(webfm_id).val(Drupal.settings.basePath + 'webfm_send/' + fid);
doc.find(webfm_id).val(Drupal.settings.basePath + Drupal.settings.webfmpopup.fileDirectory + fpath);
doc.find(webfm_id).change();
window.opener.focus();
window.close();
}
// read GET parameter from the url
// for example on the url http://example.com/page.php?some=value&more=evenmore&get_it=yes
// calling get_url_param('get_it') would return 'yes'
function get_url_param(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null ) return "";
else return results[1];
}
//helper function - used as a wysiwyg callback
function webfmImageBrowser(fid, url, type, win) {
var qstring = "?q=webfmpopup&url=webfmtest&webfmid=" + fid;
win.open(Drupal.settings.basePath+qstring, '', 'width=760,height=560,resizable=1');
}
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | webfm-6.x-2.12.patch | 1.14 KB | jm.federico |
| #5 | wysiwyg_webfm_373598.patch | 1.88 KB | attiks |
Comments
Comment #1
robmilne commentedThe php function has a http://drupal.org/project/webfmpopup url. Are you planning to create a webfmpopup contrib module? If so I can remove the webfm_popup module that I placed inside webfm rc4.
Comment #2
robmilne commentedBy the way, commenting out the line of code in the 'sendtocaller' javascript defeats the file security of the module. Besides, it won't work if the files are guarded by a .htaccess file.
Comment #3
attiks commentedI'll have a look at RC4 first, i used some other code from 153623 for the popup stuff. In my opinion the popup should be part of the module so all wysiwyg editors can use it.
I commented out the your code because i got some strange results if the file selected was not available in the database.
Comment #4
attiks commentedPatch against rc4 attached. I still get the full filename in the wysiwyg if the file doesn't exist in the database.
Comment #5
attiks commentedComment #6
Niko_K commentedDoes this code only work with the tinymce plugin for the wysiwyg module or can it also be used with other editors (such as FCKeditor integrated into the wysiwyg module)?
Comment #7
attiks commentedThis code is kind of old, it's functionality is included in the web file manager, I assume it works with all wysiwyg complaint editors
Comment #8
dawehnera general question
wouldn't it be cool if there would be a integration into http://drupal.org/project/wysiwyg
The advantage you can support every wyswyg-editor with writing one plugin.
Comment #9
attiks commentedAs far as I know the integration is allready done, there's a webfm popup module included.
I'm closing is this issue
Comment #10
jm.federico commentedOK, so I'm opening this with a new patch for webfm_popup.js
What I'm fixing here is that WebFM was sending the real path to TinyMCE, insted of the WebFM path which is what we want, this is how things should be:
Be aware that it seems like all of the TinyMCE patches have security issues and they don't respect permissions, haven't really tested that, but it is better than nothing.
Comment #11
jm.federico commentedComment #12
jm.federico commentedOk People,
Patch against 2.12
Works with Wysiwyg Module + Tinymce
Comment #13
robmilne commentedIn head
Comment #15
albertogreco commentedTank you very much for your work.
There is an error again in the last patch.
The function
getBasePath()is undefuned.If I change it with
Drupal.settings.basePathall works very fine for me.So the lines:
became as:
Comment #16
nhck commentedThis is already fixed in the dev release.