diff --git a/uvote/api/api_uvote.php b/uvote/api/api_uvote.php index 2bf568c..00b0307 100644 --- a/uvote/api/api_uvote.php +++ b/uvote/api/api_uvote.php @@ -4,7 +4,8 @@ class api_uvote extends \SYSTEM\API\api_system { //votes public static function call_vote_action_vote($poll_ID, $vote) { return votes::write_vote($poll_ID, $vote);} - + public static function call_vote_action_vote_sub($poll_ID, $vote) { + return votes::write_vote_sub($poll_ID, $vote);} public static function call_vote_action_data($location, $birthyear, $gender, $children) { return votes::write_data($location, $birthyear, $gender, $children);} @@ -23,16 +24,50 @@ class api_uvote extends \SYSTEM\API\api_system { return votes::vote_accord_with_party($party);} //graphs - public static function call_graph_bt_to_uvote_overall_by_time($timespan = 84600){ + public static function call_graph_bt_to_uvote_overall_by_time($timespan = 592200){ return graphs::graph_bt_to_uvote_overall_by_time($timespan);} - public static function call_graph_bt_to_user_overall_by_time($timespan = 84600){ + public static function call_graph_bt_to_user_overall_by_time($timespan = 592200){ return graphs::graph_bt_to_user_overall_by_time($timespan);} - + public static function call_graph_party_to_user_overall_by_time_party_cdu($party = 'cdu', $timespan = 592200){ + return graphs::graph_party_to_user_overall_by_time($party, $timespan);} + public static function call_graph_party_to_user_overall_by_time_party_csu($party = 'csu', $timespan = 592200){ + return graphs::graph_party_to_user_overall_by_time($party, $timespan);} + public static function call_graph_party_to_user_overall_by_time_party_spd($party = 'spd', $timespan = 592200){ + return graphs::graph_party_to_user_overall_by_time($party, $timespan);} + public static function call_graph_party_to_user_overall_by_time_party_gruene($party = 'gruene', $timespan = 592200){ + return graphs::graph_party_to_user_overall_by_time($party, $timespan);} + public static function call_graph_party_to_user_overall_by_time_party_linke($party = 'linke', $timespan = 592200){ + return graphs::graph_party_to_user_overall_by_time($party, $timespan);} + + public static function call_donut_party_to_user_overall(){ + return graphs::donut_party_to_user_overall();} + public static function call_donut_party_to_community_overall(){ + return graphs::donut_party_to_community_overall();} //comments public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) { return comments::write_comment($poll_ID, $c_choice, $c_txt, $c_src);} public static function call_vote_action_commentrate($c_ID, $val) { return comments::write_commentrate($c_ID, $val);} + + public static function call_load_tab($set, $cat){ + if($set == 'basic'){ + return stats_basic::basic_basic($cat); + } + if($set == 'bilance'){ + return stats_bilance::basic_bilance($cat); + } + if($set == 'bilance_choice'){ + return stats_bilance_choice::basic_bilance_choice($cat); + } + } + public static function call_load_list($filter, $time){ + return lists::generate_votelist($filter); + } + public static function call_load_list_text_search($text){ + return lists::text_search($text); + } } + + \ No newline at end of file diff --git a/uvote/api/votes/bars.php b/uvote/api/votes/bars.php new file mode 100644 index 0000000..144fe4e --- /dev/null +++ b/uvote/api/votes/bars.php @@ -0,0 +1,132 @@ + 0 ? round($vars['total_pro']/$vars['total_total']*100) : 0; + $vars['total_con_percentage'] = $vars['total_total'] > 0 ? round($vars['total_con']/$vars['total_total']*100) : 0; + $vars['total_ent_percentage'] = $vars['total_total'] > 0 ? round($vars['total_ent']/$vars['total_total']*100) : 0; + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/user_total.tpl'),$vars); + } + public static function get_uvote_choice_overall(){ + $vars = \SQL\UVOTE_DATA_CHOICE_OVERALL::Q1(array()); + $vars['total_total'] = $vars['pro'] + $vars['con'] + $vars['ent']; + $vars['total_pro_percentage'] = round($vars['pro']/$vars['total_total']*100+1); + $vars['total_con_percentage'] = round($vars['con']/$vars['total_total']*100+1); + $vars['total_ent_percentage'] = round($vars['ent']/$vars['total_total']*100+1); + new SYSTEM\LOG\INFO($vars['total_ent_percentage']); + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/uvote_total.tpl'),$vars); + } + public static function get_bt_choice_overall(){ + $vars = \SQL\UVOTE_DATA_CHOICE_BT_OVERALL::Q1(array()); + $vars['total_total'] = $vars['pro'] + $vars['con'] + $vars['ent']; + $vars['total_pro_percentage'] = round($vars['pro']/$vars['total_total']*100+1); + $vars['total_con_percentage'] = round($vars['con']/$vars['total_total']*100+1); + $vars['total_ent_percentage'] = round($vars['ent']/$vars['total_total']*100+1); + new SYSTEM\LOG\INFO($vars['total_ent_percentage']); + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/bt_total.tpl'),$vars); + } + public static function bilance_community(){ + $result = ''; + $vars = \SQL\UVOTE_DATA_UVOTE_TO_PARTY_OVERALL::QA(array()); + foreach($vars as $bar){ + $bar['match_percentage'] = round($bar['class_MATCH']/($bar['class_MATCH']+$bar['class_MISSMATCH'])*100,2); + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_bilance/bars_community.tpl'), $bar); + } + return $result; + } + public static function bilance_bt(){ + $result = ''; + $vars = \SQL\UVOTE_DATA_BT_TO_PARTY_OVERALL::QA(array()); + foreach($vars as $bar){ + $bar['match_percentage'] = round($bar['class_MATCH']/($bar['class_MATCH']+$bar['class_MISSMATCH'])*100,2); + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_bilance/bars_community.tpl'), $bar); + } + return $result; + } + public static function bilance_user(){ + $result = ''; + $res = \SQL\UVOTE_DATA_USER_BILANCE::QA(array(\SYSTEM\SECURITY\Security::getUser()->id)); + foreach($res as $row){ + //$res2 = votes::vote_accord_with_party($row['party']); + //$row['according_laws'] = self::build_according_law_html($res2, $row['party']); + $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_analysis/tpl/tab_bilance/bars_user.tpl'), $row); + } + return $result; + } + public static function build_according_law_html($part, $party){ + $part = json_decode($part, true); + $result = "
Bei folgenden Gesetzen hast du genauso abgestimmt wie die ".$party.":

"; + foreach ($part['result'] as $p){ + $result .= $p['title']."
"; + } + $result .= "

"; + return $result; + } + public static function bilance_choice_user_party($choice){ + $bar = switchers::bar_class($choice); + $result = ''; + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'user_to_party_by_choice', + '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 = ? AND uvote_votes_per_party.choice = ? GROUP BY party;', + array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); + while($row = $res->next()){ + $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2); + $row['bar'] = $bar; + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_bilance_choice/bars_user.tpl'), $row);; + } + if(empty($result)){ + return 'Keine relevanten Daten verfügbar'; + } + return $result; + } + public static function bilance_choice_user_bt($choice){ + $bar = switchers::bar_class($choice); + $icon_type = switchers::tablerow_class($choice); + $result = ''; + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'user_to_party_by_choice_bt', + 'SELECT user_ID, 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 INNER JOIN uvote_votes + ON uvote_data.poll_ID = uvote_votes.ID + WHERE user_ID = ? AND uvote_votes.bt_choice = ? GROUP by user_ID;', + array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); + while($row = $res->next()){ + if(empty($row['class_MATCH'])){ + return 'Keine relevanten Daten verfügbar

'; + } + $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2); + $row['bar'] = $bar; + $row['icon_type'] = $icon_type; + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_bilance_choice/urvotebt_by_choice.tpl'), $row);; + } + if(empty($result)){ + return 'Keine relevanten Daten verfügbar

'; + } + + return $result; + } + public static function bilance_user_bt(){ + $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'] = ($row['class_MATCH']+$row['class_MISSMATCH']) > 0 ? round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2) : 0; + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_bilance/bars_user_bt.tpl'), $row); + } + return $result; + } +} \ No newline at end of file diff --git a/uvote/api/votes/graphs.php b/uvote/api/votes/graphs.php index a64bb21..02622c7 100644 --- a/uvote/api/votes/graphs.php +++ b/uvote/api/votes/graphs.php @@ -16,10 +16,51 @@ class graphs { public static function graph_bt_to_user_overall_by_time ($timespan = 84600,$returnasjson = true){ $result = array(); $res = \SQL\UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id)); + $matchhandler = 0; + $missmatchhandler = 0; while ($row = $res->next()){ + $match = $row['class_match']+$matchhandler; + $missmatch = $row['class_mismatch']+$missmatchhandler; $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)); + 'class_match' => ($match) / ($match+$missmatch)*100); + $matchhandler = $match; + $missmatchhandler = $missmatch; + } + return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result; + } + + public static function graph_party_to_user_overall_by_time ($party, $timespan, $returnasjson = true){ + $result = array(); + $res = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, $party, \SYSTEM\SECURITY\Security::getUser()->id)); + $total = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH::Q1(array($party, \SYSTEM\SECURITY\Security::getUser()->id)); + $matchhandler = 0; + $missmatchhandler = 0; + while ($row = $res->next()){ + $match = $row['class_match']+$matchhandler; + $missmatch = $row['class_mismatch']+$missmatchhandler; + $result[] = array( 0 => $row['day'], + 'class_match' => ($match) / ($match+$missmatch)*100); + $matchhandler = $match; + $missmatchhandler = $missmatch; + } + return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result; + } + + public static function donut_party_to_user_overall ($returnasjson = true){ + $result = array(); + $res = \SQL\UVOTE_DATA_USER_TO_PARTIES_OVERALL::QQ(array(\SYSTEM\SECURITY\Security::getUser()->id)); + while ($row = $res->next()){ + $result[] = array( 0 => $row['party'], + 'class_match' => $row['class_MATCH']); + } + return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result; + } + public static function donut_party_to_community_overall ($returnasjson = true){ + $result = array(); + $res = \SQL\UVOTE_DATA_COMMUNITY_TO_PARTIES_OVERALL::QQ(array()); + while ($row = $res->next()){ + $result[] = array( 0 => $row['party'], + 'class_match' => $row['class_MATCH']); } return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result; } diff --git a/uvote/api/votes/lists.php b/uvote/api/votes/lists.php new file mode 100644 index 0000000..6c336c2 --- /dev/null +++ b/uvote/api/votes/lists.php @@ -0,0 +1,78 @@ + 0 ? 'Abstimmen' : 'Ansehen'; + $vote['uv'] = $vote['bt'] = ''; + $vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5'; + $user_vote = votes::getUserPollData($vote['ID']); + $vote['vote_class'] = switchers::tablerow_class($user_vote); + $vote['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id='; + if($time_remain > 0){ + $vote['statusmarker'] = 'aktuell'; + $result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); + } else { + $vote['statusmarker'] = 'vergangen'; + $result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); + } + } + return $result[0].$result[1]; + } + public static function get_all_tags_of_vote($poll_ID){ + $result = ''; + $vars = \SQL\UVOTE_DATA_USER_TAGS_OF_VOTE::QA(array($poll_ID)); + foreach ($vars as $tag){ + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/tag.tpl'),$tag); + } + return $result; + } + + public static function text_search($text){ + $result = array('',''); + $votes = \SQL\UVOTE_DATA_TEXT_SEARCH::QA(array($text)); + foreach($votes as $vote){ + $time_remain = strtotime($vote['time_end'])- microtime(true); + $time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']); + $vote_count = votes::get_count_user_votes_per_poll($vote['ID']); + $vote['votecount'] = $vote_count['count']; + $vote['tags'] = self::get_all_tags_of_vote($vote['ID']); + $vote['time_left'] = round($time_remain/($time_span+1)*100,0); + $vote['time_done'] = 100-$vote['time_left']; + $vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen'; + $vote['uv'] = $vote['bt'] = ''; + $vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5'; + $user_vote = votes::getUserPollData($vote['ID']); + $vote['vote_class'] = switchers::tablerow_class($user_vote); + $vote['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id='; + if($time_remain > 0){ + $vote['statusmarker'] = 'aktuell'; + $result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); + } else { + $vote['statusmarker'] = 'vergangen'; + $result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); + } + } + return $result[0].$result[1]; + } +} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + diff --git a/uvote/api/votes/stats_basic.php b/uvote/api/votes/stats_basic.php new file mode 100644 index 0000000..a531a38 --- /dev/null +++ b/uvote/api/votes/stats_basic.php @@ -0,0 +1,41 @@ +id); + $vars['user_temp_votes'] = votes::get_user_temp_votes(); + $vars['user_overall_votes'] = votes::get_user_overall_votes(); + $vars['analysis_help_basic_stats'] = \SYSTEM\PAGE\text::get('analysis_help_basic_stats'); + $vars['analysis_math_basic_stats'] = \SYSTEM\PAGE\text::get('analysis_math_basic_stats'); + $vars['analysis_help_basic_votes'] = \SYSTEM\PAGE\text::get('analysis_help_basic_votes'); + $vars['analysis_math_basic_votes'] = \SYSTEM\PAGE\text::get('analysis_math_basic_votes'); + $vars['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id='; + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/tab_basic_user.tpl'),$vars); + } + public static function community_basic(){ + $vars['basic_stats_community'] = bars::get_uvote_choice_overall(); + $vars['analysis_help_community'] = \SYSTEM\PAGE\text::get('analysis_help_community'); + $vars['analysis_math_community'] = \SYSTEM\PAGE\text::get('analysis_math_community'); + $vars['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id='; + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/tab_basic_community.tpl'),$vars); + } + + public static function bt_basic(){ + $vars['basic_stats_bt'] = bars::get_bt_choice_overall(); + $vars['analysis_help_bt_basic'] = \SYSTEM\PAGE\text::get('analysis_help_bt_basic'); + $vars['analysis_math_bt_basic'] = \SYSTEM\PAGE\text::get('analysis_math_bt_basic'); + $vars['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id='; + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/tab_basic_bt.tpl'),$vars); + } +} diff --git a/uvote/api/votes/stats_bilance.php b/uvote/api/votes/stats_bilance.php new file mode 100644 index 0000000..81e43b4 --- /dev/null +++ b/uvote/api/votes/stats_bilance.php @@ -0,0 +1,46 @@ +prepare( 'selVoteByGrp', - 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ?;', + 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ? AND uvote_data.group = 1;', + array(\SYSTEM\SECURITY\Security::getUser()->id,$poll_ID)); + $result = $res->next(); + return $result['choice']; + } + public static function getUserPollDataSub($poll_ID){ + if (!\SYSTEM\SECURITY\Security::isLoggedIn()){ + return NULL;} + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selVoteByGrp', + 'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ? AND uvote_data.group = 2;', array(\SYSTEM\SECURITY\Security::getUser()->id,$poll_ID)); $result = $res->next(); return $result['choice']; } public static function get_barsperusers($poll_ID,$return_as_json = true){ - $con = new \SYSTEM\DB\Connection(new \SQL\uVote()); + $con = new \SYSTEM\DB\Connection(); //count $res = $con->prepare( 'selVoteBy_count', 'SELECT COUNT(*) as "count" FROM `uvote_data` WHERE `poll_ID` = ?;', @@ -72,11 +84,25 @@ class votes { return $res; } - public static function get_user_temp_votes($user_ID){ - return \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array($user_ID, $user_ID, $user_ID));} + public static function get_user_temp_votes(){ + $vars = \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id)); + $v = $vars['voted']; + $nv = $vars['not_voted']; + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/temp_votes.tpl'), + array( 'vote_percent'=> $v > 0 ? round($v/($nv+$v)*100, 2) : 0, + 'no_vote_percent'=> $nv > 0 ? round($nv/($nv+$v)*100, 2) : 0, + 'voted'=> $v, + 'not_voted'=> $nv));} - public static function get_user_overall_votes($user_ID, $creationDate){ - return \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array($user_ID, $user_ID, $user_ID, $creationDate));} + public static function get_user_overall_votes(){ + $vars = \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->creationDate)); + $v = $vars['voted']; + $nv = $vars['not_voted']; + return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/tab_basic/overall_votes.tpl'), + array( 'vote_perc'=> $v > 0 ? round($v/($nv+$v)*100, 2) : 0, + 'no_vote_perc'=> $v > 0 ? round($nv/($nv+$v)*100, 2) : 0, + 'voted'=> $v, + 'not_voted'=> $nv));} public static function get_bar_bt_per_poll($poll_ID){ return \SQL\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));} @@ -104,7 +130,8 @@ class votes { $user = \SYSTEM\SECURITY\Security::getUser()->id; $data = \SQL\UVOTE_ACCORD_WITH_FRACTION::QA(array($party,$user)); //$data_escaped = array_walk_recursive($data, 'mysql_real_escape_string'); - return \SYSTEM\LOG\JsonResult::toString($data); + //return \SYSTEM\LOG\JsonResult::toString($data); + return json.encode($data); } public static function get_users_choice_per_poll($poll_ID){ return \SQL\UVOTE_DATA_USERS_CHOICE_PER_POLL::QA(array($poll_ID));} @@ -113,17 +140,33 @@ class votes { return \SQL\UVOTE_DATA_USERS_CHOICE_PER_POLL::QA(array($poll_ID));} public static function get_voteinfo($poll_ID){ - $con = new \SYSTEM\DB\Connection(new \SQL\uVote()); + $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'selVoteByID', - 'SELECT * FROM `uvote_votes` WHERE `ID` = ?;', + 'SELECT * FROM `uvote_votes` WHERE `ID` = ? AND uvote_votes.group = 1;', + array($poll_ID)); + $res = $res->next(); +// $res['title'] = utf8_encode($res['title']); + return $res; + } + public static function get_sublinks($poll_ID){ + $result = ''; + $res = \SQL\UVOTE_DATA_POLL_INITIATIVE::QA(array($poll_ID)); + foreach ($res as $row){ + + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_poll/tpl/buttons/sub_button.tpl'), $row); + } +// $res['title'] = utf8_encode($res['title']); + return $result; + } + public static function get_voteinfo_sub($poll_ID){ + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selVoteByIDSub', + 'SELECT * FROM `uvote_votes` WHERE `ID` = ? AND uvote_votes.group = 2;', array($poll_ID)); $res = $res->next(); // $res['title'] = utf8_encode($res['title']); return $res; } - - public static function get_barsperparty($poll_ID){ - return \SQL\UVOTE_DATA_PARTY_PER_POLL::QA(array($poll_ID));} public static function get_party_choice($poll_ID, $party){ $res = \SQL\UVOTE_DATA_PARTY_CHOICE_PER_POLL::Q1(array($poll_ID, $party)); @@ -131,19 +174,24 @@ class votes { } public static function write_vote($poll_ID, $vote){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ - throw new ERROR("You need to be logged in.");} - - $con = new \SYSTEM\DB\Connection(new \SQL\uVote()); + $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'selVote', - 'SELECT * FROM `uvote_votes` WHERE `ID` = ? AND time_end < CURDATE();', - array($poll_ID)); - if ($res->next()){ - throw new ERROR('Your rights have expired!');} - + 'SELECT * FROM `uvote_votes` WHERE `ID` = ?;', + array($poll_ID)); $res = $con->prepare( 'insertVote', 'REPLACE uvote_data - VALUES (?, ?, ?, 0, NOW());', + VALUES (?, ?, ?, 1, NOW());', + array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote)); + return JsonResult::ok(); + } + public static function write_vote_sub($poll_ID, $vote){ + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'selVote', + 'SELECT * FROM `uvote_votes` WHERE `ID` = ?;', + array($poll_ID)); + $res = $con->prepare( 'insertVote', + 'REPLACE uvote_data + VALUES (?, ?, ?, 2, NOW());', array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote)); return JsonResult::ok(); } @@ -162,7 +210,7 @@ class votes { if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ throw new ERROR("You need to be logged in.");} - $con = new \SYSTEM\DB\Connection(new \SQL\uVote()); + $con = new \SYSTEM\DB\Connection(); $res = $con->prepare( 'insertFeedback', 'INSERT INTO uvote_beta_feedback VALUES (?, ?);', diff --git a/uvote/autoload.inc b/uvote/autoload.inc index e979a70..4ed9409 100644 --- a/uvote/autoload.inc +++ b/uvote/autoload.inc @@ -3,4 +3,5 @@ require_once dirname(__FILE__).'/path/autoload.inc'; require_once dirname(__FILE__).'/page/autoload.inc'; require_once dirname(__FILE__).'/sql/autoload.inc'; require_once dirname(__FILE__).'/files/autoload.inc'; -require_once dirname(__FILE__).'/api/autoload.inc'; \ No newline at end of file +require_once dirname(__FILE__).'/api/autoload.inc'; +require_once dirname(__FILE__).'/sai/autoload.inc'; \ No newline at end of file diff --git a/uvote/files/frontend_logos/background.gif b/uvote/files/frontend_logos/background.gif new file mode 100644 index 0000000..49434d3 Binary files /dev/null and b/uvote/files/frontend_logos/background.gif differ diff --git a/uvote/files/frontend_logos/logo.gif b/uvote/files/frontend_logos/logo.gif new file mode 100644 index 0000000..4d5edd7 Binary files /dev/null and b/uvote/files/frontend_logos/logo.gif differ diff --git a/uvote/files/frontend_logos/logo.png b/uvote/files/frontend_logos/logo.png new file mode 100644 index 0000000..4df2df4 Binary files /dev/null and b/uvote/files/frontend_logos/logo.png differ diff --git a/uvote/files/frontend_logos/logo.psd b/uvote/files/frontend_logos/logo.psd new file mode 100644 index 0000000..49afe47 Binary files /dev/null and b/uvote/files/frontend_logos/logo.psd differ diff --git a/uvote/files/frontend_logos/logo4.png b/uvote/files/frontend_logos/logo4.png new file mode 100644 index 0000000..6c9f6c8 Binary files /dev/null and b/uvote/files/frontend_logos/logo4.png differ diff --git a/uvote/files/frontend_logos/logo_new.psd b/uvote/files/frontend_logos/logo_new.psd new file mode 100644 index 0000000..cc4ac1b Binary files /dev/null and b/uvote/files/frontend_logos/logo_new.psd differ diff --git a/uvote/files/frontend_logos/logo_new_new.psd b/uvote/files/frontend_logos/logo_new_new.psd new file mode 100644 index 0000000..7ceb337 Binary files /dev/null and b/uvote/files/frontend_logos/logo_new_new.psd differ diff --git a/uvote/files/frontend_logos/tapete.gif b/uvote/files/frontend_logos/tapete.gif new file mode 100644 index 0000000..0e47f84 Binary files /dev/null and b/uvote/files/frontend_logos/tapete.gif differ diff --git a/uvote/page/autoload.inc b/uvote/page/autoload.inc index fcecc93..c61a71e 100644 --- a/uvote/page/autoload.inc +++ b/uvote/page/autoload.inc @@ -2,13 +2,12 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__),''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_page',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_register',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_bulletin',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_comment',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_uVote',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_urVote',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_myVote',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_impressum',''); + +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_start',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_votelist',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_analysis',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_options',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_poll',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list_active',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list_ended',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_poll_sub',''); \ No newline at end of file diff --git a/uvote/page/default_bulletin/css/bars_user.css b/uvote/page/default_bulletin/css/bars_user.css deleted file mode 100644 index 513c5aa..0000000 --- a/uvote/page/default_bulletin/css/bars_user.css +++ /dev/null @@ -1,4 +0,0 @@ -.progress#progress_bars_user { - height: 20px; - width: 350px; -} \ No newline at end of file diff --git a/uvote/page/default_bulletin/css/bulletin.css b/uvote/page/default_bulletin/css/bulletin.css deleted file mode 100644 index 1cb78e3..0000000 --- a/uvote/page/default_bulletin/css/bulletin.css +++ /dev/null @@ -1,48 +0,0 @@ -#bulletin_main { - float: left; - width: 100%; -} - -#bulletin_left { - float: left; -} - -#bulletin_sub1 { - margin-top: 30px; -} - -#bulletin_sub2 { - float: left; - width: 50%; - padding-top: 30px; -} - -#bulletin_sub3 { - float: right; - width: 50%; - padding-top: 30px; -} -#divider { - clear: both; -} - -#bulletin_sub4 { - padding-top: 30px; -} -#bulletin_sub5 { - padding-top: 20px; -} - -#bulletin_sub5_sub { - float: left; - width: 40%; -} - - #bulletin_sub6 { - float: right; - width: 40%; - } - - #bulletin_sub7 { - clear: both; - } \ No newline at end of file diff --git a/uvote/page/default_bulletin/css/comment.css b/uvote/page/default_bulletin/css/comment.css deleted file mode 100644 index 125793f..0000000 --- a/uvote/page/default_bulletin/css/comment.css +++ /dev/null @@ -1,22 +0,0 @@ -#comment_main { - float: left; - width: 90%; -} - -#comment_sub1 { - float: left; - font-size: 1; -} - -#comment_sub2 { - clear: both; -} - -#comment_sub3 { - font-size: 2; -} - -#comment_sub4 { - float: right; - font-size: 1; -} \ No newline at end of file diff --git a/uvote/page/default_bulletin/default_bulletin.php b/uvote/page/default_bulletin/default_bulletin.php deleted file mode 100644 index ed401eb..0000000 --- a/uvote/page/default_bulletin/default_bulletin.php +++ /dev/null @@ -1,241 +0,0 @@ -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/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 get_pro_comments (){ - $result = ''; - /*$vars = votes::getUserComments($this->poll_ID, 1); - - foreach($vars as $com){ - $rating = votes::get_commentrate($com['c_ID'], 1); - $com['count_up'] = $rating['count']; - $rating2 = votes::get_commentrate($com['c_ID'], 2); - $com['count_down'] = $rating2['count']; -// $com['c_txt'] = utf8_encode($com['c_txt']); - $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/comment.tpl'), $com); - }*/ - return $result; - - } - private function get_con_comments (){ - $result = ''; - /*$vars = votes::getUserComments($this->poll_ID, 2); - - foreach($vars as $com){ - $rating = votes::get_commentrate($com['c_ID'], 1); - $com['count_up'] = $rating['count']; - $rating2 = votes::get_commentrate($com['c_ID'], 2); - $com['count_down'] = $rating2['count']; -// $com['c_txt'] = utf8_encode($com['c_txt']); - $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/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); - $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 js(){ - return '';} - private function css(){ - return ''. - ''. - '';} - - - - public function html(){ - $poll_expired = \SQL\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID)); - $user_vote = votes::getUserPollData($this->poll_ID); - - $vars = array(); - $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['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=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 = array_merge($vars,votes::get_voteinfo($this->poll_ID)); - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/bulletin.tpl'),$vars); - } - -} \ No newline at end of file diff --git a/uvote/page/default_bulletin/tpl/bars_user.tpl b/uvote/page/default_bulletin/tpl/bars_user.tpl deleted file mode 100644 index a502a85..0000000 --- a/uvote/page/default_bulletin/tpl/bars_user.tpl +++ /dev/null @@ -1,7 +0,0 @@ -
${bulletin_bars_title}
-${urvote_bars_user} -
-
${vote_yes_perc}%
-
${vote_no_perc}%
-
${vote_ent_perc}%
-
diff --git a/uvote/page/default_bulletin/tpl/bulletin.tpl b/uvote/page/default_bulletin/tpl/bulletin.tpl deleted file mode 100644 index 1c6a945..0000000 --- a/uvote/page/default_bulletin/tpl/bulletin.tpl +++ /dev/null @@ -1,58 +0,0 @@ -
-

${title}

- ${vote_buttons} -
- -
-
- ${openvote_help_text} - ${title} - ${openvote_help_text1} -
-
- ${voice_weight} -
-
- ${bars_user}
- ${bars_bt} -
-
- ${icons_party} - ${choice_party} -
-
-
-
-

Kommentare

-
-
-
Pro
- ${comments_pro} -
-
-
Contra
- ${comments_con} -
-
-
-
- Kommentar
-
- Quelle
-
-
-
${submit}
-
-
- - - - -
\ No newline at end of file diff --git a/uvote/page/default_bulletin/tpl/icons_table_parties.tpl b/uvote/page/default_bulletin/tpl/icons_table_parties.tpl deleted file mode 100644 index b082c99..0000000 --- a/uvote/page/default_bulletin/tpl/icons_table_parties.tpl +++ /dev/null @@ -1,8 +0,0 @@ -
${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 deleted file mode 100644 index 5e75d86..0000000 --- a/uvote/page/default_bulletin/tpl/table_bt.tpl +++ /dev/null @@ -1,6 +0,0 @@ -Ergebnis Bundestag -
-
${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 deleted file mode 100644 index 699e779..0000000 --- a/uvote/page/default_bulletin/tpl/table_parties.tpl +++ /dev/null @@ -1,6 +0,0 @@ - -
-
${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 deleted file mode 100644 index 05813f2..0000000 --- a/uvote/page/default_bulletin/tpl/vote_bt.tpl +++ /dev/null @@ -1,8 +0,0 @@ -
-
-
${choice}
-
${party_yes}%
-
${party_no}%
-
${party_ent}%
-
${party_off}%
-
\ No newline at end of file diff --git a/uvote/page/default_page/css/default_page.css b/uvote/page/default_page/css/default_page.css index 84f72b3..f91f033 100644 --- a/uvote/page/default_page/css/default_page.css +++ b/uvote/page/default_page/css/default_page.css @@ -1,12 +1,24 @@ body { - padding-top: 60px; padding-bottom: 40px; } +#btn_logout:hover{ + cursor: pointer; +} +.row { + padding: 0 !important; + margin: 0 !important; + margin-top: 10px !important; + margin-bottom: 10px !important; +} /*.list { border: 2px solid #ccc; }*/ +.popover{ + max-width: 600px; + width: 600px; +} .pro{ background: #5eb95e; } diff --git a/uvote/page/default_page/css/loginform.css b/uvote/page/default_page/css/loginform.css index 63ce3ac..d3c74a5 100644 --- a/uvote/page/default_page/css/loginform.css +++ b/uvote/page/default_page/css/loginform.css @@ -1,18 +1,4 @@ -#help-block { - float: right; - padding: 0; -} -#controls { - float: right; - margin-right: 10px; -} - - #controls2 { - float: right; - margin-right: 20px; - } - .btn btn-primary#login_submit { float: right; height: 32px; diff --git a/uvote/page/default_page/css/page.css b/uvote/page/default_page/css/page.css index 198bc6d..3879dd1 100644 --- a/uvote/page/default_page/css/page.css +++ b/uvote/page/default_page/css/page.css @@ -2,6 +2,10 @@ body { padding-top: 60px; } +.panel-heading :hover{ + cursor: pointer; +} + .main_container { } @@ -18,7 +22,6 @@ body { #site-content { padding: 0; margin: 0; - margin-left: 35px; } #user_main { diff --git a/uvote/page/default_page/css/vote.css b/uvote/page/default_page/css/vote.css index a73fddb..aecc633 100644 --- a/uvote/page/default_page/css/vote.css +++ b/uvote/page/default_page/css/vote.css @@ -1,10 +1,4 @@ -#vote_main { - margin-bottom: 5px; - width: 100%; - min-height: 125px; - border: solid lightgray 1px; - background: beige; -} + #vote_sub1 { float: left; diff --git a/uvote/page/default_page/default_page.php b/uvote/page/default_page/default_page.php index 9b193b7..4ee7ac6 100644 --- a/uvote/page/default_page/default_page.php +++ b/uvote/page/default_page/default_page.php @@ -25,111 +25,8 @@ class default_page extends SYSTEM\PAGE\Page { \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_page/css/loginform.css')) ; } - 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: - return 'pro'; - case 2: - return 'con'; - case 3: - return 'ent'; - default: - return 'open'; - } - } - - private static function badge_class($choice){ - switch($choice){ - case 1: - return 'badge-success'; - case 2: - return 'badge-important'; - case 3: - return 'badge-info'; - default: - return ''; - } - } - - public static function panel_class($choice){ - switch($choice){ - case 1: - return 'panel-success'; - case 2: - return 'panel-danger'; - case 3: - return 'panel-info'; - default: - return 'panel-default'; - } - } - - 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_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']; - - $vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen'; - $vote['uv'] = $vote['bt'] = ''; - $vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5'; - - $user_vote = votes::getUserPollData($vote['ID']); - $vote['vote_class'] = $this->tablerow_class($user_vote); - 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/tpl/vote_bt.tpl'), - array( 'party' => $pv['party'], - 'choice' => $this->get_party_per_poll($pv['choice']), - 'choice_class' => $this->badge_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/tpl/vote_uv.tpl'), - array( 'badge' => self::badge_class($v['choice']), - 'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0)); - } - } - - //new panels: - $vote['panel_class'] = self::panel_class($user_vote); - - if($time_remain > 0){ - $result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote.tpl'), $vote); - } else { - $result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote.tpl'), $vote); - } - } - return $result[0].$result[1]; - } + public function getloggedinform(){ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/loggedinform.tpl'),array());} @@ -142,12 +39,18 @@ class default_page extends SYSTEM\PAGE\Page { public function exchange_loginform(){ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/loggedinformtop.tpl'),array());} + + public function get_menu(){ + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/menu.tpl'),array());} + public function exchange_menu(){ + return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/menu_loggedout.tpl'),array());} public function html($_escaped_fragment_ = NULL){ $vars = array(); if(!$_escaped_fragment_){ $vars['js'] = $this->js();} $vars['css'] = $this->css(); + $vars['menu'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->get_menu() : $this->exchange_menu(); $vars['registerform'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->getloggedinform() : $this->exchange_registerform(); $vars['loginform'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->exchange_loginform() : $this->getloginform() ; $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=files&cat=frontend_logos&id='; diff --git a/uvote/page/default_page/js/loadtexts.js b/uvote/page/default_page/js/loadtexts.js index 79987c8..e33c78f 100644 --- a/uvote/page/default_page/js/loadtexts.js +++ b/uvote/page/default_page/js/loadtexts.js @@ -2,7 +2,15 @@ $(document).ready(function() { new SYSTEM('./api.php',1,'start'); register_login(); register_logout(); + navstate(); }); +function navstate(){ + $(".nav a").on("click", function(){ + $(".nav").find(".active").removeClass("active"); + $(this).parent().addClass("active"); +}); +} + function register_login(){ $("#form_login input").not("[type=submit]").jqBootstrapValidation({ @@ -38,7 +46,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(); @@ -61,20 +69,6 @@ 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) { - 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_commentrate (c_ID, val) { alert('success'); $.getJSON('./api.php?call=vote&action=commentrate&c_ID=' + c_ID + '&val=' + val, function(data) { @@ -136,7 +130,7 @@ function send_feedback (feedback) { var val = JSON.stringify(feedback); console.log("feedback called"); $.ajax({ - url: 'http://mojotrollz.eu/web/uVote/api.php', + url: './api.php', // contentType : "application/json; charset=utf-8", data : { 'call': 'vote', @@ -155,24 +149,7 @@ function send_feedback (feedback) { }); } -function register_registerform(){ - //console.log("wegwegwegwegwegweg"); - $("#register_user_form input").not("[type=submit]").jqBootstrapValidation( - { - preventSubmit: true, - submitError: function($form, event, errors) {}, - submitSuccess: function($form, event){ - $.get('./api.php?call=account&action=create&username=' + $('#register_username').val() + '&password_sha=' + $.sha1($('#user_register_password1').val()) + '&email=' + $('#register_email').val() + '&locale=deDE', function (data) { - if(data == 1){ - window.location.reload(); - } else { - $('#help-block-user-password-combi-wrong').attr('style', 'display: block;'); - } - }); - event.preventDefault(); - } - }); -} + function loadAjaxContent(url) { var dataTmp; @@ -216,60 +193,3 @@ function loadApiPic(id) { }); } -function load_visualisation(id, timespan){ - $('img#loader').show(); - $.getJSON('./api.php?call=graph_bt_to_uvote_overall_by_time',function(json){ - if(!json || json.status != true || !json.result){ - $('img#loader').hide(); - return; - } - json = json.result; - $('img#loader').hide(); - var data = new google.visualization.DataTable(); - first = true; - $.each(json[0], function(key, value){ - if(first){ - data.addColumn('datetime',key); - first = false; - } else { - data.addColumn('number',key); - } - }); - $.each(json, function(key, value){ - first = true; - data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); - - console.log(data); - var options = {title: 'Übereinstimmung uVote Community/Bundestag', aggregationTarget: 'category', selectionMode: 'multiple', /*curveType: 'function',*/ /*focusTarget: 'category',*/ chartArea:{}, vAxis:{format:'#%', logScale: false}, interpolateNulls: false, width: "300", height: "250"}; - //LineChart - new google.visualization.ColumnChart(document.getElementById(id)).draw(data, options); - }); -} -function load_visualisation_urvote(id, timespan){ - $('img#loader').show(); - $.getJSON('./api.php?call=graph_bt_to_user_overall_by_time',function(json){ - if(!json || json.status != true || !json.result){ - $('img#loader').hide(); - return; - } - json = json.result; - $('img#loader').hide(); - var data = new google.visualization.DataTable(); - first = true; - $.each(json[0], function(key, value){ - if(first){ - data.addColumn('datetime',key); - first = false; - } else { - data.addColumn('number',key); - } - }); - $.each(json, function(key, value){ - first = true; - data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); - - console.log(data); - var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "300", height: "250"}; - new google.visualization.LineChart(document.getElementById(id)).draw(data, options); - }); -} \ No newline at end of file diff --git a/uvote/page/default_page/pics/logo.gif b/uvote/page/default_page/pics/logo.gif new file mode 100644 index 0000000..3d42bc4 Binary files /dev/null and b/uvote/page/default_page/pics/logo.gif differ diff --git a/uvote/page/default_page/tpl/loggedinformtop.tpl b/uvote/page/default_page/tpl/loggedinformtop.tpl index 130cffc..fd5d75b 100644 --- a/uvote/page/default_page/tpl/loggedinformtop.tpl +++ b/uvote/page/default_page/tpl/loggedinformtop.tpl @@ -1,3 +1,2 @@ - \ No newline at end of file +  Logout + diff --git a/uvote/page/default_page/tpl/loginform.tpl b/uvote/page/default_page/tpl/loginform.tpl index eb944b8..d34ef86 100644 --- a/uvote/page/default_page/tpl/loginform.tpl +++ b/uvote/page/default_page/tpl/loginform.tpl @@ -1,37 +1,8 @@ - - \ No newline at end of file + + + + + + diff --git a/uvote/page/default_page/tpl/menu.tpl b/uvote/page/default_page/tpl/menu.tpl new file mode 100644 index 0000000..5d42761 --- /dev/null +++ b/uvote/page/default_page/tpl/menu.tpl @@ -0,0 +1,10 @@ +
+ +
+ + diff --git a/uvote/page/default_page/tpl/menu_loggedout.tpl b/uvote/page/default_page/tpl/menu_loggedout.tpl new file mode 100644 index 0000000..8bd006c --- /dev/null +++ b/uvote/page/default_page/tpl/menu_loggedout.tpl @@ -0,0 +1,7 @@ +
+ +
\ No newline at end of file diff --git a/uvote/page/default_page/tpl/page.tpl b/uvote/page/default_page/tpl/page.tpl index c9283ae..89743a5 100644 --- a/uvote/page/default_page/tpl/page.tpl +++ b/uvote/page/default_page/tpl/page.tpl @@ -5,40 +5,30 @@ - + + ${css} ${js} - -
-