diff --git a/application/module/core/generator/GeneratorController.php b/app/core/generator/GeneratorController.php similarity index 84% rename from application/module/core/generator/GeneratorController.php rename to app/core/generator/GeneratorController.php index 7643a3a..1b6c64a 100755 --- a/application/module/core/generator/GeneratorController.php +++ b/app/core/generator/GeneratorController.php @@ -125,15 +125,15 @@ class GeneratorController { EOL; function createPluginFromTemplate($subname, $name){ - if (is_dir( DIR_MODULE.$subname . '/' . $name )){ + if (is_dir( DIR_APP.$subname . '/' . $name )){ echo 'Treco ja existe'; return; }else{ - mkdir(DIR_MODULE.$subname . '/' . $name, 0755, true); - mkdir(DIR_MODULE.$subname . '/' . $name . '/lang', 0755, true); - mkdir(DIR_MODULE.$subname . '/' . $name . '/classes', 0755, true); - mkdir(DIR_MODULE.$subname . '/' . $name . '/db', 0755, true); - mkdir(DIR_MODULE.$subname . '/' . $name . '/views', 0755, true); + mkdir(DIR_APP.$subname . '/' . $name, 0755, true); + mkdir(DIR_APP.$subname . '/' . $name . '/lang', 0755, true); + mkdir(DIR_APP.$subname . '/' . $name . '/classes', 0755, true); + mkdir(DIR_APP.$subname . '/' . $name . '/db', 0755, true); + mkdir(DIR_APP.$subname . '/' . $name . '/views', 0755, true); } $plugin_name = $name; @@ -143,23 +143,23 @@ class GeneratorController { $this->langBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->langBase); $this->langBase = str_replace("{{PLUGIN_NAME_PRETTY}}", $plugin_name_pretty, $this->langBase); - file_put_contents(DIR_MODULE.$subname . '/' . $name . '/lang/en.php', $this->langBase); - file_put_contents(DIR_MODULE.$subname . '/' . $name . '/lang/'.APP_LANG.'.php', $this->langBase); + 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); - file_put_contents(DIR_MODULE.$subname . '/' . $name . '/db/Migrate.php', $this->migrationBase); + file_put_contents(DIR_APP.$subname . '/' . $name . '/db/Migrate.php', $this->migrationBase); $this->routeBase = str_replace("{{PLUGIN_NAME}}", $plugin_name, $this->routeBase); $this->routeBase = str_replace("{{CONTROLLER}}", $controller, $this->routeBase); - file_put_contents(DIR_MODULE.$subname . '/' . $name . '/Routes.php', $this->routeBase); + file_put_contents(DIR_APP.$subname . '/' . $name . '/Routes.php', $this->routeBase); $this->objectBase = str_replace("{{OBJECT}}", $object, $this->objectBase); $this->objectBase = str_replace("{{TABLE_NAME}}", $name, $this->objectBase); - file_put_contents(DIR_MODULE.$subname . '/' . $name . "/classes/$object.php", $this->objectBase); + file_put_contents(DIR_APP.$subname . '/' . $name . "/classes/$object.php", $this->objectBase); $this->controllerBase = str_replace("{{OBJECT}}", $object, $this->controllerBase); $this->controllerBase = str_replace("{{CONTROLLER}}", $controller, $this->controllerBase); - file_put_contents(DIR_MODULE.$subname . '/' . $name . "/$controller.php", $this->controllerBase); + file_put_contents(DIR_APP.$subname . '/' . $name . "/$controller.php", $this->controllerBase); } diff --git a/application/module/core/generator/Routes.php b/app/core/generator/Routes.php similarity index 100% rename from application/module/core/generator/Routes.php rename to app/core/generator/Routes.php diff --git a/application/module/core/lang/en.php b/app/core/lang/en.php similarity index 100% rename from application/module/core/lang/en.php rename to app/core/lang/en.php diff --git a/application/module/core/lang/pt_br.php b/app/core/lang/pt_br.php similarity index 100% rename from application/module/core/lang/pt_br.php rename to app/core/lang/pt_br.php diff --git a/application/module/core/sanity/Routes.php b/app/core/sanity/Routes.php similarity index 100% rename from application/module/core/sanity/Routes.php rename to app/core/sanity/Routes.php diff --git a/application/module/core/sanity/classes/Migrator.class.php b/app/core/sanity/classes/Migrator.class.php similarity index 98% rename from application/module/core/sanity/classes/Migrator.class.php rename to app/core/sanity/classes/Migrator.class.php index 62b6a78..2fc3e1f 100755 --- a/application/module/core/sanity/classes/Migrator.class.php +++ b/app/core/sanity/classes/Migrator.class.php @@ -86,7 +86,7 @@ class Migrator{ $module_configs = Array(); $plugins = Array(); - $rdi = new RecursiveDirectoryIterator(DIR_MODULE); + $rdi = new RecursiveDirectoryIterator(DIR_APP); foreach(new RecursiveIteratorIterator($rdi) as $file){ if( strpos($file, 'version.php') ){ @@ -180,4 +180,4 @@ class Migrator{ $this->save(); } -} \ No newline at end of file +} diff --git a/application/module/core/sanity/lib.php b/app/core/sanity/lib.php similarity index 100% rename from application/module/core/sanity/lib.php rename to app/core/sanity/lib.php diff --git a/application/module/core/template/Output.class.php b/app/core/template/Output.class.php similarity index 54% rename from application/module/core/template/Output.class.php rename to app/core/template/Output.class.php index e42a2c3..acd3a2f 100755 --- a/application/module/core/template/Output.class.php +++ b/app/core/template/Output.class.php @@ -1,5 +1,7 @@ _template = ( defined('TEMPLATE_DEFAULT') ) ? TEMPLATE_DEFAULT : 'DefaultTemplate'; $this->_extension = ( defined('TEMPLATE_FILETYPE') ) ? TEMPLATE_FILETYPE : '.mustache'; @@ -31,8 +32,9 @@ class Output { } public function setTemplate($template = 'DefaultTemplate') { - $this->_template = $template; - return $this; + self::getInstance()->_template = $template; +// self::getInstance()->_template = ''; + return self::getInstance(); } public static function renderView($name, $values = null, $location = null) { @@ -42,11 +44,11 @@ class Output { $location = implode('/', $segments) . '/views/'; } - self::$_instance->setView($name, $values, $location)->render(); + self::getInstance()->setView($name, $values, $location)->render(); } - public function setView($name, $values = Array(), $location = null) { - + public static function setView($name, $values = Array(), $location = null) { + $instance = self::getInstance(); $folder = ''; if (!$location) { $segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']); @@ -56,26 +58,32 @@ class Output { $folder = $location; $location .= $name; - if (strpos($this->_extension, $location) == 0) { - $location .= $this->_extension; + if (strpos($instance->_extension, $location) == 0) { + $location .= $instance->_extension; } - $this->view = Array(); - $this->view['location'] = $location; - $this->view['folder'] = $folder; - $this->view['values'] = $values; - return $this; + $instance->view = Array(); + $instance->view['location'] = $location; + $instance->view['folder'] = $folder; + $instance->view['values'] = $values; + return self::getInstance(); } - public function addValue($key, $value){ - $this->view['values'][$key] = $value; + public static function addValue($key, $value){ + self::getInstance()->view['values'][$key] = $value; } - public function render() { - if(!is_file(__DIR__."/classes/".strtolower($this->_template)."/".$this->_template.'.php') ){ - $this->_template = 'DefaultTemplate'; + public static function render() { + $instance = self::getInstance(); + + if(!is_file(__DIR__."/classes/".strtolower($instance->_template)."/".$instance->_template.'.php') ){ + $instance->_template = 'DefaultTemplate'; } - include_once __DIR__."/classes/".strtolower($this->_template)."/".$this->_template.'.php'; - last_class()->setView($this->view)->render(); + + include_once __DIR__."/classes/".strtolower($instance->_template)."/".$instance->_template.'.php'; + + $class = new $instance->_template; + $class->setView($instance->view)->render(); + } } diff --git a/application/module/core/template/Routes.php b/app/core/template/Routes.php similarity index 74% rename from application/module/core/template/Routes.php rename to app/core/template/Routes.php index 6296ecf..960e4c4 100755 --- a/application/module/core/template/Routes.php +++ b/app/core/template/Routes.php @@ -7,11 +7,9 @@ RouteCollection::get('*', function(){ include_once 'Output.class.php'; - GLOBAL $SIDEBAR, $DROPDOWN, $OUTPUT; + GLOBAL $SIDEBAR, $DROPDOWN; $SIDEBAR = new Menu( array('id' => 'side-menu', 'class' => "nav") ); $DROPDOWN = new Menu( array("class" => 'dropdown-menu') ); - $OUTPUT = Output::getInstance(); - -}, -11)->doIgnore(); \ No newline at end of file +}, -11)->doIgnore(); diff --git a/application/module/core/template/classes/dashboard/Dashboard.php b/app/core/template/classes/dashboard/Dashboard.php similarity index 100% rename from application/module/core/template/classes/dashboard/Dashboard.php rename to app/core/template/classes/dashboard/Dashboard.php diff --git a/application/module/core/template/classes/dashboard/template.html b/app/core/template/classes/dashboard/template.html similarity index 100% rename from application/module/core/template/classes/dashboard/template.html rename to app/core/template/classes/dashboard/template.html diff --git a/application/module/core/template/classes/defaulttemplate/DefaultTemplate.php b/app/core/template/classes/defaulttemplate/DefaultTemplate.php similarity index 100% rename from application/module/core/template/classes/defaulttemplate/DefaultTemplate.php rename to app/core/template/classes/defaulttemplate/DefaultTemplate.php diff --git a/application/module/core/template/classes/defaulttemplate/template.html b/app/core/template/classes/defaulttemplate/template.html similarity index 100% rename from application/module/core/template/classes/defaulttemplate/template.html rename to app/core/template/classes/defaulttemplate/template.html diff --git a/application/module/core/template/classes/nulltemplate/NullTemplate.php b/app/core/template/classes/nulltemplate/NullTemplate.php similarity index 100% rename from application/module/core/template/classes/nulltemplate/NullTemplate.php rename to app/core/template/classes/nulltemplate/NullTemplate.php diff --git a/app/core/wellcome/Routes.php b/app/core/wellcome/Routes.php new file mode 100755 index 0000000..5640b11 --- /dev/null +++ b/app/core/wellcome/Routes.php @@ -0,0 +1,17 @@ + 'Bem vindo')); + Output::addValue('palavrinha', 'Oi'); + Output::render(); +}); + +RouteCollection::add('get', '/welcome', 'WellcomeController@welcome'); diff --git a/application/module/core/wellcome/WellcomeController.php b/app/core/wellcome/WellcomeController.php similarity index 100% rename from application/module/core/wellcome/WellcomeController.php rename to app/core/wellcome/WellcomeController.php diff --git a/application/module/core/wellcome/lang/en.php b/app/core/wellcome/lang/en.php similarity index 100% rename from application/module/core/wellcome/lang/en.php rename to app/core/wellcome/lang/en.php diff --git a/application/module/core/wellcome/lang/fr.php b/app/core/wellcome/lang/fr.php similarity index 100% rename from application/module/core/wellcome/lang/fr.php rename to app/core/wellcome/lang/fr.php diff --git a/application/module/core/wellcome/lang/pt_br.php b/app/core/wellcome/lang/pt_br.php similarity index 100% rename from application/module/core/wellcome/lang/pt_br.php rename to app/core/wellcome/lang/pt_br.php diff --git a/application/module/core/wellcome/views/wellcome.mustache b/app/core/wellcome/views/wellcome.mustache similarity index 100% rename from application/module/core/wellcome/views/wellcome.mustache rename to app/core/wellcome/views/wellcome.mustache diff --git a/application/module/core/wellcome/Routes.php b/application/module/core/wellcome/Routes.php deleted file mode 100755 index dc9f835..0000000 --- a/application/module/core/wellcome/Routes.php +++ /dev/null @@ -1,18 +0,0 @@ -setTemplate(); - //$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'); diff --git a/bootstrap.php b/bootstrap.php index 7e9398a..4904d06 100755 --- a/bootstrap.php +++ b/bootstrap.php @@ -12,5 +12,5 @@ use Routes\RouteCollection as RouteCollection; Lang::buildStrings(); -RouteCollection::getInstance()->crawl(__DIR__.'/application')->loadRoutes(); +RouteCollection::getInstance()->crawl(DIR_APP)->loadRoutes(); RouteCollection::getInstance()->submit(); diff --git a/config/info.php b/config/info.php index 91360a0..a7064f1 100755 --- a/config/info.php +++ b/config/info.php @@ -4,8 +4,7 @@ define('APP_LANG', 'pt_br'); define('DIR_CONFIG', __DIR__.'/'); define('DIR_ROOT', __DIR__.'/../'); -define('DIR_APPLICATION', DIR_ROOT . 'application/'); -define('DIR_MODULE', DIR_APPLICATION . 'module/'); +define('DIR_APP', DIR_ROOT . 'app/'); define('TEMPLATE_DEFAULT', 'Dashboard'); //define('TEMPLATE_DEFAULT', 'DefaultTemplate'); @@ -14,4 +13,4 @@ define('TEMPLATE_FILETYPE', '.mustache'); define('INSTALL_REQUIRE', FALSE); -define('CACHE_LANG', FALSE); \ No newline at end of file +define('CACHE_LANG', FALSE); diff --git a/publiclib.php b/publiclib.php index 163312f..6f2c3ea 100755 --- a/publiclib.php +++ b/publiclib.php @@ -1,5 +1,24 @@