diff --git a/README.md b/README.md index c02add2..7bb2b42 100644 --- a/README.md +++ b/README.md @@ -702,6 +702,23 @@ In a sample case, we have this controller: ``` ***Pay attention:*** *Use the registrations only for objects that you need to access from the entire application. E.g.: If you need to connect a one more database but you just use for one model, it's better to load just inside the model, for awesome performance.* + + ## Add new modules, libraries and functions + + To add new classes or functions, you can put a folder in system directory with a autoload.php file. All autoload.php files are included to framework automatically. + + ### Use Composer + + Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. + To use Composer packages and autoloads, just configure your _composer.json_ with this vendor-dir: system/vendor. + + ```json + { + "config": { + "vendor-dir": "./system/vendor/" + } + } + ``` ## License diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4dc5ebf --- /dev/null +++ b/composer.json @@ -0,0 +1,8 @@ +{ + "config": { + "vendor-dir": "./system/vendor/" + }, + "require": { + "php": ">=5.3.0" + } +} diff --git a/system/caches/.gitignore b/system/caches/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/system/engine/controller.php b/system/engine/controller.php index 548713b..f580424 100644 --- a/system/engine/controller.php +++ b/system/engine/controller.php @@ -64,15 +64,17 @@ abstract class Controller { $this->templateTypes = array("tpl", "twig", "dwoo", "mustache", "smarty"); + $thema = ($this->config->get("config_template") != NULL) ? $this->config->get("config_template") : "default"; + foreach($this->templateTypes as $extensionTemplate) { if(isset($pegRout[2])){ - if (file_exists(DIR_TEMPLATE . 'default/'.$pegRout[0].'/'.$pegRout[1].'_'.$pegRout[2].'.'.$extensionTemplate) != false) { - $this->template = 'default/'.$pegRout[0].'/'.$pegRout[1].'_'.$pegRout[2].'.'.$extensionTemplate; + if (file_exists(DIR_TEMPLATE . $thema.'/'.$pegRout[0].'/'.$pegRout[1].'_'.$pegRout[2].'.'.$extensionTemplate) != false) { + $this->template = $thema.'/'.$pegRout[0].'/'.$pegRout[1].'_'.$pegRout[2].'.'.$extensionTemplate; break; } } else { - if (file_exists(DIR_TEMPLATE . 'default/'.$pegRout[0].'/'.$pegRout[1].'.'.$extensionTemplate) != false) { - $this->template = 'default/'.$pegRout[0].'/'.$pegRout[1].'.'.$extensionTemplate; + if (file_exists(DIR_TEMPLATE . $thema.'/'.$pegRout[0].'/'.$pegRout[1].'.'.$extensionTemplate) != false) { + $this->template = $thema.'/'.$pegRout[0].'/'.$pegRout[1].'.'.$extensionTemplate; break; } } @@ -118,6 +120,11 @@ abstract class Controller { return traduzir($str); })); + $twig->addFilter(new Twig_SimpleFilter('config', function ($str) { + // do something different from the built-in date filter + return $this->config->get($str); + })); + foreach ($this->twig as $key => $item) { $twig->addFilter(new Twig_SimpleFilter($key, $item)); } diff --git a/system/system.php b/system/system.php index 79f6ea8..9559fe4 100644 --- a/system/system.php +++ b/system/system.php @@ -116,8 +116,8 @@ if(!empty($configs)){ } if(USE_DB_CONFIG === true) { - - $query = $db->query("SELECT * FROM settings ORDER BY store_id DESC, setting_id ASC"); + + $query = (defined('CUSTOM_DB_CONFIG')) ? $db->query(CUSTOM_DB_CONFIG) : $db->query("SELECT * FROM settings ORDER BY store_id DESC, setting_id ASC"); foreach ($query->rows as $setting) { if (!$setting['serialized']) { diff --git a/system/vendor/.gitignore b/system/vendor/.gitignore new file mode 100644 index 0000000..e69de29