Read kurs from database.
This commit is contained in:
parent
60cadc9284
commit
db2ade9da0
|
@ -11,12 +11,12 @@ class DBActivity implements Activity {
|
|||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) {
|
||||
$query = 'SELECT name,start,stop,organiser,location FROM events WHERE start > :date ORDER BY start ASC LIMIT 1';
|
||||
$query = 'SELECT name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1';
|
||||
return $this->retrieve($date, $query);
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) {
|
||||
$query = 'SELECT name,start,stop,organiser,location FROM events WHERE start < :date ORDER BY start DESC LIMIT 1';
|
||||
$query = 'SELECT name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1';
|
||||
return $this->retrieve($date, $query);
|
||||
}
|
||||
|
||||
|
@ -29,23 +29,12 @@ class DBActivity implements Activity {
|
|||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['start']),
|
||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['stop']),
|
||||
$result['organiser'],
|
||||
$result['location']
|
||||
$result['location'],
|
||||
$result['description']
|
||||
);
|
||||
return $ev;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Database";
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Location";
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "User";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,13 @@ class SimpleEvent extends Event {
|
|||
|
||||
private $name, $start, $end, $org, $loc;
|
||||
|
||||
public function __construct($name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc){
|
||||
public function __construct($name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc, $descr){
|
||||
$this->name = $name;
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
$this->org = $org;
|
||||
$this->log = $loc;
|
||||
$this->loc = $loc;
|
||||
$this->descr = explode("\n", $descr);
|
||||
}
|
||||
|
||||
public function getStart(){
|
||||
|
@ -42,7 +43,7 @@ class SimpleEvent extends Event {
|
|||
}
|
||||
|
||||
public function getDescription() {
|
||||
return [];
|
||||
return $this->descr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
<title>Kursverkstedet</title>
|
||||
<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="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/events.css">
|
||||
|
||||
<nav>
|
||||
<li><a href="../">hjem</a></li>
|
||||
<li class="active"><a href="../kurs/">kurs</a></li>
|
||||
<li><a href="../prosjekt/">prosjekt</a></li>
|
||||
<li><a href="../sosiale/">sosiale</a></li>
|
||||
<li><a href="../wiki/">wiki</a></li>
|
||||
</nav>
|
||||
|
||||
<header>Kurs­verk­stedet</header>
|
||||
|
||||
<main>
|
||||
|
||||
<article>
|
||||
<h2><img src="linuxfix.jpg"><strong><em>i dag</em></strong> Linux-introkurs</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid: <a>2016-09-01 19:15</a>
|
||||
<li>Sted: <a>KJL2</a>
|
||||
<li>Kursholder: <a>Andreas Danner Nilsen</a>
|
||||
</ul>
|
||||
<p>Lurer du på hva Linux er?
|
||||
|
||||
<p>Dette kurset gir en kortfattet innføring om hvordan operativsystemet Unix oppstod og utviklet seg til en hel haug med operativsystemer vi bruker i dag; Linux, BSD, MacOS X med flere. Og det vil forhåpentligvis komme innom alle de viktigste begrepene i Unix-universet, litt om de mange fraksjoneringene av operativsystemet som har gitt opphav til nesten alle OS i dag (ett stort unntak), nerdekulturen som følger med og litt smått om personene bak det hele.
|
||||
|
||||
<p>Hovedfokus i kurset er allikevel mer praktisk rettet mot bruk av kommandolinjen, skall, jobbhåndtering og enkel bruk av viktige verktøy i Linux.
|
||||
|
||||
<p>Ingen forkunnskaper behøves, dette er et nybegynnerkurs for alle som vil begynne å bruke Linux (eller et annet operativsystem i Unix-familien) og vil ha et sted å starte.
|
||||
|
||||
<p><a class="btn" href="#">Påminn meg via SMS</a>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<h2><img src="linuxfix.jpg"><em>fredag</em> Vulkan</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid: <a>2016-09-01 19:15</a>
|
||||
<li>Sted: <a>KJL2</a>
|
||||
<li>Kursholder: <a>Andreas Danner Nilsen</a>
|
||||
</ul>
|
||||
<p>Vulkan is a brand new Graphics API designed to give programmers total control over what happens on a GPU.
|
||||
|
||||
<p><a class="btn" href="#">Les mer</a> <a class="btn" href="#">Påminn meg</a>
|
||||
</article>
|
||||
|
||||
</main>
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'no_NO');
|
||||
require __DIR__ . '/../../src/_autoload.php';
|
||||
require __DIR__ . '/../../sql_config.php';
|
||||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
new \pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
?><!DOCTYPE html>
|
||||
<html lang="no">
|
||||
<title>Kursverkstedet</title>
|
||||
<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="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/events.css">
|
||||
|
||||
<nav>
|
||||
<li><a href="../">hjem</a></li>
|
||||
<li class="active"><a href="../kurs/">kurs</a></li>
|
||||
<li><a href="../prosjekt/">prosjekt</a></li>
|
||||
<li><a href="../sosiale/">sosiale</a></li>
|
||||
<li><a href="../wiki/">wiki</a></li>
|
||||
</nav>
|
||||
|
||||
<header>Kurs­verk­stedet</header>
|
||||
|
||||
<main>
|
||||
|
||||
<?php $limit = 0; ?>
|
||||
<?php foreach($agenda->getEventsBetween(new \DateTimeImmutable, (new \DateTimeImmutable)->add(new \DateInterval('P1M'))) as $event) { ?>
|
||||
|
||||
<article>
|
||||
<h2>
|
||||
<?php if ($event->getImageURL()) { ?>
|
||||
<img src="<?= $event->getImageURL() ?>">
|
||||
<?php } ?>
|
||||
<?php if (\pvv\side\Agenda::isToday($event->getStart())) { ?><strong><?php } ?>
|
||||
<em><?= $event->getRelativeDate() ?></em>
|
||||
<?php if (\pvv\side\Agenda::isToday($event->getStart())) { ?></strong><?php } ?>
|
||||
<a href="<?= $event->getURL() ?>"><?= $event->getName() ?></a>
|
||||
</h2>
|
||||
<ul class="subtext">
|
||||
<li>Tid: <strong><?= trim(strftime('%e. %b %H.%M', $event->getStart()->getTimeStamp())) ?></strong>
|
||||
<li>Sted: <strong><?= $event->getLocation() ?></strong>
|
||||
<li>Arrangør: <strong><?= $event->getOrganiser() ?></strong>
|
||||
</ul>
|
||||
|
||||
<?php $description = $event->getDescription(); ?>
|
||||
<?php if ($limit) array_splice($description, $limit); ?>
|
||||
<?= implode($description, "</p>\n<p>") ?>
|
||||
|
||||
<p><a class="btn" href="#">Påminn meg</a>
|
||||
</article>
|
||||
|
||||
<?php if (!$limit || $limit > 4) {$limit = 4;} else $limit = 2; ?>
|
||||
<?php } ?>
|
||||
|
||||
</main>
|
Reference in New Issue