__active = false; } } /** * Turn sessions on if 'Session.start' is set to false in core.php * * @param string $base */ function activate($base = null) { $this->__active = true; } /** * Used to read a session values set in a controller for a key or return values for all keys. * * In your view: $session->read('Controller.sessKey'); * Calling the method without a param will return all session vars * * @param string $name the name of the session key you want to read * * @return values from the session vars * @access public */ function read($name = null) { if ($this->__active === true && $this->__start()) { return parent::read($name); } return false; } /** * Used to check is a session key has been set * * In your view: $session->check('Controller.sessKey'); * * @param string $name * @return boolean * @access public */ function check($name) { if ($this->__active === true && $this->__start()) { return parent::check($name); } return false; } /** * Returns last error encountered in a session * * In your view: $session->error(); * * @return string last error * @access public */ function error() { if ($this->__active === true && $this->__start()) { return parent::error(); } return false; } /** * Used to render the message set in Controller::Session::setFlash() * * In your view: $session->flash('somekey'); * Will default to flash if no param is passed * * @param string $key The [Message.]key you are rendering in the view. * @return string Will echo the value if $key is set, or false if not set. * @access public */ function flash($key = 'flash') { if ($this->__active === true && $this->__start()) { if (parent::check('Message.' . $key)) { $flash = parent::read('Message.' . $key); if ($flash['layout'] == 'default') { if (!empty($flash['params']['class'])) { $class = $flash['params']['class']; } else { $class = 'message'; } $out = '