Changes to the Framework

This commit is contained in:
2020-11-02 16:01:27 -03:00
parent 47091f1754
commit ac574f3e53
91 changed files with 401 additions and 29524 deletions
+25 -17
View File
@@ -15,7 +15,8 @@ class GeneratorController {
<?php
use Schema\Wrapper as Wrapper;
use \App\Core\Sanity\MigratorController as Migrator;
function {{PLUGIN_NAME}}_upgrade(\$pluginversion) {
if (\$pluginversion < "0.0.1") {
\$table = Wrapper::get_table("{{PLUGIN_NAME}}");
@@ -26,20 +27,20 @@ class GeneratorController {
\$table->addSoftDelete();
\$table->create();
Migrator::getInstance()->update_plugin_version("{{PLUGIN_NAME}}", "1.0.0");
Migrator::getInstance()->update_plugin_version("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}", "1.0.0");
return;
}
//if (\$pluginversion < "0.0.2") {
//\$table = Wrapper::get_table("{{PLUGIN_NAME}}");
//Migrator::getInstance()->update_plugin_version("{{PLUGIN_NAME}}", "1.0.1");
//Migrator::getInstance()->update_plugin_version("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}", "1.0.1");
//return;
//}
}
function {{PLUGIN_NAME}}_rollback(\$pluginversion) {
if(\$pluginversion > "0.0.1"){
\$table = Wrapper::get_table("{{PLUGIN_NAME}}");
\$table = Wrapper::get_table("{{SUB_PLUGIN_NAME}}_{{PLUGIN_NAME}}");
\$table->drop();
return;
}
@@ -62,8 +63,8 @@ class GeneratorController {
namespace {{NAMESPACE}};
use \{{NAMESPACE}}\Classes\{{OBJECT}} as {{OBJECT}};
use \App\Core\Template\Output as Output;
use \{{NAMESPACE}}\Classes\{{OBJECT}} as {{OBJECT}};
class {{CONTROLLER}} {
@@ -88,7 +89,8 @@ class GeneratorController {
/**
* Create
* Render the main {{OBJECT}} formular
*
* Render the main {{OBJECT}} formulary
*/
function create(){
Output::setView('form', ['id' => 0]);
@@ -97,7 +99,8 @@ class GeneratorController {
/**
* Store
* Store the param on the database
*
* Store the param on the database
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
function store({{OBJECT}} \${{OBJECT_LOWER}}){
@@ -106,7 +109,8 @@ class GeneratorController {
/**
* Show
* Render one register
*
* Render one register
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
@@ -116,17 +120,19 @@ class GeneratorController {
/**
* Edit
* Render the formular for a database {{OBJECT}}
*
* Render the formular for a database {{OBJECT}}
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
function edit({{OBJECT}} \${{OBJECT_LOWER}}){
Output::setView('form', \${{OBJECT_LOWER}});
Output::render();
}
/**
* Update
* Store the changes of the param on the database
* Store the changes of the param on the database
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
@@ -136,16 +142,17 @@ class GeneratorController {
/**
* Destroy
* If the object has soft delete.
* If the object has soft delete.
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
function destroy({{OBJECT}} \${{OBJECT_LOWER}}){
}
/**
* Purge
* Remove object even with soft delete.
* Remove object even with soft delete.
*
* @param {{OBJECT}} \${{OBJECT_LOWER}}
*/
@@ -230,11 +237,11 @@ class GeneratorController {
private $formTemplate =
<<<EOL
{{@ if( {{id}} ): @}}
<form method="POST" action="{{ENDPOINT}}/{{id}}/edit">
<form method="POST" action="/{{ENDPOINT}}/{{id}}/edit">
<input type="hidden" name="id" value="{{id}}" />
<input type="hidden" name="_method" value="put" />
{{@ else: @}}
<form method="POST" action="{{ENDPOINT}}">
<form method="POST" action="/{{ENDPOINT}}">
<input type="hidden" name="id" value="" />
{{@ endif; @}}
@@ -266,7 +273,7 @@ class GeneratorController {
mkdir(DIR_APP.$subname . "/" . $name . "/db", 0755, true);
mkdir(DIR_APP.$subname . "/" . $name . "/views", 0755, true);
}
$plugin_name = $name;
$namespace = "App\\".ucfirst($subname)."\\".ucfirst($name);
$plugin_name_pretty = ucwords(str_replace("_", " ", $name));
@@ -278,7 +285,8 @@ class GeneratorController {
file_put_contents(DIR_APP.$subname . "/" . $name . "/lang/en.php", $this->langBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/lang/".APP_LANG.".php", $this->langBase);
$this->migrationBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->migrationBase);
$this->migrationBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->migrationBase);
$this->migrationBase = str_replace("{{SUB_PLUGIN_NAME}}", $subname, $this->migrationBase);
file_put_contents(DIR_APP.$subname . "/" . $name . "/db/Migrate.php", $this->migrationBase);
$this->routeBase = str_replace("{{NAMESPACE}}", $namespace, $this->routeBase);
+1 -1
View File
@@ -3,7 +3,7 @@
use Routes\RouteCollection as RouteCollection;
RouteCollection::cli('/', function(){
echo "/core/create/[h:subname]/[h:name]\n";
echo "/create/[h:subname]/[h:name]\n";
});
RouteCollection::cli('/routes', '\App\Core\Generator\GeneratorController@listRoutes');
+18 -5
View File
@@ -155,6 +155,16 @@ class MigratorController {
$status = true;
foreach ($this->install as $key => $item) {
/*
*
*
*
*/
$funname = explode('_', $item->name);
if(sizeof($funname) > 1){ unset($funname[0]); }
$funname = implode('_', $funname);
if (isset($item->require)) {
if (!self::is_satisfy_array($item->require)) {
$status = false;
@@ -162,19 +172,22 @@ class MigratorController {
}
}
if (!self::is_satisfy($item->name, $item->version)) {
if (!function_exists($item->name . '_upgrade')) {
if (!function_exists($funname . '_upgrade')) {
echo 'adsdsadasdsadassad';
$this->update_plugin_version($item->name, $item->version);
$this->upgrade[] = $item;
$this->instaled[$item->name] = $item;
unset($this->install[$key]);
continue;
}
call_user_func($item->name . '_upgrade', 0);
$this->instaled[$item->name] = $item;
call_user_func($funname . '_upgrade', '0');
$this->upgrade[] = $this->instaled[$item->name];
unset($this->install[$key]);
$status = false;
}
}
foreach ($this->upgrade as $item) {
if (isset($item->require)) {
if (!self::is_satisfy_array($item->require)) {
@@ -182,12 +195,12 @@ class MigratorController {
continue;
}
}
if (!self::is_satisfy($item->name, $item->version)) {
if (!self::is_satisfy($funname, $item->version)) {
if (!function_exists($item->name . '_upgrade')) {
$this->update_plugin_version($item->name, $item->version);
continue;
}
call_user_func($item->name . '_upgrade', $this->instaled[$item->name]->version);
call_user_func($funname . '_upgrade', $this->instaled[$item->name]->version);
$status = false;
}
}
+18
View File
@@ -103,6 +103,24 @@ class Output {
$SIDEBAR->add_on_new($key, $route, $name, $icon, $attributes, $weight);
}
//========
public static function headAdd($route, $name){
global $DROPDOWN;
$DROPDOWN[] = ['route' => $route, 'name' => $name];
}
public static function addSubHeader($key, $name, $icon = '', $attributes = [], $weight = 0){
global $DROPDOWN;
$DROPDOWN->create_submenu($key, $name, $icon, $attributes , $weight);
}
public static function addOnSubHeader($key, $route, $name, $icon = '', $attributes = [], $weight = 0){
global $DROPDOWN;
$DROPDOWN->add_on_new($key, $route, $name, $icon, $attributes, $weight);
}
public static function icon($icon){
return "<i class='$icon' aria-hidden='true'></i>";
}
+6 -2
View File
@@ -1,7 +1,8 @@
<?php
use Routes\RouteCollection as RouteCollection;
use Menus\Menu as Menu;
use Routes\RouteCollection as RouteCollection;
RouteCollection::get('*', function(){
@@ -10,6 +11,9 @@ RouteCollection::get('*', function(){
GLOBAL $SIDEBAR, $DROPDOWN;
$SIDEBAR = new Menu( array('id' => 'side-menu', 'class' => "nav") );
$DROPDOWN = new Menu( array("class" => 'dropdown-menu') );
//HACK
//$DROPDOWN = new Menu( array("class" => 'dropdown-menu') );
$DROPDOWN = [];
}, -11)->doIgnore();
@@ -1,4 +1,4 @@
<?php
<?php
use Template\RenderableTemplate as RenderableTemplate;
@@ -7,43 +7,48 @@ class Dashboard extends RenderableTemplate {
public $content;
public function render() {
global $DROPDOWN, $SIDEBAR;
if (is_ajax_request()) {
$this->content = file_get_contents($this->getView()['location']);
$this->implate();
if(is_file($this->getView()['location'])){
$this->content = file_get_contents($this->getView()['location']);
$this->implate();
}else{
$this->content = '';
$this->implate();
}
return;
}
global $DROPDOWN, $SIDEBAR;
//global $DROPDOWN, $SIDEBAR;
$head = '';
$head .= '<script src="/plugins/jquery/jquery.min.js"></script>';
$head .= '<script src="/plugins/jquery/dist/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 .= '<script src="/plugins/jquery-mask-plugin/dist/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/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />';
$head .= '<script src="/plugins/bootstrap/dist/js/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="/plugins/fontawesome/css/all.css" rel="stylesheet" />';
$head .= '<link href="/dist/style.css" rel="stylesheet">';
$head .= '<link href="/dist/themes/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/metismenu/dist/metisMenu.min.css" rel="stylesheet">';
$head .= '<script src="/plugins/metismenu/dist/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>';
//$head .= '<link rel="stylesheet" href="/plugins/datatables/dataTables.css">';
//$head .= '<script src="/plugins/datatables/dataTables.js"></script>';
//Bind input ranges to a span on label. Show percentage.
$head .= '<script src="/plugins/sliderTelepatic/dist/sliderTelepatic.min.js"></script>';
$head .= '<script src="/plugins/trumbowyg/dist/trumbowyg.min.js"></script>';
$head .= '<link rel="stylesheet" href="/plugins/trumbowyg/dist/ui/trumbowyg.min.css">';
$foot = '';
$foot .= '<script src="/dist/script.js"></script>';
@@ -52,6 +57,15 @@ class Dashboard extends RenderableTemplate {
$this->content = str_replace("{{usermenu}}", "", $this->content);
$this->content = str_replace("{{elements}}", $SIDEBAR->render(), $this->content);
$header = '';
//HACK
foreach ($DROPDOWN as $item){
$header .= "<a class='dropdown-item' href='".$item['route']."'>".$item['name']."</a>";
}
$this->content = str_replace("{{projects}}", $header, $this->content);
$this->content = str_replace("{{head}}", $head, $this->content);
@@ -6,52 +6,69 @@
</head>
<body>
<div id="wrapper">
<!-- 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>
{{elements}}
<nav id="main-sidebar" class="sidebar" >
<button class="form-control btn-danger menu-toggle menu-small main-menu-toggle">Fechar</button>
<div class="logo">
<img src='/media/logo_white.png' alt="logo" />
</div>
<ul id="side-second-menu" class="hidden nav">
</ul>
</nav>
<!-- /#sidebar-wrapper -->
<!-- /#sidebar-wrapper -->
<div class="search-nav">
<input class="form-control" type="text" placeholder="Busca" />
</div>
<!-- Page Content -->
{{elements}}
<ul id="side-second-menu" class="hidden nav"></ul>
</nav>
<nav id="secondary-sidebar" class="sidebar float-sidebar hidden" >
<button class="form-control btn-danger menu-close">Fechar</button>
<ul id="side-second-menu" class="hidden nav"></ul>
</nav>
<nav id='right-menu' class="sidebar float-sidebar hidden" style="right:0;">
<button class="form-control btn-danger menu-close">Fechar</button>
<ul id="side-second-menu" class="hidden nav"></ul>
</nav>
<div id="wrapper" class="menu-open">
<div id="main-page-wrapper">
<header class='navbar navbar-default navbar-fixed-top' style='min-height: 50px; background-color: #000;'>
<ul class="nav navbar-nav navbar-left">
<li class="tooltip-sidebar-toggle">
<a href="" id="menu-toggle">
<a class="main-menu-toggle">
<i class="fa fa-th-list" aria-hidden="true"></i>
</a>
</li>
</ul>
<ul class="nav navbar-top-links navbar-right">
<!--{{usermenu}}-->
<li class="nav-item dropdown no-arrow">
<a class="nav-link" role="button">
<i class="fa fa-comment"></i>
</a>
</li>
<li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-user fa-fw"></i>
</a>
<div class="dropdown-menu dropdown-menu-right" >
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#"><i class=""></i>Settings</a>
<a class="dropdown-item" href="#"><i class=""></i>Activity Log</a>
<a class="dropdown-item" href="/projects/form">New project</a>
<div class="dropdown-divider"></div>
{{projects}}
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" ><i class=""></i>Logout</a>
</div>
</li>
</ul>
</header>
+68
View File
@@ -0,0 +1,68 @@
<?php
use Template\RenderableTemplate as RenderableTemplate;
class Ide extends RenderableTemplate {
public $content;
public function render() {
if (is_ajax_request()) {
$this->content = file_get_contents($this->getView()['location']);
$this->implate();
return;
}
$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/fileTree.js"></script>';
$this->content = file_get_contents(__DIR__ . '/template.html');
$this->content = str_replace("{{usermenu}}", "", $this->content);
$this->content = str_replace("{{elements}}", '', $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();
}
}
+126
View File
@@ -0,0 +1,126 @@
<html>
<head>
{{head}}
<style>
.filemanager{
padding-left: 5px;
overflow: auto;
}
.filemanager ul{
display: none;
padding: 0px 0px 0px 20px;
border-left: 2px white dashed;
}
.filemanager li{
white-space: nowrap;
list-style: none;
}
.filemanager .open{
display: block !important;
}
.filemanager span{
color: white;
font-size: 1.2em;
}
.filemanager i{
margin-right: 1em;
color: orange;
}
</style>
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/lib/codemirror.js'></script>
<link rel=stylesheet href="http://misc.inforsistemas-devel1.com.br/codemirror/lib/codemirror.css" />
<link rel=stylesheet href="http://misc.inforsistemas-devel1.com.br/addon/hint/show-hint.css" />
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/addon/hint/show-hint.js'></script>
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/mode/clike/clike.js'></script>
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/mode/xml/xml.js'></script>
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/mode/javascript/javascript.js'></script>
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/mode/css/css.js'></script>
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/mode/htmlmixed/htmlmixed.js'></script>
<script src='http://misc.inforsistemas-devel1.com.br/codemirror/mode/php/php.js'></script>
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<!-- Sidebar -->
<nav id="sidebar-wrapper">
<div class="logo" style="">
<img src='/media/logo_white.png' alt="logo" />
</div>
<ul class="filemanager" data-deffer="true" data-endpoint="projects/files">
<li>
<a data-kind="folder-root">urfat</a>
<ul>
</ul>
</li>
</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="">
<div id="file-pannel">
<ul class="nav nav-tabs" role="tablist">
<li id="file-list" role="presentation" class="active">
<a href="#draft" aria-controls="home" role="tab" data-toggle="tab">
Home
</a>
</li>
</ul>
<div id="file-tabs" class="tab-content">
<div role="tabpanel" class="tab-pane active" id="draft">
<textarea id="text" style="width:100%; height: 100%;"></textarea>
</div>
</div>
</div>
<!---->
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<div id="modal" class="modal fade" role="dialog"> </div>
{{footer}}
</body>
</html>
+4 -12
View File
@@ -1,16 +1,8 @@
<?php
use RR\Response;
use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;
use App\Core\Template\Output as Output;
RouteCollection::add('GET','/', function(){
Output::setTemplate('');
Output::setView('welcome');
Output::addValue('string', Array('welcome' => 'Bem vindo'));
Output::addValue('palavrinha', 'Oi');
Output::render();
});
RouteCollection::get('/welcome', '\App\Core\Welcome\WelcomeController@welcome');
RouteCollection::add('get', '/', '\App\Core\Welcome\WelcomeController@welcome');
//RouteCollection::add('get', '/welcome', 'WellcomeController@welcome');
+4 -4
View File
@@ -2,12 +2,12 @@
namespace App\Core\Welcome;
use RR\Response as R;
use App\Core\Template\Output;
class WelcomeController{
class WelcomeController {
function welcome(){
R::json(Array('message' => \Lang::getString('welcome', 'welcome')))->send()->done();
function welcome() {
Output::render();
}
}
-11
View File
@@ -1,11 +0,0 @@
<?php
use RR\Response as R;
class WellcomeController{
function welcome(){
R::json(Array('message' => Lang::getString('welcome', 'welcome')))->send()->done();
}
}