-
Notifications
You must be signed in to change notification settings - Fork 3
/
creamy.php
69 lines (57 loc) · 1.67 KB
/
creamy.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
// Load necessary classes.
require_once("creamy/config.php");
require_once("creamy/backend.php");
require_once("creamy/file.php");
// Check if backend got called.
if(!Creamy::is_included()) {
// Redirect to backend
header("Location: " . Config::$creamy_dir);
}
/**
* This is the main class of creamy, a free and simple content
* management system in the style of perch.
*/
class Creamy {
/**
* Return the parsed markdown content to the calling page.
*/
public static function content($content_area, array $options = array()) {
// Check for additional parameters via GET
$url_params = self::get_parameters();
// Merge with options passed by frontend and defaults
$options = array_merge(Config::$default_options, $url_params, $options);
// Check if content region is alread initialized.
$indexer = new Indexer();
$indexer->init_content($content_area, $options);
// Show content on page.
$backend = new Backend();
$backend->show_content($content_area, $options);
}
/**
* Show a theme (static code snippet)
*/
public static function theme($theme_name, array $options = array()) {
$backend = new Backend();
$backend->display($theme_name, $options);
}
/**
* Extract GET parameters from the current url.
*/
private static function get_parameters() {
if(!empty($_GET)) {
return $_GET;
} else {
return array();
}
}
/**
* Check if this script was included by another script.
*/
public static function is_included() {
$current_script = File::path($_SERVER['SCRIPT_FILENAME']);
$this_file = File::path(__FILE__);
return ( $current_script != $this_file );
}
}
?>