'Taggic',
'email' => 'Taggic@t-online.de',
'date' => '2016-06-02',
'name' => 'rater (action plugin component)',
'desc' => 'to store votes and display feedback.',
'url' => 'http://www.dokuwiki.org/plugin:rater',
);
}
/******************************************************************************
** Register its handlers with the dokuwiki's event controller
*/
function register(Doku_Event_Handler &$controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, '_handle_act', array());
$controller->register_hook('TPL_ACT_UNKNOWN', 'BEFORE', $this, 'output', array());
}
/******************************************************************************
** Handle the action
*/
function _handle_act(&$event, $param) {
if ($event->data === 'rate_voteup') {
$this->raterfile = $_GET['rater_file'];
$this->rater_id = $_GET['rater_id'];
$this->rater_name = $_GET['rater_name'];
$this->rater_ip = $_GET['rater_ip'];
$this->rater_end = $_GET['rater_end'];
$this->anker_id = $_GET['anker'];
$this->vote = 1;
}
elseif ($event->data === 'rate_votedown') {
$this->raterfile = $_GET['rater_file'];
$this->rater_id = $_GET['rater_id'];
$this->rater_name = $_GET['rater_name'];
$this->rater_ip = $_GET['rater_ip'];
$this->rater_end = $_GET['rater_end'];
$this->anker_id = $_GET['anker'];
$this->vote = 2;
}
else return;
$event->preventDefault(); // https://www.dokuwiki.org/devel:events#event_object
}
/******************************************************************************
** Generate output
*/
function output(&$data) {
if (($data->data == 'rate_voteup') && ($this->vote == 1)) {
$data->preventDefault();
$rater_rating = 1;
}
elseif (($data->data == 'rate_votedown') && ($this->vote == 2)) {
$data->preventDefault();
$rater_rating = 2;
}
else { return; }
global $ID;
global $lang;
global $conf;
$rater_type = "vote";
$rater_id = $this->rater_id;
$rater_name = $this->rater_name;
$rater_ip = $this->rater_ip;
$rater_end = $this->rater_end;
$anker_id = $this->anker_id;
// Config settings
$rater_ip_voting_restriction = $this->getConf('voting_restriction'); // restrict ip address voting (true or false)
$rater_ip_vote_qty = $this->getConf('vote_qty'); // how many times an ip address can vote
$rater_already_rated_msg = sprintf($this->getConf('already_rated_msg'),$rater_ip_vote_qty);
$rater_not_selected_msg = $this->getConf('not_selected_msg');
$rater_thankyou_msg = $this->getConf('thankyou_msg');
$rater_generic_text = $this->getConf('generic_text'); // generic item text
$rater_end_of_line_char = $this->getConf('eol_char'); // to separate the records
// msg("eol_char = |".$rater_end_of_line_char."|",0);
if($rater_end_of_line_char == '') $rater_end_of_line_char = '\n';
$msg_votended = $this->getLang('msg_votended');
$alink_Back = $this->getLang('alink_Back');
$today = date('d.m.Y');
//check if vote period already ended
if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
{$rater_endmsg =sprintf($msg_votended,date('d.m.Y',strtotime($rater_end))).'
';
echo '