示例#1
0
 /**
  * Constructor.
  */
 function __construct($values, $model_name)
 {
     $this->model_name = $model_name;
     $uri = "/" . hyphenate($model_name);
     if ($this->model()) {
         $uri .= ($pk = $values[$this->model()->pk]) ? "/{$pk}" : '';
     }
     $this->uri($uri);
     parent::__construct($values);
 }
示例#2
0
 /**
  * Constructor.
  */
 function __construct($params = null)
 {
     $config = self::$config;
     // Request param defaults.
     $default_params = array('env' => self::$env, 'uri' => $_SERVER['REQUEST_URI'], 'layout' => $config->app['default_layout'], 'view' => $config->app['default_action'], 'output' => $config->app['default_output'], 'models' => array(), 'messages' => array(), 'notices' => array(), 'warnings' => array(), 'errors' => array(), 'method' => strtolower($_SERVER['REQUEST_METHOD']), 'post' => $_SERVER['REQUEST_METHOD'] == 'POST' ? true : false, 'get' => $_SERVER['REQUEST_METHOD'] == 'GET' ? true : false, 'ajax' => $_SERVER["HTTP_X_REQUESTED_WITH"] == 'XMLHttpRequest' || isset($_REQUEST['__ajax']) ? true : false, 'host' => $_SERVER['HTTP_HOST']);
     // Merge defaults with $_SERVER.
     foreach (array_merge($_SERVER, $default_params) as $key => $val) {
         $key = strtolower($key);
         if ($params[$key] === null) {
             $params[$key] = $val;
         }
     }
     // Apply params to request.
     parent::__construct($params);
 }
示例#3
0
 /**
  * Setup session.
  */
 function __construct($params = null)
 {
     // Enable sessions by HTTP request only.
     if ($_SERVER['HTTP_HOST'] && !self::$instance) {
         register_shutdown_function('session_write_close');
         $this->__session_maxlifetime = intval(ini_get('session.gc_maxlifetime'));
         $this->__session_data = null;
         // Session params by config.
         if ($params) {
             // Session domain sharing.
             if ($params['share_domain']) {
                 ini_set('session.cookie_domain', '.' . preg_replace('/(.*?)([^\\.]+\\.[^\\.]+)$/', '\\2', $_SERVER['HTTP_HOST']));
                 unset($params['share_domain']);
             }
             // Directly set all ini.
             foreach ((array) $params as $key => $value) {
                 ini_set('session.' . $key, $value);
             }
         }
         // Initiate cache sessions by config param session->use_cache.
         if ($params['use_cache']) {
             $this->__session_cache = true;
             // Internal save handlers?
             session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
         }
         // Start.
         session_start();
         // Cronstruct arrayinterface.
         parent::__construct($_SESSION);
         // Save session id.
         $this->id = session_id();
         // Singleton.
         self::$instance =& $this;
     }
     return self::$instance;
 }
示例#4
0
 function __construct($path = null, $required = true, $refresh = false)
 {
     if ($path) {
         parent::__construct((array) self::load($path, $required = true, $refresh));
     }
 }