From 64e2b0c6e7db7d8399864e40a0a5e0e3991ee33a Mon Sep 17 00:00:00 2001 From: ahwelp Date: Mon, 29 Apr 2019 17:28:24 -0300 Subject: [PATCH] More changes --- .../module/core/template/Output.class.php | 4 ++++ .../defaulttemplate/DefaultTemplate.php | 11 +++++---- .../classes/defaulttemplate/template.html | 10 ++++++++ .../classes/nulltemplate/NullTemplate.php | 20 ++++++++++++++++ .../module/core/template/views/body.html | 24 ------------------- .../core/template/views/body_section.html | 10 -------- .../module/core/template/views/header.html | 17 ------------- .../module/core/template/views/sidebar.html | 15 ------------ application/module/core/wellcome/Routes.php | 8 ++++--- .../core/wellcome/views/wellcome.mustache | 2 +- 10 files changed, 47 insertions(+), 74 deletions(-) create mode 100755 application/module/core/template/classes/defaulttemplate/template.html create mode 100755 application/module/core/template/classes/nulltemplate/NullTemplate.php delete mode 100755 application/module/core/template/views/body.html delete mode 100755 application/module/core/template/views/body_section.html delete mode 100755 application/module/core/template/views/header.html delete mode 100755 application/module/core/template/views/sidebar.html diff --git a/application/module/core/template/Output.class.php b/application/module/core/template/Output.class.php index dbea721..e42a2c3 100755 --- a/application/module/core/template/Output.class.php +++ b/application/module/core/template/Output.class.php @@ -67,6 +67,10 @@ class Output { return $this; } + public function addValue($key, $value){ + $this->view['values'][$key] = $value; + } + public function render() { if(!is_file(__DIR__."/classes/".strtolower($this->_template)."/".$this->_template.'.php') ){ $this->_template = 'DefaultTemplate'; diff --git a/application/module/core/template/classes/defaulttemplate/DefaultTemplate.php b/application/module/core/template/classes/defaulttemplate/DefaultTemplate.php index d578fba..74b21f1 100755 --- a/application/module/core/template/classes/defaulttemplate/DefaultTemplate.php +++ b/application/module/core/template/classes/defaulttemplate/DefaultTemplate.php @@ -10,11 +10,14 @@ class DefaultTemplate extends RenderableTemplate { public function render() { - if (is_file($this->getView()['location'])) { - $this->content = file_get_contents($this->getView()['location']); - $this->implate(); + $this->content = file_get_contents(__DIR__ . '/template.html'); + + if(is_file($this->getView()['location'])){ + $this->content = str_replace('{{>content}}', $this->replaceSections(file_get_contents($this->getView()['location']), $this->_view['values']), $this->content); + }else{ + $this->content = str_replace('{{>content}}', '', $this->content); } - + $this->implate(); } } diff --git a/application/module/core/template/classes/defaulttemplate/template.html b/application/module/core/template/classes/defaulttemplate/template.html new file mode 100755 index 0000000..95baca6 --- /dev/null +++ b/application/module/core/template/classes/defaulttemplate/template.html @@ -0,0 +1,10 @@ + + + + + + + + {{>content}} + + \ No newline at end of file diff --git a/application/module/core/template/classes/nulltemplate/NullTemplate.php b/application/module/core/template/classes/nulltemplate/NullTemplate.php new file mode 100755 index 0000000..8723fdf --- /dev/null +++ b/application/module/core/template/classes/nulltemplate/NullTemplate.php @@ -0,0 +1,20 @@ +getView()['location'])) { + $this->content = file_get_contents($this->getView()['location']); + $this->implate(); + } + + } + +} diff --git a/application/module/core/template/views/body.html b/application/module/core/template/views/body.html deleted file mode 100755 index 0a541c0..0000000 --- a/application/module/core/template/views/body.html +++ /dev/null @@ -1,24 +0,0 @@ - -
- - {{sidebar}} - - - -
- - {{header}} - - - - - - -
-
- -
-
- diff --git a/application/module/core/template/views/body_section.html b/application/module/core/template/views/body_section.html deleted file mode 100755 index e99026e..0000000 --- a/application/module/core/template/views/body_section.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
-
- -
-
- -
- {{footer}} - \ No newline at end of file diff --git a/application/module/core/template/views/header.html b/application/module/core/template/views/header.html deleted file mode 100755 index f87ac0b..0000000 --- a/application/module/core/template/views/header.html +++ /dev/null @@ -1,17 +0,0 @@ -
- - -
\ No newline at end of file diff --git a/application/module/core/template/views/sidebar.html b/application/module/core/template/views/sidebar.html deleted file mode 100755 index f4d292d..0000000 --- a/application/module/core/template/views/sidebar.html +++ /dev/null @@ -1,15 +0,0 @@ - - - \ No newline at end of file diff --git a/application/module/core/wellcome/Routes.php b/application/module/core/wellcome/Routes.php index 3152aa0..dc9f835 100755 --- a/application/module/core/wellcome/Routes.php +++ b/application/module/core/wellcome/Routes.php @@ -8,9 +8,11 @@ RouteCollection::add('GET','/', function(){ global $OUTPUT; $OUTPUT->setTemplate(); - $OUTPUT->renderView('wellcome', Array('string' => Array('welcome' => 'Bem vindo'))); - - //$OUTPUT->renderView('wellcome', Array('string' => Lang::getStrings('welcome'))); + //$OUTPUT->renderView('wellcome', Array('string' => Array('welcome' => 'Bem vindo'))); + $OUTPUT->setView('wellcome'); + $OUTPUT->addValue('string', Array('welcome' => 'Bem vindo')); + $OUTPUT->addValue('palavrinha', 'Oi'); + $OUTPUT->render(); }); RouteCollection::add('get', '/welcome', 'WellcomeController@welcome'); diff --git a/application/module/core/wellcome/views/wellcome.mustache b/application/module/core/wellcome/views/wellcome.mustache index b02dcf2..4b7b50c 100755 --- a/application/module/core/wellcome/views/wellcome.mustache +++ b/application/module/core/wellcome/views/wellcome.mustache @@ -3,4 +3,4 @@ {{string.welcome}} to hell...
-I shal be your guide \ No newline at end of file +I shal be your guide {{palavrinha}} \ No newline at end of file