new concept

This commit is contained in:
Nael 2014-01-14 22:46:58 +01:00
parent 4f3bd3366e
commit ef465496df
12 changed files with 136 additions and 70 deletions

View File

@ -10,5 +10,10 @@ $uvote_config = array( array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_ERRORREPORTIN
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_PASSWORD, 'dsjgfasudzfsvad'),
array(SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_DBNAME, 'host_uVote'),
array(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_SYSTEMPATHREL, '../system/'),
array(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_NAVIMG, '/web/system/sai/page/default_page/img/logo.png'),//not working, cuz paths are not set yet! \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/img/logo.png')),
array(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_BASEURL, 'http://mojotrollz.eu/web/uVote/sai.php?'),
array(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE, 'mojotrollz - Admin Area'),
array(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_COPYRIGHT, '<a href="http://www.mojotrollz.eu/web/uVote/" target="_blank">uVote</a>, &copy; WebCraft Media 2013'),
array(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS, array('deDE', 'enUS', 'huHU')),
array(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG, 'deDE'));

17
sai.php Normal file
View File

@ -0,0 +1,17 @@
<?php
require_once '../system/autoload.inc.php'; //SYSTEM Classes
require_once 'uVote/autoload.inc.php'; //Project Classes
require_once 'config.php'; //Server config
SYSTEM\system::start($uvote_config); //Start System time + config
SYSTEM\system::include_ExceptionShortcut(); //allow ERROR() instead of \SYSTEM\LOG\ERROR()
SYSTEM\system::include_ResultShortcut(); //allow JsonResult() instead of \SYSTEM\LOG\JsonResult()
SYSTEM\system::register_errorhandler_dbwriter(); //write errors to database (must be first errorhandler to register)
SYSTEM\system::register_errorhandler_jsonoutput(); //print errors as json to caller
require_once '../system/sai/autoload.inc.php';
require_once 'uVote/sai/autoload.inc.php';
require_once 'uVote/sai/register_modules.php';
$sai = new SYSTEM\SAI\saigui();
echo $sai->html();

View File

@ -2,7 +2,13 @@
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);}
return votes::write_vote($poll_ID, $vote);
}
public static function call_vote_action_open_vote($poll_ID) {
return votes::open_vote($poll_ID);
}
public static function call_vote_action_barsperusers($poll_ID){
return votes::get_barsperusers($poll_ID);}
}

View File

@ -12,6 +12,15 @@ class votes {
return $result;
}
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_barsperusers($poll_ID,$return_as_json = true){
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
@ -86,4 +95,19 @@ class votes {
array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote));
return JsonResult::ok();
}
public static function open_vote($poll_ID){
new \SYSTEM\LOG\INFO($poll_ID);
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
throw new ERROR("You need to be logged in.");}
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
$res = $con->prepare( 'selVote',
'SELECT * FROM `uvote_votes` WHERE ID = ?;',
array($poll_ID));
$vote = votes::getVoteOfGroup($poll_ID);
new INFO(print_r($vote, true));
$vars = array('vote_text' => $vote['text'], 'vote_title' => $vote['title'], 'vote_init' => $vote['initiative'], 'poll_ID' => $vote['ID'], 'time_end' => $vote['time_end']);
$result = SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vars);
return $res;
}
}

View File

@ -1,4 +1,8 @@
body {
padding-top: 60px;
padding-bottom: 40px;
}
#list {
border: 2px solid #ccc;
}

View File

@ -17,12 +17,25 @@ class default_page extends SYSTEM\PAGE\Page {
return '<link href="'.SYSTEM\WEBPATH(new PPAGE(),'default_page\css\default_page.css').'" rel="stylesheet">';}
public function generate_votelist(){
$result = "";
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$vars = array('vote_title' => $vote['title'], 'vote_text' => $vote['text'], 'poll_ID' => $vote['ID'], 'time_end' => $vote['time_end']);
$vars = array('vote_title' => $vote['title'], 'vote_text' => $vote['text'], 'vote_init' => $vote['initiative'], 'poll_ID' => $vote['ID'], 'time_end' => $vote['time_end']);
$result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vars);
}
new \SYSTEM\LOG\INFO("generated votelist successfully");
return $result;
}
public function generate_vote(){
$result = "";
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$vars = array('vote_title' => $vote['title'], 'vote_text' => $vote['text'], 'vote_init' => $vote['initiative'], 'poll_ID' => $vote['ID'], 'time_end' => $vote['time_end']);
$result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/full_vote.tpl'), $vars);
}
return $result;
}
@ -44,6 +57,7 @@ class default_page extends SYSTEM\PAGE\Page {
$vars['js'] = $this->js();
$vars['css'] = $this->css();
$vars['votelist'] = $this->generate_votelist();
$vars['vote'] = $this->generate_vote();
$vars['registerform'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->getloggedinform() : $this->exchange_registerform();
$vars['loginform'] = \SYSTEM\SECURITY\Security::isLoggedIn() ? $this->exchange_loginform() : $this->getloginform() ;
$vars['PIC_PATH'] = SYSTEM\WEBPATH(new PPAGE(),'default_page/pics/');

View File

@ -0,0 +1,21 @@
<div style="padding: 5px; background: lightyellow; margin-bottom: 8px; -webkit-box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5); box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5);">
<div class="row" style="width: 100%; margin: 0; margin-top: 15px;">
<div class="span6">
<h4>${vote_title}</h4>
Initiiert von: ${vote_init}
</div>
<div class="span5" style="margin-top: 15px;">
<a class="btn btn-large btn-green btnvote_yes" style="width: 110px;" poll_ID="${poll_ID}">Pro &raquo;</a>
<a class="btn btn-large btn-red btnvote_no" style="width: 110px; background-color: red;" href="#" poll_ID="${poll_ID}">Contra &raquo;</a>
<a class="btn btn-large btn-grey btnvote_off" style="width: 110px; background-color: grey;" href="#" poll_ID="${poll_ID}">Enthaltung &raquo;</a>-->
<div class="progress">
<div class="bar countdownbar" pollid="${poll_ID}" style="width: 0%;">
</div>
<div class="countdown"></div>
</div>
</div>
<div class="span5" id="openvoteinfo${poll_ID}" style="margin: 0; display: none; width: 100%; margin-top: 15px;">
</div>
</div>

View File

@ -6,6 +6,10 @@ $(document).ready(function() {
//loadUrlPic($(this).attr('url'));
});
$('.btn_vote').click(function () {
//vote_click($(this).attr('poll_ID'));
open_vote($(this).attr('poll_ID'));
});
$('.btnvote_yes').click(function () {
vote_click($(this).attr('poll_ID'),1);
});
@ -117,6 +121,17 @@ function vote_click (poll_ID, vote) {
});
}
function open_vote (poll_ID) {
$.getJSON('./api.php?call=vote&action=open_vote&poll_ID=' + poll_ID , function(data) {
var items = [];
if(data.status == true){
alert("sucess");
} else {
alert(data.result.message);
}
});
}
function loadAjaxContent(url) {
var dataTmp;
$.get(url, function (data) {

View File

@ -38,63 +38,22 @@
<li><a href="#" url="?action=Download">Download</a></li>
</ul>
${loginform}
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container" id="site-content-wrapper" style="margin-top: 0; ">
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="container" id="site-content-wrapper" style="margin-top: 0;">
<div id="site-content" style="padding: 0; margin: 0;">
<div class="container" style="background: lightyellow; margin: 0; margin-top: -18px; -webkit-box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5); box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5);">
<img src="${PIC_PATH}logo2.png" width="600" style="margin-left: 20px;" />
<div class="container" style="margin-right: 30px; float: right; width: 220px;">
<!-- margin-left: 600px; margin-right: -60px; padding: 5px; margin-top: -240px;-->
${registerform}
</div>
<div id="list" style="padding: 0px; max-height: 720px; overflow-y: scroll; float: left;">
${votelist}
</div>
<div id="stats" style="float: right;">
<!-- <div class="hero-unit" style="height: 300px; padding: 5px; padding-top: 50px; width: 400px; margin-left: 700px; margin-top: -260px; background: white;">
<i class="icon-tags" style="margin-left: 20px; margin-top: -30px;" ></i>Informieren
<p></p>
<i class="icon-tags" style="margin-left: 20px; margin-top: 10px;"></i>Diskutieren
<p></p>
<i class="icon-tags" style="margin-left: 20px;"></i>Abstimmen
<p></p>
<i class="icon-tags" style="margin-left: 20px;"></i>Vergleichen
<p></p>
<i class="icon-tags" style="margin-left: 20px;"></i>Verändern
<p></p>
</div>-->
</div>
<div class="container" style="background: black; height: 40px; -webkit-box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5); box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5);">
<form class="navbar-form pull-left">
<input class="span2" type="password" placeholder="" style="margin-left: 5px;">
<button type="submit" class="btn" style="margin-top: 5px;">suchen</button>
</form>
</div>
<!-- Example row of columns -->
<div class="hero-unit" style="padding: 0px; padding-top: 5px">
${votelist}
</div> <!-- /container -->
<div class="navbar-inner">
<div class="container">
<p>Entwurf der Seite von Tobias Rechel, Mojotrollz.eu</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,29 +1,25 @@
<div class="hero-unit" style="padding: 5px; background: lightyellow; margin-bottom: 8px; -webkit-box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5); box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5);">
<div class="row" style="width: 100%; margin: 0; margin-top: 15px;">
<div style="padding: 5px; background: lightyellow; margin-bottom: 8px; -webkit-box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5); box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5);">
<div class="row" style="width: 100%; margin: 0; margin-top: 5px; margin-bottom: 8px;">
<div class="span6">
<h3>${vote_title}</h3>
<h4>${vote_title}</h4>
Initiiert von: ${vote_init}
<br>
Politikfeld(er):
</div>
<div class="span5" style="margin-top: 15px;">
<a class="btn btn-large btn-green btnvote_yes" style="width: 110px;" poll_ID="${poll_ID}">Pro &raquo;</a>
<a class="btn btn-large btn-red btnvote_no" style="width: 110px; background-color: red;" href="#" poll_ID="${poll_ID}">Contra &raquo;</a>
<a class="btn btn-large btn-grey btnvote_off" style="width: 110px; background-color: grey;" href="#" poll_ID="${poll_ID}">Enthaltung &raquo;</a>
<a class="btn btn_vote" poll_ID="${poll_ID}" style="float: right; margin-top: 10px;">Abstimmen</a>
<!--<div class="span5" style="margin-top: 15px;">
<a class="btn btn-large btn-green btnvote_yes" style="width: 110px;" poll_ID="$">Pro &raquo;</a>
<a class="btn btn-large btn-red btnvote_no" style="width: 110px; background-color: red;" href="#" poll_ID="$">Contra &raquo;</a>
<a class="btn btn-large btn-grey btnvote_off" style="width: 110px; background-color: grey;" href="#" poll_ID="$">Enthaltung &raquo;</a>-->
<!-- Countdown-Generator by www.coolplace.cc -->
<div class="progress">
<div class="bar countdownbar" pollid="${poll_ID}" style="width: 0%;">
<!-- <div class="progress">
<div class="bar countdownbar" pollid="$" style="width: 0%;">
</div>
<div class="countdown"></div>
</div>
</div>-->
</div>
<div class="span5" id="openvoteinfo${poll_ID}" style="margin: 0; display: none; width: 100%; margin-top: 15px;">
</div>
</div>
</div>
<div>
<button class="btn dropdown-toggle btn_openvoteinfo" data-toggle="dropdown" poll_ID=${poll_ID} style="width: 100%; height: 15px; top: 0;">
<span class="caret"></span>
</button>
</div>
</div>

View File

@ -0,0 +1,3 @@
<?php
SYSTEM\autoload::registerFolder(dirname(__FILE__).'','');
//SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_server_handling','');

View File

@ -0,0 +1,2 @@
<?php
//\SYSTEM\SAI\sai::register('saimod_mojotrollz_server_handling');