Projects/nettsiden-old
Projects
/
nettsiden-old
Archived
8
0
Fork 0

Generalize navigation and PHP configuration

This commit is contained in:
Yorin Anne De Jong 2017-11-11 15:20:58 +01:00
parent 9068042a7e
commit 6574bd576e
17 changed files with 98 additions and 292 deletions

2
dev.sh
View File

@ -14,4 +14,4 @@ if test \! -d vendor; then
ln -s ../vendor/simplesamlphp/simplesamlphp/www/ www/simplesaml
fi
php -S [::1]:1080 -t www/
php -S [::1]:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/

36
inc/navbar.php Normal file
View File

@ -0,0 +1,36 @@
<?php
function navbar($depth, $active = NULL) {
$result = "\n\t<ul>\n";
$menuItems = [
'hjem' => '',
'kalender' => 'kalender',
'aktiviteter' => 'aktiviteter',
'prosjekter' => 'prosjekt',
'kontakt' => 'kontakt',
'wiki' => 'pvv',
];
foreach($menuItems as $caption => $link) {
$result .= "\t\t<li" . ($active === $link ? ' class="active"' : '') . '>'
. '<a href="' . str_repeat('../', $depth) . $link . '/">'
. $caption
. "</a></li>\n"
;
}
return $result . "\t</ul>\n";
}
function loginBar($sp = 'default-sp') {
$result = "\n";
require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple($sp);
$attr = $as->getAttributes();
if($attr) {
$uname = $attr['uid'][0];
$result .= "\t<p class=\"login\">logget inn som: " . htmlspecialchars($uname) . "</p>\n";
} else {
$result .= "\t<a class=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">logg inn</a>\n";
}
return $result;
}

View File

@ -1,13 +1,10 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../../inc/navbar.php';
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../sql_config.php';
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$customActivity = new \pvv\side\DBActivity($pdo);
@ -50,27 +47,6 @@ if($new == 0){
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/admin.css">
<nav>
<ul>
<li><a href="../">hjem</a></li>
<li><a href="../kalender/">kalender</a></li>
<li><a href="../aktiviteter/">aktiviteter</a></li>
<li><a href="../prosjekt/">prosjekter</a></li>
<li><a href="../kontakt/">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
</nav>
<header class="admin">Aktivitets&shy;administrasjon</header>
<main>
@ -116,3 +92,8 @@ if($new == 0){
</article>
</main>
<nav>
<?= navbar(2); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,13 +1,9 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../../inc/navbar.php';
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../sql_config.php';
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@ -44,27 +40,6 @@ $events = array_values(array_filter(
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/admin.css">
<nav>
<ul>
<li><a href="../../index.php">hjem</a></li>
<li><a href="../../kalender/">kalender</a></li>
<li><a href="../../aktiviteter/">aktiviteter</a></li>
<li><a href="../../prosjekt/">prosjekter</a></li>
<li><a href="../../kontakt">kontakt</a></li>
<li><a href="../../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
</nav>
<header class="admin">Aktivitets&shy;administrasjon</header>
<main>
@ -141,3 +116,8 @@ $events = array_values(array_filter(
</article>
</main>
<nav>
<?= navbar(2); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,8 +1,6 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../sql_config.php';
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);

View File

@ -1,5 +1,5 @@
<?php
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
require_once __DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
?>
@ -10,28 +10,6 @@ $attrs = $as->getAttributes();
<link rel="stylesheet" href="../css/events.css">
<link rel="stylesheet" href="../css/admin.css">
<nav>
<ul>
<li><a href="../">hjem</a></li>
<!--<li><a href="../prosjekt/">prosjekter</a></li>-->
<li><a href="../kalender/">kalender</a></li>
<li><a href="../aktiviteter/">aktiviteter</a></li>
<li><a href="../prosjekt/">prosjekter</a></li>
<li><a href="../kontakt/">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
</nav>
<header class="admin">Stor-&shy;gutt-&shy;leketøy</header>
<main>
@ -43,3 +21,8 @@ $attrs = $as->getAttributes();
</article>
</main>
<nav>
<?= navbar(1); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,13 +1,10 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../../inc/navbar.php';
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../sql_config.php';
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$projectManager = new \pvv\side\ProjectManager($pdo);
$projects = $projectManager->getAll();
@ -44,27 +41,6 @@ if($new == 0){
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/admin.css">
<nav>
<ul>
<li><a href="../../index.php">hjem</a></li>
<li><a href="../../kalender/">kalender</a></li>
<li><a href="../../aktiviteter/">aktiviteter</a></li>
<li><a href="../../prosjekt/">prosjekter</a></li>
<li><a href="../../kontakt">kontakt</a></li>
<li><a href="../../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
</nav>
<header class="admin">Prosjekt&shy;administrasjon</header>
<main>
@ -104,3 +80,8 @@ if($new == 0){
</article>
</main>
<nav>
<?= navbar(2); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,13 +1,9 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../../inc/navbar.php';
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../sql_config.php';
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@ -44,27 +40,6 @@ $projects = array_values(array_filter(
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/admin.css">
<nav>
<ul>
<li><a href="../../index.php">hjem</a></li>
<li><a href="../../kalender/">kalender</a></li>
<li><a href="../../aktiviteter/">aktiviteter</a></li>
<li><a href="../../prosjekt/">prosjekter</a></li>
<li><a href="../../kontakt">kontakt</a></li>
<li><a href="../../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
</nav>
<header class="admin">Prosjekt&shy;administrasjon</header>
<main>
@ -137,3 +112,8 @@ $projects = array_values(array_filter(
</article>
</main>
<nav>
<?= navbar(2); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,8 +1,6 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../sql_config.php';
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);

View File

@ -1,11 +1,9 @@
<?php
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../inc/navbar.php';
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@ -81,23 +79,6 @@ foreach($events as $event) {
</main>
<nav>
<ul>
<li><a href="../">hjem</a></li>
<!--<li><a href="../prosjekt/">prosjekter</a></li>-->
<li><a href="../kalender/">kalender</a></li>
<li class="active"><a href="../aktiviteter/">aktiviteter</a></li>
<li><a href="../prosjekt/">prosjekter</a></li>
<li><a href="../kontakt/">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
<?= navbar(1, 'aktiviteter'); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,11 +1,9 @@
<?php
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../inc/navbar.php';
require __DIR__ . '/../src/_autoload.php';
require __DIR__ . '/../sql_config.php';
require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
$translation = ['i dag', 'i morgen', 'denne uka', 'neste uke', 'denne måneden', 'neste måned'];
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
@ -94,23 +92,6 @@ For å bli med i våre prosjekter og komitéer må du søke.
</main>
<nav>
<ul>
<li class="active"><a href="index.php">hjem</a></li>
<!--<li><a href="prosjekt/">prosjekter</a></li>-->
<li><a href="kalender/">kalender</a></li>
<li><a href="aktiviteter/">aktiviteter</a></li>
<li><a href="prosjekt/">prosjekter</a></li>
<li><a href="kontakt/">kontakt</a></li>
<li><a href="pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
<?php echo navbar(0, ''); ?>
<?php echo loginbar(); ?>
</nav>

View File

@ -1,11 +1,9 @@
<?php
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../inc/navbar.php';
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
use \pvv\side\Agenda;
$months_translations = ['Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember'];
@ -103,23 +101,6 @@ $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
</main>
<nav>
<ul>
<li><a href="../">hjem</a></li>
<!--<li><a href="../prosjekt/">prosjekter</a></li>-->
<li class="active"><a href="../kalender/">kalender</a></li>
<li><a href="../aktiviteter/">aktiviteter</a></li>
<li><a href="../prosjekt/">prosjekter</a></li>
<li><a href="../kontakt/">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
<?= navbar(1, 'kalender'); ?>
<?= loginbar(); ?>
</nav>

View File

@ -2,11 +2,9 @@
<?php
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../inc/navbar.php';
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
?>
<html lang="no">
<title>Kommunikasjonsverkstedet</title>
@ -40,23 +38,6 @@ Det er også mulig å ta i bruk analog kontakt ved å møte opp <a href="https:/
</main>
<nav>
<ul>
<li><a href="../">hjem</a></li>
<!--<li><a href="../prosjekt/">prosjekter</a></li>-->
<li><a href="../kalender/">kalender</a></li>
<li><a href="../aktiviteter/">aktiviteter</a></li>
<li><a href="../prosjekt/">prosjekter</a></li>
<li class="active"><a href="../kontakt/">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
<?= navbar(1, 'kontakt'); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,12 +1,11 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../inc/navbar.php';
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
require_once __DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
@ -53,27 +52,6 @@ if($new == 0){
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/admin.css">
<nav>
<ul>
<li><a href="../index.php">hjem</a></li>
<li><a href="../kalender/">kalender</a></li>
<li><a href="../aktiviteter/">aktiviteter</a></li>
<li class="active"><a href="../prosjekt/">prosjekter</a></li>
<li><a href="../kontakt/">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</ul>
<?php
if($attrs){
$uname = $attrs["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
</nav>
<header>Prosjekt&shy;verk&shy;stedet</header>
<main>
@ -101,3 +79,8 @@ if($new == 0){
</article>
</main>
<nav>
<?= navbar(1, 'prosjekt'); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,13 +1,9 @@
<?php
ini_set('display_errors', '1');
error_reporting(E_ALL);
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
require __DIR__ . '/../../inc/navbar.php';
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$attrs = $as->getAttributes();
$translation = ['i dag', 'i morgen', 'denne uka', 'neste uke', 'denne måneden', 'neste måned'];
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
@ -72,22 +68,6 @@ $projects = $projectManager->getAll();
</main>
<nav>
<ul>
<li><a href="../">hjem</a></li>
<li><a href="../kalender/">kalender</a></li>
<li><a href="../aktiviteter/">aktiviteter</a></li>
<li class="active"><a href="../prosjekt/">prosjekter</a></li>
<li><a href="../kontakt/">kontakt</a></li>
<li><a href="../pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
<?= navbar(1, 'prosjekt'); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,10 +1,9 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple('default-sp');
$as->requireAuth();
@ -45,26 +44,6 @@ $projects = array_values(array_filter(
<link rel="stylesheet" href="../css/events.css">
<link rel="stylesheet" href="../css/admin.css">
<nav>
<ul>
<li class="active"><a href="index.php">hjem</a></li>
<li><a href="aktiviteter/">aktiviteter</a></li>
<li><a href="../prosjekt/">prosjekter</a></li>
<li><a href="kontakt">kontakt</a></li>
<li><a href="pvv/">wiki</a></li>
</ul>
<?php
$attr = $as->getAttributes();
if($attr){
$uname = $attr["uid"][0];
echo '<p class="login">logget inn som: ' . $uname . '</p>';
}else{
echo '<a class="login" href="' . $as->getLoginURL() . '">logg inn</a>';
}
?>
</nav>
<header>Prosjekt&shy;verkstedet</header>
<main>
@ -128,4 +107,9 @@ $projects = array_values(array_filter(
</div>
</article>
</main>
</main>
<nav>
<?= navbar(1, 'prosjekt'); ?>
<?= loginbar(); ?>
</nav>

View File

@ -1,8 +1,6 @@
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
setlocale(LC_ALL, 'no_NO');
error_reporting(E_ALL);
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../sql_config.php';
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);