Tooo many changes to list

This commit is contained in:
2019-04-29 16:55:06 -03:00
parent f71d63b578
commit e696e99c4c
20 changed files with 284 additions and 172 deletions
+2
View File
@@ -1,3 +1,5 @@
.idea
config/database.db
config/modules.ini
+3 -3
View File
@@ -31,9 +31,9 @@ class GeneratorController {
};
/* $menu = (new CliMenuBuilder)
->setTitle(Lang::get_string('main_title', 'generator'))
->addItem(Lang::get_string('name_definition', 'generator'), $module_name)
->addItem(Lang::get_string('show_info', 'generator'), $show_info)
->setTitle(Lang::getString('main_title', 'generator'))
->addItem(Lang::getString('name_definition', 'generator'), $module_name)
->addItem(Lang::getString('show_info', 'generator'), $show_info)
->setItemExtra('[COMPLETE!]')
->addLineBreak('-')
->setBorder(1, 2, 'yellow')
+5 -5
View File
@@ -1,23 +1,23 @@
<?php
use BBRouter\RouteCollection as RouteCollection;
use Routes\RouteCollection as RouteCollection;
RouteCollection::add('CLI', '/core/purge', function(){
RouteCollection::cli('/core/purge', function(){
echo "Purging Everything\n";
});
RouteCollection::add('CLI', '/core/purge/[h:module]', function($module){
RouteCollection::cli('/core/purge/[h:module]', function($module){
echo "Purgin $module\n";
});
RouteCollection::add('CLI', '/core/routes', function(){
RouteCollection::cli('/core/routes', function(){
foreach(RouteCollection::return_routes() as $route){
echo str_pad( implode(',', $route->_verb), 10) . "| $route->_uri \n";
}
});
RouteCollection::add('CLI', '/core/generator', function(){
RouteCollection::cli('/core/generator', function(){
include_once 'GeneratorController.php';
last_class()->menu();
+2 -2
View File
@@ -1,5 +1,5 @@
<?php
$string['generator']['module_name'] = 'generator';
$lang['generator']['module_name'] = 'generator';
$string['generator']['main_title'] = 'Module Generator';
$lang['generator']['main_title'] = 'Module Generator';
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
$string['generator']['module_name'] = 'wellcome';
$lang['generator']['module_name'] = 'wellcome';
$string['generator']['main_title'] = 'Gerador de modulos!';
$lang['generator']['main_title'] = 'Gerador de modulos!';
+5 -2
View File
@@ -1,9 +1,9 @@
<?php
use BBRouter\RouteCollection as RouteCollection;
use Routes\RouteCollection as RouteCollection;
use DDLWrapper\Wrapper as Wrapper;
RouteCollection::add('CLI', 'sanity/install', function() {
RouteCollection::cli('sanity/install', function() {
include_once 'classes/Migrator.class.php';
global $DB;
@@ -17,8 +17,11 @@ RouteCollection::add('CLI', 'sanity/install', function() {
RouteCollection::add('*', '*', function() {
global $ROUTE;
if(INSTALL_REQUIRE){
//App need to be installed
if (!is_file(DIR_CONFIG . 'modules.ini')) {
$ROUTE->do_block()->set_http_error(500);
}
}
}, -19)->do_ignore()->middleware_ignore('auth');
+25 -103
View File
@@ -3,16 +3,17 @@
class Output {
private static $_instance;
private $_doctype = "<!DOCTYPE html>";
private $_head_items = Array();
private $_body = "";
private $_content = "";
private $_foot_items = Array();
private $view = false;
protected $values = Array();
private $_template = '';
private $_extension = '';
//SINGLETON==============================================
private function __construct() {
$this->_template = ( defined('TEMPLATE_DEFAULT') ) ? TEMPLATE_DEFAULT : 'DefaultTemplate';
$this->_extension = ( defined('TEMPLATE_FILETYPE') ) ? TEMPLATE_FILETYPE : '.mustache';
}
private static function newObj() {
@@ -29,127 +30,48 @@ class Output {
return self::$_instance;
}
public static function load_view($name, $values = null, $location = null) {
public function setTemplate($template = 'DefaultTemplate') {
$this->_template = $template;
return $this;
}
public static function renderView($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');
self::$_instance->setView($name, $values, $location)->render();
}
$location .= $name;
public function setView($name, $values = Array(), $location = null) {
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) {
$folder = '';
if (!$location) {
$segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']);
array_pop($segments);
$location = implode('/', $segments) . '/views/';
}
$folder = $location;
$location .= $name;
if (strpos('.php', $location) == 0) {
$location .= '.php';
if (strpos($this->_extension, $location) == 0) {
$location .= $this->_extension;
}
$this->view = Array();
$this->view['location'] = $location;
$this->view['folder'] = $folder;
$this->view['values'] = $values;
return $this;
}
public function render() {
if (is_ajax_request()) {
echo $this->_content;
if ($this->view) {
$this->render_view();
if(!is_file(__DIR__."/classes/".strtolower($this->_template)."/".$this->_template.'.php') ){
$this->_template = 'DefaultTemplate';
}
return;
include_once __DIR__."/classes/".strtolower($this->_template)."/".$this->_template.'.php';
last_class()->setView($this->view)->render();
}
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;
}
}
+3 -3
View File
@@ -1,9 +1,9 @@
<?php
use BBRouter\RouteCollection as RouteCollection;
use MenuBuilder\Menu as Menu;
use Routes\RouteCollection as RouteCollection;
use Menus\Menu as Menu;
RouteCollection::add('GET', '*', function(){
RouteCollection::get('*', function(){
include_once 'Output.class.php';
@@ -0,0 +1,71 @@
<?php
use Template\RenderableTemplate as RenderableTemplate;
class Dashboard extends RenderableTemplate {
public $content;
public function render() {
if (is_ajax_request()) {
$this->content = file_get_contents($this->getView()['location']);
$this->implate();
return;
}
global $DROPDOWN, $SIDEBAR;
$head = '';
$head .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
$head .= '<script src="/plugins/jquery/jquery.min.js"></script>';
$head .= '<script src="/plugins/mousetrap/mousetrap.min.js"></script>';
$head .= '<script src="/plugins/jquery-mask-plugin/jquery.mask.min.js"></script>';
$head .= '<link href="/plugins/bootstrap/bootstrap.min.css" rel="stylesheet" />';
$head .= '<script src="/plugins/bootstrap/bootstrap.min.js"></script>';
$head .= '<link href="/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />';
$head .= '<link href="/plugins/normalize-css/normalize.css" rel="stylesheet">';
$head .= '<link href="/dist/style.css" rel="stylesheet">';
$head .= '<link href="/dist/theme/black_and_white.css" rel="stylesheet">';
$head .= '<link href="/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">';
$head .= '<script src="/plugins/metisMenu/metisMenu.min.js"></script>';
$head .= '<link href="/plugins/select2/select2.min.css" rel="stylesheet">';
$head .= '<script src="/plugins/select2/select2.min.js"></script>';
$head .= '<link rel="stylesheet" href="/plugins/datatables/dataTables.css">';
$head .= '<script src="/plugins/datatables/dataTables.js"></script>';
$head .= '<link rel="stylesheet" href="/plugins/trumbowyg/ui/trumbowyg.min.css">';
$head .= '<script src="/plugins/trumbowyg/trumbowyg.min.js"></script>';
$foot = '';
$foot .= '<script src="/dist/script.js"></script>';
$foot .= '<script src="/dist/exercicio_form.js"></script>';
$this->content = file_get_contents(__DIR__ . '/template.html');
$this->content = str_replace("{{usermenu}}", "", $this->content);
$this->content = str_replace("{{elements}}", $SIDEBAR->render(), $this->content);
$this->content = str_replace("{{head}}", $head, $this->content);
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->content = str_replace("{{footer}}", $foot, $this->content);
$this->implate();
}
}
@@ -0,0 +1,71 @@
<html>
<head>
{{head}}
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<!-- Sidebar -->
<nav id="sidebar-wrapper">
<div class="logo" style="">
<img src='/media/logo_white.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 -->
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="main-page-wrapper">
<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>
<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">
{{>content}}
</div>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<div id="modal" class="modal fade" role="dialog"> </div>
{{footer}}
</body>
</html>
@@ -0,0 +1,20 @@
<?php
use Template\RenderableTemplate as RenderableTemplate;
class DefaultTemplate extends RenderableTemplate {
public function __construct() {
}
public function render() {
if (is_file($this->getView()['location'])) {
$this->content = file_get_contents($this->getView()['location']);
$this->implate();
}
}
}
+11 -8
View File
@@ -1,13 +1,16 @@
<?php
use BBRouter\RouteCollection as RouteCollection;
use RequestResponse\Response as Response;
use Routes\RouteCollection as RouteCollection;
include_once 'WellcomeController.php';
RouteCollection::add('GET','/', function(){
RouteCollection::add("GET", '/', function() {
global $OUTPUT;
$OUTPUT->load_view('wellcome');
})->middleware_ignore('auth');
$OUTPUT->setTemplate();
$OUTPUT->renderView('wellcome', Array('string' => Array('welcome' => 'Bem vindo')));
RouteCollection::add("GET", '/wellcome', function() {
Response::json('This is an other wellcome message')->send();
})->middleware_ignore('auth');
//$OUTPUT->renderView('wellcome', Array('string' => Lang::getStrings('welcome')));
});
RouteCollection::add('get', '/welcome', 'WellcomeController@welcome');
+11
View File
@@ -0,0 +1,11 @@
<?php
use RR\Response as R;
class WellcomeController{
function welcome(){
R::json(Array('message' => Lang::getString('welcome', 'welcome')))->send()->done();
}
}
@@ -1,2 +1,7 @@
<?php
$lang['welcome']['module_name'] = 'welcome';
$lang['welcome']['welcome'] = 'Welcome!';
+7
View File
@@ -0,0 +1,7 @@
<?php
$lang['welcome']['module_name'] = 'welcome';
$lang['welcome']['welcome'] = 'Bienvenue!';
@@ -1,7 +1,7 @@
<?php
$string['wellcome']['module_name'] = 'wellcome';
$lang['welcome']['module_name'] = 'welcome';
$string['wellcome']['wellcome'] = 'Bem-vindo!';
$lang['welcome']['welcome'] = 'Bem-vindo!';
@@ -1,7 +1,6 @@
<div style="text-align: center">
<img src="media/logo_black.png" />
</div>
Wellcome to hell...
{{string.welcome}} to hell...
<br />
I shal be your guide
+5 -3
View File
@@ -4,11 +4,13 @@ include_once 'vendor/autoload.php';
include_once 'config/info.php';
include_once 'publiclib.php';
include_once 'config/database.php';
if(is_file('config/database.php')){
include_once 'config/database.php';
}
use BBRouter\RouteCollection as RouteCollection;
use Routes\RouteCollection as RouteCollection;
Lang::build_strings();
Lang::buildStrings();
RouteCollection::getInstance()->crawl(__DIR__.'/application')->load_routes();
RouteCollection::getInstance()->submit();
+9
View File
@@ -6,3 +6,12 @@ define('DIR_CONFIG', __DIR__.'/');
define('DIR_ROOT', __DIR__.'/../');
define('DIR_APPLICATION', DIR_ROOT . 'application/');
define('DIR_MODULE', DIR_APPLICATION . 'module/');
define('TEMPLATE_DEFAULT', 'Dashboard');
//define('TEMPLATE_DEFAULT', 'DefaultTemplate');
define('TEMPLATE_FILETYPE', '.mustache');
define('INSTALL_REQUIRE', FALSE);
define('CACHE_LANG', FALSE);
+14 -27
View File
@@ -177,7 +177,18 @@ $_LANG = Array();
class Lang {
public static function get_string($string = '', $module = null, $lang = null) {
public static function getStrings($module = '', $lang = null){
global $_LANG;
if($lang == null){
$lang = APP_LANG;
}
if (isset($_LANG[$lang][$module])) {
return $_LANG[$lang][$module];
}
return $module;
}
public static function getString($string = '', $module = null, $lang = null) {
global $_LANG;
if($lang == null){
$lang = APP_LANG;
@@ -191,10 +202,10 @@ class Lang {
return $string;
}
public static function build_strings() {
public static function buildStrings() {
global $_LANG;
if (isset($_SESSION['cache']['strings'])) {
if (isset($_SESSION['cache']['strings']) && CACHE_LANG) {
$_LANG = $_SESSION['cache']['strings'];
return;
}
@@ -218,27 +229,3 @@ class Lang {
abstract class Controller {
}
/*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 );
}*/