** currently not working for new versions of jckeditor, possibly because the config.js is not getting read **
This prevents code stripping or manipulation of code between the geshibot tags (using curly braces) in CKeditor WYSIWYG. (or anyother specified tag)
{code class="brush: text"}CKEDITOR.config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP Code CKEDITOR.config.protectedSource.push( //g ); // ASP Code CKEDITOR.config.protectedSource.push( /(]+>[\s|\S]*?<\/asp:[^\>]+>)|(]+\/>)/gi ); // ASP.Net Code{/code}
Firstly make sure you have set Joomla's whitelist/blacklist thing properly as descibed in this article.
j1.5 http://docs.joomla.org/Why_does_some_HTML_get_removed_from_articles_in_version_1.5.8%3F
j2.5
The easiest way of checking this is to turn off your editor, paste some code in, save the article and see if joomla has stripped the code out.
Next choose CKditor as your WYSIWYG, install if needed.
To prevent any code in between the geshibot tags being stripped out we need to add some code to
/plugins/editors/jckeditor/config.js - if it does not exist create one
The config.js by default is very empty and will probably look like the following:
{code class="brush: text"}/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = 'fr'; // config.uiColor = '#AADC6E'; };{/code}Add these following lines:
These 2 lines will prevent the html entities being escaped or altered. I have added them because someone else thought it would be a good idea and in the CKeditor plugin config these cannot be set. These might not be required to prevent code stripping.
{code class="brush: text"}config.htmlEncodeOutput = false; config.entities = false;{/code}
These lines prevent anything that matches their RegEx being touched. In this case anything in between geshibot or code tags using curly braces.
{code class="brush: text"}config.protectedsource.push( /{code[\s\S]*?}[\s\S]*?{\/code}/g ) ; // Protects all code between code tag config.protectedsource.push( /{geshibot[\s\S]*?}[\s\S]*?{\/geshibot}/g ) ; // Protects all code between GESHI tags {/code}
The final code should look like:
{code class="brush: text"}/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = 'fr'; // config.uiColor = '#AADC6E'; // The following work outside this function config.htmlEncodeOutput = false; config.entities = false; config.protectedsource.push( /{code[\s\S]*?}[\s\S]*?{\/code}/g ) ; // Protects all code between code tag config.protectedsource.push( /{geshibot[\s\S]*?}[\s\S]*?{\/geshibot}/g ) ; // Protects all code between GESHI tags };{/code}
NB: The following examples and the addtional lines above apear to work outside of the config function.
{code class="brush: text"}config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP Code config.protectedSource.push( //g ); // ASP Code config.protectedSource.push( /(]+>[\s|\S]*?<\/asp:[^\>]+>)|(]+\/>)/gi ); // ASP.Net Code{/code}
and possibly this syntax variation might work:
{code class="brush: text"}CKEDITOR.config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP Code CKEDITOR.config.protectedSource.push( //g ); // ASP Code CKEDITOR.config.protectedSource.push( /(]+>[\s|\S]*?<\/asp:[^\>]+>)|(]+\/>)/gi ); // ASP.Net Code{/code}
Save file, empty you browser cache to make sure nothing is left. CKeditor will now leave all code between the geshibot tags alone.
This code will allow you to specify the parameters of Geshibot in the first bracket aswell.
Please note, when you uninstall or upgrade this change will dissapear and will have to mod the file again. Also, the geshibot tags and the code between it will only be visible on the source page.
This technique can be used to protect other needed tags for CKeditor.
My sample config.js that i am using
{code class="brush: text"}/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = 'fr'; // config.uiColor = '#AADC6E'; // spell check as you type // config.scayt_autoStartup = true; // Whether the editor must output an empty value, if it's contents is made by an empty paragraph only. default is true // config.ignoreEmptyParagraph = false; // Whether to escape HTML when the editor updates the original input element, default value false config.htmlEncodeOutput = false; // Note: option now available in version 3.4.1 and will override this setting - does not affect protected storage config.entities = false; // Protects all code between code tag config.protectedSource.push( /{code[\s\S]*?}[\s\S]*?{\/code}/g ); // Protects all code between GESHI tags config.protectedSource.push( /{geshibot[\s\S]*?}[\s\S]*?{\/geshibot}/g ); // Whether to escape basic HTML entities in the document, default value true config.basicEntities = false; };{/code}