Version 1.0

This commit is contained in:
Artur Welp
2019-03-11 19:44:28 -03:00
parent d61f18b04d
commit 06b6875ca9
110 changed files with 31928 additions and 0 deletions
+155
View File
@@ -0,0 +1,155 @@
<?php
class Output {
private static $_instance;
private $_doctype = "<!DOCTYPE html>";
private $_head_items = Array();
private $_body = "";
private $_content = "";
private $_foot_items = Array();
private $view = false;
//SINGLETON==============================================
private function __construct() {
}
private static function newObj() {
if (!isset(self::$_instance)) {
self::$_instance = new Output();
}
return self::$_instance;
}
public function getInstance() {
if (!isset(self::$_instance)) {
return self::newObj();
}
return self::$_instance;
}
public static function load_view($name, $values = null, $location = null) {
if (!$location) {
$segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']);
array_pop($segments);
$location = implode('/', $segments) . '/views/';
}
if (is_array($values) && count($values) > 0) {
extract($values, EXTR_PREFIX_SAME, 'data');
}
$location .= $name;
if (strpos('.php', $location) == 0) {
$location .= '.php';
}
if (!file_exists($location)) {
//return require_once GENERAL_VIEW_FOLDER . 'errors/404.php';
}
return require_once( $location );
}
private function render_view() {
if (is_array($this->view['values']) && count($this->view['values']) > 0) {
extract($this->view['values'], EXTR_PREFIX_SAME, 'data');
}
return require_once( $this->view['location'] );
}
public function set_view($name, $values = null, $location = null) {
if (!$location) {
$segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']);
array_pop($segments);
$location = implode('/', $segments) . '/views/';
}
$location .= $name;
if (strpos('.php', $location) == 0) {
$location .= '.php';
}
$this->view = Array();
$this->view['location'] = $location;
$this->view['values'] = $values;
}
public function render() {
if (is_ajax_request()) {
echo $this->_content;
if ($this->view) {
$this->render_view();
}
return;
}
global $DROPDOWN, $SIDEBAR;
$this->_head_items[] = '<script src="/plugins/jquery/jquery.min.js"></script>';
$this->_head_items[] = '<script src="/plugins/mousetrap/mousetrap.min.js"></script>';
$this->_head_items[] = '<script src="/plugins/jquery-mask-plugin/jquery.mask.min.js"></script>';
$this->_head_items[] = '<link href="/plugins/bootstrap/bootstrap.min.css" rel="stylesheet" />';
$this->_head_items[] = '<script src="/plugins/bootstrap/bootstrap.min.js"></script>';
$this->_head_items[] = '<link href="/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />';
$this->_head_items[] = '<link href="/plugins/normalize-css/normalize.css" rel="stylesheet">';
$this->_head_items[] = '<link href="/dist/style.css" rel="stylesheet">';
$this->_head_items[] = '<link href="/dist/theme/black_and_white.css" rel="stylesheet">';
$this->_head_items[] = '<link href="/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">';
$this->_head_items[] = '<script src="/plugins/metisMenu/metisMenu.min.js"></script>';
$this->_head_items[] = '<link href="/plugins/select2/select2.min.css" rel="stylesheet">';
$this->_head_items[] = '<script src="/plugins/select2/select2.min.js"></script>';
$this->_head_items[] = '<link rel="stylesheet" href="/plugins/datatables/dataTables.css">';
$this->_head_items[] = '<script src="/plugins/datatables/dataTables.js"></script>';
$this->_foot_items[] = '<script src="/dist/script.js"></script>';
$head = "<head>";
foreach ($this->_head_items as $head_item) {
$head .= $head_item . "\n";
}
$head .= "</head>";
$foot = "";
foreach ($this->_foot_items as $foot_item) {
$foot .= $foot_item;
}
$header = str_replace("{{usermenu}}", "", file_get_contents(__DIR__ . '/views/header.html'));
$sidebar = str_replace("{{elements}}", $SIDEBAR->render(), file_get_contents(__DIR__ . '/views/sidebar.html'));
$body_first = file_get_contents(__DIR__ . "/views/body.html");
$body_first = str_replace("{{header}}", $header, $body_first);
$body_first = str_replace("{{sidebar}}", $sidebar, $body_first);
$body_first .= $this->_content;
$foot .= '<div id="modal" class="modal fade" role="dialog"> </div>';
$body_end = file_get_contents(__DIR__ . "/views/body_section.html");
$body_end = str_replace("{{footer}}", $foot, $body_end);
echo $this->_doctype . "\n";
echo "<html> \n";
echo $head;
echo $body_first;
if ($this->view) {
$this->render_view();
}
echo $body_end;
echo "</html>";
}
public function set_content($content) {
$this->_content = $content;
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
use BBRouter\RouteCollection as RouteCollection;
use MenuBuilder\Menu as Menu;
RouteCollection::add('GET', '*', function(){
include_once 'Output.class.php';
GLOBAL $SIDEBAR, $DROPDOWN, $OUTPUT;
$SIDEBAR = new Menu( array('id' => 'side-menu', 'class' => "nav") );
$DROPDOWN = new Menu( array("class" => 'dropdown-menu') );
$OUTPUT = Output::getInstance();
}, -11)->do_ignore();
+24
View File
@@ -0,0 +1,24 @@
<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">
+10
View File
@@ -0,0 +1,10 @@
</div>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
{{footer}}
</body>
+17
View File
@@ -0,0 +1,17 @@
<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>
+15
View File
@@ -0,0 +1,15 @@
<!-- 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 -->