mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-07-02 01:49:17 +00:00
too manu changes (will list by files)
.gitignore ignores some launch files changelog.md, readme.md added end file line public.php moved started the work on it router.php added require to functions & moved the function in the file set an ini value to show errors defied some constants moved the public page management to public/public.php exampleModule -> headGenerator.php started working on module management *.json reworked files function.php added this file to manages cores functions website.php the Website Object for theme & modules page.php created a test theme
This commit is contained in:
55
admin/system/functions.php
Normal file
55
admin/system/functions.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
function loadJSON($file) {
|
||||
return json_decode(file_get_contents($file), true);
|
||||
}
|
||||
|
||||
function getWebPage($useCache) {
|
||||
$fileCache = ROOT . "/cache" . URL . ".html";
|
||||
|
||||
if($useCache && file_exists($fileCache)) {
|
||||
return file_get_contents($fileCache);
|
||||
}
|
||||
|
||||
// var_dump(URL);
|
||||
$fileURI = ROOT . "/pages" . URL . ".json";
|
||||
$json = loadJSON($fileURI);
|
||||
$template = $json["template"];
|
||||
|
||||
$json["template"] = null;
|
||||
|
||||
define("PAGE", $json);
|
||||
|
||||
$templates = loadJSON(ROOT . "/admin/settings/templates.json");
|
||||
|
||||
require_once ROOT . "/admin/themes/" . SETTINGS["theme"] . "/" . $templates[$template]["URI"];
|
||||
|
||||
$function = $templates[$template]["function"];
|
||||
|
||||
if(function_exists($function)) {
|
||||
$content = $function();
|
||||
|
||||
if($useCache && $templates[$template]["static"]) file_put_contents($fileCache, $content);
|
||||
|
||||
return $content;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function endsWith($haystack, $needle) {
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
/*
|
||||
function generateWebPage()
|
||||
load pages/page.json
|
||||
load variables for theme
|
||||
generate the basic web page
|
||||
*/
|
||||
|
||||
?>
|
40
admin/system/website.php
Normal file
40
admin/system/website.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class Website {
|
||||
|
||||
private $root;
|
||||
|
||||
private const TEMPLATEJSON = "templates.json";
|
||||
|
||||
|
||||
public function __construct(String $root) {
|
||||
$this->root = $root;
|
||||
}
|
||||
|
||||
private function getTemplateFileURI() {
|
||||
return $this->root . "/admin/settings/" . self::TEMPLATEJSON;
|
||||
}
|
||||
|
||||
public function addTemplate(String $name, String $path, String $func, $bool) {
|
||||
var_dump($_SERVER);
|
||||
|
||||
$val = array(
|
||||
$name => array(
|
||||
"URI" => $path,
|
||||
"function" => $func,
|
||||
"static" => $bool
|
||||
)
|
||||
);
|
||||
if(! file_exists($this->getTemplateFileURI())) {
|
||||
file_put_contents($this->getTemplateFileURI(), json_encode($val));
|
||||
} else {
|
||||
$json = json_decode(file_get_contents($this->getTemplateFileURI()), true);
|
||||
$json = array_merge($json, $val);
|
||||
file_put_contents($this->getTemplateFileURI(), json_encode($json));
|
||||
}
|
||||
}
|
||||
|
||||
public function addJS() {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user