Ipb 2.1:Using Editors Class
From IpbWiki
IPB 2.1 comes with a handler for displaying a text editor. There are two editors to choose from; Rich Text Editor (WYSIWYG) and a standard BBCode editor. The Rich Text Editor is only available when using IE6, Mozilla and Firefox due to the javascript which controls this editor and the lack of compatibility with other browsers. Safari and Opera are due to add support and the editor classes will be updated when they do.
There are two main functions:
This returns the HTML code for the editor to use in your skins, etc.
This returns the raw post. In the case of the rich text editor, it parses the WYSIWYG HTML into BBCode tags. (For example: Bold becomes Bold) so this function will always return raw BBCode tags.
First off, we include the handler in our script.
// Load and config the std/rte editors
//-----------------------------------------
require_once( ROOT_PATH."sources/handlers/han_editor.php" );
$han_editor = new han_editor();
$han_editor->ipsclass =& $this->ipsclass;
$han_editor->init();
To generate the HTML for the editor:
$raw_post is either raw HTML for the rich text editor or raw BBCode tagged text when using the standard editor. (See the document on the BBCode parser for more information)
'Post' is the name of the form field you wish use. In this case it'll return $_POST['Post'].
To process the editor's text into tagged BBCode text:
'Post' is the name of the form field you used when displaying the editor.
To use the HTML generated by editor class for displaying the actual editor (in our example; $editor_html) you'll need to use it like this:
{$editor_html}
<br /><input type="submit" value="Post" /></div>
</form>
The form tag MUST have: id='postingform' onsubmit='return ValidateForm()' otherwise the editor will fail.
