I've created 2 new dialog plugins that insert data regarding RSS feeds and Google AdSense respectively. They simply create <rss attrib="value"> and <adsense attrib="value"> which is then parsed by a PHP script when the page is viewed. This part of the plugins works fine and the correct values are entered into the <rss> and <adsense> tags.
However the images for the <rss></rss> and <adsense></adsense> tags in the WYSIWYG mode only show if the source button is click twice (i.e. go to source mode and then back to Editor mode) and not initially as the editor loads up.
The plugins are modelled around how the flash dialog displays the flash logo.
The code is as follows.
FCKCommands.RegisterCommand( 'AdSense', new FCKDialogCommand( 'AdSense', FCKLang.AdSenseDlgTitle, FCKPlugins.Items['adsense'].Path + 'fck_adsense.html', 400, 350 ) ) ;
var oAdSenseItem = new FCKToolbarButton('AdSense', FCKLang['DlgAdSenseTitle']);
oAdSenseItem.IconPath = FCKPlugins.Items['adsense'].Path + 'adsense.gif' ;
FCKToolbarItems.RegisterItem( 'AdSense', oAdSenseItem ) ;
var FCKAdsenseProcessor = new Object();
FCKAdsenseProcessor.ProcessDocument = function(A)
{
var B = A.getElementsByTagName('ADSENSE');
var C;
var i = B.length - 1;
while (i >= 0 && (C = B[i--]))
{
var D = C.cloneNode(true);
D.setAttribute('google_ad_client', C.getAttribute('google_ad_client'));
var E = FCKDocumentProcessors_CreateFakeImage('FCK__Adsense', D);
E.setAttribute('_fckadsense', 'true', 0);
FCKAdsenseProcessor.RefreshView(E, C);
C.parentNode.insertBefore(E, C);
C.parentNode.removeChild(C);
};
};
FCKAdsenseProcessor.RefreshView = function(A, B)
{
if (B.width > 0)
A.style.width = FCKTools.ConvertHtmlSizeToStyle(B.width);
if (B.height > 0)
A.style.height = FCKTools.ConvertHtmlSizeToStyle(B.height);
};
FCKDocumentProcessors.addItem(FCKAdsenseProcessor);
Any assistance would be greatly appreciated.
P.S. and if you know to get a context menu to work with this code that would be an added bonus!
However the images for the <rss></rss> and <adsense></adsense> tags in the WYSIWYG mode only show if the source button is click twice (i.e. go to source mode and then back to Editor mode) and not initially as the editor loads up.
The plugins are modelled around how the flash dialog displays the flash logo.
The code is as follows.
FCKCommands.RegisterCommand( 'AdSense', new FCKDialogCommand( 'AdSense', FCKLang.AdSenseDlgTitle, FCKPlugins.Items['adsense'].Path + 'fck_adsense.html', 400, 350 ) ) ;
var oAdSenseItem = new FCKToolbarButton('AdSense', FCKLang['DlgAdSenseTitle']);
oAdSenseItem.IconPath = FCKPlugins.Items['adsense'].Path + 'adsense.gif' ;
FCKToolbarItems.RegisterItem( 'AdSense', oAdSenseItem ) ;
var FCKAdsenseProcessor = new Object();
FCKAdsenseProcessor.ProcessDocument = function(A)
{
var B = A.getElementsByTagName('ADSENSE');
var C;
var i = B.length - 1;
while (i >= 0 && (C = B[i--]))
{
var D = C.cloneNode(true);
D.setAttribute('google_ad_client', C.getAttribute('google_ad_client'));
var E = FCKDocumentProcessors_CreateFakeImage('FCK__Adsense', D);
E.setAttribute('_fckadsense', 'true', 0);
FCKAdsenseProcessor.RefreshView(E, C);
C.parentNode.insertBefore(E, C);
C.parentNode.removeChild(C);
};
};
FCKAdsenseProcessor.RefreshView = function(A, B)
{
if (B.width > 0)
A.style.width = FCKTools.ConvertHtmlSizeToStyle(B.width);
if (B.height > 0)
A.style.height = FCKTools.ConvertHtmlSizeToStyle(B.height);
};
FCKDocumentProcessors.addItem(FCKAdsenseProcessor);
Any assistance would be greatly appreciated.
P.S. and if you know to get a context menu to work with this code that would be an added bonus!
RE: New plugin image not initially shown
I'm working on something very similar. I've got a sort of custom HTML contorl that I'm representing in WYSIWYG as a placeholder image (like the flash). You right the image to edit the control properties.
I was able to get the context menu to work by following the example on this page:
http://wiki.fckeditor.net/Developer%27s ... n/Plug-ins
change the line:
if ( tagName == 'SPAN' && tag._fckplaceholder )
to
if ( tagName == 'IMG' && tag._fckadsense )
and I think you should be good to go.
as for why the image doesn't show up on the first time, I'm not sure.
I've got a question for you:
Where are you defining the style for FCK__Adsense used in CreateFakeImage ?
RE: New plugin image not initially shown
The file where I defined FCK_AdSense is the
/FCKeditor/editor/css/fck_internal.css
file.
Like I said, my AdSense image IS shown after you press the SOURCE button twice.
RE: New plugin image not initially shown
I figured out how to append my own stylesheets to FCKeditor. I was able to define my style in a .css in the plugin directory rather than modifying /FCKeditor/editor/css/fck_internal.css
// add this plugin's stylesheets to the editor's list of stylesheet to load
FCKConfig.EditorAreaCSS.push( FCKPlugins.Items['MyPlugin'].Path + 'styles.css') ;
It's based on the hint on this page:
http://wiki.fckeditor.net/Developer's_G ... ion/Styles
Treating FCKConfig.EditorAreaCSS like an array works because FCKeditor reads it in as an array:
(from /_source/internals/fck_1.js ):
FCK._GetEditorAreaStyleTags = function()
{
var sTags = '' ;
var aCSSs = FCKConfig.EditorAreaCSS ;
for ( var i = 0 ; i < aCSSs.length ; i++ )
sTags += '<link href="' + aCSSs[i] + '" rel="stylesheet" type="text/css" />' ;
return sTags ;
}
sorry, still don't know why you have to switch to between the source view twice.
Re: New plugin image not initially shown
I'm very interesting in that sort of plug-in to add server-side variable content in a page and representing it by an image.
This way the content writer will "preview" the rendering code.
Thank's