示例#1
0
 protected function _router()
 {
     if ($this->_router == null) {
         //Get the Yasui_Router object from the registry
         $this->_router = Yasui_Registry::get('router');
     }
     return $this->_router;
 }
示例#2
0
 /**
  * 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;
     }
 }
示例#3
0
文件: View.php 项目: javiyt/YasuiPHP
 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;
 }
示例#4
0
文件: Form.php 项目: javiyt/YasuiPHP
 private function loadLang()
 {
     if (Yasui_Registry::exists('lang')) {
         $lang = Yasui_Registry::get('lang');
         $lang->loadFile('Validate');
         return $lang->getFile('Validate');
     }
     return array();
 }
示例#5
0
 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;
 }
示例#6
0
文件: DB.php 项目: javiyt/YasuiPHP
 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);
 }
示例#7
0
 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];
             }
         }
     }
 }
示例#8
0
文件: Front.php 项目: javiyt/YasuiPHP
 /**
  * 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');
 }
示例#9
0
 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');
 }