session.php
Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 if(!class_exists('cakesession')) {
00039 uses('session');
00040 }
00041 class SessionHelper extends CakeSession {
00042
00043
00044
00045
00046
00047 var $helpers = null;
00048
00049
00050
00051
00052
00053 var $__active = true;
00054
00055
00056
00057
00058
00059 function __construct($base = null) {
00060 if (!defined('AUTO_SESSION') || AUTO_SESSION === true) {
00061 parent::__construct($base, false);
00062 } else {
00063 $this->__active = false;
00064 }
00065 }
00066
00067
00068
00069
00070
00071 function activate($base = null) {
00072 $this->__active = true;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 function read($name = null) {
00086 if ($this->__active === true && $this->__start()) {
00087 return parent::read($name);
00088 }
00089 return false;
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 function check($name) {
00101 if ($this->__active === true && $this->__start()) {
00102 return parent::check($name);
00103 }
00104 return false;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114 function error() {
00115 if ($this->__active === true && $this->__start()) {
00116 return parent::error();
00117 }
00118 return false;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 function flash($key = 'flash') {
00131 if ($this->__active === true && $this->__start()) {
00132 if (parent::check('Message.' . $key)) {
00133 $flash = parent::read('Message.' . $key);
00134
00135 if ($flash['layout'] == 'default') {
00136 $out = '<div id="' . $key . 'Message" class="message">' . $flash['message'] . '</div>';
00137 } elseif ($flash['layout'] == '' || $flash['layout'] == null) {
00138 $out = $flash['message'];
00139 } else {
00140 $view =& ClassRegistry::getObject('view');
00141 list($tmpLayout, $tmpVars, $tmpTitle) = array($view->layout, $view->viewVars, $view->pageTitle);
00142 list($view->layout, $view->viewVars, $view->pageTitle) = array($flash['layout'], $flash['params'], '');
00143 $out = $view->renderLayout($flash['message']);
00144 list($view->layout, $view->viewVars, $view->pageTitle) = array($tmpLayout, $tmpVars, $tmpTitle);
00145 }
00146 e($out);
00147 parent::del('Message.' . $key);
00148 return true;
00149 }
00150 }
00151 return false;
00152 }
00153
00154
00155
00156
00157
00158
00159 function valid() {
00160 if ($this->__active === true && $this->__start()) {
00161 return parent::valid();
00162 }
00163 }
00164
00165
00166
00167
00168
00169
00170
00171 function write() {
00172 trigger_error(__('You can not write to a Session from the view', true), E_USER_WARNING);
00173 }
00174
00175
00176
00177
00178
00179
00180 function id() {
00181 return parent::id();
00182 }
00183
00184
00185
00186
00187
00188
00189
00190
00191 function __start() {
00192 if(!parent::started()) {
00193 parent::start();
00194 }
00195 return true;
00196 }
00197 }
00198 ?>