protected function _router() { if ($this->_router == null) { //Get the Yasui_Router object from the registry $this->_router = Yasui_Registry::get('router'); } return $this->_router; }
/** * Constructor de la clase, se hace privado para forzar a usar la función estática conexión * @param array $datos * @access private */ public function __construct($datos = array()) { if (count($datos) == 0) { $config = Yasui_Registry::get('config'); $this->_connectData = $config->database; } else { $this->_connectData = $datos; } }
private function __construct() { $this->addTemplatePath(LAYOUT_ROOT); $this->addHelperPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Helper'); $request = Yasui_Registry::get('request'); $this->_baseURL = $request->baseURL(); unset($request); $this->_layout = 'indexLayout' . VIEWS_EXTENSION; }
private function loadLang() { if (Yasui_Registry::exists('lang')) { $lang = Yasui_Registry::get('lang'); $lang->loadFile('Validate'); return $lang->getFile('Validate'); } return array(); }
public function generateURL(array $url, $link, $attr = array()) { $router = Yasui_Registry::get('router'); $html = '<a href="' . $router->getURL($url) . '"'; foreach ($attr as $key => $value) { $html .= ' ' . $key . '="' . $value . '"'; } $html .= '>' . $link . '</a>'; return $html; }
public function __construct($tableConfig = array()) { if ($this->_dbAdapter == null) { $this->_dbAdapter = new Yasui_Database(); } if (count($tableConfig) == 0) { $config = Yasui_Registry::get('config'); $tableConfig = $config->session; } $this->setConfig($tableConfig); }
public function __construct() { $this->_request = Yasui_Registry::get('request'); if ($this->_request->route) { $routIni = new Yasui_Config('routes.ini', 'ini'); $this->_routes = $routIni->toArray(); $route = $this->_routeExists($this->_request->route); if ($route) { $variables = $this->_map($this->_request->route, $route); foreach ($variables as $key => $value) { $this->_request->{$key} = $value; } } else { $router = explode('/', trim($this->_request->route, '/')); if (count($router) > 0) { //First parameter in $_GET['router'] can be module or controller $tmp = preg_replace('/\\W/', '', array_shift($router)); if (isset($tmp)) { if (is_dir(APPLICATION_ROOT . CONTROLLER_ROOT . $tmp)) { $this->_data['module'] = $tmp; } else { $this->_data['controller'] = $tmp; } } } if (count($router) > 0) { //Second parameter in $_GET['router'] can be controller or action $tmp = preg_replace('/\\W/', '', array_shift($router)); if (isset($tmp)) { //Module not null, so the controller hasnt been set, so the second parameter is the controller //and the thrid parameter is the action if ($this->_data['module'] != null) { $this->_data['controller'] = $tmp; } else { $this->_data['action'] = $tmp; } } } if (count($router) > 0) { //Have to extract third parameter because it is the action if ($this->_data['module'] != null) { $tmp = preg_replace('/\\W/', '', array_shift($router)); if (isset($tmp)) { $this->_data['action'] = $tmp; } } } $limite = count($router); for ($i = 0; $i < $limite; $i = $i + 2) { $this->_request->{$router}[$i] = $router[$i + 1]; } } } }
/** * Constructor of the class * @access public */ public function __construct() { //Get the Yasui_Router from the registry $this->_router = Yasui_Registry::get('router'); //Instantiate the Yasui_View object $this->_view = Yasui_View::getInstance(); //Adds init action to execute before the main action $this->addPreAction('init'); //Adds preDispatch action to execute before the main action $this->addPreAction('preDispatch'); //Adds the renderView action to execute after the main action $this->addPostAction('renderView'); }
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'); }
} //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();
<?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();