Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BugFix: Vote details link prevented if tracedetails switched off

Signed-off-by: Taggic <taggic@t-online.de>
  • Loading branch information...
commit ff05883b805e8276f867b932b725cdda8a3b2dfe 1 parent 69905b7
Taggic authored
Showing with 45 additions and 40 deletions.
  1. +1 −1  INFO
  2. +1 −1  VERSION
  3. +19 −22 action.php
  4. +1 −1  plugin.info.txt
  5. +23 −15 syntax.php
2  INFO
View
@@ -2,7 +2,7 @@
author Taggic
email taggic@t-online.de
-date 2011-10-05
+date 2011-12-16
name rater
desc provides a simple star rater
url http://www.dokuwiki.org/plugin:rater
2  VERSION
View
@@ -1 +1 @@
-2011-10-05
+2011-12-16
41 action.php
View
@@ -23,7 +23,7 @@ function getInfo(){
return array(
'author' => 'Taggic',
'email' => 'Taggic@t-online.de',
- 'date' => '2011-09-26',
+ 'date' => '2011-12-16',
'name' => 'rater (action plugin component)',
'desc' => 'to store votes and display feedback.',
'url' => 'http://www.dokuwiki.org/plugin:rater',
@@ -47,15 +47,17 @@ function _handle_act(&$event, $param) {
$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_ip = $_GET['rater_ip'];
$this->rater_end = $_GET['rater_end'];
- $this->vote = 2;
+ $this->anker_id = $_GET['anker'];
+ $this->vote = 2;
}
else return;
@@ -81,16 +83,7 @@ function output(&$data) {
$rater_name = $this->rater_name;
$rater_ip = $this->rater_ip;
$rater_end = $this->rater_end;
-
-/* if (($rater_end!='never') && (date('d.m.Y',strtotime($rater_end))<date('d.m.Y')))
- { $rastr ='<'; }
- elseif (($rater_end!='never') && (date('d.m.Y',strtotime($rater_end))==date('d.m.Y')))
- { $rastr ='='; }
- elseif (($rater_end!='never') && (date('d.m.Y',strtotime($rater_end))>date('d.m.Y')))
- { $rastr ='>'; }
- echo date('d.m.Y',strtotime($rater_end)). $rastr . date('d.m.Y').'<br>'; */
-
-
+ $anker_id = $this->anker_id;
// Config settings
$rater_ip_voting_restriction = $this->getConf('voting_restriction'); // restrict ip address voting (true or false)
@@ -103,20 +96,21 @@ function output(&$data) {
$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') && (date('d.m.Y',strtotime($rater_end))<=date('d.m.Y')))
+ if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
{$rater_endmsg =sprintf($msg_votended,date('d.m.Y',strtotime($rater_end))).'<br>';
- echo $rater_endmsg.'<br><a href="doku.php?id='.$ID.'" />'.$alink_Back.'</a>';
- return;}
+
+ echo '<div class="thumb__negative_feedback">'.$rater_endmsg.
+ '<a href="doku.php?id='.$ID.'" />'.$alink_Back.'</a></div>';
+ return;
+ }
// save vote
$rater_filename = metaFN('rater_'.$rater_id.'_'.$rater_name.'_'.$rater_type, '.rating');
// trace ip or login
-
-
-
$rater_file=fopen($rater_filename,"a+");
$rater_str="";
$rater_str = rtrim(fread($rater_file, 1024*8),$rater_end_of_line_char);
@@ -151,8 +145,11 @@ function output(&$data) {
// reload original page
// $ret .= $rater_msg.'<br><a href="doku.php?id='.$ID.'" />back</a>';
-// echo $ret;
- echo '<meta http-equiv="refresh" content="0; URL=doku.php?id='.$ID.$addMXG.'">';
+ echo '<div class="thumb__positive_feedback">'.$rater_ip.' : '.$rater_msg.'<br />'.
+ '<a href="doku.php?id='.$ID.'" />'.$alink_Back.'</a></div>';
+
+// echo "anker = ".$anker_id.'<br>';
+ echo '<meta http-equiv="refresh" content="0; URL=doku.php?id='.$ID.'#'.$anker_id.'">';
}
/******************************************************************************/
2  plugin.info.txt
View
@@ -3,7 +3,7 @@
base rater
author Taggic
email taggic@t-online.de
-date 2011-10-05
+date 2011-12-16
name rater
desc provides a simple 5 star rater and thumb voting
url http://www.dokuwiki.org/plugin:rater
38 syntax.php
View
@@ -101,7 +101,9 @@ function render($mode, &$renderer, $data) {
$rater_id = $data['rater_id'];
$rater_name = $data['rater_name'];
- if (!isset($data['rater_end'])) $data['rater_end']='never';
+ if (!isset($data['rater_end'])) {$data['rater_end']='never'; $rater_end='never';}
+ else {$rater_end=$data['rater_end'];}
+
if(!isset($data['rater_tracedetails'])) $data['rater_tracedetails']='0';
if(!isset($rater_id)) $rater_id=1;
$rater_item_name = $data['rater_name']; // item name what is to be rated
@@ -117,7 +119,7 @@ function render($mode, &$renderer, $data) {
$rater_rating=0;
$rater_votes=0;
$rater_msg="";
-
+ $today = date('d.m.Y');
// check to trace ip or user name
$user_grp = pageinfo();
$rater_realname = $user_grp['userinfo']['name'];
@@ -192,12 +194,12 @@ function render($mode, &$renderer, $data) {
// Assign star image
$rater_stars = $this->assign_star_image($rater_rating);
$anker_id = 'rateanker_'. uniqid((double)microtime()*1000000,1);
-
+
// build the return value for details
- if (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))>=date('d.m.Y')))
+ if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
{ $ret_details = '<div class="rating__details">'.sprintf($msg_ratingend,date('d.m.Y',strtotime($data['rater_end']))).'<br />';
$alink_Details = '<a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a>'; }
- elseif (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))<date('d.m.Y')))
+ elseif (($rater_end!='never') || (strtotime($today) <= strtotime($rater_end)))
{ $ret_details = '<div class="rating__details">'.sprintf($msg_ratingended,date('d.m.Y',strtotime($data['rater_end']))).'<br />';
$alink_Details = '<a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a>';}
else
@@ -242,7 +244,8 @@ function hidden'.$rater_id.'()
$ret .= '<tr><td style="display : none" id="details_'.$rater_id.'">'.$ret_details.'</td></tr>';
$ret .= '<tr><td>';
- if (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))<date('d.m.Y')))
+
+ if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
{
$rater_msg =''; }
else {
@@ -291,11 +294,12 @@ function hidden'.$rater_id.'()
}
fclose($rater_file);
}
- //check if vote period already ended
- if (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))>=date('d.m.Y')))
- {$rater_endmsg = sprintf($msg_votend,date('d.m.Y',strtotime($data['rater_end']))).'<br />';}
- elseif (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))<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($data['rater_end']))).'<br />';}
+ elseif (($rater_end!='never') || (strtotime($today) <= strtotime($rater_end)))
+ {$rater_endmsg = sprintf($msg_votend,date('d.m.Y',strtotime($data['rater_end']))).'<br />';}
else
{$rater_endmsg ='';}
// build the return value for details if details option is on
@@ -307,7 +311,7 @@ function hidden'.$rater_id.'()
$ret_details .= '</div>';
// Output vote
- $ret .= '<form name="'.$data['rater_id'].$data['rater_name'].$data['rater_type'].'" method="post" action="doku.php?id=' . $ID .'">';
+// $ret .= '<form name="'.$data['rater_id'].$data['rater_name'].$data['rater_type'].'" method="post" action="doku.php?id=' . $ID .'">';
$ret .= '<table class="hreview">';
@@ -331,11 +335,15 @@ function hidden'.$rater_id.'()
$ret .= $addMSG.'<a class="thumbup tup" href="doku.php?id='.$ID.'&do=rate_voteup&rater_id='.$rater_id.'&rater_ip='.$rater_ip.'&rater_end='.$data['rater_end'].'&anker='.$anker_id.'&rater_name='.$rater_name.'"></a>'.
'<span id="vote1_1" style="color:#5b8f22">('.$vote1.')&nbsp;</span>'.
'<a class="thumbdown tdn" href="doku.php?id='.$ID.'&do=rate_votedown&rater_id='.$rater_id.'&rater_ip='.$rater_ip.'&rater_end='.$data['rater_end'].'&anker='.$anker_id.'&rater_name='.$rater_name.'"></a>'.
- '<span id="vote1_2" style="color:#FF1822">('.$vote2.')</span><a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a></td></tr>';
- $ret .= '<tr><td style="display : none" id="details_'.$rater_id.'">'.$ret_details.'</td></tr>';
+ '<span id="vote1_2" style="color:#FF1822">('.$vote2.')</span>';
+ if($data['rater_tracedetails']==='1') {
+ $ret .= '<a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a></td></tr>'.
+ '<tr><td style="display : none" id="details_'.$rater_id.'">'.$ret_details.'</td></tr>';
+ }
+ else $ret .='</td></tr>';
if($rater_msg!="") $ret .= "<div>".$rater_msg."</div>";
$ret .= '</table>';
- $ret .= '</form>';
+// $ret .= '</form>';
}
/******************************************************************************/
elseif ($rater_type=="stat") {
@@ -473,7 +481,7 @@ function hidden'.$rater_id.'()
// output statistic
$ret = '<table class="rating_stat_table"><form method="post" action="doku.php?id=' . $ID .'" >'.
- '<tr><TH class="rating_stat_th">Item</TH><TH class="rating_stat_th">Value</TH><TH class="rating_stat_th">Details</TH></tr>';
+ '<tr><th class="rating_stat_th">Item</th><th class="rating_stat_th">Value</th><th class="rating_stat_th">Details</th></tr>';
foreach($found_ratings as $findings) {
$dtls_id = uniqid((double)microtime()*1000000,1);
$alink_id++;
Please sign in to comment.
Something went wrong with that request. Please try again.