Merge branch 'master' of mojotrollz.eu:hosting

Conflicts:
	uVote/uVote/page/default_bulletin/default_bulletin.php
	uVote/uVote/page/default_page/default_page.php
	uVote/uVote/page/default_page/vote.tpl
This commit is contained in:
Nael 2014-03-03 11:02:35 +01:00
commit e5732455c4
6 changed files with 86 additions and 91 deletions

View File

@ -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 '<h4>Stimme hier ab</h4>
@ -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);
}

View File

@ -14,9 +14,21 @@ class default_page extends SYSTEM\PAGE\Page {
}
private function css(){
return '<link href="'.SYSTEM\WEBPATH(new PPAGE(),'default_page\css\default_page.css').'" rel="stylesheet">';}
return '<link href="'.SYSTEM\WEBPATH(new PPAGE(),'default_page\css\default_page.css').'" rel="stylesheet">';}
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());}

View File

@ -8,24 +8,13 @@
</td>
<td class="${bt_vote_class}" style="width: 80px; margin-top: 10px; border-left: 1px solid lightgray;">
<img src="${frontend_logos}icon_bt.png" width="80"/>
<img src="${frontend_logos}icon_cdu.png" width="30"/><span class="badge ${choice_class_cdu}" style="float:right;">${cdu}</span><br/>
<img src="${frontend_logos}icon_csu.png" width="30"/><span class="badge ${choice_class_csu}" style="float:right;">${csu}</span><br/>
<img src="${frontend_logos}icon_spd.png" width="30"/><span class="badge ${choice_class_spd}" style="float:right;">${spd}</span><br/>
<img src="${frontend_logos}icon_gruene.png" width="30"/><span class="badge ${choice_class_gruene}" style="float:right;">${gruene}</span><br/>
<img src="${frontend_logos}icon_linke.png" width="30"/><span class="badge ${choice_class_linke}" style="float:right;">${linke}</span>
${bt}
</td>
<td class="${uv_vote_class}" style="width: 50px; height: 100%; border-left: 1px solid lightgray;">
<img src="${frontend_logos}icon_urn.png" width="15"/>
<div style="float: right"><font size=1>uVote</font></div>
<span class="badge badge-success" style="">${uv_pro}%</span>
<span class="badge badge-important" style="">${uv_con}%</span>
<span class="badge" style="">${uv_ent}%</span>
<br>
<br>
<br>
<img src="${frontend_logos}icon_urn.png" width="25"/><br/>
${uv}
<span class="badge badge-info" style="">${uv_count}</span>
</td>
<td style="margin: 0; padding: 0; width: 3px;" >
<table class="poll_time" time="${time_end}" style="width: 100%; height: 100%; margin: 0; padding: 0;">
<tr id="time_done" style="height: ${time_done}%; background: white; margin: 0; padding: 0;"><td style="width: 1px; margin: 0; padding: 0;"></td></tr>

View File

@ -0,0 +1 @@
<img src="${frontend_logos}icon_${party}.png" width="30"/><span class="badge ${choice_class}" style="float:right;">${choice}</span><br/>

View File

@ -0,0 +1 @@
<span class="badge ${badge}" style="">${perc}%</span><br/>

View File

@ -1,7 +1,7 @@
<div style="width: 50%; float: left;">
<h5>Entscheidungsverhalten der uVote Community</h5>
<span style="float: left,">
<span style="float: left;">
${votes_all}
</span>
<span style=""> Wie oft die uVote Community