| [ Index ] |
|
Code source de CakePHP 1.1.13.4450 |
1 <?php 2 /* SVN FILE: $Id: session.php 4409 2007-02-02 13:20:59Z phpnut $ */ 3 /** 4 * Short description for file. 5 * 6 * Long description for file 7 * 8 * PHP versions 4 and 5 9 * 10 * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/> 11 * Copyright 2005-2007, Cake Software Foundation, Inc. 12 * 1785 E. Sahara Avenue, Suite 490-204 13 * Las Vegas, Nevada 89104 14 * 15 * Licensed under The MIT License 16 * Redistributions of files must retain the above copyright notice. 17 * 18 * @filesource 19 * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. 20 * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project 21 * @package cake 22 * @subpackage cake.cake.libs.view.helpers 23 * @since CakePHP(tm) v 1.1.7.3328 24 * @version $Revision: 4409 $ 25 * @modifiedby $LastChangedBy: phpnut $ 26 * @lastmodified $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $ 27 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 28 */ 29 /** 30 * Session Helper. 31 * 32 * Session reading from the view. 33 * 34 * @package cake 35 * @subpackage cake.cake.libs.view.helpers 36 * 37 */ 38 class SessionHelper extends CakeSession { 39 /** 40 * Used to determine if methods implementation is used, or bypassed 41 * 42 * @var boolean 43 */ 44 var $__active = true; 45 /** 46 * Class constructor 47 * 48 * @param string $base 49 */ 50 function __construct($base = null) { 51 if (!defined('AUTO_SESSION') || AUTO_SESSION === true) { 52 parent::__construct($base, false); 53 } else { 54 $this->__active = false; 55 } 56 } 57 /** 58 * Used to read a session values set in a controller for a key or return values for all keys. 59 * 60 * In your view: $session->read('Controller.sessKey'); 61 * Calling the method without a param will return all session vars 62 * 63 * @param string $name the name of the session key you want to read 64 * @return values from the session vars 65 * @access public 66 */ 67 function read($name = null) { 68 if ($this->__active === true) { 69 return $this->readSessionVar($name); 70 } 71 return false; 72 } 73 /** 74 * Used to check is a session key has been set 75 * 76 * In your view: $session->check('Controller.sessKey'); 77 * 78 * @param string $name 79 * @return boolean 80 * @access public 81 */ 82 function check($name) { 83 if ($this->__active === true) { 84 return $this->checkSessionVar($name); 85 } 86 return false; 87 } 88 /** 89 * Returns last error encountered in a session 90 * 91 * In your view: $session->error(); 92 * 93 * @return string last error 94 * @access public 95 */ 96 function error() { 97 if ($this->__active === true) { 98 return $this->getLastError(); 99 } 100 return false; 101 } 102 /** 103 * Used to render the message set in Controller::Session::setFlash() 104 * 105 * In your view: $session->flash('somekey'); 106 * Will default to flash if no param is passed 107 * 108 * @param string $key The [Message.]key you are rendering in the view. 109 * @return string Will echo the value if $key is set, or false if not set. 110 * @access public 111 */ 112 function flash($key = 'flash') { 113 if ($this->__active === true) { 114 if ($this->checkSessionVar('Message.' . $key)) { 115 e($this->readSessionVar('Message.' . $key)); 116 $this->delSessionVar('Message.' . $key); 117 } else { 118 return false; 119 } 120 } 121 return false; 122 } 123 124 /** 125 * Used to check is a session is valid in a view 126 * 127 * @return boolean 128 * @access public 129 */ 130 function valid() { 131 if ($this->__active === true) { 132 return $this->isValid(); 133 } 134 } 135 } 136 137 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 19:27:47 2007 | par Balluche grâce à PHPXref 0.7 |