[pLog-svn] r1125 - in plugins/trunk/karma: . class class/action
class/karma class/view locale templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Fri Feb 18 09:37:47 GMT 2005
Author: mark
Date: 2005-02-18 09:37:47 +0000 (Fri, 18 Feb 2005)
New Revision: 1125
Added:
plugins/trunk/karma/class/view/
plugins/trunk/karma/class/view/adminkarmapluginsettingsview.class.php
plugins/trunk/karma/locale/locale_zh_TW.php
Removed:
plugins/trunk/karma/class/dao/
Modified:
plugins/trunk/karma/class/action/adminkarmapluginsettingsaction.class.php
plugins/trunk/karma/class/action/adminkarmapluginupdatesettingsaction.class.php
plugins/trunk/karma/class/action/karmarateaction.class.php
plugins/trunk/karma/class/action/viewmoderateddownaction.class.php
plugins/trunk/karma/class/action/viewmoderateddownarticleaction.class.php
plugins/trunk/karma/class/karma/karmalib.class.php
plugins/trunk/karma/locale/locale_en_UK.php
plugins/trunk/karma/pluginkarma.class.php
plugins/trunk/karma/templates/moderateddownlist.template
plugins/trunk/karma/templates/pluginsettings.template
Log:
Almost complete.
1. Refine locales
2. Refine moderateddownlist
Finally, I know how to use plugintemplatedview(), I think I can apply this to flickr/delicious and authimage.
Modified: plugins/trunk/karma/class/action/adminkarmapluginsettingsaction.class.php
===================================================================
--- plugins/trunk/karma/class/action/adminkarmapluginsettingsaction.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/class/action/adminkarmapluginsettingsaction.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -1,7 +1,7 @@
<?php
include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/karma/class/view/adminkarmapluginsettingsview.class.php" );
class AdminKarmaPluginSettingsAction extends BlogOwnerAdminAction
{
@@ -20,18 +20,11 @@
*/
function perform()
{
- $this->_view = new AdminPluginTemplatedView( $this->_blogInfo, "karma", "pluginsettings" );
- // export the current settings to the view
- $this->_view->setValue( "pluginEnabled", $this->_blogSettings->getValue( "plugin_karma_enabled" ));
- $this->_view->setValue( "disableNegative", $this->_blogSettings->getValue( "plugin_karma_disable_negative_articles" ));
- $this->_view->setValue( "negativeThreshold", $this->_blogSettings->getValue( "plugin_karma_negative_threshold" ));
- $this->_view->setValue( "trackVoters", $this->_blogSettings->getValue( "plugin_karma_track_voters" ));
- $this->_view->setValue( "scoring", $this->_blogSettings->getValue( "plugin_karma_scoring_coefficient" ));
- $this->_view->setValue( "minVotes", $this->_blogSettings->getValue( "plugin_karma_minimum_amount_votes" ));
- $this->setCommonData();
-
- // better to return true if everything fine
- return true;
+ $this->_view = new AdminKarmaPluginSettingsView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
}
}
?>
Modified: plugins/trunk/karma/class/action/adminkarmapluginupdatesettingsaction.class.php
===================================================================
--- plugins/trunk/karma/class/action/adminkarmapluginupdatesettingsaction.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/class/action/adminkarmapluginupdatesettingsaction.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -1,12 +1,11 @@
<?php
include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
- include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/karma/class/view/adminkarmapluginsettingsview.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/karma/class/karma/karmalib.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/customfields/customfield.class.php" );
- include_once( PLOG_CLASS_PATH."plugins/karma/class/karma/karmalib.class.php" );
class AdminKarmaPluginUpdateSettingsAction extends BlogOwnerAdminAction
{
@@ -16,7 +15,6 @@
var $_negativeThreshold;
var $_trackVoters;
var $_scoringCoefficient;
- var $_minimumVotes;
/**
* Constructor. If nothing else, it also has to call the constructor of the parent
@@ -39,6 +37,10 @@
// get the parameters from the request
$this->_disablePosts = $this->_request->getValue( "disableNegative" );
$this->_negativeThreshold = $this->_request->getValue( "negativeThreshold" );
+ $val2 = new IntegerValidator();
+ if( !$val2->validate( $this->_negativeThreshold ) || $this->_negativeThreshold < 0 )
+ $this->_negativeThreshold = PLUGIN_KARMA_DEFAULT_NEGATIVE_THRESHOLD;
+
$this->_trackVoters = $this->_request->getValue( "trackVoters" );
// check the scoring coefficient
@@ -47,13 +49,6 @@
if( !$val->validate( $this->_scoringCoefficient ) || $this->_scoringCoefficient < 0 )
$this->_scoringCoefficient = PLUGIN_KARMA_DEFAULT_COEFFICIENT;
- // check the minimum amount of points needed before the algorithm kicks in
- // and starts disabling articles :)
- $this->_minimumVotes = $this->_request->getValue( "minVotes" );
- $val2 = new IntegerValidator();
- if( !$val2->validate( $this->_minimumVotes ) || $this->_minimumVotes < 0 )
- $this->_minimumVotes = PLUGIN_KARMA_DEFAULT_MIN_VOTES;
-
return true;
}
@@ -70,7 +65,7 @@
// check if the checkbox fields exists
if( !array_key_exists( "positiveKarma", $blogFields )) {
$customPositiveKarma = new CustomField( "positiveKarma",
- "Positive votes (karma)",
+ $this->_locale->tr("positiveKarma_help"),
CUSTOM_FIELD_TEXTBOX,
$this->_blogInfo->getId(),
false,
@@ -87,7 +82,7 @@
// check if the field for the password exists
if( !array_key_exists( "negativeKarma", $blogFields )) {
$customNegativeKarma = new CustomField( "negativeKarma",
- "Negative votes (karma)",
+ $this->_locale->tr("negativeKarma_help"),
CUSTOM_FIELD_TEXTBOX,
$this->_blogInfo->getId(),
false,
@@ -143,17 +138,17 @@
$blogSettings->setValue( "plugin_karma_negative_threshold", $this->_negativeThreshold );
$blogSettings->setValue( "plugin_karma_track_voters", $this->_trackVoters );
$blogSettings->setValue( "plugin_karma_scoring_coefficient", $this->_scoringCoefficient );
- $blogSettings->setValue( "plugin_karma_minimum_amount_votes", $this->_minimumVotes );
$this->_blogInfo->setSettings( $blogSettings );
$blogs = new Blogs();
// update the settings in the db, and make sure that everything went fine
if( !$blogs->updateBlogSettings( $this->_blogInfo->getId(), $this->_blogInfo->getSettings())) {
- $this->_view = new AdminErrorView( $this->_blogInfo );
- $this->_view->setMessage( "There was an error saving the plugin configuration." );
- $this->setCommonData();
- return false;
+ $this->_view = new AdminKarmaPluginSettingsView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
}
// check if the fields already exist and if not, create them
@@ -162,14 +157,18 @@
else
$this->_updateFields();
- $this->_session->setValue( "blogInfo", $this->_blogInfo );
- $this->saveSession();
-
- $this->_view = new AdminMessageView( $this->_blogInfo );
- $this->_view->setMessage( "Plugin settings saved successfully!" );
- $this->setCommonData();
-
- // better to return true if everything fine
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new AdminKarmaPluginSettingsView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("karma_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
return true;
}
}
Modified: plugins/trunk/karma/class/action/karmarateaction.class.php
===================================================================
--- plugins/trunk/karma/class/action/karmarateaction.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/class/action/karmarateaction.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -79,8 +79,8 @@
$blogSettings = $this->_blogInfo->getSettings();
$pluginEnabled = $blogSettings->getValue( "plugin_karma_enabled" );
$pluginTrackVoters = $blogSettings->getValue( "plugin_karma_track_voters" );
- $pluginMinVotes = $blogSettings->getValue( "plugin_karma_minimum_amount_votes" );
- if( $pluginMinVotes == "" ) $pluginMinVotes = PLUGIN_KARMA_DEFAULT_MIN_VOTES;
+ $negativeThreshold = $blogSettings->getValue( "plugin_karma_negative_threshold" );
+ if( $negativeThreshold == "" ) $negativeThreshold = PLUGIN_KARMA_DEFAULT_NEGATIVE_THRESHOLD;
$pluginCoefficient = $blogSettings->getValue( "plugin_karma_scoring_coefficient" );
if( $pluginCoefficient == "" ) $pluginCoefficient = PLUGIN_KARMA_DEFAULT_COEFFICIENT;
// try to record the vote
@@ -135,7 +135,7 @@
// get the score
$positiveScore = $article->getField( "positiveKarma" );
$negativeScore = $article->getField( "negativeKarma" );
- if( KarmaScoreLogic::karmaScore( $positiveScore, $negativeScore, $pluginMinVotes, $pluginCoefficient ) == KARMA_SCORE_MODERATE_DOWN ) {
+ if( KarmaScoreLogic::karmaScore( $positiveScore, $negativeScore, $negativeThreshold, $pluginCoefficient ) == KARMA_SCORE_MODERATE_DOWN ) {
// check if the post has to be moderated down
_debug("moderating down!");
if( $article->getStatus() != POST_STATUS_KARMA_MODERATED_DOWN ) {
@@ -159,10 +159,25 @@
else
BlogController::setForwardAction( "viewModeratedDownArticle" );
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
// and return everything normal
return true;
+ } else {
+ // if moderated down disable, we just need to call the normal view article action
+ BlogController::setForwardAction( "ViewArticle" );
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ // and return everything normal
+ return true;
}
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
return true;
}
}
Modified: plugins/trunk/karma/class/action/viewmoderateddownaction.class.php
===================================================================
--- plugins/trunk/karma/class/action/viewmoderateddownaction.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/class/action/viewmoderateddownaction.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -2,13 +2,14 @@
include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
include_once( PLOG_CLASS_PATH."class/view/defaultview.class.php" );
- include_once( PLOG_CLASS_PATH."class/net/sessioninfo.class.php" );
+ // include_once( PLOG_CLASS_PATH."class/net/sessioninfo.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogsettings.class.php" );
include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/referers.class.php" );
include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php");
/**
* shows all the posts that have been moderated down
Modified: plugins/trunk/karma/class/action/viewmoderateddownarticleaction.class.php
===================================================================
--- plugins/trunk/karma/class/action/viewmoderateddownarticleaction.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/class/action/viewmoderateddownarticleaction.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -38,7 +38,7 @@
{
// fetch the article
$articles = new Articles();
- $articles->_db->debug=true;
+ $articles->_db->debug=false;
$article = $articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId(),
false, -1, -1, -1, POST_STATUS_KARMA_MODERATED_DOWN );
@@ -48,11 +48,11 @@
return false;
}
- $nextArticle = $articles->getBlogNextArticle( $article->getId(), $this->_blogInfo->getId());
- $prevArticle = $articles->getBlogPrevArticle( $article->getId(), $this->_blogInfo->getId());
+ $nextArticle = $articles->getBlogNextArticle( $article );
+ $prevArticle = $articles->getBlogPrevArticle( $article );
$blogSettings = $this->_blogInfo->getSettings();
- $this->_view = new BlogTemplatedView( "postandcomments", $this->_blogInfo );
+ $this->_view = new BlogTemplatedView( $this->_blogInfo , "postandcomments" );
// check if we have to update how many times an article has been read
if( $this->_config->getValue( "update_article_reads" )) {
Modified: plugins/trunk/karma/class/karma/karmalib.class.php
===================================================================
--- plugins/trunk/karma/class/karma/karmalib.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/class/karma/karmalib.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -5,11 +5,13 @@
include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
include_once( PLOG_CLASS_PATH."debug.php" );
- define( "PLUGIN_KARMA_DEFAULT_MIN_VOTES", 3 );
+ define( "PLUGIN_KARMA_DEFAULT_NEGATIVE_THRESHOLD", 3 );
define( "PLUGIN_KARMA_DEFAULT_COEFFICIENT", 1.5 );
define( "KARMA_SCORE_MODERATE_DOWN", 1 );
define( "KARMA_SCORE_MODERATE_UP", 2 );
+ define( "DEBUG_ENABLED", false );
+
/**
* encapsulates the scoring logic
*
@@ -24,17 +26,17 @@
*
* @param positiveKarma
* @param negativeKarma
- * @param minNumVotes
+ * @param negativeThreshold
* @param coef
* @returns KARMA_SCORE_MODERATE_DOWN if the post should be moderated down,
* KARMA_SCORE_MODERATE_UP if the post should be moderated up.
*/
- function karmaScore( $positiveKarma, $negativeKarma, $minNumVotes = PLUGIN_KARMA_DEFAULT_MIN_VOTES, $coef = PLUGIN_KARMA_DEFAULT_COEFFICIENT )
+ function karmaScore( $positiveKarma, $negativeKarma, $negativeThreshold = PLUGIN_KARMA_DEFAULT_NEGATIVE_THRESHOLD, $coef = PLUGIN_KARMA_DEFAULT_COEFFICIENT )
{
// the algorithm only starts working when we have at least 100 votes
// altogether, or more.
// TODO: This should be made configurable!!
- if( $positiveKarma + $negativeKarma >= $minNumVotes ) {
+ if( $positiveKarma + $negativeKarma >= $negativeThreshold ) {
if( ($coef * $positiveKarma) <= $negativeKarma )
return KARMA_SCORE_MODERATE_DOWN;
else
@@ -194,7 +196,7 @@
$query = "SELECT * FROM ".$this->getPrefix()."karma_voters
WHERE client_ip = '$clientIp' AND
article_id = $articleId";
- $this->_db->debug=true;
+ $this->_db->debug=false;
$result = $this->Execute( $query );
if( !$result )
Added: plugins/trunk/karma/class/view/adminkarmapluginsettingsview.class.php
===================================================================
--- plugins/trunk/karma/class/view/adminkarmapluginsettingsview.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/class/view/adminkarmapluginsettingsview.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -0,0 +1,36 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class AdminKarmaPluginSettingsView extends AdminPluginTemplatedView
+ {
+
+ function AdminKarmaPluginSettingsView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "karma", "pluginsettings" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_karma_enabled" );
+ $disableNegative = $blogSettings->getValue( "plugin_karma_disable_negative_articles" );
+ $negativeThreshold = $blogSettings->getValue( "plugin_karma_negative_threshold" );
+ $trackVoters = $blogSettings->getValue( "plugin_karma_track_voters" );
+ $scoring = $blogSettings->getValue( "plugin_karma_scoring_coefficient" );
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "disableNegative", $disableNegative );
+ $this->setValue( "negativeThreshold", $negativeThreshold );
+ $this->setValue( "trackVoters", $trackVoters );
+ $this->setValue( "scoring", $scoring );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Modified: plugins/trunk/karma/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/karma/locale/locale_en_UK.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/locale/locale_en_UK.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -1,4 +1,30 @@
<?php
+$messages["manageAppearancePlugins"] = "Appearance Management";
+$messages["karmaPluginSettings"] = "Karma";
+$messages["karma"] = "Karma";
+
+$messages["karma_disablenegative"] = "Remove the the moderated down articles from the main page, until they have enough positive karma to be brought back to the main page.";
+$messages["karma_negativethreshold"] = "Minimum amount of negative votes needed to disable an article.";
+$messages["karma_trackvoters"] = "Don't allow users to vote more than once per article.";
+$messages["karma_scoring"] = "How much value do positive votes have compared to negative votes?";
+$messages["karma_plugin_enabled"] = "Enable this plugin";
+$messages["karma_plugin"] = "Karma Plugin";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_disablenegative"] = "Disable Negative";
+$messages["label_negativethreshold"] = "Negative Threshold";
+$messages["label_trackvoters"] = "Track Voters";
+$messages["label_scoring"] = "Scoring";
+
+$messages["negativeKarma_help"] = "Negative Votes";
+$messages["positiveKarma_help"] = "Positive Votes";
+
+$messages["karma_1_times"] = "The Same";
+$messages["karma_1.5_times"] = "50% More";
+$messages["karma_2_times"] ="Twice More";
+
+$messages["karma_settings_saved_ok"] = "karma settings saved successfully!";
+
$messages["post_status_karma_moderated_down"] = "Moderated Down";
-$messages["karmaPluginSettings"] = "Karma";
?>
\ No newline at end of file
Added: plugins/trunk/karma/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/karma/locale/locale_zh_TW.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/locale/locale_zh_TW.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -0,0 +1,30 @@
+<?php
+$messages["manageAppearancePlugins"] = "ç¶²èªå¤è§ç®¡ç";
+$messages["karmaPluginSettings"] = "æç« è©éè¨å®";
+$messages["karma"] = "æç« è©é";
+
+$messages["karma_disablenegative"] = "å¾ç¶²èªä¸»é é¢ç§»é¤ä¸æ¶çæç« ï¼é¤éè½æè¶³å¤ çæ£åè©éæè½ä½¿éç¯æç« å䏿¶";
+$messages["karma_negativethreshold"] = "æç« 䏿¶æéè¦çæå°è² è² åè©é忏ã";
+$messages["karma_trackvoters"] = "ä¸å
許使ç¨è
å°æ¯ä¸ç¯æç« è¶
é䏿¬¡ä»¥ä¸çè©éã";
+$messages["karma_scoring"] = "æ£åè©éèè² åè©éå¨è¨ç®æç« 忏ä¸çæ¬éã";
+$messages["karma_plugin_enabled"] = "åå夿ç¨å¼";
+$messages["karma_plugin"] = "æç« è©é夿ç¨å¼";
+
+$messages["label_configuration"] = "è¨å®";
+$messages["label_enable"] = "åå";
+$messages["label_disablenegative"] = "ééè² åè©é";
+$messages["label_negativethreshold"] = "è² åè©éåæ¸éæª»";
+$messages["label_trackvoters"] = "追蹤使ç¨è
";
+$messages["label_scoring"] = "è©éæ¬é";
+
+$messages["negativeKarma_help"] = "è² åè©å¹åæ¸";
+$messages["positiveKarma_help"] = "æ£åè©é忏";
+
+$messages["karma_1_times"] = "æ£åè©éçå¹å¼èè² åè©éç¸å";
+$messages["karma_1.5_times"] = "æ£åè©éçå¹å¼æ¯è² åè©å¹ç 1.5 å";
+$messages["karma_2_times"] = "æ£åè©éçå¹å¼æ¯è² åè©å¹ç 2 å";
+
+$messages["karma_settings_saved_ok"] = "æç« è©éè¨å®å²åæåã";
+
+$messages["post_status_karma_moderated_down"] = "䏿¶";
+?>
\ No newline at end of file
Modified: plugins/trunk/karma/pluginkarma.class.php
===================================================================
--- plugins/trunk/karma/pluginkarma.class.php 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/pluginkarma.class.php 2005-02-18 09:37:47 UTC (rev 1125)
@@ -12,6 +12,7 @@
*/
class PluginKarma extends PluginBase
{
+ var $pluginEnabled;
function PluginKarma()
{
@@ -20,7 +21,7 @@
$this->id = "karma";
$this->description = "Implements karma rating for posts";
$this->author = "The pLog Team";
- $this->locales = Array( "en_UK" );
+ $this->locales = Array( "en_UK", "zh_TW" );
$this->init();
}
@@ -31,16 +32,27 @@
function init()
{
$this->registerBlogAction( "karmaRate", "KarmaRateAction" );
- $this->registerBlogAction( "viewModeratedDown", "ViewModeratedDownAction" );
+ $this->registerBlogAction( "viewModeratedDown", "ViewModeratedDownAction" );
$this->registerBlogAction( "viewModeratedDownArticle", "ViewModeratedDownArticleAction" );
$this->registerAdminAction( "karmaPluginSettings", "AdminKarmaPluginSettingsAction" );
$this->registerAdminAction( "pluginKarmaUpdateSettings", "AdminKarmaPluginUpdateSettingsAction" );
// add a menu entry
- $this->addMenuEntry( "/menu/controlCenter/manageSettings", "karmaPluginSettings", "admin.php?op=karmaPluginSettings", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/manageSettings", "karmaPluginSettings", "admin.php?op=karmaPluginSettings", "", true, false );
}
+ function register()
+ {
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_karma_enabled" );
+ }
+
+ function isEnabled()
+ {
+ return $this->pluginEnabled;
+ }
+
/**
* returns the correct url to the action that scores the points
*
Modified: plugins/trunk/karma/templates/moderateddownlist.template
===================================================================
--- plugins/trunk/karma/templates/moderateddownlist.template 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/templates/moderateddownlist.template 2005-02-18 09:37:47 UTC (rev 1125)
@@ -1,7 +1,5 @@
-{include file="$admintemplatepath/header.template"}
-{include file="$admintemplatepath/navigation.template" showOpt=Smileys title=$locale->tr("Smileys")}
+{include file="$blogtemplate/header.template"}
{foreach from=$moderateddown item=article}
<a href="{$karma->moderatedDownLink($article)}">{$article->getTopic()}</a><br/>
{/foreach}
-{include file="$admintemplatepath/footernavigation.template"}
-{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
+{include file="$blogtemplate/footer.template"}
\ No newline at end of file
Modified: plugins/trunk/karma/templates/pluginsettings.template
===================================================================
--- plugins/trunk/karma/templates/pluginsettings.template 2005-02-18 07:33:36 UTC (rev 1124)
+++ plugins/trunk/karma/templates/pluginsettings.template 2005-02-18 09:37:47 UTC (rev 1125)
@@ -1,28 +1,59 @@
{include file="$admintemplatepath/header.template"}
-{include file="$admintemplatepath/navigation.template" showOpt=karmaPluginSettings title=$locale->tr("karmaPluginSettings")}
-<p>
-This plugin will allow your visitors to rate your postings. It works by creating two new
-custom fields that will be used to store the positive and negative scores of every post. When the
-number of negative votes goes under a certain threshold, the post status will be set to
-"moderated down" and will not be displayed in the main page anymore.
-</p>
+{include file="$admintemplatepath/navigation.template" showOpt=karmaPluginSettings title=$locale->tr("karma_plugin")}
<form name="pluginKarmaSettings" action="admin.php" method="post">
- <input type="checkbox" name="pluginEnabled" value="1" {if $pluginEnabled}checked="checked"{/if} />
- Enable this plugin.<br/><br/>
- <input type="checkbox" name="disableNegative" value="1" {if $disableNegative}checked="checked"{/if} /> Remove the the moderated down articles from the main page, until they have enough positive karma to be brought back to the main page.<br/><br/>
-Minimum amount of negative votes needed to disable an article:
-<input type="text" name="negativeThreshold" value="{$negativeThreshold}" width="10" /><br/><br/>
-<input type="checkbox" name="trackVoters" value="1" {if $trackVoters}checked="checked"{/if} />
-Don't allow users to vote more than once per article.<br/><br/>
-How much value do positive votes have compared to negative votes?
-<select name="scoring">
- <option value="1" {if $scoring==1}selected="selected"{/if}>The same</option>
- <option value="1.5" {if $scoring==1.5}selected="selected"{/if}>50% more</option>
- <option value="2" {if $scoring==2}selected="selected"{/if}>Twice more valuable</option>
-</select>
-<br/><br/>
- <input type="hidden" name="op" value="pluginKarmaUpdateSettings" />
- <input type="submit" name="{$locale->tr("update")}" value="{$locale->tr("update")}" />
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("karma_plugin_enabled")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="disableNegative">{$locale->tr("label_disablenegative")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="disableNegative" id="disableNegative" {if $disableNegative} checked="checked" {/if} value="1" />{$locale->tr("karma_disablenegative")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="negativeThreshold">{$locale->tr("label_negativethreshold")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("karma_negativethreshold")}</div>
+ <input class="text" type="text" name="negativeThreshold" id="negativeThreshold" value="{$negativeThreshold}" width="10" />
+ </div>
+
+ <div class="field">
+ <label for="trackVoters"">{$locale->tr("label_trackvoters")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="trackVoters"" id="trackVoters"" {if $trackVoters} checked="checked" {/if} value="1" />{$locale->tr("karma_trackvoters")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="scoring">{$locale->tr("label_scoring")}</label>
+ <span class="required"></span>
+ <div class="formHelp">{$locale->tr("karma_scoring")}</div>
+ <select name="scoring" id="scoring">
+ <option value="1" {if $scoring==1}selected="selected"{/if}>{$locale->tr("karma_1_times")}</option>
+ <option value="1.5" {if $scoring==1.5}selected="selected"{/if}>{$locale->tr("karma_1.5_times")}</option>
+ <option value="2" {if $scoring==2}selected="selected"{/if}>{$locale->tr("karma_2_times")}</option>
+ </select>
+ </div>
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="pluginKarmaUpdateSettings" />
+ <input type="reset" name="{$locale->tr("reset")}" />
+ <input type="submit" name="{$locale->tr("update")}" value="{$locale->tr("update")}" />
+ </div>
</form>
{include file="$admintemplatepath/footernavigation.template"}
{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list