diff --git a/uVote/page/default_bulletin/default_bulletin.php b/uVote/page/default_bulletin/default_bulletin.php
index 3ff6035..7475dc8 100644
--- a/uVote/page/default_bulletin/default_bulletin.php
+++ b/uVote/page/default_bulletin/default_bulletin.php
@@ -17,15 +17,15 @@ class default_bulletin extends SYSTEM\PAGE\Page {
private function bars_party(){
$partyvotes = votes::get_barsperparty($this->poll_ID);
- $pbpp = "";
+ $result = "";
foreach($partyvotes as $vote){
$vote['party_yes'] = round($vote['votes_pro']/$vote['total']*100,0);
$vote['party_no'] = round($vote['votes_contra']/$vote['total']*100,0);
$vote['party_ent'] = round(($vote['nr_attending'] - $vote['votes_pro'] - $vote['votes_contra'])/$vote['total']*100,0);
- $pbpp .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/table_parties.tpl'), $vote);
+ $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/table_parties.tpl'), $vote);
}
- return $pbpp;
+ return $result;
}
private function bars_bt(){
@@ -40,16 +40,11 @@ class default_bulletin extends SYSTEM\PAGE\Page {
private function voice_weight(){
$vars = votes::get_count_user_votes_per_poll($this->poll_ID);
- if (!$vars['count']){
- $vars['voteweight'] = 100;
- }
- else {$vars['voteweight'] = 1/$vars['count']*100;
- }
- return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/voteweight.tpl'), $vars);;
+ $vars['voteweight'] = 1/$vars['count']*100;
+ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/voteweight.tpl'), $vars);
}
- private function vote_buttons($poll_expired){
- $user_poll = votes::getUserPollData($this->poll_ID);
+ private function vote_buttons($poll_expired,$user_poll){
if($poll_expired){
if(!$user_poll){
return '
Stimme hier ab
@@ -102,21 +97,25 @@ class default_bulletin extends SYSTEM\PAGE\Page {
public function html(){
$poll_expired = \DBD\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID));
+ $user_vote = votes::getUserPollData($this->poll_ID);
- /*$poll_data = array();
- $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(1));
- $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(2));
- $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(3));*/
$vars = array();
- $vars['bars_party'] = $poll_expired ? '' : $this->bars_party();
- $vars['bars_user'] = $this->bars_user();
- $vars['bars_bt'] = $this->bars_bt();
+ $vars['bars_party'] = $vars['bars_user'] = $vars['bars_bt'] = $vars['voice_weight'] = 'Vote to see results!';
$vars['js'] = $this->js();
$vars['css'] = $this->css();
- $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
- $vars ['vote_buttons'] = $this->vote_buttons($poll_expired);
- $vars['voice_weight'] = $this->voice_weight();
- $vars['poll_ID'] = $this->poll_ID;
+
+ $vars['vote_buttons'] = $this->vote_buttons($poll_expired,$user_vote);
+
+ if($user_vote){
+ $vars['bars_party'] = $poll_expired ? '' : $this->bars_party();
+ $vars['bars_user'] = $this->bars_user();
+ $vars['bars_bt'] = $this->bars_bt();
+ $vars['voice_weight'] = $this->voice_weight();
+ }
+
+ $vars['poll_ID'] = $this->poll_ID; //put it here - so its filled in!
+ $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
+
$vars = array_merge($vars,votes::get_voteinfo($this->poll_ID));
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/bulletin.tpl'),$vars);
}
diff --git a/uVote/page/default_page/default_page.php b/uVote/page/default_page/default_page.php
index eab05bf..ea5b3e9 100644
--- a/uVote/page/default_page/default_page.php
+++ b/uVote/page/default_page/default_page.php
@@ -14,9 +14,21 @@ class default_page extends SYSTEM\PAGE\Page {
}
private function css(){
- return '';}
-
-
+ return '';}
+
+ private function get_party_per_poll($choice){
+ switch($choice){
+ case 1:
+ return 'PRO';
+ case 2:
+ return 'CON';
+ case 3:
+ return 'ENT';
+ default:
+ return 'NONE';
+ }
+ }
+
private static function tablerow_class($choice){
switch($choice){
case 1:
@@ -30,49 +42,59 @@ class default_page extends SYSTEM\PAGE\Page {
}
}
- public function generate_votelist(){
-
+ private static function badge_class($choice){
+ switch($choice){
+ case 1:
+ return 'badge-success';
+ case 2:
+ return 'badge-important';
+ case 3:
+ return '';
+ default:
+ return '';
+ }
+ }
+
+ public function generate_votelist(){
$result = array('','');
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$time_remain = strtotime($vote['time_end'])- microtime(true);
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
- $vote['vote_class'] = $this->tablerow_class(votes::getUserPollData($vote['ID']));
- $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
- $vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen';
+ $vote_count = votes::get_count_user_votes_per_poll($vote['ID']);
+
+ $vote['title'] = utf8_encode($vote['title']);
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
$vote['time_done'] = 100-$vote['time_left'];
- $cdu = votes::get_party_choice($vote['ID'], 'cdu');
- $vote['cdu'] = $this->get_party_per_poll($cdu['choice']);
- $vote['choice_class_cdu'] = $this->tablerow_class($cdu['choice']);
- $csu = votes::get_party_choice($vote['ID'], 'csu');
- $vote['csu'] = $this->get_party_per_poll($csu['choice']);
- $vote['choice_class_csu'] = $this->tablerow_class($csu['choice']);
- $spd = votes::get_party_choice($vote['ID'], 'spd');
- $vote['spd'] = $this->get_party_per_poll($spd['choice']);
- $vote['choice_class_spd'] = $this->tablerow_class($spd['choice']);
- $gruene = votes::get_party_choice($vote['ID'], 'gruene');
- $vote['gruene'] = $this->get_party_per_poll($gruene['choice']);
- $vote['choice_class_gruene'] = $this->tablerow_class($gruene['choice']);
- $linke = votes::get_party_choice($vote['ID'], 'linke');
- $vote['linke'] = $this->get_party_per_poll($linke['choice']);
- $vote['choice_class_linke'] = $this->tablerow_class($linke['choice']);
- $uvote = votes::get_users_choice_per_poll($vote['ID']);
- $vo = votes::get_count_user_votes_per_poll($vote['ID']);
- $vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : '';
-
- $vote['uv_pro'] = $vote['uv_con'] = $vote['uv_ent'] = '0';
+ $vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen';
+ $vote['uv'] = $vote['bt'] = '';
+ $vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5';
- foreach($uvote as $v){
- switch($v['choice']){
- case 1: $vote['uv_pro'] = $v['count'] > 0 ? $v['count']/$vo['count']*100 : '0'; break;
- case 2: $vote['uv_con'] = $v['count'] > 0 ? $v['count']/$vo['count']*100 : '0'; break;
- case 3: $vote['uv_ent'] = $v['count'] > 0 ? $v['count']/$vo['count']*100 : '0'; break;
- default:
+ $user_vote = votes::getUserPollData($vote['ID']);
+ if($user_vote){
+ //user vote
+ $vote['vote_class'] = $this->tablerow_class($user_vote);
+
+ //bt vote
+ $party_votes = votes::get_barsperparty($vote['ID']);
+ $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
+ foreach($party_votes as $pv){
+ $vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote_bt.tpl'),
+ array( 'party' => $pv['party'],
+ 'choice' => $this->get_party_per_poll($pv['choice']),
+ 'choice_class' => $this->tablerow_class($pv['choice'])));
+ }
+
+ //uvote vote
+ $uvote = votes::get_users_choice_per_poll($vote['ID']);
+ $vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : '';
+ foreach($uvote as $v){
+ $vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote_uv.tpl'),
+ array( 'badge' => self::badge_class($v['choice']),
+ 'perc' => $v['count'] > 0 ? $v['count']/$vote_count['count']*100 : 0));
}
}
- $vote['title'] = utf8_encode($vote['title']);
if($time_remain > 0){
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vote);
@@ -81,24 +103,7 @@ class default_page extends SYSTEM\PAGE\Page {
}
}
return $result[0].$result[1];
- }
-
- private function get_party_per_poll($choice){
- switch($choice){
- case 1:
- return 'PRO';
- case 2:
- return 'CON';
- case 3:
- return 'ENT';
- default:
- return 'NONE';
- }
-
-
-
- }
-
+ }
public function get_coverpage(){
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/cover.tpl'), array());}
diff --git a/uVote/page/default_page/vote.tpl b/uVote/page/default_page/vote.tpl
index dfb0f65..a42a295 100644
--- a/uVote/page/default_page/vote.tpl
+++ b/uVote/page/default_page/vote.tpl
@@ -8,24 +8,13 @@
- ${cdu}
- ${csu}
- ${spd}
- ${gruene}
- ${linke}
+ ${bt}
|
-
- uVote
- ${uv_pro}%
- ${uv_con}%
- ${uv_ent}%
-
-
-
-
+ 
+ ${uv}
+ ${uv_count}
|
-
|
diff --git a/uVote/page/default_page/vote_bt.tpl b/uVote/page/default_page/vote_bt.tpl
new file mode 100644
index 0000000..57a4a31
--- /dev/null
+++ b/uVote/page/default_page/vote_bt.tpl
@@ -0,0 +1 @@
+ ${choice}
\ No newline at end of file
diff --git a/uVote/page/default_page/vote_uv.tpl b/uVote/page/default_page/vote_uv.tpl
new file mode 100644
index 0000000..0172bb6
--- /dev/null
+++ b/uVote/page/default_page/vote_uv.tpl
@@ -0,0 +1 @@
+${perc}%
\ No newline at end of file
diff --git a/uVote/page/user_main_uVote/uVote.tpl b/uVote/page/user_main_uVote/uVote.tpl
index ce068ce..4a4c591 100644
--- a/uVote/page/user_main_uVote/uVote.tpl
+++ b/uVote/page/user_main_uVote/uVote.tpl
@@ -1,7 +1,7 @@
Entscheidungsverhalten der uVote Community
-
+
${votes_all}
Wie oft die uVote Community
|