generated from KanFF/onepageMD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (35 loc) · 1.23 KB
/
index.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
<?php
/**
* Project: onepageMD
* File: index.php entry point for all requests
* Author: Samuel Roland
* Creation date: 20.02.2021
*/
require "helpers.php";
require "constants.php";
checkConfigBeforeLoading();
$config = getConfig();
//TODO: choose the language depending on the cookies
$language = null;
if (isset($_COOKIE['lang']) == true && isLanguageAvailable($_COOKIE['lang'])) {
$language = $_COOKIE['lang'];
setcookie("lang", $_COOKIE['lang']);
} else {
$language = $config['content']['default_language'];
setcookie("lang", $language);
}
//Get MD content
$rawMDContent = getRawMDForAGivenLanguage($language);
if ($rawMDContent != false) {
$content = getRawMDForAGivenLanguage($language);
$maintitle = extractMainTitleInRawMDContent($config, $content);
$content = removeTheMainTitleInRawMDContent($content);
//Interpret markdown content only if $content contains for Markdown (to avoid global <p></p>)
if ($config['content']['no-markdown-in-content'] != true) {
$content = lauchOperationsOnContent($content); //raw MD will be transformed to HTML
}
require_once "gabarit.php"; //get the layout and include the content inside
} else {
$maintitle = "Erreur...";
require_once "error.php"; //the error page is displayed
}