Skip to content

Commit

Permalink
Merge pull request #18 from roothaan/develop
Browse files Browse the repository at this point in the history
Release 2017.08.27
  • Loading branch information
jasperroel authored Aug 27, 2017
2 parents 890c376 + 6226d36 commit 4bd60d8
Show file tree
Hide file tree
Showing 29 changed files with 302 additions and 187 deletions.
32 changes: 12 additions & 20 deletions 2013/admin/paths.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

$paths = array(
"" => "home.php",
"home" => "home.php",
Expand Down Expand Up @@ -58,17 +59,6 @@
'privacy' => 1
);

// 1 == <div class="noHeaderFooter"><div id="page"><div id="content">
// 2 == nothing
$noHeaderFooter = array(
"beamer" => 2,
"kaart" => 2,
// TODO => This should probably be 2. Also, terrible name??
"delete_locatie" => 1,
'kml' => 2,
'deelgebieden-kml' => 2
);

$urlToParse = $_SERVER['REQUEST_URI'];
if (getenv('PROXY_BASE_URL')) {
$pos = strpos($urlToParse, getenv('PROXY_BASE_URL'));
Expand All @@ -77,20 +67,22 @@
}
}

$urlParts = parse_url($urlToParse);
JotihuntUtils::setUrlParts($urlToParse);

$urlArray = array();
if (isset($urlParts['path'])) {
$urlArray = explode('/', trim($urlParts['path'], '/'));
}

if (count($urlArray) > 0 && in_array($urlArray[0], $needsNoEvent)) {
if (in_array(JotihuntUtils::getUrlPart(0), $needsNoEvent)) {
define('NEEDS_NO_EVENT', true);
}

if(isset($needsNoDb[$urlArray[0]])) {
if(isset($needsNoDb[JotihuntUtils::getUrlPart(0)])) {
define('NO_DB_REQUIRED', true);
}

if(array_key_exists(JotihuntUtils::getUrlPart(0), $paths)) {
define('JH_PATH', $paths[JotihuntUtils::getUrlPart(0)]);
}

unset($needsNoEvent);
unset($needsNoDb);
unset($needsNoDb);
unset($paths);
unset($urlToParse);
unset($urlParts);
1 change: 1 addition & 0 deletions 2013/cronjob/SyncJotihunt.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function print_debug($message) {

print_debug('<h1>Nieuws</h1>');
$nieuwscollection = $jotihuntinformatie->updateNieuws();

foreach ( $nieuwscollection as $nieuwsitem ) {
if($debug) {
print_debug('<h2>Nieuws bericht</h2>');
Expand Down
10 changes: 5 additions & 5 deletions 2013/delvos.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
$authMgr->requireAdmin();

// Handle ID
if (isset($urlArray[1])) {
$id = intval($urlArray[1]);
if (null != JotihuntUtils::getUrlPart(1)) {
$id = intval(JotihuntUtils::getUrlPart(1));
$driver->removeVossenLocation($id);
}

// Handle TEAM
$team = '';
if (isset($urlArray[2])) {
$team = '/'.$urlArray[2];
if (null != JotihuntUtils::getUrlPart(2)) {
$team = '/' . JotihuntUtils::getUrlPart(1);
}

header("Location: ".WEBSITE_URL."vossen".$team);
header('Location: ' . WEBSITE_URL . 'vossen' . $team);
die();
4 changes: 3 additions & 1 deletion 2013/fullscreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
$headerOptions = array();
$headerOptions['title'] = 'Fullscreen Kaart';
$headerOptions['includeBody'] = false;
require_once BASE_DIR . 'header.php'; ?>
require_once BASE_DIR . 'header.php';

?>

<style>
.foxText {
Expand Down
5 changes: 4 additions & 1 deletion 2013/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,7 @@ function showHideMenu()
<!-- end #header -->
<!-- end #header-wrapper -->

<?php } // end 'includeBody' ?>
<?php
} // end 'includeBody'
unset($_headerOptions);
?>
1 change: 1 addition & 0 deletions 2013/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
} ?>

<h1>Home</h1>

<p>Welkom op de Jotihunt-spelsite van de <a href="http://roothaangroep.nl/" target="_blank">Roothaangroep</a>. De Jotihunt is een door Scouting Gelderland georganiseerde vossenjacht die ieder jaar tijdens de JOTA/JOTI plaats vindt. Tijdens de 30 uur durende vossenjacht proberen maar liefst 70 groepen uit heel Gelderland 12 verschillende vossenteams te vinden. Hierbij worden zij geholpen door aanwijzingen die regelmatig op <a href="https://www.jotihunt.net" target="_blank">Jotihunt.net</a> verschijnen.</p>
<p>Deze site is bedoeld voor hunters van de Generaal Roothaangroep. Via deze site kunnen vossen-locaties worden opgezocht, het rijschema worden bekeken en dankzij de alarmpagina worden wij zo snel mogelijk gewaarschuwd wanneer een vossenteam actief/inactief wordt, een nieuw bericht op de site verschijnt en we een plaatsje stijgen/zakken in de scorelijst.</p>
<p>Ook dit jaar zijn wij op <strong><a href="https://www.facebook.com/RoothaanJotihunt">facebook.com/RoothaanJotihunt</a></strong> te volgen. Stay tuned voor foto's, filmpjes en andere nieuwtjes!</p>
Expand Down
Binary file added 2013/images/themes/2017/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2013/images/themes/2017/logo-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 25 additions & 11 deletions 2013/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,34 @@ static function getPhoneNumbersForUserId($userId) {
}
return $result;
}

private static $noHeaderFooter = array(
'beamer',
'kaart',
'delete_locatie',
'kml',
'deelgebieden-kml'
);

static function createKmlCoordinates($coordinates) {
$result = '';
if (!is_array($coordinates)) {
return $result;
private static $urlParts = array();

public static function setUrlParts($urlToParse) {
$_urlParts = parse_url($urlToParse);

if (isset($_urlParts['path'])) {
JotihuntUtils::$urlParts = explode('/', trim($_urlParts['path'], '/'));
}

foreach ($coordinates as $coordinate) {
$result .= $coordinate->getLongitude();
$result .= ',';
$result .= $coordinate->getLatitude();
$result .= ',0.0 ';
}

public static function getUrlPart($part) {
if (isset(JotihuntUtils::$urlParts[$part])) {
return urldecode(JotihuntUtils::$urlParts[$part]);
}
return trim($result);
return null;
}

public static function hasHeaderOrFooter() {
return !in_array(JotihuntUtils::getUrlPart(0), JotihuntUtils::$noHeaderFooter);
}
}
?>
2 changes: 1 addition & 1 deletion 2013/includes/map_deelgebieden.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function drawDeelgebieden(map, eventId) {
var kmlUrl = window.location.origin + '/deelgebieden-kml?event_id=' + eventId
var kmlUrl = window.location.origin + '/deelgebieden-kml/' + eventId
console.log("Using kmlUrl: " + kmlUrl);
var kmlOptions = {
suppressInfoWindows: false,
Expand Down
13 changes: 4 additions & 9 deletions 2013/index.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
<?php
ob_start();
require_once 'admin/paths.php';
require_once 'init.php';

if(!isset($noHeaderFooter[$urlArray[0]])) {
if(JotihuntUtils::hasHeaderOrFooter()) {
require_once BASE_DIR . 'header.php';
echo '<div id="page"><div id="content">';
} else if ($noHeaderFooter[$urlArray[0]] == 1) {
echo '<div class="noHeaderFooter"><div id="page"><div id="content">';
}

define('opoiLoaded',true);

if(isset($paths[$urlArray[0]])) {
require_once $paths[$urlArray[0]];
if(defined('JH_PATH')) {
require_once JH_PATH;
} else {
header("HTTP/1.0 404 Not Found");
echo '404 - Deze pagina is helaas niet gevonden.';
}

if(!isset($noHeaderFooter[$urlArray[0]])) {
if(JotihuntUtils::hasHeaderOrFooter()) {
echo '</div></div>';
require_once BASE_DIR . 'footer.php';
} else if ($noHeaderFooter[$urlArray[0]] == 1) {
echo '</div></div></div>';
}
ob_end_flush();
2 changes: 2 additions & 0 deletions 2013/init.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

define('BASE_DIR', dirname(__FILE__) . '/');

require_once BASE_DIR . 'includes/global_include.php';
require_once BASE_DIR . 'includes/functions.php';
require_once BASE_DIR . 'admin/paths.php';

$authMgr->attemptAuth();
if (! $driver->isReady()) {
Expand Down
130 changes: 10 additions & 120 deletions 2013/kml/deelgebieden.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,132 +5,22 @@
if(!defined("opoiLoaded")) die('Incorrect or unknown use of application');
//JotihuntUtils::requireLogin();

if (!isset($_GET['event_id'])) {
require_once CLASS_DIR . 'jotihunt/helpers/DeelgebiedHelper.class.php';

if(!empty(JotihuntUtils::getUrlPart(1))) {
$eventId = intval(JotihuntUtils::getUrlPart(1));
} else {
echo 'No event_id';
die();
}

$eventId = intval($_GET['event_id']);
$event = $driver->getEventById($eventId);
$deelgebiedHelper = new DeelgebiedHelper();
$kmlOutput = $deelgebiedHelper->getKmlForEventId($eventId);

if (!$event) {
if (!$kmlOutput) {
header('HTTP/1.1 404 Not Found');
echo 'Not a valid event_id ['.$eventId.']';
die();
}

// Then grab all Deelgebieden
$_allDeelgebieden = $driver->getAllDeelgebiedenForEvent($eventId);
$kml = array();
$allDeelgebieden = array();

// Then all Coordinates for that Deelgebied
foreach ($_allDeelgebieden as $deelgebied) {
$coordinates = $driver->getAllCoordinatesForDeelgebied($deelgebied->getId());
$kml[$deelgebied->getName()] = $coordinates;
$allDeelgebieden[$deelgebied->getName()] = $deelgebied;
}

// Cool, we got here, let's go print stuff!
// Creates the Document.
$dom = new DOMDocument('1.0', 'UTF-8');

// Creates the root KML element and appends it to the root document.
$node = $dom->createElementNS('http://earth.google.com/kml/2.2', 'kml');
$parNode = $dom->appendChild($node);

// Creates a KML Document element and append it to the KML element.
$dnode = $dom->createElement('Document');
$docNode = $parNode->appendChild($dnode);

// Add a Name (the event)
$node = $dom->createElement('name');
$node->appendChild($dom->createTextNode($event->getName()));
$docNode->appendChild($node);

// Add a Folder
$folderNode = $dom->createElement('Folder');
$docNode->appendChild($folderNode);

$node = $dom->createElement('name');
$node->appendChild($dom->createTextNode('Deelgebieden'));
$folderNode->appendChild($node);

// for each deelgebied
foreach ($kml as $deelgebiedName => $coordinates) {
// Generate styleUrl #ID-name
$deelgebied = $allDeelgebieden[$deelgebiedName];
$styleUrl = 'poly-'.$deelgebied->getId() . '-' . $deelgebiedName;

$placemarkNode = $dom->createElement('Placemark');
$folderNode->appendChild($placemarkNode);

$node = $dom->createElement('styleUrl');
$node->appendChild($dom->createTextNode('#'.$styleUrl));
$placemarkNode->appendChild($node);

$node = $dom->createElement('name');
$node->appendChild($dom->createTextNode($deelgebied->getName()));
$placemarkNode->appendChild($node);

$node = $dom->createElement('ExtendedData');
$placemarkNode->appendChild($node);

// Polygon, outerBoundaryIs, LinearRing
$polygonNode = $dom->createElement('Polygon');
$placemarkNode->appendChild($polygonNode);

$outerBoundaryIsNode = $dom->createElement('outerBoundaryIs');
$polygonNode->appendChild($outerBoundaryIsNode);

$linearRingNode = $dom->createElement('LinearRing');
$outerBoundaryIsNode->appendChild($linearRingNode);

//[tessellate=1, coordinates=..]
$tessellateNode = $dom->createElement('tessellate', 1);
$linearRingNode->appendChild($tessellateNode);

$coordinatesNode = $dom->createElement('coordinates');
$coordinatesNode->appendChild($dom->createTextNode(JotihuntUtils::createKmlCoordinates($coordinates)));
$linearRingNode->appendChild($coordinatesNode);
}

// Now, create Style items (inside the $folderNode node)
foreach ($kml as $deelgebiedName => $coordinates) {
// Generate styleUrl #ID-name
$deelgebied = $allDeelgebieden[$deelgebiedName];
$styleUrl = 'poly-'.$deelgebied->getId() . '-' . $deelgebiedName;

$styleNode = $dom->createElement('Style');
$styleNode->setAttribute('id', $styleUrl);
$dnode->appendChild($styleNode);

$linestyleNode = $dom->createElement('LineStyle');
$styleNode->appendChild($linestyleNode);

$node = $dom->createElement('color');
$node->appendChild($dom->createTextNode($deelgebied->getLineColor()));
$linestyleNode->appendChild($node);

$node = $dom->createElement('width');
$node->appendChild($dom->createTextNode('1'));
$linestyleNode->appendChild($node);

$polystyleNode = $dom->createElement('PolyStyle');
$styleNode->appendChild($polystyleNode);

$node = $dom->createElement('color');
$node->appendChild($dom->createTextNode($deelgebied->getPolyColor()));
$polystyleNode->appendChild($node);

$node = $dom->createElement('fill');
$node->appendChild($dom->createTextNode('1'));
$polystyleNode->appendChild($node);

$node = $dom->createElement('outline');
$node->appendChild($dom->createTextNode('1'));
$polystyleNode->appendChild($node);
}

$kmlOutput = $dom->saveXML();
header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmlOutput;
$deelgebiedHelper->outputAsKml($kmlOutput);
4 changes: 2 additions & 2 deletions 2013/vossen.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
?>Dit event heeft nog geen deelgebieden<?php
} else {

if(isset($urlArray[1]) && !empty($urlArray[1])) {
$deelgebiedName = urldecode($urlArray[1]);
if(null != JotihuntUtils::getUrlPart(1)) {
$deelgebiedName = JotihuntUtils::getUrlPart(1);
} else {
$deelgebiedName = $allDeelgebieden[0]->getName();
}
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ Bijvoorbeeld `/forwarded`
Dit is een `boolean` waarde ((`1`/`true` of `0`/`false`).
Standaard staan de errors uit.

`DEV_MODE`
Dit is een `boolean` waarde ((`1`/`true` of `0`/`false`).
Als deze aanstaat is het mogelijk om:
- API calls te doen met een ingelogde user
- Testen uit te voeren (/test)
- De Google maps kaart toont een dummy hunter


# Overig
## Update tot PHP7
Expand Down
Loading

0 comments on commit 4bd60d8

Please sign in to comment.