chiro-canto/public/articles/index.php

73 lines
1.9 KiB
PHP

<?php
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
require("$root/articles/config.php");
require("$root/articles/Article.php");
function archive() {
$result = array();
$data = Article::getList();
$result['articles'] = $data['results'];
$result['totalRows'] = $data['totalRows'];
$result['pageTitle'] = "Article Archive | Chiro - Canto";
require("$root/articles/archive.php");
}
function view() {
if (! isset($_GET['article']) || ! $_GET['article']) {
home();
return;
}
$results = array();
$results['article'] = Article::getById( (int)$_GET["articleId"] );
$results['pageTitle'] = $results['article']->title . " | Chiro - Canto";
require("$root/articles/view.php");
}
function home() {
$results = array();
$data = Article::getList(HOMEPAGE_NUM_ARTICLES);
$results['articles'] = $data['results'];
$results['totalRows'] = $data['totalRows'];
$results['pageTitle'] = "Articles | Chiro - Canto";
require("home.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Articles | Chiro - Canto</title>
<link rel="stylesheet" type="text/css" href="/styles/style.css">
</head>
<?php
include("$root/analytics/matomo.php");
?>
<body>
<?php include("$root/menu.php");?>
<?php include("$root/header.php");?>
<section>
<?php
$action = isset($_GET['action']) ? $_GET['action'] : "";
switch ($action) {
case 'archive':
archive();
break;
case 'view':
view();
break;
default:
home();
}
?>
<h2>Articles</h2>
<article>
<h3></h3>
</article>
</section>
<?php include("$root/footer.php");?>
</body>
<script src="/scripts/script.js"></script>
</html>