3.1 compat

This commit is contained in:
Ingo Schommer 2013-04-11 14:23:03 +02:00
parent 3b251c5627
commit ea3fc6ad2b
5 changed files with 20 additions and 24 deletions

View File

@ -7,13 +7,13 @@
*/ */
class CommentAdmin extends LeftAndMain { class CommentAdmin extends LeftAndMain {
public static $url_segment = 'comments'; private static $url_segment = 'comments';
public static $url_rule = '/$Action'; private static $url_rule = '/$Action';
public static $menu_title = 'Comments'; private static $menu_title = 'Comments';
public static $allowed_actions = array( private static $allowed_actions = array(
'approvedmarked', 'approvedmarked',
'deleteall', 'deleteall',
'deletemarked', 'deletemarked',

View File

@ -6,7 +6,7 @@
class CommentingController extends Controller { class CommentingController extends Controller {
public static $allowed_actions = array( private static $allowed_actions = array(
'delete', 'delete',
'spam', 'spam',
'ham', 'ham',

View File

@ -7,7 +7,7 @@
*/ */
class Comment extends DataObject { class Comment extends DataObject {
public static $db = array( private static $db = array(
"Name" => "Varchar(200)", "Name" => "Varchar(200)",
"Comment" => "Text", "Comment" => "Text",
"Email" => "Varchar(200)", "Email" => "Varchar(200)",
@ -19,27 +19,27 @@ class Comment extends DataObject {
'AllowHtml' => "Boolean" 'AllowHtml' => "Boolean"
); );
public static $has_one = array( private static $has_one = array(
"Author" => "Member" "Author" => "Member"
); );
public static $default_sort = '"Created" DESC'; private static $default_sort = '"Created" DESC';
public static $has_many = array(); private static $has_many = array();
public static $many_many = array(); private static $many_many = array();
public static $defaults = array( private static $defaults = array(
"Moderated" => 1, "Moderated" => 1,
"IsSpam" => 0 "IsSpam" => 0
); );
public static $casting = array( private static $casting = array(
'AuthorName' => 'Varchar', 'AuthorName' => 'Varchar',
'RSSName' => 'Varchar' 'RSSName' => 'Varchar'
); );
public static $searchable_fields = array( private static $searchable_fields = array(
'Name', 'Name',
'Email', 'Email',
'Comment', 'Comment',
@ -47,7 +47,7 @@ class Comment extends DataObject {
'BaseClass', 'BaseClass',
); );
public static $summary_fields = array( private static $summary_fields = array(
'Name' => 'Submitted By', 'Name' => 'Submitted By',
'Email' => 'Email', 'Email' => 'Email',
'Comment' => 'Comment', 'Comment' => 'Comment',

View File

@ -13,19 +13,15 @@ class CommentsExtension extends DataExtension {
* {@link Comment} objects. If the owner class is a sitetree class * {@link Comment} objects. If the owner class is a sitetree class
* it also enables a checkbox allowing comments to be turned off and off * it also enables a checkbox allowing comments to be turned off and off
*/ */
public static function add_to_class($class, $extensionClass, $args = null) { public static function get_extra_config($class, $extension, $args = null) {
Config::inst()->update($class, 'has_many', array( $config = array('has_many' => array('Comments' => 'Comment'));
'Comments' => 'Comment'
));
// if it is attached to the SiteTree then we need to add ProvideComments // if it is attached to the SiteTree then we need to add ProvideComments
if(is_subclass_of($class, 'SiteTree') || $class == 'SiteTree') { if(is_subclass_of($class, 'SiteTree') || $class == 'SiteTree') {
Config::inst()->update($class, 'db', array( $config['db'] = array('ProvideComments' => 'Boolean');
'ProvideComments' => 'Boolean'
));
} }
parent::add_to_class($class, $extensionClass, $args); return $config;
} }

View File

@ -231,7 +231,7 @@ class CommentsTest extends FunctionalTest {
*/ */
class CommentableItem extends DataObject implements TestOnly { class CommentableItem extends DataObject implements TestOnly {
public static $db = array( private static $db = array(
'ProvideComments' => 'Boolean', 'ProvideComments' => 'Boolean',
'Title' => 'Varchar' 'Title' => 'Varchar'
); );