3 Extension Name: JQE WYSIWYG editor
4 Extension Url: http://vanillaforums.org/get/487
5 Description: Add a WYSIWYG editor to the comment form using Jquery JQE
8 Author Url: stage.nexvision at laposte.net
12 if (!defined('IN_VANILLA')) exit();
13 define('JQE_PATH', dirname(__FILE__
) . '/');
14 require(JQE_PATH
. 'settings.php');
16 require(JQE_PATH
. 'autolink.php');
18 if (!function_exists('kses')) require(JQE_PATH
. 'kses.php');
19 // Check to see if user is allowed to comment
20 $Configuration["JQE_LOGINREQUIRED"] = false; //if u are using Add Comments Extension set this to false
21 if( $Configuration["JQE_LOGINREQUIRED"]===false or $Context->Session
->UserID
> 0 )
23 //If user is allowed to comment then add JQE javasript
24 if ( in_array($Context->SelfUrl
, array("post.php", "comments.php")) )
27 $Head->AddScript('extensions/JQE/jquery.rte.js');
28 $Head->AddStyleSheet('extensions/JQE/rte.css');
31 <script type="text/javascript">
32 jQuery(document).ready(function($){
33 $("#CommentBoxController").hide();
34 $("#CommentFormats").hide();
35 $("#CommentBox").rte({
36 content_css_url: "'. $Context->Configuration
['WEB_ROOT'].'extensions/JQE/rte.css'.'",
37 media_url: "'. $Context->Configuration
['WEB_ROOT'].'extensions/JQE/'.'",
39 $("#abshosturls").rte({
40 content_css_url: "'. $Context->Configuration
['WEB_ROOT'].'extensions/JQE/rte.css'.'",
41 media_url: "'. $Context->Configuration
['WEB_ROOT'].'extensions/JQE/'.'",
51 class JQEFormatter
extends StringFormatter
{
53 var $allowed_protocols;
56 function JQEFormatter($tags, $protocols)
58 $this->allowed_tags
= $tags;
59 $this->allowed_protocols
= $protocols;
60 $this->autolink
= new AutoLinksHelper();
63 function Parse($String, $Object, $FormatPurpose)
65 if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY
)
67 return $this->autolink
->AddLinks(kses($String, $this->allowed_tags
, $this->allowed_protocols
));
73 if ( $Context->Session
->UserID
> 0 && $Context->Session
->User
->Permission('PERMISSION_HTML_ALLOWED') ) {
74 //Make JQE formatter the only formatter available to post a new comment or to edit an old one
75 $Context->Configuration
['DEFAULT_FORMAT_TYPE'] = 'JQE';
76 $Context->Session
->User
->DefaultFormatType
= 'JQE';
77 $Context->Session
->User
->Preferences
['ShowFormatSelector'] = 0;
79 $JQEFormatter = $Context->ObjectFactory
->NewObject($Context, "JQEFormatter", $JQE_allowed_tags, $JQE_allowed_protocols);
80 $Context->StringManipulator
->AddManipulator("JQE", $JQEFormatter);