From 0e4cccb9796b4ff45dc5db2e09e26f1df5a90dcf Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Mon, 25 May 2009 07:00:36 +0000 Subject: [PATCH] Merged from branches/2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@77765 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CommentAdmin.php | 97 ++++++++++++++++++++++--------------------- css/editor.css | 5 ++- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/code/CommentAdmin.php b/code/CommentAdmin.php index bffd2383..ed0b13c9 100644 --- a/code/CommentAdmin.php +++ b/code/CommentAdmin.php @@ -7,9 +7,9 @@ class CommentAdmin extends LeftAndMain { static $url_segment = 'comments'; - + static $url_rule = '/$Action'; - + static $menu_title = 'Comments'; static $allowed_actions = array( @@ -20,40 +20,41 @@ class CommentAdmin extends LeftAndMain { 'showtable', 'spammarked', 'EditForm', + 'unmoderated' ); - + public function init() { parent::init(); - + Requirements::javascript(CMS_DIR . '/javascript/CommentAdmin_right.js'); Requirements::css(CMS_DIR . 'css/CommentAdmin.css'); } - + public function showtable($params) { return $this->getLastFormIn($this->renderWith('CommentAdmin_right')); } - + public function Section() { $url = rtrim($_SERVER['REQUEST_URI'], '/'); if(strrpos($url, '&')) { $url = substr($url, 0, strrpos($url, '&')); } $section = substr($url, strrpos($url, '/') + 1); - + if($section != 'approved' && $section != 'unmoderated' && $section != 'spam') { $section = Session::get('CommentsSection'); } - + if($section != 'approved' && $section != 'unmoderated' && $section != 'spam') { $section = 'approved'; } - + return $section; } - + public function EditForm() { $section = $this->Section(); - + if($section == 'approved') { $filter = "\"IsSpam\"=0 AND \"NeedsModeration\"=0"; $title = "

". _t('CommentAdmin.APPROVEDCOMMENTS', 'Approved Comments')."

"; @@ -64,27 +65,27 @@ class CommentAdmin extends LeftAndMain { $filter = '"IsSpam"'; $title = "

"._t('CommentAdmin.SPAM', 'Spam')."

"; } - + $filter .= ' AND "ParentID">0'; - + $tableFields = array( "Name" => _t('CommentAdmin.AUTHOR', 'Author'), "Comment" => _t('CommentAdmin.COMMENT', 'Comment'), "Parent.Title" => _t('CommentAdmin.PAGE', 'Page'), "CommenterURL" => _t('CommentAdmin.COMMENTERURL', 'URL'), "Created" => _t('CommentAdmin.DATEPOSTED', 'Date Posted') - ); - + ); + $popupFields = new FieldSet( new TextField('Name', _t('CommentAdmin.NAME', 'Name')), new TextField('CommenterURL', _t('CommentAdmin.COMMENTERURL', 'URL')), new TextareaField('Comment', _t('CommentAdmin.COMMENT', 'Comment')) ); - + $idField = new HiddenField('ID', '', $section); $table = new CommentTableField($this, "Comments", "PageComment", $section, $tableFields, $popupFields, array($filter)); $table->setParentClass(false); - + $fields = new FieldSet( new TabSet( 'Root', new Tab(_t('CommentAdmin.COMMENTS', 'Comments'), @@ -94,37 +95,37 @@ class CommentAdmin extends LeftAndMain { ) ) ); - + $actions = new FieldSet(); - + if($section == 'unmoderated') { $actions->push(new FormAction('acceptmarked', _t('CommentAdmin.ACCEPT', 'Accept'))); } - + if($section == 'approved' || $section == 'unmoderated') { $actions->push(new FormAction('spammarked', _t('CommentAdmin.SPAMMARKED', 'Mark as spam'))); } - + if($section == 'spam') { $actions->push(new FormAction('hammarked', _t('CommentAdmin.MARKASNOTSPAM', 'Mark as not spam'))); } - + $actions->push(new FormAction('deletemarked', _t('CommentAdmin.DELETE', 'Delete'))); - + if($section == 'spam') { $actions->push(new FormAction('deleteall', _t('CommentAdmin.DELETEALL', 'Delete All'))); } - + $form = new Form($this, "EditForm", $fields, $actions); - + return $form; } - + function deletemarked() { $numComments = 0; $folderID = 0; $deleteList = ''; - + if($_REQUEST['Comments']) { foreach($_REQUEST['Comments'] as $commentid) { $comment = DataObject::get_by_id('PageComment', $commentid); @@ -136,21 +137,21 @@ class CommentAdmin extends LeftAndMain { } else { user_error("No comments in $commentList could be found!", E_USER_ERROR); } - + echo <<Count(); - + foreach($spam as $comment) { $comment->delete(); } @@ -161,14 +162,14 @@ JS; $('Form_EditForm').getPageFromServer($('Form_EditForm_ID').value); statusMessage("$msg"); JS; - + } - + function spammarked() { $numComments = 0; $folderID = 0; $deleteList = ''; - + if($_REQUEST['Comments']) { foreach($_REQUEST['Comments'] as $commentid) { $comment = DataObject::get_by_id('PageComment', $commentid); @@ -176,13 +177,13 @@ JS; $comment->IsSpam = true; $comment->NeedsModeration = false; $comment->write(); - + if(SSAkismet::isEnabled()) { try { $akismet = new SSAkismet(); $akismet->setCommentAuthor($comment->getField('Name')); $akismet->setCommentContent($comment->getField('Comment')); - + $akismet->submitSpam(); } catch (Exception $e) { // Akismet didn't work, most likely the service is down. @@ -194,7 +195,7 @@ JS; } else { user_error("No comments in $commentList could be found!", E_USER_ERROR); } - + $msg = sprintf(_t('CommentAdmin.MARKEDSPAM', 'Marked %s comments as spam.'), $numComments); echo <<IsSpam = false; $comment->NeedsModeration = false; $comment->write(); - + if(SSAkismet::isEnabled()) { try { $akismet = new SSAkismet(); $akismet->setCommentAuthor($comment->getField('Name')); $akismet->setCommentContent($comment->getField('Comment')); - + $akismet->submitSpam(); } catch (Exception $e) { // Akismet didn't work, most likely the service is down. } } - + $numComments++; } } } else { user_error("No comments in $commentList could be found!", E_USER_ERROR); } - + $msg = sprintf(_t('CommentAdmin.MARKEDNOTSPAM', 'Marked %s comments as not spam.'), $numComments); echo <<value(); } - + /** * Return the number of comments marked as spam */ diff --git a/css/editor.css b/css/editor.css index 71863561..2554d353 100644 --- a/css/editor.css +++ b/css/editor.css @@ -10,10 +10,13 @@ body.mceContentBody { min-height: 200px; font-size: 62.5%; } + +/* body.mceContentBody a.broken { background-color: #FF7B71; border: 1px red solid; color: #fff; padding: 1px; text-decoration: underline; -} \ No newline at end of file +} +*/ \ No newline at end of file