diff --git a/_config.php b/_config.php index 85a71c9..1071adc 100644 --- a/_config.php +++ b/_config.php @@ -26,6 +26,6 @@ * consult the Commenting class. */ -if(class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) { +if(Config::inst()->get('Commenting', 'sitetree_comments') && class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) { Commenting::add('SiteTree'); -} \ No newline at end of file +} diff --git a/code/Commenting.php b/code/Commenting.php index 2ea6827..affeb04 100644 --- a/code/Commenting.php +++ b/code/Commenting.php @@ -13,12 +13,18 @@ */ class Commenting { - + /** * @var array map of enabled {@link DataObject} and related configuration */ private static $enabled_classes = array(); - + + /** + * @config + * @var bool Whether to enable commenting on SiteTree objects by default + */ + private static $sitetree_comments = true; + /** * @var array default configuration values */ diff --git a/code/extensions/CommentsExtension.php b/code/extensions/CommentsExtension.php index baffb25..53065db 100644 --- a/code/extensions/CommentsExtension.php +++ b/code/extensions/CommentsExtension.php @@ -107,17 +107,17 @@ class CommentsExtension extends DataExtension { // do not include the comments on pages which don't have id's such as security pages if($this->owner->ID < 0) return false; - - $controller = new CommentingController(); + + $controller = CommentingController::create(); $controller->setOwnerRecord($this->owner); $controller->setBaseClass($this->ownerBaseClass); $controller->setOwnerController(Controller::curr()); $moderatedSubmitted = Session::get('CommentsModerated'); Session::clear('CommentsModerated'); - + $form = ($enabled) ? $controller->CommentsForm() : false; - + // a little bit all over the show but to ensure a slightly easier upgrade for users // return back the same variables as previously done in comments return $interface->process(new ArrayData(array(