diff --git a/app/core/sanity/MigratorController.php b/app/core/sanity/MigratorController.php old mode 100755 new mode 100644 index d5b20a2..31c8dd6 --- a/app/core/sanity/MigratorController.php +++ b/app/core/sanity/MigratorController.php @@ -62,12 +62,13 @@ class MigratorController { return false; } - private function is_satisfy_array($array) { - foreach ($array as $item) { - if (!self::is_satisfy($item->name, $item->version)) { + private function is_satisfy_array($array) { + foreach ($array as $item) { + if (!self::is_satisfy($item['name'], $item['version'])) { return false; } } + return true; } @@ -82,7 +83,7 @@ class MigratorController { $this->instaled[$name]->version = $version; } - private function load_installed_plugins() { + private function load_installed_plugins() { $installed = parse_ini_file(DIR_CONFIG . 'modules.ini', true); foreach ($installed as $key => $item) { @@ -103,9 +104,12 @@ class MigratorController { $module_configs[] = str_replace('version.php', '', $file); } } - foreach ($module_configs as $module_config) { + foreach ($module_configs as $module_config) { $plugin = new \stdClass(); include $module_config . 'version.php'; + if($plugin->version == '0.0.0'){ + continue; + } $plugins[$plugin->name] = $plugin; if (is_file($module_config . 'db/Migrate.php')) { include $module_config . 'db/Migrate.php'; @@ -195,5 +199,12 @@ class MigratorController { } $this->save(); } + + /* + * Rollback Everything + */ + function reset(){ + var_dump( $this->load_installed_plugins() ); + } } diff --git a/app/core/sanity/Routes.php b/app/core/sanity/Routes.php old mode 100755 new mode 100644 index 95a5e69..8fa6477 --- a/app/core/sanity/Routes.php +++ b/app/core/sanity/Routes.php @@ -3,16 +3,41 @@ use Routes\RouteCollection as RouteCollection; use ORM\Connections as Connections; use Schema\Wrapper as Wrapper; +use App\Core\Template\Output as Output; + +RouteCollection::get('*', function () { + Output::addOnSubmenu('dev', '/paths', "Caminhos", "", ['class' => 'nav-link']); +}, -10)->doIgnore(); RouteCollection::cli('sanity/install', function() { - Wrapper::set_driver(Connections::getConnection()); + Wrapper::begin(); App\Core\Sanity\MigratorController::getInstance()->execute_plan(); Wrapper::commit(); - + })->middlewareIgnore('auth'); +RouteCollection::cli('install', function() { + Wrapper::set_driver(Connections::getConnection()); + Wrapper::begin(); + App\Core\Sanity\MigratorController::getInstance()->execute_plan(); + Wrapper::commit(); +})->middlewareIgnore('auth'); + +RouteCollection::cli('install/[d:module]', function() { + Wrapper::set_driver(Connections::getConnection()); + Wrapper::begin(); + App\Core\Sanity\MigratorController::getInstance()->execute_plan(); + Wrapper::commit(); +})->middlewareIgnore('auth'); + +RouteCollection::cli('reset', function() { + Wrapper::set_driver(Connections::getConnection()); + Wrapper::begin(); + App\Core\Sanity\MigratorController::getInstance()->reset(); + Wrapper::commit(); +}); RouteCollection::add('*', '*', function() { App\Core\Sanity\MigratorController::getInstance()->sentinel(); -}, -19)->doIgnore()->middlewareIgnore('auth'); \ No newline at end of file +}, -19)->doIgnore()->middlewareIgnore('auth'); diff --git a/app/core/sanity/lib.php b/app/core/sanity/lib.php old mode 100755 new mode 100644 diff --git a/app/core/welcome/Routes.php b/app/core/welcome/Routes.php old mode 100755 new mode 100644 index ebc2de7..3267676 --- a/app/core/welcome/Routes.php +++ b/app/core/welcome/Routes.php @@ -5,19 +5,27 @@ use Routes\RouteCollection as RouteCollection; //Menu itens RouteCollection::get('*', function() { - - Output::headAdd('/', 'Dashboard'); - // Output::addMenu('/', 'Dashboard', "", ['class' => 'nav-link']); - Output::addSubMenu('dashboard', 'Dashboard', "", ['class' => 'nav-link']); - Output::addOnSubMenu('dashboard', '/', 'Dashboard', "", ['class' => 'nav-link']); - Output::addOnSubMenu('dashboard', '/teste', 'Test', "", ['class' => 'nav-link']); - + Output::addMenu('/', 'Dashboard', "", ['class' => 'nav-link'], -10); + Output::addMenu('/dre', 'DRE', "", ['class' => 'nav-link'], -10); }, -10)->doIgnore(); RouteCollection::onHttpError('404', function($code){ - Output::setView(404)->render(); + http_response_code(404); + Output::setTemplate('NullTemplate'); + Output::render('404'); }); -RouteCollection::add('get', '/', '\App\Core\Welcome\WelcomeController@welcome');//->middlewareIgnore('auth'); +RouteCollection::add('get', '/', '\App\Core\Welcome\WelcomeController@welcome'); RouteCollection::add('get', '/teste', '\App\Core\Welcome\WelcomeController@teste'); -//RouteCollection::add('get', '/welcome', 'WellcomeController@welcome'); +RouteCollection::add('get', '/dre', '\App\Core\Welcome\WelcomeController@dre'); +//Filters + +RouteCollection::addDefaultMiddleware('fillpost', function () { + + if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST'){ + return; + } + + $_POST = array_merge( $_POST, (array) json_decode( file_get_contents('php://input')) ); + +}); \ No newline at end of file diff --git a/app/core/welcome/WelcomeController.php b/app/core/welcome/WelcomeController.php old mode 100755 new mode 100644 index 2ed5dd1..5e03077 --- a/app/core/welcome/WelcomeController.php +++ b/app/core/welcome/WelcomeController.php @@ -10,8 +10,12 @@ class WelcomeController { Output::render(); } + function dre() { + Output::render('dre'); + } + function teste(){ - echo 'saddsaadsdsa'; + var_dump($_SESSION); } } diff --git a/app/core/welcome/lang/en.php b/app/core/welcome/lang/en.php old mode 100755 new mode 100644 diff --git a/app/core/welcome/lang/fr.php b/app/core/welcome/lang/fr.php old mode 100755 new mode 100644 diff --git a/app/core/welcome/lang/pt_br.php b/app/core/welcome/lang/pt_br.php old mode 100755 new mode 100644 diff --git a/app/core/welcome/views/dre.mustache b/app/core/welcome/views/dre.mustache new file mode 100644 index 0000000..266027f --- /dev/null +++ b/app/core/welcome/views/dre.mustache @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/core/welcome/views/welcome.mustache b/app/core/welcome/views/welcome.mustache old mode 100755 new mode 100644 index 4b7b50c..ec779fc --- a/app/core/welcome/views/welcome.mustache +++ b/app/core/welcome/views/welcome.mustache @@ -3,4 +3,6 @@ {{string.welcome}} to hell...
-I shal be your guide {{palavrinha}} \ No newline at end of file +I shal be your guide {{palavrinha}} + + \ No newline at end of file