Skip to content

Commit

Permalink
Add Config files
Browse files Browse the repository at this point in the history
  • Loading branch information
supremacia committed Aug 10, 2017
1 parent 2b23488 commit a06ba57
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
86 changes: 86 additions & 0 deletions Config/Database/Blog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* Config\Database
* PHP version 7
*
* @category Database
* @package Config
* @author Bill Rocha <prbr@ymail.com>
* @copyright 2016 Bill Rocha <http://google.com/+BillRocha>
* @license <https://opensource.org/licenses/MIT> MIT
* @version GIT: 0.0.1
* @link http://paulorocha.tk/devbr
*/

namespace Config\Database;

/**
* Config\Database Class
*
* @category Database
* @package Config
* @author Bill Rocha <prbr@ymail.com>
* @license <https://opensource.org/licenses/MIT> MIT
* @link http://paulorocha.tk/devbr
*/
class Blog
{
static $config = [
'mysql'=>[
'dsn'=>'mysql:host=localhost;dbname=devbr_site;charset=utf8',
'user'=>'devbr_site',
'passw'=>'devbr#123'],
'sqlite'=>['dsn'=>'sqlite.db']
];
static $default = 'mysql';

//Configuração da tabela de usuário | Lib\User
static $userTable = ['table'=>'usuario',
'id'=>'id',
'name'=>'nome',
'token'=>'token',
'life'=>'vida',
'login'=>'login',
'password'=>'senha',
'level'=>'nivel',
'status'=>'status'];

/**
* Get Database configurations
*
* @param string $alias Database config name
*
* @return bool|array Array (or false) of the configurations
*/
static function get($alias = null)
{
if ($alias === null) {
return static::$config[static::$default];
}
if (isset(static::$config[$alias])) {
return static::$config[$alias];
} else {
return false;
}
}

/**
* Get default database configuration
*
* @return string Alias of the default configurated database
*/
static function getDefault()
{
return static::$default;
}

/**
* Get user configuration
*
* @return array Array of user table configs.
*/
static function getUserConfig()
{
return static::$userTable;
}
}
27 changes: 27 additions & 0 deletions Config/Routers/Blog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

$router->respond('get', '/blog', 'Blog\Page::index')
->respond('get', '/blog\?(.*)', 'Blog\Page::index')

->respond('get', 'login', 'Blog\Page::login')
->respond('get', 'perfil', 'Blog\Page::perfil')

->respond('get', 'e/(?<id>(.*)?)', 'Blog\Page::edit')
->respond('get', 'a/(?<id>.*?)', 'Blog\Page::view')

//AJAX ----------
->respond('post', 'x/put', 'Blog\Ajax::put')
->respond('post', 'x/save', 'Blog\Ajax::save')
->respond('post', 'x/checklink', 'Blog\Ajax::checkLink')
->respond('post', 'x/delete/(?<id>(\d+)?)', 'Blog\Ajax::delete')
->respond('post', 'x/upload/(?<id>(\d+)?)', 'Blog\Ajax::upload')

//USER for Facebook
->respond('post', 'x/userlog', 'User\Facebook::userlog')

//USERS
->respond('get', 'u/(?<id>(.*)?)', 'User\Facebook::perfil')

//ADMIN
->respond('get', 'admin', 'Blog\Admin::index')
->respond('get', 'admin/(\d+)/(\d+)/(\d+)', 'Blog\Admin::pagination');

0 comments on commit a06ba57

Please sign in to comment.