From 14c7691cd994d0788283bff750841799dba1f478 Mon Sep 17 00:00:00 2001 From: Naeltard Date: Fri, 2 Oct 2015 19:37:06 +0200 Subject: [PATCH] new order --- .../default_bulletin/default_bulletin.php | 9 +- uvote/page/default_bulletin/tpl/bars_user.tpl | 6 +- .../tpl/icons_table_parties.tpl | 7 - uvote/page/default_bulletin/tpl/table_bt.tpl | 6 +- .../default_bulletin/tpl/table_parties.tpl | 14 +- uvote/page/default_bulletin/tpl/vote_bt.tpl | 14 +- uvote/page/default_page/js/loadtexts.js | 4 +- uvote/page/default_page/tpl/page.tpl | 20 +- uvote/page/default_page/tpl/vote.tpl | 2 +- uvote/page/page_uvote.php | 2 +- uvote/page/user_list_active/tpl/active.tpl | 8 + .../user_list_active/user_list_active.php | 6 +- uvote/page/user_main/js/user_main.js | 7 + uvote/page/user_main/main_menu.tpl | 38 +--- .../page/user_main_poll/js/user_main_poll.js | 13 ++ uvote/page/user_main_poll/tpl/full_vote.tpl | 24 ++- uvote/page/user_main_poll/user_main_poll.php | 182 +++++++++++++++++- uvote/sql/qq/UVOTE_GENERATE_VOTELIST.php | 2 +- uvote/sql/qq/UVOTE_POLL_EXPIRED.php | 2 +- 19 files changed, 286 insertions(+), 80 deletions(-) create mode 100644 uvote/page/user_main_poll/js/user_main_poll.js diff --git a/uvote/page/default_bulletin/default_bulletin.php b/uvote/page/default_bulletin/default_bulletin.php index ed401eb..15fb5c7 100644 --- a/uvote/page/default_bulletin/default_bulletin.php +++ b/uvote/page/default_bulletin/default_bulletin.php @@ -193,11 +193,12 @@ class default_bulletin extends SYSTEM\PAGE\Page { } private function js(){ - return '';} + return \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin/js/vote.js'));} private function css(){ - return ''. - ''. - '';} + return \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\bars_user.css')). + \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\bulletin.css')). + \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\comment.css')); + } diff --git a/uvote/page/default_bulletin/tpl/bars_user.tpl b/uvote/page/default_bulletin/tpl/bars_user.tpl index a502a85..2d67845 100644 --- a/uvote/page/default_bulletin/tpl/bars_user.tpl +++ b/uvote/page/default_bulletin/tpl/bars_user.tpl @@ -1,7 +1,7 @@
${bulletin_bars_title}
${urvote_bars_user}
-
${vote_yes_perc}%
-
${vote_no_perc}%
-
${vote_ent_perc}%
+
${vote_yes_perc}%
+
${vote_no_perc}%
+
${vote_ent_perc}%
diff --git a/uvote/page/default_bulletin/tpl/icons_table_parties.tpl b/uvote/page/default_bulletin/tpl/icons_table_parties.tpl index b082c99..fa6b9e8 100644 --- a/uvote/page/default_bulletin/tpl/icons_table_parties.tpl +++ b/uvote/page/default_bulletin/tpl/icons_table_parties.tpl @@ -1,8 +1 @@
${urvote_party_table_desc}
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/uvote/page/default_bulletin/tpl/table_bt.tpl b/uvote/page/default_bulletin/tpl/table_bt.tpl index 5e75d86..7237f29 100644 --- a/uvote/page/default_bulletin/tpl/table_bt.tpl +++ b/uvote/page/default_bulletin/tpl/table_bt.tpl @@ -1,6 +1,6 @@ Ergebnis Bundestag
-
${bt_pro}%
-
${bt_con}%
-

${bt_ent}%

+
${bt_pro}%
+
${bt_con}%
+

${bt_ent}%

diff --git a/uvote/page/default_bulletin/tpl/table_parties.tpl b/uvote/page/default_bulletin/tpl/table_parties.tpl index 699e779..1fc807c 100644 --- a/uvote/page/default_bulletin/tpl/table_parties.tpl +++ b/uvote/page/default_bulletin/tpl/table_parties.tpl @@ -1,6 +1,12 @@ -
-
${party_yes}%
-
${party_no}%
-
${party_ent}%
+
+
+
${party_yes}%
+
+
+
${party_no}%
+
+
+
${party_ent}%
+
diff --git a/uvote/page/default_bulletin/tpl/vote_bt.tpl b/uvote/page/default_bulletin/tpl/vote_bt.tpl index 05813f2..381e96e 100644 --- a/uvote/page/default_bulletin/tpl/vote_bt.tpl +++ b/uvote/page/default_bulletin/tpl/vote_bt.tpl @@ -1,8 +1,8 @@ -
-
-
${choice}
-
${party_yes}%
-
${party_no}%
-
${party_ent}%
-
${party_off}%
+
+
+
${choice}
+
${party_yes}%
+
${party_no}%
+
${party_ent}%
+
${party_off}%
\ No newline at end of file diff --git a/uvote/page/default_page/js/loadtexts.js b/uvote/page/default_page/js/loadtexts.js index 79987c8..8aeb6b4 100644 --- a/uvote/page/default_page/js/loadtexts.js +++ b/uvote/page/default_page/js/loadtexts.js @@ -38,7 +38,7 @@ function register_logout(){ function load_openvoteinfo (poll_ID){ var openvoteinfo; - $.get('./index.php?action=openinfo&poll_ID=' + poll_ID, function (data) { + $.get('./api.php?page=openinfo&poll_ID=' + poll_ID, function (data) { openvoteinfo = data; bodyelem = $(""); bodyelem.animate(); @@ -62,7 +62,7 @@ function get_barsperparty (poll_ID) { } function vote_click (poll_ID, vote) { - $.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) { + $.getJSON('./api.php?call=vote&page=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) { var items = []; if(data.status == true){ alert("success"); diff --git a/uvote/page/default_page/tpl/page.tpl b/uvote/page/default_page/tpl/page.tpl index c9283ae..5c02c9f 100644 --- a/uvote/page/default_page/tpl/page.tpl +++ b/uvote/page/default_page/tpl/page.tpl @@ -34,11 +34,23 @@
-
- -
- + +
+
+ +
diff --git a/uvote/page/default_page/tpl/vote.tpl b/uvote/page/default_page/tpl/vote.tpl index c071dee..00eea39 100644 --- a/uvote/page/default_page/tpl/vote.tpl +++ b/uvote/page/default_page/tpl/vote.tpl @@ -2,7 +2,7 @@
${title}
- ${full_vote_btn} + ${full_vote_btn} ${fade}
diff --git a/uvote/page/page_uvote.php b/uvote/page/page_uvote.php index faf5ecc..a72344e 100644 --- a/uvote/page/page_uvote.php +++ b/uvote/page/page_uvote.php @@ -29,7 +29,7 @@ class page_uvote extends \SYSTEM\API\api_default { //return (new user_main_poll($poll_ID))->html();} if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ return (new default_register ())->html();} - return (new default_bulletin($poll_ID))->html();} + return (new user_main_poll($poll_ID))->html();} public static function page_user_list(){ return (new user_list())->html();} diff --git a/uvote/page/user_list_active/tpl/active.tpl b/uvote/page/user_list_active/tpl/active.tpl index 4700613..db8fd60 100644 --- a/uvote/page/user_list_active/tpl/active.tpl +++ b/uvote/page/user_list_active/tpl/active.tpl @@ -1,2 +1,10 @@ +
+
+ ${welcome_text} + ${user_count} Nutzer auf uVote +
+ + +
${votelist} \ No newline at end of file diff --git a/uvote/page/user_list_active/user_list_active.php b/uvote/page/user_list_active/user_list_active.php index 8d06192..c2b3203 100644 --- a/uvote/page/user_list_active/user_list_active.php +++ b/uvote/page/user_list_active/user_list_active.php @@ -39,7 +39,10 @@ class user_list_active extends SYSTEM\PAGE\Page { return ''; } } - + private function user_count(){ + $vars = votes::get_user_count(); + return $vars['count']; + } public function generate_votelist(){ $result = array('',''); $votes = votes::getAllVotesOfGroup(1); @@ -98,6 +101,7 @@ class user_list_active extends SYSTEM\PAGE\Page { $vars = array(); $vars['votelist'] = $this->generate_votelist(); $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=files&cat=frontend_logos&id='; + $vars['user_count'] = $this->user_count(); $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register')); $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote')); return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_list_active/tpl/active.tpl'), $vars); diff --git a/uvote/page/user_main/js/user_main.js b/uvote/page/user_main/js/user_main.js index 99d2afa..7fd3d6e 100644 --- a/uvote/page/user_main/js/user_main.js +++ b/uvote/page/user_main/js/user_main.js @@ -1,5 +1,12 @@ function init_user_main(){ register_registerform(); + + //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(); + + $('#feedback_submit').click(function (data){ var test = $('textarea#feedback_text').val(); send_feedback(test); diff --git a/uvote/page/user_main/main_menu.tpl b/uvote/page/user_main/main_menu.tpl index 055e91d..dec6819 100644 --- a/uvote/page/user_main/main_menu.tpl +++ b/uvote/page/user_main/main_menu.tpl @@ -1,45 +1,9 @@ -
-
-
-

- Feedback -

-
-
-
-
-
-

uVote BETA Feedback

- -
- -
-
-
-
+
diff --git a/uvote/page/user_main_poll/js/user_main_poll.js b/uvote/page/user_main_poll/js/user_main_poll.js new file mode 100644 index 0000000..98bbf96 --- /dev/null +++ b/uvote/page/user_main_poll/js/user_main_poll.js @@ -0,0 +1,13 @@ +function init_user_main_poll(){ + $('.btnvote_yes').click(function () { + vote_click($(this).attr('poll_ID'),1); + }); + $('.btnvote_no').click(function () { + vote_click($(this).attr('poll_ID'),2); + }); + $('.btnvote_off').click(function () { + vote_click($(this).attr('poll_ID'),3); + }); + + +} \ No newline at end of file diff --git a/uvote/page/user_main_poll/tpl/full_vote.tpl b/uvote/page/user_main_poll/tpl/full_vote.tpl index 47f533b..eeea1e8 100644 --- a/uvote/page/user_main_poll/tpl/full_vote.tpl +++ b/uvote/page/user_main_poll/tpl/full_vote.tpl @@ -1,8 +1,28 @@ +
+
+

${title}

+ + ${openvote_help_text} + + ${title} + ${openvote_help_text1} + ${vote_buttons} + ${voice_weight} +
+
+ ${bars_user}
+ ${bars_bt} +
+
+ ${icons_party} + ${choice_party} +
+
-
+ -
+
diff --git a/uvote/page/user_main_poll/user_main_poll.php b/uvote/page/user_main_poll/user_main_poll.php index b1e80e5..51821b3 100644 --- a/uvote/page/user_main_poll/user_main_poll.php +++ b/uvote/page/user_main_poll/user_main_poll.php @@ -4,9 +4,187 @@ class user_main_poll extends SYSTEM\PAGE\Page { public function __construct($poll_ID){ $this->poll_ID = $poll_ID; } + 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/tpl/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) : $pv['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 bars_user(){ + $bars = votes::get_barsperusers($this->poll_ID,false); + $bars['vote_yes_perc'] = round($bars['yes_perc']*100,0); + $bars['vote_no_perc'] = round($bars['no_perc']*100,0); + $bars['vote_ent_perc'] = round($bars['ent_perc']*100,0); + $bars['title'] = 'Gemessen auf uVote'; + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/bars_user.tpl'),$bars); + } + + private function bars_party(){ + $partyvotes = votes::get_barsperparty($this->poll_ID); + + $result = ""; + foreach($partyvotes as $vote){ + $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/tpl/table_parties.tpl'), $vote); + } + + return $result; + } + + private function icons_party(){ + $vars = votes::get_bar_bt_per_poll($this->poll_ID); + if (!$vars['bt_total']){ + return '';} + $info = array(); + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/icons_table_parties.tpl'), $info); + } + + private function bars_bt(){ + $vars = votes::get_bar_bt_per_poll($this->poll_ID); + if (!$vars['bt_total']){ + return 'Keine Ergebnisse für den Bundestag verfügbar';} + $vars['bt_ent'] = round(($vars['bt_attending'] - $vars['bt_pro'] - $vars['bt_con'])/$vars['bt_total']*100,0); + $vars['bt_pro'] = round($vars['bt_pro']/$vars['bt_total']*100,0); + $vars['bt_con'] = round($vars['bt_con']/$vars['bt_total']*100,0); + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/table_bt.tpl'), $vars); + } + + private function voice_weight(){ + $vars = votes::get_count_user_votes_per_poll($this->poll_ID); + $vars['voteweight'] = $vars['count'] ? round(1/$vars['count']*100) : 'no votes'; + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/voteweight.tpl'), $vars); + } + + private function p_fields (){ + $result = ""; + + $list = array (array(1, 'Aussenpolitik'), + array(2, 'Aussenpolitik'), + array(4, 'Aussenpolitik'), + array(8, 'Aussenpolitik')); + foreach($list as $l){ + if($p_fields & $l[0]) $result .= $l[1]; + } + return $result; + } + + private function vote_buttons($poll_expired,$user_poll){ + if($poll_expired){ + if(!$user_poll){ + return '
Stimme hier ab
+ Pro + Contra + Enthaltung';} + $classes = array('','',''); + switch($user_poll){ + 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 Stimme hier ab
+ Pro + Contra + Enthaltung + '; + } else { + return 'ye soon to come infos'; + } + } + private function get_voteinfo(){ + $var = votes::get_voteinfo($this->poll_ID); + return $var['iframe_link']; + } + private function js(){ + return \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin/js/vote.js'));} + private function css(){ + return \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\bars_user.css')). + \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\bulletin.css')). + \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\comment.css')); + } public function html(){ - $vote = votes::get_voteinfo($this->poll_ID); //votes::getVoteOfGroup($poll_ID); - $result = SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/full_vote.tpl'), $vote); + $poll_expired = \SQL\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID)); + $user_vote = votes::getUserPollData($this->poll_ID); + $vars = array(); + $vars = array_merge($vars,votes::get_voteinfo($this->poll_ID)); + //$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['vote_buttons'] = $this->vote_buttons($poll_expired, $user_vote); + $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=files&cat=frontend_logos&id='; + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register')); + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote')); + //$vars['vote'] = $this->get_voteinfo(); //votes::getVoteOfGroup($poll_ID); + $result = SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/full_vote.tpl'), $vars); return $result; } diff --git a/uvote/sql/qq/UVOTE_GENERATE_VOTELIST.php b/uvote/sql/qq/UVOTE_GENERATE_VOTELIST.php index 707b920..09a07f0 100644 --- a/uvote/sql/qq/UVOTE_GENERATE_VOTELIST.php +++ b/uvote/sql/qq/UVOTE_GENERATE_VOTELIST.php @@ -4,5 +4,5 @@ namespace SQL; class UVOTE_GENERATE_VOTELIST extends \SYSTEM\DB\QP { public static function get_class(){return \get_class();} public static function mysql(){return -'SELECT * FROM `uvote_votes` WHERE `group` = ? AND time_end > NOW() ORDER BY (time_end-time_start) ASC;' +'SELECT * FROM `uvote_votes` WHERE `group` = ? ORDER BY (time_end-time_start) ASC;' ;}} \ No newline at end of file diff --git a/uvote/sql/qq/UVOTE_POLL_EXPIRED.php b/uvote/sql/qq/UVOTE_POLL_EXPIRED.php index 03de097..26963f9 100644 --- a/uvote/sql/qq/UVOTE_POLL_EXPIRED.php +++ b/uvote/sql/qq/UVOTE_POLL_EXPIRED.php @@ -4,5 +4,5 @@ namespace SQL; class UVOTE_POLL_EXPIRED extends \SYSTEM\DB\QP { public static function get_class(){return \get_class();} public static function mysql(){return -'SELECT * FROM `uvote_votes` WHERE `ID` = ? AND time_end > CURDATE();' +'SELECT * FROM `uvote_votes` WHERE `ID` = ?;' ;}} \ No newline at end of file