From 63ff9536d103d42436247d334ec0712a1f72d183 Mon Sep 17 00:00:00 2001 From: Jeremy Shipman Date: Tue, 2 Oct 2007 02:47:02 +0000 Subject: [PATCH] Created the option of having bbcode in comments. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42885 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/sitefeatures/PageComment.php | 17 ++++++++++++++++- code/sitefeatures/PageCommentInterface.php | 1 - templates/PageCommentInterface_singlecomment.ss | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/code/sitefeatures/PageComment.php b/code/sitefeatures/PageComment.php index 330b6dc1..170dae09 100755 --- a/code/sitefeatures/PageComment.php +++ b/code/sitefeatures/PageComment.php @@ -21,6 +21,8 @@ class PageComment extends DataObject { static $moderate = false; + static $bbcode = false; + /** * Return a link to this comment * @return string link to this comment. @@ -28,7 +30,11 @@ class PageComment extends DataObject { function Link() { return $this->Parent()->Link() . '#PageComment_'. $this->ID; } - + + function ParsedBBCode(){ + $parser = new BBCodeParser($this->Comment); + return $parser->parse(); + } function DeleteLink() { if(Permission::check('CMS_ACCESS_CMSMain')) { @@ -185,6 +191,15 @@ class PageComment extends DataObject { static function moderationEnabled() { return self::$moderate; } + + static function enableBBCode() { + self::$bbcode = true; + } + + static function bbCodeEnabled() { + return self::$bbcode; + } + } ?> \ No newline at end of file diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index 78c26540..a6d339bf 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -127,7 +127,6 @@ class PageCommentInterface_Form extends Form { $this->saveInto($comment); $comment->IsSpam = false; $comment->NeedsModeration = PageComment::moderationEnabled(); - $comment->write(); if(Director::is_ajax()) { diff --git a/templates/PageCommentInterface_singlecomment.ss b/templates/PageCommentInterface_singlecomment.ss index 52bc28d4..ad923ec4 100755 --- a/templates/PageCommentInterface_singlecomment.ss +++ b/templates/PageCommentInterface_singlecomment.ss @@ -1,5 +1,9 @@

- $Comment.XML + <% if bbCodeEnabled %> + $ParsedBBCode + <% else %> + $Comment.XML + <% end_if %>

<% _t('PBY','Posted by') %> $Name.XML, $Created.Nice ($Created.Ago)