BUGFIX: removed requirement of settings

This commit is contained in:
Will Rossiter 2010-12-03 14:16:35 +13:00
parent f0b544e50a
commit c6f619b0dc
2 changed files with 8 additions and 45 deletions

View File

@ -36,8 +36,14 @@ class Commenting {
* @param string classname to add commenting to
* @param array $setting Settings. See {@link self::$default_config} for
* available settings
*
* @throws InvalidArgumentException
*/
public static function add($class, array $settings) {
public static function add($class, $settings = false) {
if($settings && !is_array($settings)) {
throw new InvalidArgumentException('$settings needs to be an array or null', E_USER_ERROR);
}
self::$enabled_classes[$class] = $settings;
Object::add_extension($class, 'CommentsExtension');

View File

@ -66,26 +66,6 @@ class CommentInterface extends RequestHandler {
return $form;
}
function Comments() {
// Comment limits
$limit = array();
$limit['start'] = isset($_GET['commentStart']) ? (int)$_GET['commentStart'] : 0;
$limit['limit'] = Comment::$comments_per_page;
$spamfilter = isset($_GET['showspam']) ? '' : "AND \"IsSpam\" = 0";
$unmoderatedfilter = Permission::check('CMS_ACCESS_CommentAdmin') ? '' : "AND \"NeedsModeration\" = 0";
$order = self::$order_comments_by;
$comments = DataObject::get("Comment", "\"ParentID\" = '" . Convert::raw2sql($this->page->ID) . "' $spamfilter $unmoderatedfilter", $order, "", $limit);
if(is_null($comments)) {
return;
}
// This allows us to use the normal 'start' GET variables as well (In the weird circumstance where you have paginated comments AND something else paginated)
$comments->setPaginationGetVar('commentStart');
return $comments;
}
function CommentRssLink() {
return Director::absoluteBaseURL() . "Comment/rss?pageid=" . $this->page->ID;
@ -100,27 +80,4 @@ class CommentInterface extends RequestHandler {
return Director::absoluteBaseURL() . "Comment/deleteallcomments?pageid=" . $this->page->ID;
}
}
}
/**
* @package comments
*/
class CommentInterface_Form extends Form {
}
/**
* @package comments
*/
class CommentInterface_Controller extends ContentController {
function __construct() {
parent::__construct(null);
}
function newspamquestion() {
if(Director::is_ajax()) {
echo Convert::raw2xml(sprintf(_t('CommentInterface_Controller.SPAMQUESTION', "Spam protection question: %s"),MathSpamProtection::getMathQuestion()));
}
}
}