Bladeren bron

More changes

ahwelp 6 jaren geleden
bovenliggende
commit
64e2b0c6e7

+ 4 - 0
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';

+ 7 - 4
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();
     }
 
 }

+ 10 - 0
application/module/core/template/classes/defaulttemplate/template.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+    <head>
+
+    </head>
+
+    <body>
+        {{>content}}
+    </body>
+</html>

+ 20 - 0
application/module/core/template/classes/nulltemplate/NullTemplate.php

@@ -0,0 +1,20 @@
+<?php
+
+use Template\RenderableTemplate as RenderableTemplate;
+
+class NullTemplate extends RenderableTemplate {
+
+    public function __construct() {
+
+    }
+
+    public function render() {
+
+        if (is_file($this->getView()['location'])) {
+            $this->content = file_get_contents($this->getView()['location']);
+            $this->implate();
+        }
+
+    }
+
+}

+ 0 - 24
application/module/core/template/views/body.html

@@ -1,24 +0,0 @@
-<body>
-    <div id="wrapper">
-        <!-- Sidebar -->
-        {{sidebar}}
-        <!-- /#sidebar-wrapper -->
-
-        <!-- Page Content -->
-        <div id="main-page-wrapper">
-
-            {{header}}
-
-            <div id="progress" class="progress hidden" >
-                <div class="progress-bar progress-bar-striped progress-bar-animated active" style="width: 100%;"></div>
-            </div>
-            <!-- BreadCrumbs -->
-
-            <!-- /BreadCrumbs -->
-
-            <div id="page-content-wrapper">
-                <div class="container-fluid" style="height: 1024px;">
-
-                    <div class="row">
-                        <div id="content" class="col-lg-12">
-                            

+ 0 - 10
application/module/core/template/views/body_section.html

@@ -1,10 +0,0 @@
-                        </div>
-                    </div>
-                </div>
-
-            </div>
-        </div>
-        <!-- /#page-content-wrapper -->
-    </div>
-    {{footer}}
-</body>

+ 0 - 17
application/module/core/template/views/header.html

@@ -1,17 +0,0 @@
-<header style='min-height: 50px; background-color: #000;'>
-    <ul class="nav navbar-nav navbar-left">
-        <li class="tooltip-sidebar-toggle">
-            <a href="" id="menu-toggle">
-                <i class="fa fa-th-list" aria-hidden="true"></i>
-            </a>
-        </li>
-    </ul>
-    <!-- <ul id='menu-usuario' class="nav navbar-nav navbar-right nav-dropdown">
-        <li class="dropdown">
-            <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" data-method="reload">
-                <i class="fa fa-user" aria-hidden="true"></i> <span class="caret"></span>
-            </a>
-            {{usermenu}}
-        </li>
-    </ul> -->
-</header>

+ 0 - 15
application/module/core/template/views/sidebar.html

@@ -1,15 +0,0 @@
-<!-- Sidebar -->
-<nav id="sidebar-wrapper">
-    <div class="logo" style="">
-        <img src='/media/logo.png' alt="logo" />
-    </div>
-    <!-- <div class="search-nav" style="">
-        <input class="form-control" type="text" placeholder="Busca"/>
-    </div> -->
-
-    <hr />
-    {{elements}}
-    <ul id="side-second-menu" class="hidden nav">
-    </ul>
-</nav>
-<!-- /#sidebar-wrapper -->

+ 5 - 3
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');

+ 1 - 1
application/module/core/wellcome/views/wellcome.mustache

@@ -3,4 +3,4 @@
 </div>
 {{string.welcome}} to hell...
 <br />
-I shal be your guide
+I shal be your guide {{palavrinha}}