diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d781e64 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode/ +cache/ diff --git a/admin/modules/default/exampleModule.php b/admin/modules/default/exampleModule.php deleted file mode 100644 index 2a33568..0000000 --- a/admin/modules/default/exampleModule.php +++ /dev/null @@ -1,3 +0,0 @@ -function testModule($modulesVars, $elementVars) { - return new DO -} \ No newline at end of file diff --git a/admin/modules/default/headGenerator.php b/admin/modules/default/headGenerator.php new file mode 100644 index 0000000..cca252c --- /dev/null +++ b/admin/modules/default/headGenerator.php @@ -0,0 +1,5 @@ +Title"; +} diff --git a/admin/settings/admin.json b/admin/settings/admin.json index ce6b10a..d117f6e 100644 --- a/admin/settings/admin.json +++ b/admin/settings/admin.json @@ -1,4 +1,5 @@ { "theme": "default", + "cache": true, "modules": ["default"] -} \ No newline at end of file +} diff --git a/admin/settings/templates.json b/admin/settings/templates.json index e75d0bf..ba2ab81 100644 --- a/admin/settings/templates.json +++ b/admin/settings/templates.json @@ -1,6 +1 @@ -{ - "default": { - "URI": "pouet/pouet.php", - "static": true - } -} \ No newline at end of file +{"Page":{"URI":"templates\/page.php","function":"page","static":true}} diff --git a/admin/system/functions.php b/admin/system/functions.php new file mode 100644 index 0000000..ed85c5e --- /dev/null +++ b/admin/system/functions.php @@ -0,0 +1,55 @@ + diff --git a/admin/system/website.php b/admin/system/website.php new file mode 100644 index 0000000..a35c1ba --- /dev/null +++ b/admin/system/website.php @@ -0,0 +1,40 @@ +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() { + + } +} diff --git a/admin/themes/default/templates/page.php b/admin/themes/default/templates/page.php index 15c5adc..41d3e68 100644 --- a/admin/themes/default/templates/page.php +++ b/admin/themes/default/templates/page.php @@ -1,3 +1,13 @@ \ No newline at end of file +function page() { +// require_once "includes/header.php"; + +// echo PAGE["content"]; + +// require_once "includes/footer.php"; + + return "
Header
" . PAGE["content"] . ""; +} + +?> diff --git a/changelog.md b/changelog.md index f91dea3..5514766 100644 --- a/changelog.md +++ b/changelog.md @@ -7,8 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -### Changed +### Changed ### Deprecated ### Removed ### Fixed -### Security \ No newline at end of file +### Security diff --git a/pages/index.json b/pages/index.json index de23d3f..1dee938 100644 --- a/pages/index.json +++ b/pages/index.json @@ -1,9 +1,9 @@ { "title": "Home", - "template": "page", + "template": "Page", "access": "public", - "content": "

hello world

", + "content": "
Hello World
", "modules": { "?": "?" } -} \ No newline at end of file +} diff --git a/public.php b/public.php deleted file mode 100644 index f53ae0b..0000000 --- a/public.php +++ /dev/null @@ -1,21 +0,0 @@ - \ No newline at end of file diff --git a/public/public.php b/public/public.php new file mode 100644 index 0000000..9a3484a --- /dev/null +++ b/public/public.php @@ -0,0 +1,40 @@ +" . getWebPage($isCacheActive) . ""; + +//load .css & .js + +$doc = new DOMDocument(); +libxml_use_internal_errors(true); +$doc->loadHTML($webPage); +libxml_clear_errors(); + +//handle modules here + +echo $doc->saveHTML(); + +/* + +if cache is active + if active is active load cache (scripts.js styles.css) + load templates.json + if template has cache for webpage and cache exist + load the file + else + launch generateWebPage() + +load theme css & js + + +if modules are in the page + load the modules + + + +*/ +?> diff --git a/readme.md b/readme.md index bfea702..df373aa 100644 --- a/readme.md +++ b/readme.md @@ -267,4 +267,4 @@ if static is true then static webpage will be generated "static": false } } -``` \ No newline at end of file +``` diff --git a/router.php b/router.php index 7ac467e..d0131dd 100644 --- a/router.php +++ b/router.php @@ -1,20 +1,33 @@ title); + require_once "public/public.php"; } else echo "404"; /* @@ -30,39 +43,4 @@ verify if user is logged in */ - - - - - - - - - - - - - - - - - - - - - - - - - - -function endsWith($haystack, $needle) { - $length = strlen($needle); - if ($length == 0) { - return true; - } - - return (substr($haystack, -$length) === $needle); -} - -?> \ No newline at end of file +?> diff --git a/test.php b/test.php index bfa79ad..8c4f0d8 100644 --- a/test.php +++ b/test.php @@ -1,31 +1,37 @@

pouet

"; -$doc->loadHTML($test); +// $doc = new DOMDocument(); +// $test = "

pouet

"; +// $doc->loadHTML($test); -appendHTML($doc->getElementsByTagName("body")->item(0), ""); +// appendHTML($doc->getElementsByTagName("body")->item(0), ""); -echo $doc->saveHTML(); +// echo $doc->saveHTML(); +// echo gettype(true); -function appendHTML(DOMNode $parent, $source) { - $tmpDoc = new DOMDocument(); - $html = ""; - $html .= $source; - $html .= ""; - $tmpDoc->loadHTML(''.$html); +// include_once "admin/system/website.php"; +// $website = new Website(__DIR__); +// $website->addTemplate("Blog Page", "templates/blog.php", "page", true); - foreach ($tmpDoc->childNodes as $item) - if ($item->nodeType == XML_PI_NODE) - $tmpDoc->removeChild($item); - $tmpDoc->encoding = 'UTF-8'; - - foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) { - $importedNode = $parent->ownerDocument->importNode($node, true); - $parent->appendChild($importedNode); - } -} +// phpinfo(); -?> \ No newline at end of file +// function appendHTML(DOMNode $parent, $source) { +// $tmpDoc = new DOMDocument(); +// $html = ""; +// $html .= $source; +// $html .= ""; +// $tmpDoc->loadHTML(''.$html); + +// foreach ($tmpDoc->childNodes as $item) +// if ($item->nodeType == XML_PI_NODE) +// $tmpDoc->removeChild($item); +// $tmpDoc->encoding = 'UTF-8'; + +// foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) { +// $importedNode = $parent->ownerDocument->importNode($node, true); +// $parent->appendChild($importedNode); +// } +// } + +?>