diff --git a/uVote/api/api_uvote.php b/uVote/api/api_uvote.php
index 8af9c52..ac01b77 100644
--- a/uVote/api/api_uvote.php
+++ b/uVote/api/api_uvote.php
@@ -4,6 +4,20 @@ class api_uvote extends \SYSTEM\API\api_login {
public static function call_vote_action_vote($poll_ID, $vote) {
return votes::write_vote($poll_ID, $vote);
+ }
+ public static function call_vote_action_data($location, $birthyear, $gender, $children) {
+ return votes::write_data($location, $birthyear, $gender, $children);
+
+ }
+
+ public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) {
+ return votes::write_comment($poll_ID, $c_choice, $c_txt, $c_src);
+
+ }
+
+ public static function call_vote_action_commentrate($c_ID, $val) {
+ return votes::write_commentrate($c_ID, $val);
+
}
public static function call_vote_action_new_vote($ID, $title, $iframe_link) {
@@ -33,4 +47,7 @@ class api_uvote extends \SYSTEM\API\api_login {
return votes::vote_submit($poll_ID);
}
+
+ public static function call_graph_bt_to_uvote_overall_by_time($timespan = 84600){
+ return votes::get_graph_bt_to_uvote_overall_by_time($timespan);}
}
diff --git a/uVote/api/votes/votes.php b/uVote/api/votes/votes.php
index d206d82..da8d590 100644
--- a/uVote/api/votes/votes.php
+++ b/uVote/api/votes/votes.php
@@ -1,23 +1,58 @@
next()){
+ $result[] = array( 0 => $row['day'],
+ 'match' => $row['class_match'] > 0 ? round($row['class_match'] / ($row['class_match']+$row['class_mismatch']),2) : 0,
+ 'mismatch' => $row['class_match'] > 0 ? round($row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']),2) : 0);
+ }
+ return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
+ }
+
+ public static function get_graph_bt_to_user_overall_by_time ($timespan = 84600,$returnasjson = true){
+ $result = array();
+ $res = \DBD\UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id));
+ while ($row = $res->next()){
+ $result[] = array( 0 => $row['day'],
+ 'class_match' => $row['class_match'] / ($row['class_match']+$row['class_mismatch']+1),
+ 'class_mismatch' => $row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']+1));
+ }
+ return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
+ }
+
public static function getAllVotesOfGroup($groupid){
return \DBD\UVOTE_GENERATE_VOTELIST::QA(array($groupid));}
+ public static function getAllExpVotesOfGroup($groupid){
+ return \DBD\UVOTE_GENERATE_VOTELIST_EXP::QA(array($groupid));}
+
+ public static function getUserComments($poll_ID, $c_choice){
+ return \DBD\UVOTE_GENERATE_COMMENTS_PER_POLL::QA(array($poll_ID, $c_choice));}
+
public static function countAllPolls(){
$res = \DBD\UVOTE_DATA_COUNT_VOTES::QQ();
return $res;}
public static function insertPartyChoice($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice){
return \DBD\UVOTE_GENERATE_VOTELIST::QI(array($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice));}
-
- public static function getVoteOfGroup($poll_ID){
+
+ public static function insertUserComment($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp){
+ return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::QI(array($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp));}
+ /*public static function getVoteOfGroup($poll_ID){
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
$res = $con->prepare( 'selVoteByGrp',
'SELECT * FROM `uvote_votes` WHERE `ID` = ? LIMIT 1;',
array($poll_ID));
$result = $res->next();
return $result;
+ }*/
+
+ public static function get_user_choice_per_poll($poll_ID, $user_ID){
+ return \DBD\UVOTE_DATA_USER_CHOICE_PER_POLL::Q1(array($poll_ID, $user_ID));
}
public static function getUserPollData($poll_ID){
@@ -80,12 +115,18 @@ class votes {
public static function get_user_temp_votes($user_ID){
return \DBD\UVOTE_DATA_TEMP_VOTES::Q1(array($user_ID, $user_ID, $user_ID));}
+ public static function get_user_overall_votes($user_ID, $creationDate){
+ return \DBD\UVOTE_DATA_OVERALL_VOTES::Q1(array($user_ID, $user_ID, $user_ID, $creationDate));}
+
public static function get_bar_bt_per_poll($poll_ID){
return \DBD\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));}
public static function get_user_count(){
return \DBD\UVOTE_DATA_USER_COUNT_USERS::Q1(array());}
+ public static function get_commentrate($c_ID, $val){
+ return \DBD\UVOTE_DATA_USER_COMMENTRATE_PER_COMMENT::Q1(array($c_ID, $val));}
+
public static function get_count_user_votes_per_poll($poll_ID){
return \DBD\UVOTE_DATA_USER_COUNT_CHOICE_PER_POLL::Q1(array($poll_ID));}
@@ -112,6 +153,7 @@ class votes {
'SELECT * FROM `uvote_votes` WHERE `ID` = ?;',
array($poll_ID));
$res = $res->next();
+ $res['title'] = utf8_encode($res['title']);
return $res;
}
@@ -136,11 +178,30 @@ class votes {
$res = $con->prepare( 'insertVote',
'REPLACE uvote_data
- VALUES (?, ?, ?, 0, NOW());',
+ VALUES (?, ?, ?, 0, NOW());',
array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote));
return JsonResult::ok();
}
+ public static function write_data($location, $birthyear, $gender, $children){
+ if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
+ throw new ERROR("You need to be logged in.");}
+ return \DBD\UVOTE_DATA_USER_ADD_DATA_INSERT::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children, \SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children));}
+
+ public static function write_comment($poll_ID, $c_choice, $c_txt, $c_src){
+ if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
+ throw new ERROR("You need to be logged in.");}
+ return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::Q1(array($c_choice, $poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $c_txt, $c_src));}
+
+ public static function write_commentrate($c_ID, $val){
+ if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
+ throw new ERROR("You need to be logged in.");}
+ return \DBD\UVOTE_DATA_USER_COMMENTRATE_INSERT::Q1(array($c_ID, \SYSTEM\SECURITY\Security::getUser()->id, $val));}
+
+ public static function get_add_data(){
+ return \DBD\UVOTE_DATA_USER_ADD_DATA::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id));
+ }
+
public static function write_poll($ID, $title, $iframe_link ){
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
$res = $con->prepare( 'insertPoll',
@@ -163,7 +224,7 @@ class votes {
}
public static function open_vote($poll_ID){
- $vote = votes::getVoteOfGroup($poll_ID);
+ $vote = self::get_voteinfo($poll_ID); //votes::getVoteOfGroup($poll_ID);
$result = SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/full_vote.tpl'), $vote);
return $result;
}
diff --git a/uVote/dbd/qq/UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME.php b/uVote/dbd/qq/UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME.php
new file mode 100644
index 0000000..70eea8b
--- /dev/null
+++ b/uVote/dbd/qq/UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME.php
@@ -0,0 +1,19 @@
+ FROM_UNIXTIME(?);'
+);}}
diff --git a/uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php b/uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php
index a0d0a19..47215fb 100644
--- a/uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php
+++ b/uVote/dbd/qq/UVOTE_DATA_PARTY_PER_POLL.php
@@ -7,5 +7,5 @@ class UVOTE_DATA_PARTY_PER_POLL extends \SYSTEM\DB\QP {
//pg
'',
//mys
-'SELECT * FROM `uvote_votes_per_party` WHERE `poll_ID` = ?;'
+'SELECT * FROM `uvote_votes_per_party` WHERE `poll_ID` = ? ORDER BY party;'
);}}
\ No newline at end of file
diff --git a/uVote/dbd/qq/UVOTE_DATA_TEMP_VOTES.php b/uVote/dbd/qq/UVOTE_DATA_TEMP_VOTES.php
new file mode 100644
index 0000000..77959ae
--- /dev/null
+++ b/uVote/dbd/qq/UVOTE_DATA_TEMP_VOTES.php
@@ -0,0 +1,14 @@
+ NOW();'
+);}}
diff --git a/uVote/dbd/qq/UVOTE_DATA_USERS_CHOICE_PER_POLL.php b/uVote/dbd/qq/UVOTE_DATA_USERS_CHOICE_PER_POLL.php
new file mode 100644
index 0000000..289442e
--- /dev/null
+++ b/uVote/dbd/qq/UVOTE_DATA_USERS_CHOICE_PER_POLL.php
@@ -0,0 +1,11 @@
+ NOW() ORDER BY (time_end-time_start) ASC;'
);}}
\ No newline at end of file
diff --git a/uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php b/uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php
new file mode 100644
index 0000000..232dabb
--- /dev/null
+++ b/uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php
@@ -0,0 +1,11 @@
+${title}
-
-
${vote_yes_perc}%
-
${vote_no_perc}%
-
${vote_ent_perc}%
-
\ No newline at end of file
+${bulletin_bars_title}
+${urvote_bars_user}
+
+
${vote_yes_perc}%
+
${vote_no_perc}%
+
${vote_ent_perc}%
diff --git a/uVote/page/default_bulletin/bulletin.tpl b/uVote/page/default_bulletin/bulletin.tpl
index bf67a62..a27dcec 100644
--- a/uVote/page/default_bulletin/bulletin.tpl
+++ b/uVote/page/default_bulletin/bulletin.tpl
@@ -1,22 +1,61 @@
-
- ${bars_user}
+
+
${title}
+ ${vote_buttons}
+
+
+
+
+ ${openvote_help_text}
+ ${title}
+ ${openvote_help_text1}
+
+
+ ${voice_weight}
+
+
+
+ ${bars_user}
+
+
+ ${bars_bt}
+
+
+
+ ${icons_party}
+ ${choice_party}
+
+
+
+
+
+
+
Pro
+ ${comments_pro}
+
+
+
Contra
+ ${comments_con}
+
+
+
+
+
Kommentar
+
+
Quelle
+
+
+ Seite
+ Argument Pro
+ Argument Con
+
+
${submit}
+
+
+
+
+
-
-
Ergebnis Bundestag
- ${bars_bt}
-
-
-
-
- ${vote_buttons}
-
-
-
-
-
- ${bars_party}
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/uVote/page/default_bulletin/comment.tpl b/uVote/page/default_bulletin/comment.tpl
new file mode 100644
index 0000000..54f4a99
--- /dev/null
+++ b/uVote/page/default_bulletin/comment.tpl
@@ -0,0 +1,15 @@
+
+
${timestamp}
+
${c_txt}
+
+
+
${nr_up}
+
+
${nr_down}
+
+
+
+
Quelle: ${c_src}
+
+
+
\ No newline at end of file
diff --git a/uVote/page/default_bulletin/default_bulletin.php b/uVote/page/default_bulletin/default_bulletin.php
index 08fd882..1d49487 100644
--- a/uVote/page/default_bulletin/default_bulletin.php
+++ b/uVote/page/default_bulletin/default_bulletin.php
@@ -4,7 +4,82 @@ class default_bulletin extends SYSTEM\PAGE\Page {
public function __construct($poll_ID) {
$this->poll_ID=$poll_ID;}
+
+ public function vote_choice(){
+ $vars = votes::getUserPollData($this->poll_ID);
+ return $this->tablerow_class($vars);
+ }
+
+ private static function tablerow_class($choice){
+ switch($choice){
+ case 1:
+ return 'pro';
+ case 2:
+ return 'con';
+ case 3:
+ return 'ent';
+ default:
+ return 'open';
+ }
+ }
+
+ 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 function choice_party (){
+ $result = '';
+ $party_votes = votes::get_barsperparty($this->poll_ID);
+
+// $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
+ foreach($party_votes as $pv){
+
+ $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/vote_bt.tpl'),
+ array( 'party' => $pv['party'],
+ 'choice' => $this->get_party_per_poll($pv['choice']),
+ 'choice_class' => $this->tablerow_class($pv['choice']),
+ 'party_yes' => $pv['votes_pro'] > 0 ? round($pv['votes_pro']/$pv['total']*100,0) : 'votes_pro',
+ 'party_no' => $pv['votes_contra'] > 0 ? round($pv['votes_contra']/$pv['total']*100,0) : $pv['votes_contra'],
+ 'party_off' => $pv['total'] > 0 ? round(($pv['total'] - $pv['nr_attending'])/$pv['total']*100,0) : $pv['total'],
+ 'party_ent' => $pv['nr_attending'] > 0 ? round(($pv['nr_attending'] - $pv['votes_pro'] - $pv['votes_contra'])/$pv['nr_attending']*100,0) : $pv['nr_attending']));
+ }
+ return $result;
+ }
+
+ private function get_pro_comments (){
+ $result = '';
+ $vars = votes::getUserComments($this->poll_ID, 1);
+ foreach($vars as $com){
+ $com['count'] = votes::get_commentrate($com['c_ID'], 1);
+ $com['c_txt'] = utf8_encode($com['c_txt']);
+ $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com);
+ }
+ return $result;
+
+ }
+ private function get_con_comments (){
+ $result = '';
+ $vars = votes::getUserComments($this->poll_ID, 2);
+
+ foreach($vars as $com){
+ $com['count'] = votes::get_commentrate($com['c_ID'], 2);
+ $com['nr_down'] = $c['count'];
+ $com['c_txt'] = utf8_encode($com['c_txt']);
+ $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com);
+ }
+ return $result;
+
+ }
private function bars_user(){
$bars = votes::get_barsperusers($this->poll_ID,false);
$bars['vote_yes_perc'] = round($bars['yes_perc']*100,0);
@@ -19,15 +94,20 @@ class default_bulletin extends SYSTEM\PAGE\Page {
$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);
+ $vote['party_yes'] = $vote['votes_pro'] > 0 ? round($vote['votes_pro']/$vote['total']*100,0) : $vote['votes_pro'];
+ $vote['party_no'] = $vote['votes_contra'] > 0 ? round($vote['votes_contra']/$vote['total']*100,0) : $vote['votes_contra'];
+ $vote['party_ent'] = $vote['nr_attending'] > 0 ? round(($vote['nr_attending'] - $vote['votes_pro'] - $vote['votes_contra'])/$vote['total']*100,0) : $vote['nr_attending'];
$result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/table_parties.tpl'), $vote);
}
return $result;
}
+ private function icons_party(){
+ $vars = array();
+ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/icons_table_parties.tpl'), $vars);
+ }
+
private function bars_bt(){
$vars = votes::get_bar_bt_per_poll($this->poll_ID);
if (!$vars['bt_total']){
@@ -40,7 +120,7 @@ class default_bulletin extends SYSTEM\PAGE\Page {
private function voice_weight(){
$vars = votes::get_count_user_votes_per_poll($this->poll_ID);
- $vars['voteweight'] = 1/$vars['count']*100;
+ $vars['voteweight'] = round(1/$vars['count']*100);
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/voteweight.tpl'), $vars);
}
@@ -60,7 +140,7 @@ class default_bulletin extends SYSTEM\PAGE\Page {
private function vote_buttons($poll_expired,$user_poll){
if($poll_expired){
if(!$user_poll){
- return '
Stimme hier ab
+ return '
Stimme hier ab
Enthaltung ';}
$classes = array('','','');
switch($user_poll){
- case 1: $classes = array('btn-success','',''); break;
- case 2: $classes = array('','btn-danger',''); break;
- case 3: $classes = array('','','btn-info'); break;
+ case 1: $classes = array('btn-success disabled','btn-danger','btn-info'); break;
+ case 2: $classes = array('btn-success','btn-danger disabled','btn-info'); break;
+ case 3: $classes = array('btn-success','btn-danger','btn-info disabled'); break;
default: array('','','');
}
- return '
Ändere deine bereits abgegebene Stimme hier ab
+ return '
Ändere deine Stimme hier ab
Enthaltung ';
+ size="3">Enthaltung
+ ';
} else {
return 'ye soon to come infos';
}
@@ -108,26 +189,41 @@ class default_bulletin extends SYSTEM\PAGE\Page {
private function css(){
return '
';}
+
+
public function html(){
$poll_expired = \DBD\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID));
$user_vote = votes::getUserPollData($this->poll_ID);
$vars = array();
- $vars['bars_party'] = $vars['bars_user'] = $vars['bars_bt'] = $vars['voice_weight'] = 'Vote to see results!';
+ $vars['choice_party'] = '';
+ $vars['voice_weight'] = $vars['bars_user'] = $vars['bars_bt'] = '';
+ $vars['bars_party'] = '';
+ $vars['icons_party'] = '';
+ $vars['vote_class'] = $this->vote_choice();
+ $vars['comments_pro'] = '';
+ $vars['comments_con'] = '';
$vars['js'] = $this->js();
$vars['css'] = $this->css();
$vars['vote_buttons'] = $this->vote_buttons($poll_expired,$user_vote);
// $vars['p_fields'] = $this->p_fields();
if($user_vote){
- $vars['bars_party'] = $poll_expired ? '' : $this->bars_party();
+ $vars['comments_pro'] = $this->get_pro_comments();
+ $vars['comments_con'] = $this->get_con_comments();
+ $vars['icons_party'] = $this->icons_party();
+ $vars['choice_party'] = $this->choice_party();
+ $vars['bars_party'] = $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['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, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
+ $vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
+ $vars = array_merge($vars, \SYSTEM\locale::getStrings(100));
$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_bulletin/icons_table_parties.tpl b/uVote/page/default_bulletin/icons_table_parties.tpl
new file mode 100644
index 0000000..b082c99
--- /dev/null
+++ b/uVote/page/default_bulletin/icons_table_parties.tpl
@@ -0,0 +1,8 @@
+
${urvote_party_table_desc}
+
\ No newline at end of file
diff --git a/uVote/page/default_bulletin/js/vote.js b/uVote/page/default_bulletin/js/vote.js
deleted file mode 100644
index e69de29..0000000
diff --git a/uVote/page/default_bulletin/table_bt.tpl b/uVote/page/default_bulletin/table_bt.tpl
index d8b2f21..19fbaa4 100644
--- a/uVote/page/default_bulletin/table_bt.tpl
+++ b/uVote/page/default_bulletin/table_bt.tpl
@@ -1,7 +1,6 @@
-
-
-
${bt_pro}%
-
${bt_con}%
-
-
-
\ No newline at end of file
+Ergebnis Bundestag
+
+
${bt_pro}%
+
${bt_con}%
+
+
diff --git a/uVote/page/default_bulletin/table_parties.tpl b/uVote/page/default_bulletin/table_parties.tpl
index 0aa9c3d..aced008 100644
--- a/uVote/page/default_bulletin/table_parties.tpl
+++ b/uVote/page/default_bulletin/table_parties.tpl
@@ -1,9 +1,7 @@
-
-
-
-
-
-
+
+
+
${party_yes}%
+
${party_no}%
+
${party_ent}%
- ${choice}
\ No newline at end of file
diff --git a/uVote/page/default_bulletin/vote_bt.tpl b/uVote/page/default_bulletin/vote_bt.tpl
new file mode 100644
index 0000000..a25b758
--- /dev/null
+++ b/uVote/page/default_bulletin/vote_bt.tpl
@@ -0,0 +1,8 @@
+
+
+
${choice}
+
${party_yes}%
+
${party_no}%
+
${party_ent}%
+
${party_off}%
+
\ No newline at end of file
diff --git a/uVote/page/default_comment/comment.tpl b/uVote/page/default_comment/comment.tpl
new file mode 100644
index 0000000..8f01cea
--- /dev/null
+++ b/uVote/page/default_comment/comment.tpl
@@ -0,0 +1,4 @@
+
${timestamp}
+
${c_txt}
+
${c_src}
+
\ No newline at end of file
diff --git a/uVote/page/default_comment/default_comment.php b/uVote/page/default_comment/default_comment.php
new file mode 100644
index 0000000..32b9b0c
--- /dev/null
+++ b/uVote/page/default_comment/default_comment.php
@@ -0,0 +1,87 @@
+poll_ID=$poll_ID;}
+
+ public function vote_choice(){
+ $vars = votes::getUserPollData($this->poll_ID);
+ return $this->tablerow_class($vars);
+ }
+
+ private static function tablerow_class($choice){
+ switch($choice){
+ case 1:
+ return 'pro';
+ case 2:
+ return 'con';
+ case 3:
+ return 'ent';
+ default:
+ return 'open';
+ }
+ }
+
+
+
+ private function get_pro_comments (){
+ $result = '';
+ $vars = votes::getUserComments($this->poll_ID, 1);
+ foreach($vars as $com){
+ $com['c_txt'] = utf8_encode($com['c_txt']);
+ $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com);
+ }
+ return $result;
+
+ }
+ private function get_con_comments (){
+ $result = '';
+ $vars = votes::getUserComments($this->poll_ID, 2);
+
+ foreach($vars as $com){
+ $com['c_txt'] = utf8_encode($com['c_txt']);
+ $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com);
+ }
+ return $result;
+
+ }
+
+
+
+
+
+
+ private function js(){
+ return '';}
+ private function css(){
+ return '
';}
+
+ public function html(){
+ $poll_expired = \DBD\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID));
+ $user_vote = votes::getUserPollData($this->poll_ID);
+
+ $vars = array();
+ $vars['comments_pro'] = '';
+ $vars['comments_con'] = '';
+ $vars['js'] = $this->js();
+ $vars['css'] = $this->css();
+
+ $vars['vote_buttons'] = $this->vote_buttons($poll_expired,$user_vote);
+// $vars['p_fields'] = $this->p_fields();
+ if($user_vote){
+ $vars['comments_pro'] = $this->get_pro_comments();
+ $vars['comments_con'] = $this->get_con_comments();
+ }
+
+ $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, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
+ $vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
+ $vars = array_merge($vars, \SYSTEM\locale::getStrings(100));
+
+ $vars = array_merge($vars,votes::get_voteinfo($this->poll_ID));
+ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_comment/comment.tpl'),$vars);
+ }
+
+}
\ No newline at end of file
diff --git a/uVote/page/default_page/default_page.php b/uVote/page/default_page/default_page.php
index 7076d02..72b012d 100644
--- a/uVote/page/default_page/default_page.php
+++ b/uVote/page/default_page/default_page.php
@@ -1,7 +1,6 @@
'.
''.
diff --git a/uVote/page/default_page/full_vote.tpl b/uVote/page/default_page/full_vote.tpl
index f181275..6d87166 100644
--- a/uVote/page/default_page/full_vote.tpl
+++ b/uVote/page/default_page/full_vote.tpl
@@ -3,7 +3,7 @@
Quelle:
${iframe_link}
-
+
diff --git a/uVote/page/default_page/js/loadtexts.js b/uVote/page/default_page/js/loadtexts.js
index 04fa820..281d082 100644
--- a/uVote/page/default_page/js/loadtexts.js
+++ b/uVote/page/default_page/js/loadtexts.js
@@ -1,74 +1,90 @@
-/* jQuery on document ready */
-$(document).ready(function() {
- // handle navigation link click
- /*$('.navbar ul li a').not('#menu_uvote').click(function () {
- loadAjaxContent($(this).attr('url'));
-
- //loadUrlPic($(this).attr('url'));
- });*/
-
-
-
- /*$('.btn_openvoteinfo').click(function () {
- if($("#openvoteinfo"+$(this).attr('poll_ID')).is(':visible')){
- $('#openvoteinfo'+$(this).attr('poll_ID')).slideUp('slow');
- }else{
- load_openvoteinfo($(this).attr('poll_ID'));
- }
- });*/
+$(document).ready(function() {
+ load_user_main();
+ load_user_list();
+ register_login();
+ register_logout();
+});
- //jqBootstrapValidation
-
-
+function load_user_list(){
+ $('#user_list').load('./?action=user_list', function(){
+ register_user_list();});
+}
+function load_user_main(){
$('#user_main').load('./?action=user_main', function(){
- register_registerform();
- $('#feedback_submit').click(function (data){
- var test = $('textarea#feedback_text').val();
- send_feedback(test);
-
- });
- $('#tabs_user_main a').click(function (e) {
- e.preventDefault();
- $(this).tab('show');
- load_user_main_tab($(this).attr('action'));
- });
+ register_user_main();
+ });
+}
+function register_user_list(){
+ $('#tabs_user_list a').click(function (e) {
+ e.preventDefault();
+ load_user_list_tab($(this).attr('action'));
+ $(this).tab('show');
+ });
+ $('.btn_vote').click(function () {
+ //vote_click($(this).attr('poll_ID'));
+ $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
+ open_vote($(this).attr('poll_ID'));
+ register_registerform();
+ });
+ $('.btn_fade').click(function () {
+ $('#vote_data_panel' + $(this).attr('poll_ID')).toggle();
+ });
+}
+function register_user_main(){
+ register_registerform();
+ $('#feedback_submit').click(function (data){
+ var test = $('textarea#feedback_text').val();
+ send_feedback(test);
+ });
+ $('#tabs_user_main a').click(function (e) {
+ e.preventDefault();
+ load_user_main_tab($(this).attr('action'));
+ $(this).tab('show');
+ });
+}
+
+function register_login(){
+ $("#form_login input").not("[type=submit]").jqBootstrapValidation({
//load_user_main_tab('user_main_uVote');
});
- $('#user_list').load('./?action=user_list', function(){
- $('.btn_vote').click(function () {
- //vote_click($(this).attr('poll_ID'));
- $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
- open_vote($(this).attr('poll_ID'));
- register_registerform();
- });
+ $('#user_list').load('./?action=user_list', function(){
$('#tabs_user_list a').click(function (e) {
e.preventDefault();
$(this).tab('show');
load_user_list_tab($(this).attr('action'));
+
});
+ $('.btn_vote').click(function () {
+ //vote_click($(this).attr('poll_ID'));
+ $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
+ open_vote($(this).attr('poll_ID'));
+ register_registerform();
+ });
+ $('.btn_fade').click(function () {
+ $('#vote_data_panel' + $(this).attr('poll_ID')).show();
+ });
//load_user_main_tab('user_main_uVote');
});
-
-});
-$("#form_login input").not("[type=submit]").jqBootstrapValidation({
+ $("#form_login input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
$.get('./api.php?call=account&action=login&username=' + $('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
- if(data == 1){
- window.location.reload();
- } else {
- $('#help-block-user-password-combi-wrong').attr('style', 'display: block;');
- }
- });
- event.preventDefault();
- }
+ if(data == 1){
+ window.location.reload();
+ } else {
+ $('#help-block-user-password-combi-wrong').attr('style', 'display: block;');
+ }
+ });
+ event.preventDefault();
+ }
});
-
+}
+function register_logout(){
$("#form_logout input").not("[type=submit]").jqBootstrapValidation(
{
preventSubmit: true,
@@ -80,7 +96,8 @@ $("#form_login input").not("[type=submit]").jqBootstrapValidation({
event.preventDefault();
}
});
-
+}
+
function register_registerform(){
console.log("wegwegwegwegwegweg");
$("#register_user_form input").not("[type=submit]").jqBootstrapValidation(
@@ -100,40 +117,51 @@ function register_registerform(){
});
}
-function drawChart(){
- //load_visualisation('#graph_bt_uv_overall',84600);
-}
-
-function load_user_main_tab(action){
-
- switch(action){
-
+function load_user_main_tab(action){
+ switch(action){
case 'user_main_uVote':
- $('#tab_uVote').load('./?action='+ action);
+ //$('#tab_uVote').load('./?action='+ action); //causes error
return;
case 'user_main_urVote':
$('#tab_urVote').load('./?action='+ action);
return;
case 'user_main_myVote':
$('#tab_myVote').load('./?action='+ action, function(){
- $('.add_data_submit').click(function () {
- submit_add_data();
- alert('success');
- });
+ $('.add_data_submit').click(function () {
+ submit_add_data();
+ alert('success');
+ });
});
return;
default:
}
}
-function load_user_list_tab(action){
-
- switch(action){
-
+function load_user_list_tab(action){
+ switch(action){
case 'user_list_active':
- $('#tab_active').load('./?action='+ action);
+ $('#tab_active').load('./?action='+ action, function(){
+ $('.btn_fade').click(function () {
+ $('#vote_data_panel' + $(this).attr('poll_ID')).show();
+ });
+ $('.btn_vote').click(function () {
+ //vote_click($(this).attr('poll_ID'));
+ $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
+ open_vote($(this).attr('poll_ID'));
+ register_registerform();
+
+ })});
return;
case 'user_list_ended':
- $('#tab_ended').load('./?action='+ action);
+ $('#tab_ended').load('./?action='+ action, function(){
+ $('.btn_fade').click(function () {
+ $('#vote_data_panel' + $(this).attr('poll_ID')).show();
+ });
+ $('.btn_vote').click(function () {
+ //vote_click($(this).attr('poll_ID'));
+ $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
+ open_vote($(this).attr('poll_ID'));
+ register_registerform();
+ })});
return;
default:
}
@@ -186,6 +214,36 @@ function vote_click (poll_ID, vote) {
});
}
+function submit_commentrate (c_ID, val) {
+ $.getJSON('./api.php?call=vote&action=commentrate&c_ID=' + c_ID + '&val=' + val, function(data) {
+ var items = [];
+ if(data.status == true){
+ alert("success");
+ } else {
+ alert(data.result.message);
+ }
+ });
+}
+
+function submit_c_data (poll_ID) {
+ var c_txt = $("#c_txt_pro").val();
+ var c_src = $("#c_src_pro").val();
+ var a = document.getElementById("side_select");
+ var c_choice = a.options[a.selectedIndex].value;
+ alert(c_choice);
+ $.getJSON('./api.php?call=vote&action=comment&poll_ID=' + poll_ID + '&c_choice=' + c_choice + '&c_txt=' + c_txt + '&c_src=' + c_src, function(data) {
+ var items = [];
+ if(data.status == true){
+ alert("success");
+ $('#user_main').load('./?action=open_bulletin&poll_ID=' + poll_ID, function(){
+ open_vote(poll_ID);
+ });
+ } else {
+ alert(data.result.message);
+ }
+ });
+}
+
function submit_add_data () {
var a = document.getElementById("location");
var location = a.options[a.selectedIndex].text;
@@ -206,19 +264,7 @@ function submit_add_data () {
}
function send_feedback (feedback) {
-
-// $.getJSON('./api.php?call=vote&action=feedback&feedback=' + feedback, function(data) {
-// console.log("hallo3672rt2ziuzir");
-// var items = [];
-// alert(feedback);
-// if(data.status == true){
-// alert("success");
-// } else {
-// alert(data.result.message);
-// }
-// });
-
-$.ajax({
+ $.ajax({
url: 'http://mojotrollz.eu/web/uVote/api.php',
// contentType : "application/json; charset=utf-8",
data : {
@@ -230,7 +276,8 @@ $.ajax({
type : 'POST' ,
success: function(data) {
alert("success");
- }});
+ }
+ });
}
function open_vote (poll_ID) {
@@ -244,9 +291,23 @@ function open_vote (poll_ID) {
$('.btnvote_off').click(function () {
vote_click($(this).attr('poll_ID'),3);
});
+ $('.submit_pro').click(function () {
+ submit_c_data($(this).attr('poll_ID'));
+ alert('success');
+ });
+ $('.c_up').click(function () {
+ submit_commentrate($(this).attr('c_ID'), 1);
+ });
+ $('.c_down').click(function () {
+ submit_commentrate($(this).attr('c_ID'), 2);
+ });
+ $('.c_spam').click(function () {
+ submit_commentrate($(this).attr('c_ID'), 3);
+ });
$('#test').click(function(){
$('#myModal').modal();
});
+
register_registerform();
});
}
diff --git a/uVote/page/default_page/page.tpl b/uVote/page/default_page/page.tpl
index f76d114..86ac927 100644
--- a/uVote/page/default_page/page.tpl
+++ b/uVote/page/default_page/page.tpl
@@ -68,9 +68,9 @@
-
+
-
+
diff --git a/uVote/page/default_page/parties_on_vote.tpl b/uVote/page/default_page/parties_on_vote.tpl
index 5a66521..1762160 100644
--- a/uVote/page/default_page/parties_on_vote.tpl
+++ b/uVote/page/default_page/parties_on_vote.tpl
@@ -1,4 +1,4 @@
-
- ${choice}
+
+
${choice}
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/uVote/page/default_page/vote.tpl b/uVote/page/default_page/vote.tpl
index df93ac5..56a913e 100644
--- a/uVote/page/default_page/vote.tpl
+++ b/uVote/page/default_page/vote.tpl
@@ -1,27 +1,37 @@
-
-
-
- ${title}
-
- ${full_vote_btn}
-
-
-
+
+
+
+
+
+
${bt}
-
-
-
- uVote
-
+
+
+
+
+ uVote
+
${uv}
-
${uv_count}
-
-
-
-
-
-
-
+
+ ${uv_count}
+
+
+
+
+
diff --git a/uVote/page/default_page/vote_bt.tpl b/uVote/page/default_page/vote_bt.tpl
index 57a4a31..02f4418 100644
--- a/uVote/page/default_page/vote_bt.tpl
+++ b/uVote/page/default_page/vote_bt.tpl
@@ -1 +1 @@
-${choice}
\ No newline at end of file
+${choice}
\ No newline at end of file
diff --git a/uVote/page/default_register/register.tpl b/uVote/page/default_register/register.tpl
index 7fd1828..d91f7a0 100644
--- a/uVote/page/default_register/register.tpl
+++ b/uVote/page/default_register/register.tpl
@@ -1,5 +1,6 @@
-
+
+
+
+ uVote BETA Feedback
+ Sag uns was dich stört!
+
+
+
diff --git a/uVote/page/user_main_myVote/myVote.tpl b/uVote/page/user_main_myVote/myVote.tpl
index f80e03c..7c67ab4 100644
--- a/uVote/page/user_main_myVote/myVote.tpl
+++ b/uVote/page/user_main_myVote/myVote.tpl
@@ -1,14 +1,163 @@
-Geburtsjahr
-
-
-
-
-
-
+Einstellungen
+
+${myvote_bodytext}
+
+
+
+${location}
+
+ ${keineangaben_location}
+ Baden-Württemberg
+ Bayern
+ Berlin
+ Brandenburg
+ Bremen
+ Hamburg
+ Hessen
+ Mecklenburg-Vorpommern
+ Niedersachsen
+ Nordrhein-Westfalen
+ Rheinland-Pfalz
+ Saarland
+ Sachsen
+ Sachsen-Anhalt
+ Schleswig-Holstein
+ Thüringen
+
+
+${birthyear}
+
+ ${keineangaben_age}
+ 2007
+ 2006
+ 2005
+ 2004
+ 2003
+ 2002
+ 2001
+ 2000
+ 1999
+ 1998
+ 1997
+ 1996
+ 1995
+ 1994
+ 1993
+ 1992
+ 1991
+ 1990
+ 1989
+ 1988
+ 1987
+ 1986
+ 1985
+ 1984
+ 1983
+ 1982
+ 1981
+ 1980
+ 1979
+ 1978
+ 1977
+ 1976
+ 1975
+ 1974
+ 1973
+ 1972
+ 1971
+ 1970
+ 1969
+ 1968
+ 1967
+ 1966
+ 1965
+ 1964
+ 1963
+ 1962
+ 1961
+ 1960
+ 1959
+ 1958
+ 1957
+ 1956
+ 1955
+ 1954
+ 1953
+ 1952
+ 1951
+ 1950
+ 1949
+ 1948
+ 1947
+ 1946
+ 1945
+ 1944
+ 1943
+ 1942
+ 1941
+ 1940
+ 1939
+ 1938
+ 1937
+ 1936
+ 1935
+ 1934
+ 1933
+ 1932
+ 1931
+ 1930
+ 1929
+ 1928
+ 1927
+ 1926
+ 1925
+ 1924
+ 1923
+ 1922
+ 1921
+ 1920
+ 1919
+ 1918
+ 1917
+ 1916
+ 1915
+ 1914
+ 1913
+ 1912
+ 1911
+ 1910
+ 1909
+ 1908
+ 1907
+ 1906
+ 1905
+ 1904
+ 1903
+ 1902
+ 1901
+ 1900
+
+
+ ${gender}
+
+ ${keineangaben_gender}
+ ${male}
+ ${female}
+ ${none}
+ ${no_data}
+
+
+
+ ${children}
+
+ ${keineangaben_children}
+ ${yes}
+ ${no}
+ ${no_data}
+
+
+
+
+
Absenden
+
\ No newline at end of file
diff --git a/uVote/page/user_main_myVote/user_main_myVote.php b/uVote/page/user_main_myVote/user_main_myVote.php
index 02db8b5..b459db6 100644
--- a/uVote/page/user_main_myVote/user_main_myVote.php
+++ b/uVote/page/user_main_myVote/user_main_myVote.php
@@ -1,7 +1,26 @@
get_add_data();
+ $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, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
+ $vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
+ $vars = array_merge($vars, \SYSTEM\locale::getStrings(110));
+ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_myVote/myVote.tpl'), $vars);
}
}
\ 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 dfb4d23..698a4bb 100644
--- a/uVote/page/user_main_uVote/uVote.tpl
+++ b/uVote/page/user_main_uVote/uVote.tpl
@@ -1,24 +1,38 @@
-
-
+
+ ${welcome_text}
+
+
+
+ Übereinstimmung von uVote & Politik
+ ${uvote_to_bt}
+
+
+
+
+
+
+
+
Entscheidungsverhalten der uVote Community
-
+
${votes_all}
Wie oft die uVote Community
insgesamt Dafür, Dagegen oder
Enthaltung gestimmt hat.
-
+
Entscheidungsverhalten des Bundestags
${votes_all_bt}
- Wie oft der Bundestag
+ Wie oft der Bundestag
Dafür, Dagegen oder
Enthaltung gestimmt hat.
-
-
-
- ${user_count} Nutzer auf uVote
-
\ No newline at end of file
+
+
+
+
+ ${user_count} Nutzer auf uVote
+
diff --git a/uVote/page/user_main_uVote/user_main_uVote.php b/uVote/page/user_main_uVote/user_main_uVote.php
index 1b52897..c7bc9dc 100644
--- a/uVote/page/user_main_uVote/user_main_uVote.php
+++ b/uVote/page/user_main_uVote/user_main_uVote.php
@@ -1,7 +1,17 @@
uvote_to_parties();
$vars['votes_all'] = $this->votes_all();
$vars['votes_all_bt'] = $this->votes_all_bt();
$vars['user_count'] = $this->user_count();
+ $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, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
+ $vars = array_merge($vars, \SYSTEM\locale::getStrings(100));
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'),$vars);
}
diff --git a/uVote/page/user_main_uVote/uvoteparties.tpl b/uVote/page/user_main_uVote/uvoteparties.tpl
new file mode 100644
index 0000000..8c30031
--- /dev/null
+++ b/uVote/page/user_main_uVote/uvoteparties.tpl
@@ -0,0 +1,8 @@
+
+
+
+
+ ${class_MATCH}
+ ${class_MISSMATCH}
+ ${match_percentage}%
+
\ No newline at end of file
diff --git a/uVote/page/user_main_urVote/all_polls.tpl b/uVote/page/user_main_urVote/all_polls.tpl
new file mode 100644
index 0000000..3027b6b
--- /dev/null
+++ b/uVote/page/user_main_urVote/all_polls.tpl
@@ -0,0 +1,15 @@
+
+
Aktueller Status
+
+
+
Teilnahme an aktuellen Abstimmungen
+
+
+ Teilgenommen: ${voted},
+ nicht Teilgenommen: ${not_voted}
+
+
+
diff --git a/uVote/page/user_main_urVote/overall_all_polls.tpl b/uVote/page/user_main_urVote/overall_all_polls.tpl
new file mode 100644
index 0000000..bcafd92
--- /dev/null
+++ b/uVote/page/user_main_urVote/overall_all_polls.tpl
@@ -0,0 +1,11 @@
+
+
Abstimmungsquote seit Accounterstellung
+
+
+ Teilgenommen: ${voted},
+ nicht Teilgenommen: ${not_voted}
+
+
\ No newline at end of file
diff --git a/uVote/page/user_main_urVote/urVote.tpl b/uVote/page/user_main_urVote/urVote.tpl
index c4463d9..ac9ef02 100644
--- a/uVote/page/user_main_urVote/urVote.tpl
+++ b/uVote/page/user_main_urVote/urVote.tpl
@@ -1,10 +1,12 @@
-
${urVote_title}
+
${urVote_title}
+ ${urvote_body_text}
${urVote_user_party_compare}
+ ${urvote_user_party_compare_sub}
${choices_user_ID}
@@ -16,6 +18,12 @@
${user_temp_votes}
+
+
+ ${user_overall_votes}
+
+
+
\ No newline at end of file
diff --git a/uVote/page/user_main_urVote/user_main_urVote.php b/uVote/page/user_main_urVote/user_main_urVote.php
index 4fc1a7c..10cb93c 100644
--- a/uVote/page/user_main_urVote/user_main_urVote.php
+++ b/uVote/page/user_main_urVote/user_main_urVote.php
@@ -3,56 +3,68 @@ class user_main_urVote extends SYSTEM\PAGE\Page {
+ private function user_overall_votes (){
+ $vars = votes::get_user_overall_votes(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->creationDate);
+ $v = $vars['voted'] > 1 ? $vars['voted'] : 1;
+ $nv = $vars['not_voted'];
+ return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/overall_all_polls.tpl'),
+ array( 'vote_perc'=> round($v/($nv+$v)*100, 2),
+ 'no_vote_perc'=> round($nv/($nv+$v)*100, 2),
+ 'voted'=> $v,
+ 'not_voted'=> $nv));
+ }
+
private function user_temp_votes (){
$vars = votes::get_user_temp_votes(\SYSTEM\SECURITY\Security::getUser()->id);
$v = $vars['voted'];
$nv = $vars['not_voted'];
+ print_r($vars, true);
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/all_polls.tpl'),
- array( 'vote_perc'=> round($v/($nv+$v)*100,0),
- 'no_vote_perc'=> round($nv/($nv+$v)*100,0),
+ array( 'vote_perc'=> round($v/($nv+$v)*100, 2),
+ 'no_vote_perc'=> round($nv/($nv+$v)*100, 2),
'voted'=> $v,
'not_voted'=> $nv));
}
- private function user_to_bt(){
- //$vars = votes::get_user_per_party_overall($user_ID);
- $result = '';
- $con = new \SYSTEM\DB\Connection();
- $res = $con->prepare( 'bt_to_user',
- 'SELECT sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
- sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
- FROM uvote_data LEFT JOIN uvote_votes
- ON uvote_data.poll_ID = uvote_votes.ID
- WHERE user_ID = ?;',
- array(\SYSTEM\SECURITY\Security::getUser()->id));
- while($row = $res->next()){
- $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH']+1)*100,2);
-
- $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/bt_to_user_overall.tpl'), $row);
- }
- return $result;
- $row['votes_cast'] = round(($row['class_MATCH']+$row['class_MISSMATCH']),2);
+ private function user_to_bt(){
+ //$vars = votes::get_user_per_party_overall($user_ID);
+ $result = '';
+ $con = new \SYSTEM\DB\Connection();
+ $res = $con->prepare( 'bt_to_user',
+ 'SELECT sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
+ sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
+ FROM uvote_data LEFT JOIN uvote_votes
+ ON uvote_data.poll_ID = uvote_votes.ID
+ WHERE user_ID = ?;',
+ array(\SYSTEM\SECURITY\Security::getUser()->id));
+ while($row = $res->next()){
+ $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH']+1)*100,2);
+
+ $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/bt_to_user_overall.tpl'), $row);
}
-
+ return $result;
+ $row['votes_cast'] = round(($row['class_MATCH']+$row['class_MISSMATCH']),2);
+}
- private function user_per_party_overall(){
- //$vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id));
- $result = '';
- $con = new \SYSTEM\DB\Connection();
- $res = $con->prepare( 'test',
- 'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
- sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
- FROM uvote_data INNER JOIN uvote_votes_per_party
- ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
- WHERE user_ID = ? GROUP BY party;',
- array(\SYSTEM\SECURITY\Security::getUser()->id));
- while($row = $res->next()){
- $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
- $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urvoteparties.tpl'), $row);;
- }
- return $result;
+
+ private function user_per_party_overall(){
+ //$vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id));
+ $result = '';
+ $con = new \SYSTEM\DB\Connection();
+ $res = $con->prepare( 'test',
+ 'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
+ sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
+ FROM uvote_data INNER JOIN uvote_votes_per_party
+ ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
+ WHERE user_ID = ? GROUP BY party;',
+ array(\SYSTEM\SECURITY\Security::getUser()->id));
+ while($row = $res->next()){
+ $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
+ $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urvoteparties.tpl'), $row);;
}
+ return $result;
+}
public function html(){
$vars = array();
@@ -61,6 +73,7 @@ class user_main_urVote extends SYSTEM\PAGE\Page {
$vars['choices_bt_to_user'] = $this->user_to_bt();
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
$vars['user_temp_votes'] = $this->user_temp_votes();
+ $vars['user_overall_votes'] = $this->user_overall_votes();
$vars = array_merge($vars, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urVote.tpl'),$vars);