| Current Path : /home/wirbesti/unwaehlbar.ch/ |
| Current File : /home/wirbesti/unwaehlbar.ch/personDetail2.php |
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php
require_once "settings.config.php";
require_once "DBConnection.php";
require_once "i18n.php";
require_once "DAO/polvotes.php";
require_once "DAO/stats.php";
require_once "DAO/politician.php";
require_once "DAO/evaluation.php";
require_once "DAO/entry.php";
require_once "DAO/voted.php";
require_once "baseurl.php";
$pictureRoot = "./images";
$database = new DbConnection($config);
$polvoteObj = new polvotes($database);
$statsObj = new Stats($database);
$politicianObj = new Politician($database);
$evaluationObj = new Evaluation($database);
$entryObj = new Entry($database);
$voted = new Voted($database);
$id = $_GET['id'];
$language = $_COOKIE['lang'] ?? 'de';
$locality = $language;
$politicians = $politicianObj->getPoliticianById($id, $language);
$votedList = $voted->getVotesByIP($politicians);
$votes = $statsObj->getVoteTotalsForPolitician($id);
$evaluations = $evaluationObj->getEvaluationsByPolitician($id, $language);
$politician = $politicians[0];
$picture = $politician['picture'];
$src = "$pictureRoot/$picture";
$name = $politician['name'];
$position = $politician['position'];
$positionid = $politician['positionid'];
$party = $politician['party'];
$partyid = $politician['partyid'];
$canton = $politician['canton'];
$cantonid = $politician['cantonid'];
$twitter = $politician['twitter'];
$facebook = $politician['facebook'];
$email = $politician['email'];
$website = $politician['website'];
$externalLinks = explode('\r\n', $politician['biography']);
$biography = $politician['biography'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- This file has been downloaded from bootdey.com @bootdey on twitter -->
<!-- All snippets are MIT license http://bootdey.com/license -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-T51P2G7FB6"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-T51P2G7FB6');
</script>
<title><?=$name?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="./libs/site.js"></script>
<script src="./libs/jquery-3.5.1.min.js"></script>
<script src="./libs/fancyTable.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<link href="css/detail.css" rel="stylesheet" type="text/css">
<script>
var t = <?php echo json_encode($t); ?> ;
</script>
<script>
google.charts.load('current', {
'packages': ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
var lang =
'<?php echo $_SESSION['lang'] ?? 'de'; ?>';
var language = getCookie("lang");
if (typeof language == "undefined" || language == null) {
language = lang;
if (typeof language == "undefined" || language == null || language == '') {
language =
'<?php echo $_GET['language'] ?? 'de'; ?>';
}
}
function drawChart() {
var data = google.visualization.arrayToDataTable([
[t['Datum'][language], t['Beliebtheit'][language]],
<?php
$popularityPerDay = $statsObj->getPopularity($_GET['id']) ?? [];
$rows = count($popularityPerDay);
$index = 0;
foreach ($popularityPerDay as $date => $popularity) {
if ($index == ($rows -1)) {
echo '[\''.$date.'\','.$popularity['popularity'].']';
} else {
echo '[\''.$date.'\','.$popularity['popularity'].'],';
}
$index++;
}
?>
]);
var options = {
title: t['Beliebtheit'][language],
curveType: 'function',
legend: {
position: 'bottom'
}
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<section id="content" class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="<?=$baseUrl?>main.php?position=<?=$positionid?>&canton=<?=$cantonid?>">
<span>
<img id="menulogo" alt="Brand" src="<?=$baseUrl.$t['logo'][$language]?>" width="30" height="30" class="d-inline-block">
<span id="logotext"><?=ucfirst($t['unwählbar'][$language])?></span>
</span>
</a>
</div>
</div>
</nav>
<!-- Begin .page-heading -->
<div class="page-heading">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3">
<a href="#">
<img class="media-object mw150"
src="<?=$pictureRoot.'/'.$picture?>"
alt="...">
</a>
</div>
<div class="col-sm-6">
<h2 class="media-heading"><?=$name?>
</h2>
<p class="lead"><?=$position?>
</p>
<p class="lead"><?=$party?>
</p>
<p class="lead"><?=$canton?>
</p>
<div class="media-links">
<ul class="list-inline list-unstyled">
<li class="<?php if (!$facebook) {
echo 'hidden';
}?>">
<a href="<?php if ($facebook) {
echo $facebook;
} else {
echo '#';
}?>" title="facebook link" target="_blank">
<span class="fa fa-facebook-square fs35 text-primary"></span>
</a>
</li>
<li class="<?php if (!$twitter) {
echo 'hidden';
}?>">
<a href="<?php if ($twitter) {
echo $twitter;
} else {
echo '#';
} ?>" title="twitter link" target="_blank">
<span class="fa fa-twitter-square fs35 text-info"></span>
</a>
</li>
<li class="hidden">
<a href="#" title="google plus link">
<span class="fa fa-google-plus-square fs35 text-danger"></span>
</a>
</li>
<li class="hidden">
<a href="#" title="behance link">
<span class="fa fa-behance-square fs35 text-primary"></span>
</a>
</li>
<li class="hidden">
<a href="#" title="pinterest link">
<span class="fa fa-pinterest-square fs35 text-danger-light"></span>
</a>
</li>
<li class="hidden">
<a href="#" title="linkedin link">
<span class="fa fa-linkedin-square fs35 text-info"></span>
</a>
</li>
<li class="hidden">
<a href="#" title="github link">
<span class="fa fa-github-square fs35 text-dark"></span>
</a>
</li>
<li class="hidden">
<a href="#" title="phone link">
<span class="fa fa-phone-square fs35 text-system"></span>
</a>
</li>
<li class="<?php if (!$email) {
echo 'hidden';
}?>">
<a href="<?php if ($email) {
echo 'mailto:'.$email;
} else {
echo '#';
} ?>" title="email link">
<span class="fa fa-envelope-square fs35 text-muted"></span>
</a>
</li>
<li class="<?php if (!$website) {
echo 'hidden';
}?>">
<a href="<?php if ($website) {
echo $website;
} else {
echo '#';
} ?>" title="website link" target="_blank">
<span class="fa fa-link fs35 text-muted"></span>
</a>
</li>
<?php
foreach ($externalLinks as $link) {
if ($link == "") {
continue;
}
echo '<li>';
echo '<a href="'.$link.'" title="external link" target="_blank">';
echo '<span class="fa fa-external-link-square fs35 text-muted"></span>';
echo '</a>';
echo '</li>';
}
?>
</ul>
</div>
</div>
<div class="col-sm-3">
<img id="electableStatus" class="media-object mw150" src="<?php
if (($votes['upvote'] ?? 0) > ($votes['downvote'] ?? 0)) {
echo $pictureRoot.'/waehlbarlogode.jpg';
} else {
echo $pictureRoot.'/logode.jpg';
}
?>" height="200" alt="...">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="panel">
<div class="panel-heading">
<span class="panel-icon">
<i class="fa fa-star"></i>
</span>
<span class="panel-title"> <?=$t['Beliebtheit'][$language]?></span>
</div>
<div class="panel-body pn">
<table class="table mbn tc-icon-1 tc-med-2 tc-bold-last">
<thead>
<tr>
<th><i class="fa fa-thumbs-up"></i></th>
<th><i class="fa fa-thumbs-down"></i></th>
</tr>
</thead>
<tbody>
<?php
$votedfor = $votedList[$id]['voted'] ?? false;
?>
<tr id="c<?=$id?>" data-voted="<?=$votedfor?>">
<td><?=$votes['upvote'] ?? 0?>
</td>
<td><?=$votes['downvote'] ?? 0?>
</td>
</tr>
<tr>
<td><button id="like<?=$id?>"
class="voteButton"
onclick="vote(<?=$id?>, 1, <?=$votes['upvote'] ?? 0?>,<?=$votes['downvote'] ?? 0?>)"
data-bs-toggle="tooltip" data-bs-placement="top"
title="<?=$t['wählbar'][$language]?>"><i
class="fa fa-thumbs-up"></i>
</button>
</td>
<td><button id="dislike<?=$id?>"
class="voteButton"
onclick="vote(<?=$id?>,-1,<?=$votes['upvote'] ?? 0?>,<?=$votes['downvote'] ?? 0?>)"
data-bs-toggle="tooltip" data-bs-placement="top"
title="<?=$t['unwählbar'][$language]?>"><i
class="fa fa-thumbs-down"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel">
<div class="panel-heading">
<span class="panel-icon">
<i class="fa fa-pencil"></i>
</span>
<span class="panel-title"><?=$t['Information'][$language]?></span>
</div>
<div class="panel-body pb5">
<p>
<button class="btn btn-primary" type="button" data-toggle="collapse"
data-target="#collapseForm" aria-expanded="false" aria-controls="collapseForm"
onclick="initMessage()"><?=$t['Informationen'][$language].'<br/>'.$name?></button>
</p>
<div class="collapse" id="collapseForm">
<div class="card card-body">
<div class="ProCon">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions"
id="radioPro" value="pro">
<label class="form-check-label" for="radioPro">Pro</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions"
id="radioContra" value="con">
<label class="form-check-label" for="radioContra">Contra</label>
</div>
</div>
<div class="mb-3">
<label for="informationAboutPolitician" class="form-label"><?=$t['Information'][$language]?></label>
<textarea class="form-control" id="informationAboutPolitician" rows="3"></textarea>
</div>
<button id="sendButton" type="button" class="btn btn-primary" data-bs-toggle="collapse"
data-bs-target="#collapseForm"
onclick="sendInformation(<?=$id.', \''.$language.'\''?>)"><?=$t['Senden'][$language]?></button>
</div>
</div>
<br /><br />
<div id="thankyou"></div>
</div>
</div>
</div>
<div class="col-md-8">
<div class="tab-block">
<ul class="nav nav-tabs">
<li class="active">
<a href="#tab1" data-toggle="tab" onclick="hideOthers('popularity')"><?=$t['Beliebtheit'][$language]?></a>
</li>
<li>
<a href="#tab2" data-toggle="tab" onclick="hideOthers('comments')"><?=$t['kommentare'][$language]?></a>
</li>
<li>
<a href="#tab3" data-toggle="tab" onclick="hideOthers('votingbehavior')"><?=$t['Abstimmungsverhalten'][$language]?></a>
</li>
<li>
<a href="#tab4" data-toggle="tab" onclick="hideOthers('entries')"><?=$t['Einträge'][$language]?></a>
</li>
</ul>
<div class="tab-content p30" style="height: 730px;">
<div id="popularity" class="tab-pane active">
<div class="media">
<div class="media-body">
<div id="curve_chart"></div>
<p id="curveText"><?=$t['DieBeliebtheit'][$language]?>
</p>
</div>
</div>
</div>
<div id="comments" class="tab-pane">
<div data-spy="scroll" data-target="#comments" data-offset="0">
<ul class="list-group list-group-flush">
<?php
foreach ($evaluations as $evaluation) {
$type = $evaluation['type'];
$text = $evaluation['evaluationtext'];
$datum = $evaluation['created'];
$class = $type == 0 ? 'bg-danger' : 'bg-success';
echo '<div class="card">';
echo '<div class="card-body '.$class.'">';
echo '<h5 class="card-title"><strong>'.$datum.'</strong></h5>';
echo '<p class="card-text">'.$text.'</p>';
echo '</div>';
echo '</div>';
}
?>
</ul>
</div>
</div>
<div id="votingbehavior" class="tab-pane">
<div class="media">
<div class="media-body">
<table id="votingtable" class="table table-striped">
<thead>
<th><?=$t['Datum'][$language]?>
</th>
<th><?=$t['Abstimmung'][$language]?>
</th>
<th><?=$t['Gestimmt'][$language]?>
</th>
</thead>
<?php
$polvotes = $polvoteObj->displayDataById($id);
foreach ($polvotes as $polvote) :
$votedate = $polvote['votedate'];
$votedivisiontext = $polvote['affairtitle'];
if ($polvote['votedivisiontext']) {
$votedivisiontext = $votedivisiontext.' : '.$polvote['votedivisiontext'];
}
$voted = $polvote['voted'];
?>
<tr>
<td style="width: 10%;">
<h6>
<p
style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin-top: 6px;">
<?=(DateTime::createFromFormat("Y-m-d H:i:s", $votedate))->format("d.m.Y")?>
</p>
</h6>
</td>
<td style="width: 80%;">
<h6>
<p
style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin-top: 6px;">
<?=$votedivisiontext?>
</p>
</h6>
</td>
<td style="width: 10%;">
<h6>
<p
style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin-top: 6px;">
<?=$polvoteObj->votedToText($voted)?>
</p>
</h6>
</td>
</tr>
<?php
endforeach;
?>
</table>
</div>
</div>
</div>
<?php
$entries = $entryObj->getEntriesByPolitician($id);
?>
<div id="entries" class="tab-pane">
<div data-spy="scroll" data-target="#entries" data-offset="0">
<?php
try {
foreach ($entries as $entry) {
$title = str_replace("&quot;", '"', $entry['title']);
$text = str_replace("&quot;", '"', $entry['text']);
$rating = $entry['rating'];
$class = $rating == 0 ? 'negative' : 'positive';
$sources = explode("\n", $entry['source']);
$created = $entry['created'];
$imported = $entry['importdate'];
echo '<div class="card '.$class.'">';
echo '<div class="card-body">';
echo '<h5 class="card-title"><strong>'.$title.'</strong></h5>';
echo '<h6 class="card-subtitle mb-2 text-muted">Erstellt: '.(DateTime::createFromFormat("Y-m-d H:i:s", $imported))->format("d.m.Y H:i").'</h6>';
echo '<p class="card-text">'.$text.'</p>';
if ($sources) {
echo '<div class="sourceHeader"><h6><strong>'.$t['Links'][$language].'</strong></h6></div>';
}
foreach ($sources as $source) {
$isUrl = preg_match("/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|(([^\s()<>]+|(([^\s()<>]+)))*))+(?:(([^\s()<>]+|(([^\s()<>]+)))*)|[^\s`!()[]{};:'\".,<>?«»“”‘’]))/", $source);
if ($isUrl) {
echo '<a href="'.$source.'" target="_blank">';
}
echo '<p class="sourceLink">'.$source.'</p>';
if ($isUrl) {
echo '</a>';
}
}
echo '</div>';
echo '</div>';
}
} catch (\Throwable $e) {
echo $e.'<br/>';
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script>
function hideOthers(tabName) {
var allTabs = ['popularity', 'votingbehavior', 'comments', 'entries'];
allTabs.forEach(item => {
if (item == tabName) {
$('#' + item).addClass('active');
$('#' + item).addClass('show');
$('#' + item).removeAttr('hidden');
$('#' + item).removeClass('tabhidden');
} else {
$('#' + item).addClass('tabhidden');
$('#' + item).removeClass('active')
$('#' + item).attr('hidden');
$('#' + item).removeClass('show');
}
});
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#votingtable").fancyTable({
sortColumn: 0,
pagination: true,
perPage: 10,
globalSearch: true
});
});
</script>
</body>
</html>