diff --git a/classes/ezcontentobjectakismet.php b/classes/ezcontentobjectakismet.php index 8a8b874..80f2b72 100644 --- a/classes/ezcontentobjectakismet.php +++ b/classes/ezcontentobjectakismet.php @@ -51,6 +51,61 @@ function getInfoExtractor( $contentObjectVersion ) return false; } } + + /*! + \static + Returns an array of class identifiers for which a content object akismet + information extractor is available. + */ + function getExtractableClassList() + { + include_once( 'lib/ezutils/classes/ezini.php' ); + $ini = eZINI::instance( 'akismet.ini' ); + $infoExtractors = $ini->variable( 'InformationExtractorSettings', 'ClassMap' ); + + return array_keys( $infoExtractors ); + } + + /* + \static + Returns an array of nodes for which a content object akismet + information extractor is available. + */ + function getExtractableNodes( $limit = false, $offset = false ) + { + $classList = eZContentObjectAkismet::getExtractableClassList(); + + include_once( 'kernel/classes/ezcontentobjecttreenode.php' ); + $params = array( + 'ClassFilterType' => 'include', + 'ClassFilterArray' => $classList, + 'SortBy' => array( array( 'published', false ) ), + 'Limit' => $limit, + 'Offset' => $offset + ); + + $nodes = eZContentObjectTreeNode::subTree( $params, 1 ); + return $nodes; + } + + /* + \static + Returns the number of nodes for which a content object akismet + information extractor is available. + */ + function getExtractableNodesCount() + { + $classList = eZContentObjectAkismet::getExtractableClassList(); + + include_once( 'kernel/classes/ezcontentobjecttreenode.php' ); + $params = array( + 'ClassFilterType' => 'include', + 'ClassFilterArray' => $classList + ); + + $nodeCount = eZContentObjectTreeNode::subTreeCount( $params, 1 ); + return $nodeCount; + } } ?> \ No newline at end of file diff --git a/design/standard/templates/akismet/submit.tpl b/design/standard/templates/akismet/submit.tpl new file mode 100644 index 0000000..40f732b --- /dev/null +++ b/design/standard/templates/akismet/submit.tpl @@ -0,0 +1,30 @@ +
+ + + + + + +{foreach $nodes as $node sequence array('bglight','bgdark') as $sequence} + + + + + +{/foreach} +
NamePublished
{$node.name|wash}{$node.object.published|l10n( shortdatetime )}
+ +
+ +
+ +
+ +
+{include name=navigator + uri='design:navigator/google.tpl' + page_uri='akismet/submit' + item_count=$nodes_count + view_parameters=$view_parameters + item_limit=$limit} +
diff --git a/modules/akismet/module.php b/modules/akismet/module.php index 7e57216..d1c1ede 100644 --- a/modules/akismet/module.php +++ b/modules/akismet/module.php @@ -3,6 +3,12 @@ $Module = array( 'name' => 'Akismet', 'variable_params' => false, 'ui_component_match' => 'module' ); $ViewList = array(); +$ViewList['submit'] = array( + 'script' => 'submit.php', + 'functions' => array( 'submit' ), + 'single_post_actions' => array( 'SpamSubmitButton' => 'Submit' ), + 'post_action_parameters' => array( 'Submit' => array( 'ObjectIDList' => 'ObjectIDList' ) ) +); $FunctionList = array(); $FunctionList['submit'] = array(); diff --git a/modules/akismet/submit.php b/modules/akismet/submit.php new file mode 100644 index 0000000..427578d --- /dev/null +++ b/modules/akismet/submit.php @@ -0,0 +1,65 @@ +isCurrentAction( 'Submit' ) && $Module->hasActionParameter( 'ObjectIDList' ) ) +{ + $objectIDList = $Module->actionParameter( 'ObjectIDList' ); + + foreach ( $objectIDList as $objectID ) + { + $object = eZContentObject::fetch( $objectID ); + $version = $object->attribute( 'current' ); + + include_once( 'extension/akismet/classes/ezcontentobjectakismet.php' ); + $infoExtractor = eZContentObjectAkismet::getInfoExtractor( $version ); + if ( $infoExtractor ) + { + $comment = $infoExtractor->getCommentArray(); + + eZDebug::writeDebug( $comment ); + + include_once( 'extension/akismet/classes/ezakismet.php' ); + $akismet = new eZAkismet( $comment ); + + if ( !$akismet->errorsExist() ) + { + $response = $akismet->submitSpam(); + eZDebug::writeNotice( $response, 'Akismet web service response' ); + } + else + { + eZDebug::writeWarning( 'An error has occured, unable to submit spam to Akismet.' ); + } + + } + else + { + eZDebug::writeDebug( 'Unable to find Akismet info extractor' ); + } + } +} + +include_once( 'kernel/common/template.php' ); +$tpl =& templateInit(); + +$tpl->setVariable( 'nodes', $extractableNodes ); +$tpl->setVariable( 'nodes_count', $extractableNodesCount ); +$tpl->setVariable( 'limit', $limit ); + +$Result = array(); +$Result['content'] = $tpl->fetch( 'design:akismet/submit.tpl' ); +$Result['path'] = array( + array( 'url' => false, 'text' => 'Akismet' ), + array( 'url' => false, 'text' => 'Submit spam' ) +); + +?> \ No newline at end of file