Adapt basics of Spamblock Bayes for 2.0 backend.

This takes care of things emitted to the backend, but not to the
backend section generated by the plugin like spamblock actions and
messages.
This commit is contained in:
Matthias Mees 2014-06-02 20:11:44 +02:00
parent 5a88f424cd
commit ac3053214f

View file

@ -1150,29 +1150,54 @@ class serendipity_event_spamblock_bayes extends serendipity_event {
$comment[$this->type['body']] = $comment['fullBody']; $comment[$this->type['body']] = $comment['fullBody'];
unset($comment['fullBody']); unset($comment['fullBody']);
$eventData['action_more'] = '<a id="ham'. $comment ['id'] .'" if ($serendipity['version'][0] == '1') {
class="serendipityIconLink spamblockBayesControls" $eventData['action_more'] = '<a id="ham'. $comment ['id'] .'"
onclick="return ham('. $comment ['id'].');" class="serendipityIconLink spamblockBayesControls"
title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME . ': ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_HAM .'" onclick="return ham('. $comment ['id'].');"
href="'. $serendipity['baseURL'] . 'index.php?/plugin/learnAction&action=approve&category=ham&id=' . $eventData['id'] . '&entry_id='. $eventData['entry_id'] . '" title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME . ': ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_HAM .'"
><img href="'. $serendipity['baseURL'] . 'index.php?/plugin/learnAction&action=approve&category=ham&id=' . $eventData['id'] . '&entry_id='. $eventData['entry_id'] . '"
src="'. serendipity_getTemplateFile ( 'admin/img/accept.png' ) .'" ><img
alt="" />'. PLUGIN_EVENT_SPAMBLOCK_BAYES_HAM.'</a> <a src="'. serendipity_getTemplateFile ( 'admin/img/accept.png' ) .'"
id="spam'. $comment ['id'].'" alt="" />'. PLUGIN_EVENT_SPAMBLOCK_BAYES_HAM.'</a> <a
class="serendipityIconLink spamblockBayesControls" id="spam'. $comment ['id'].'"
onclick="return spam('. $comment ['id'] .');" class="serendipityIconLink spamblockBayesControls"
title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME . ': ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_SPAM .'" onclick="return spam('. $comment ['id'] .');"
href="'. $serendipity['baseURL'] . 'index.php?/plugin/learnAction&action=delete&category=spam&id=' . $eventData['id'] . '&entry_id='. $eventData['entry_id'] . '" title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME . ': ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_SPAM .'"
><img href="'. $serendipity['baseURL'] . 'index.php?/plugin/learnAction&action=delete&category=spam&id=' . $eventData['id'] . '&entry_id='. $eventData['entry_id'] . '"
src="'. $imgpath . 'spamblock_bayes.spam.png' .'" ><img src="'. $imgpath . 'spamblock_bayes.spam.png' .'" alt="" />'. PLUGIN_EVENT_SPAMBLOCK_BAYES_SPAM.'</a>
alt="" />'. PLUGIN_EVENT_SPAMBLOCK_BAYES_SPAM.'</a> <span class="spamblockBayesRating">
<span class="spamblockBayesRating"> <a href="serendipity_admin.php?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=spamblock_bayes&amp;serendipity[subpage]=4&amp;serendipity[comments]['.$comment['id'].']">
<a href="serendipity_admin.php?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=spamblock_bayes&amp;serendipity[subpage]=4&amp;serendipity[comments]['.$comment['id'].']"> <span id="'. $comment ['id'] .'_rating">'. preg_replace('/\..*/', '', $this->startClassify($comment) * 100) .'%</span>
<span id="'. $comment ['id'] .'_rating">'. preg_replace('/\..*/', '', $this->startClassify($comment) * 100) .'%</span> </a>
</a> <img src="'.serendipity_getTemplateFile ('admin/img/admin_msg_note.png').'" title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_RATING_EXPLANATION.'" />
<img src="'.serendipity_getTemplateFile ('admin/img/admin_msg_note.png').'" title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_RATING_EXPLANATION.'" /> </span>
</span> ';
'; } else {
$eventData['action_more'] = '<ul id="bayes_actions" class="plainList clearfix actions">
<li>
<a id="ham'. $comment ['id'] .'"
class="button_link spamblockBayesControls"
onclick="return ham('. $comment ['id'].');"
title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME . ': ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_HAM .'"
href="'. $serendipity['baseURL'] . 'index.php?/plugin/learnAction&action=approve&category=ham&id=' . $eventData['id'] . '&entry_id='. $eventData['entry_id'] . '"
><span class="icon-ok-circled"></span><span class="visuallyhidden"> ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_HAM .'</span></a>
</li>
<li>
<a id="spam'. $comment ['id'].'"
class="button_link spamblockBayesControls"
onclick="return spam('. $comment ['id'] .');"
title="'. PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME . ': ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_SPAM .'"
href="'. $serendipity['baseURL'] . 'index.php?/plugin/learnAction&action=delete&category=spam&id=' . $eventData['id'] . '&entry_id='. $eventData['entry_id'] . '"
><span class="icon-cancel"></span><span class="visuallyhidden"> ' . PLUGIN_EVENT_SPAMBLOCK_BAYES_SPAM .'</span></a>
</li>
<li class="bayes_spamrating">
<a href="serendipity_admin.php?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=spamblock_bayes&amp;serendipity[subpage]=4&amp;serendipity[comments]['.$comment['id'].']" title="' . PLUGIN_EVENT_SPAMBLOCK_BAYES_RATING_EXPLANATION .'">
<span id="' . $comment ['id'] . '_rating"> ' . preg_replace('/\..*/', '', $this->startClassify($comment) * 100) . '%</span>
</a>
</li>
</ul>
';
}
return true; return true;
break; break;
@ -1265,13 +1290,25 @@ class serendipity_event_spamblock_bayes extends serendipity_event {
} }
global $serendipity; global $serendipity;
if (isset($serendipity['GET']['message'])) { if (isset($serendipity['GET']['message'])) {
echo '<p class="serendipityAdminMsgNote">'.htmlspecialchars($serendipity['GET']['message']).'</p>'; if ($serendipity['version'][0] == '1') {
echo '<p class="serendipityAdminMsgNote">'.htmlspecialchars($serendipity['GET']['message']).'</p>';
} else {
echo '<span class="msg_notice"><span class="icon-info-circled"></span> ' . htmlspecialchars($serendipity['GET']['message']) . '</span>';
}
} }
if (isset($serendipity['GET']['success'])) { if (isset($serendipity['GET']['success'])) {
echo '<p class="serendipityAdminMsgSuccess">'.htmlspecialchars($serendipity['GET']['success']).'</p>'; if ($serendipity['version'][0] == '1') {
echo '<p class="serendipityAdminMsgSuccess">'.htmlspecialchars($serendipity['GET']['success']).'</p>';
} else {
echo '<span class="msg_success"><span class="icon-ok-circled"></span> ' . htmlspecialchars($serendipity['GET']['success']) . '</span>';
}
} }
if (isset($serendipity['GET']['error'])) { if (isset($serendipity['GET']['error'])) {
echo '<p class="serendipityAdminMsgError">'.htmlspecialchars($serendipity['GET']['error']).'</p>'; if ($serendipity['version'][0] == '1') {
echo '<p class="serendipityAdminMsgError">'.htmlspecialchars($serendipity['GET']['error']).'</p>';
} else {
echo '<span class="msg_error"><span class="icon-attention-circled"></span> ' . htmlspecialchars($serendipity['GET']['error']) . '</span>';
}
} }
$this->get = $serendipity['GET']; $this->get = $serendipity['GET'];