2010-11-29 23:24:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Comment administration system within the CMS
|
|
|
|
*
|
|
|
|
* @package comments
|
|
|
|
*/
|
|
|
|
class CommentAdmin extends LeftAndMain {
|
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $url_segment = 'comments';
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $url_rule = '/$Action';
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $menu_title = 'Comments';
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2013-04-11 14:23:03 +02:00
|
|
|
private static $allowed_actions = array(
|
2010-11-29 23:24:17 +01:00
|
|
|
'approvedmarked',
|
|
|
|
'deleteall',
|
|
|
|
'deletemarked',
|
|
|
|
'hammarked',
|
|
|
|
'showtable',
|
|
|
|
'spammarked',
|
|
|
|
'EditForm',
|
|
|
|
'unmoderated'
|
|
|
|
);
|
2012-07-22 02:47:59 +02:00
|
|
|
|
2010-11-29 23:24:17 +01:00
|
|
|
/**
|
2012-07-22 02:47:59 +02:00
|
|
|
* @return Form
|
2010-11-29 23:24:17 +01:00
|
|
|
*/
|
2012-06-01 08:34:31 +02:00
|
|
|
public function getEditForm($id = null, $fields = null) {
|
|
|
|
if(!$id) $id = $this->currentPageID();
|
2012-07-22 02:47:59 +02:00
|
|
|
|
2012-06-01 08:34:31 +02:00
|
|
|
$form = parent::getEditForm($id);
|
|
|
|
$record = $this->getRecord($id);
|
2012-07-22 02:47:59 +02:00
|
|
|
|
|
|
|
if($record && !$record->canView()) {
|
|
|
|
return Security::permissionFailure($this);
|
|
|
|
}
|
2012-06-01 08:34:31 +02:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
$commentsConfig = GridFieldConfig::create()->addComponents(
|
|
|
|
new GridFieldFilterHeader(),
|
|
|
|
new GridFieldDataColumns(),
|
|
|
|
new GridFieldSortableHeader(),
|
|
|
|
new GridFieldPaginator(25),
|
|
|
|
new GridFieldDeleteAction(),
|
|
|
|
new GridFieldDetailForm(),
|
|
|
|
new GridFieldExportButton(),
|
|
|
|
new GridFieldEditButton(),
|
|
|
|
new GridFieldDetailForm()
|
|
|
|
);
|
|
|
|
|
|
|
|
$needs = new GridField(
|
|
|
|
'Comments',
|
|
|
|
_t('CommentsAdmin.NeedsModeration', 'Needs Moderation'),
|
2012-12-17 20:53:16 +01:00
|
|
|
Comment::get()->filter('Moderated',0),
|
2012-07-22 02:47:59 +02:00
|
|
|
$commentsConfig
|
|
|
|
);
|
|
|
|
|
|
|
|
$moderated = new GridField(
|
|
|
|
'CommentsModerated',
|
|
|
|
_t('CommentsAdmin.CommentsModerated'),
|
2012-12-17 20:53:16 +01:00
|
|
|
Comment::get()->filter('Moderated',1),
|
2012-07-22 02:47:59 +02:00
|
|
|
$commentsConfig
|
|
|
|
);
|
|
|
|
|
2012-06-01 08:34:31 +02:00
|
|
|
$fields = new FieldList(
|
|
|
|
$root = new TabSet(
|
|
|
|
'Root',
|
2012-07-22 02:47:59 +02:00
|
|
|
new Tab('NeedsModeration', _t('CommentAdmin.NeedsModeration', 'Needs Moderation'),
|
|
|
|
$needs
|
|
|
|
),
|
|
|
|
new Tab('Comments', _t('CommentAdmin.Moderated', 'Moderated'),
|
|
|
|
$moderated
|
2012-06-01 08:34:31 +02:00
|
|
|
)
|
2012-07-22 02:47:59 +02:00
|
|
|
)
|
2012-06-01 08:34:31 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$root->setTemplate('CMSTabSet');
|
|
|
|
|
|
|
|
$actions = new FieldList();
|
|
|
|
|
|
|
|
$form = new Form(
|
|
|
|
$this,
|
|
|
|
'EditForm',
|
|
|
|
$fields,
|
|
|
|
$actions
|
|
|
|
);
|
2012-07-22 02:47:59 +02:00
|
|
|
|
2012-06-01 08:34:31 +02:00
|
|
|
$form->addExtraClass('cms-edit-form');
|
|
|
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
if($form->Fields()->hasTabset()) {
|
|
|
|
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
|
|
|
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
|
2010-12-11 06:33:21 +01:00
|
|
|
}
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
$this->extend('updateEditForm', $form);
|
2010-11-29 23:24:17 +01:00
|
|
|
|
2012-07-22 02:47:59 +02:00
|
|
|
return $form;
|
2010-11-29 23:24:17 +01:00
|
|
|
}
|
|
|
|
}
|