コード例 #1
0
ファイル: Database.php プロジェクト: javiyt/YasuiPHP
 public function __construct($dbAdapter = 'MySQL')
 {
     if ($this->_dbAdapter == null) {
         if (!Yasui_Registry::exists('databaseConnection')) {
             $config = Yasui_Registry::get('config');
             if (isset($config->database['driver']) && file_exists(dirname(__FILE__) . '/Driver/' . $config->database['driver'] . '.php')) {
                 $dbAdapter = $config->database['driver'];
             }
             require 'Yasui/Database/Driver/' . $dbAdapter . '.php';
             $adapter = 'Yasui_Database_Driver_' . $dbAdapter;
             Yasui_Registry::set('databaseConnection', new $adapter());
         }
     }
     $this->_dbAdapter = Yasui_Registry::get('databaseConnection');
 }
コード例 #2
0
ファイル: BootStrap.php プロジェクト: javiyt/YasuiPHP
}
//Define the default controller, if it is not defined before
if (!defined('DEFAULT_CONTROLLER')) {
    define('DEFAULT_CONTROLLER', 'index');
}
//Define the default action, if it is not defined before
if (!defined('DEFAULT_ACTION')) {
    define('DEFAULT_ACTION', 'index');
}
if (!defined('VIEWS_EXTENSION')) {
    define('VIEWS_EXTENSION', '.phtml');
}
//Require neccesary files to execute the framework
require 'Yasui/Autoload.php';
require 'Yasui/Front.php';
require 'Yasui/Registry.php';
require 'Yasui/Request.php';
require 'Yasui/Router.php';
require 'Yasui/View/View.php';
//Define the autoload function, if a required script is not loaded, the autoload function try to load it
function __autoload($class)
{
    //Instanstiate autoload class
    $autoload = new Yasui_Autoload($class);
}
//Create the request class and save it into the register
Yasui_Registry::set('request', new Yasui_Request());
//Create the router class and save it into the register
Yasui_Registry::set('router', new Yasui_Router());
//Create the front controller
$front = new Yasui_Front();
コード例 #3
0
ファイル: index.php プロジェクト: javiyt/YasuiPHP
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . 'library/');
require 'BootStrap.php';
Yasui_Registry::set('config', new Yasui_Config('config.ini', 'ini'));
$auth = Yasui_Auth::getInstance();
$authAdapter = $auth->getAdapter('DB');
$authAdapter->setAuthLocation('users')->setIdentityColumn('email')->setCredentialColumn('password')->setCredentialCrypt('md5');
$view = Yasui_View::getInstance();
$view->addHelperPath('application/views/helpers/');
$view->setPluginConf('menuAuth', array('authAdapter' => $authAdapter));
$view->authenticate = $authAdapter->isAuthenticate();
$front->dispatch();