2017-10-28 20:09:54 +02:00
|
|
|
<?php
|
|
|
|
date_default_timezone_set('Europe/Oslo');
|
2018-02-10 18:08:53 +01:00
|
|
|
setlocale(LC_ALL, 'nb_NO');
|
2018-02-10 18:05:38 +01:00
|
|
|
require __DIR__ . '/../../inc/navbar.php';
|
2017-10-28 20:09:54 +02:00
|
|
|
require __DIR__ . '/../../src/_autoload.php';
|
2024-02-15 22:57:03 +01:00
|
|
|
require __DIR__ . '/../../config.php';
|
2017-11-11 15:20:58 +01:00
|
|
|
|
2017-10-28 20:09:54 +02:00
|
|
|
require_once(__DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
2024-04-08 22:11:43 +02:00
|
|
|
$as = new \SimpleSAML\Auth\Simple('default-sp');
|
2017-10-28 20:09:54 +02:00
|
|
|
$as->requireAuth();
|
|
|
|
$attrs = $as->getAttributes();
|
|
|
|
|
2024-03-12 19:33:09 +01:00
|
|
|
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
2017-10-28 20:09:54 +02:00
|
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
$projectManager = new \pvv\side\ProjectManager($pdo);
|
2018-02-26 16:24:50 +01:00
|
|
|
$projects = $projectManager->getByOwner($attrs['uid'][0]);
|
2017-10-28 20:09:54 +02:00
|
|
|
|
|
|
|
$page = 1;
|
|
|
|
if(isset($_GET['page'])){
|
|
|
|
$page = $_GET['page'];
|
|
|
|
}
|
|
|
|
|
2018-08-09 00:45:56 +02:00
|
|
|
$filter = '';
|
|
|
|
if(isset($_GET['filter'])){
|
|
|
|
$filter = $_GET['filter'];
|
2017-10-28 20:09:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// filter
|
|
|
|
$projects = array_values(array_filter(
|
|
|
|
$projects,
|
2018-08-09 00:45:56 +02:00
|
|
|
function($project) use ($filter){
|
|
|
|
return (preg_match('/.*'.$filter.'.*/i', $project->getName()) or preg_match('/.*'.$filter.'.*/i', implode(" ", $project->getDescription())));
|
2017-10-28 20:09:54 +02:00
|
|
|
}
|
|
|
|
));
|
|
|
|
?>
|
2018-08-14 02:09:32 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="no">
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
|
|
|
<link rel="shortcut icon" href="favicon.ico">
|
|
|
|
<link rel="stylesheet" href="../css/normalize.css">
|
|
|
|
<link rel="stylesheet" href="../css/style.css">
|
|
|
|
<link rel="stylesheet" href="../css/events.css">
|
|
|
|
<link rel="stylesheet" href="../css/admin.css">
|
2018-08-14 03:29:10 +02:00
|
|
|
<meta name="theme-color" content="#024" />
|
2018-08-14 02:09:32 +02:00
|
|
|
<title>Prosjektverkstedet</title>
|
|
|
|
|
|
|
|
<header>Prosjekt­verk­stedet</header>
|
2017-10-28 20:09:54 +02:00
|
|
|
|
2018-02-26 16:24:50 +01:00
|
|
|
|
|
|
|
<body>
|
|
|
|
<nav>
|
|
|
|
<?= navbar(1, 'prosjekt'); ?>
|
|
|
|
<?= loginbar(); ?>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<main class="gridsplit">
|
|
|
|
<div class="gridl">
|
|
|
|
<h2 class="no-chin">Mine Prosjekter</h2>
|
|
|
|
|
|
|
|
<ul class="event-list">
|
|
|
|
<?php
|
|
|
|
$counter = 0;
|
2018-08-09 00:45:56 +02:00
|
|
|
$pageLimit = 8;
|
2018-02-26 16:24:50 +01:00
|
|
|
|
|
|
|
for($i = ($pageLimit * ($page - 1)); $i < count($projects); $i++){
|
|
|
|
if($counter == $pageLimit){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$project = $projects[$i];
|
|
|
|
$projectID = $project->getID();
|
2018-08-19 14:44:44 +02:00
|
|
|
|
|
|
|
$owner = $projectManager->getProjectOwner($projectID);
|
|
|
|
if($owner['uname'] != $attrs['uid'][0]){
|
|
|
|
continue;
|
|
|
|
}
|
2018-02-26 16:24:50 +01:00
|
|
|
?>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<div class="event">
|
|
|
|
<div class="event-info">
|
2018-08-09 00:45:56 +02:00
|
|
|
<a href="edit.php?id=<?= $project->getID() ?>">
|
|
|
|
<h3 class="no-chin"><?= $project->getName()?></h3>
|
|
|
|
</a>
|
2018-08-14 03:25:24 +02:00
|
|
|
<p style="text-decoration: none;"><?= implode("<br>", array_slice($project->getDescription(), 0, 4)); ?></p>
|
2018-02-26 16:24:50 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
2017-10-28 20:09:54 +02:00
|
|
|
|
2018-02-26 16:24:50 +01:00
|
|
|
<?php
|
|
|
|
$counter++;
|
2017-10-28 20:09:54 +02:00
|
|
|
}
|
2018-02-26 16:24:50 +01:00
|
|
|
?>
|
|
|
|
</ul>
|
2017-10-28 20:09:54 +02:00
|
|
|
|
|
|
|
<?php
|
2018-02-26 16:24:50 +01:00
|
|
|
if($page != 1){
|
2018-08-09 00:45:56 +02:00
|
|
|
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '&filter=' . urlencode($filter) . '">Forrige side</a>';
|
2018-02-26 16:24:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(($counter == $pageLimit) and (($pageLimit * $page) < count($projects))){
|
2018-08-09 00:45:56 +02:00
|
|
|
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '&filter=' . urlencode($filter) . '">Neste side</a>';
|
2017-10-28 20:09:54 +02:00
|
|
|
}
|
|
|
|
?>
|
2018-02-26 16:24:50 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="gridr">
|
|
|
|
<h2>Verktøy</h2>
|
|
|
|
<a class="btn" href="edit.php?new=1">Lag prosjekt</a>
|
|
|
|
<h2>Filter</h2>
|
2018-08-09 00:45:56 +02:00
|
|
|
<form action="mine.php" method="get">
|
2018-02-26 16:24:50 +01:00
|
|
|
<p class="no-chin">Navn</p>
|
2018-08-09 00:45:56 +02:00
|
|
|
<?= '<input type="text" name="filter" class="boxinput" value="' . $filter . '">' ?><br>
|
2018-02-26 16:24:50 +01:00
|
|
|
|
|
|
|
<div style="margin-top: 2em;">
|
|
|
|
<input type="submit" class="btn" value="Filtrer"></input>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</main>
|
2018-08-09 00:45:56 +02:00
|
|
|
</body>
|