-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
69 lines (58 loc) · 1.32 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Displays site name.
*/
function siteName()
{
echo config('name');
}
/**
* Displays site version.
*/
function siteVersion()
{
echo config('version');
}
/**
* Website navigation.
*/
function navMenu($sep = ' | ')
{
$nav_menu = '';
foreach (config('nav_menu') as $uri => $name) {
$nav_menu .= '<a href="/'.(config('pretty_uri') || $uri == '' ? '' : '?page=').$uri.'">'.$name.'</a>'.$sep;
}
echo trim($nav_menu, $sep);
}
/**
* Displays page title. It takes the data from
* URL, it replaces the hyphens with spaces and
* it capitalizes the words.
*/
function pageTitle()
{
$page = isset($_GET['page']) ? htmlspecialchars($_GET['page']) : 'Home';
echo ucwords(str_replace('-', ' ', $page));
}
/**
* Displays page content. It takes the data from
* the static pages inside the pages/ directory.
* When not found, display the 404 error page.
*/
function pageContent()
{
$page = isset($_GET['page']) ? $_GET['page'] : 'home';
$path = getcwd().'/'.config('content_path').'/'.$page.'.php';
if (file_exists(filter_var($path, FILTER_SANITIZE_URL))) {
include $path;
} else {
include config('content_path').'/404.php';
}
}
/**
* Starts everything and displays the template.
*/
function run()
{
include config('template_path').'/template.php';
}