@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function __construct() |
| 43 | 43 | { |
| 44 | - $this->_properties = new TList; |
|
| 45 | - $this->_propertyMap = new TMap; |
|
| 44 | + $this->_properties=new TList; |
|
| 45 | + $this->_propertyMap=new TMap; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function setExtends($value) |
| 84 | 84 | { |
| 85 | - $this->_extend = $value; |
|
| 85 | + $this->_extend=$value; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function getPropertyValue($registry, $property, $parameterValue) |
| 138 | 138 | { |
| 139 | - $value = $this->getObjectValue($parameterValue,$property); |
|
| 139 | + $value=$this->getObjectValue($parameterValue, $property); |
|
| 140 | 140 | |
| 141 | 141 | if(($handler=$this->createTypeHandler($property, $registry))!==null) |
| 142 | - $value = $handler->getParameter($value); |
|
| 142 | + $value=$handler->getParameter($value); |
|
| 143 | 143 | |
| 144 | - $value = $this->nullifyDefaultValue($property,$value); |
|
| 144 | + $value=$this->nullifyDefaultValue($property, $value); |
|
| 145 | 145 | |
| 146 | - if(($type = $property->getType())!==null) |
|
| 147 | - $value = $registry->convertToType($type, $value); |
|
| 146 | + if(($type=$property->getType())!==null) |
|
| 147 | + $value=$registry->convertToType($type, $value); |
|
| 148 | 148 | |
| 149 | 149 | return $value; |
| 150 | 150 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $type=$property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
| 162 | 162 | $handler=$registry->getTypeHandler($type); |
| 163 | 163 | if($handler===null && $property->getTypeHandler()) |
| 164 | - $handler = Prado::createComponent($type); |
|
| 164 | + $handler=Prado::createComponent($type); |
|
| 165 | 165 | return $handler; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | * @return mixed property value. |
| 173 | 173 | * @throws TSqlMapException if property access is invalid. |
| 174 | 174 | */ |
| 175 | - protected function getObjectValue($object,$property) |
|
| 175 | + protected function getObjectValue($object, $property) |
|
| 176 | 176 | { |
| 177 | 177 | try |
| 178 | 178 | { |
| 179 | 179 | return TPropertyAccess::get($object, $property->getProperty()); |
| 180 | 180 | } |
| 181 | - catch (TInvalidPropertyException $e) |
|
| 181 | + catch(TInvalidPropertyException $e) |
|
| 182 | 182 | { |
| 183 | 183 | throw new TSqlMapException( |
| 184 | 184 | 'sqlmap_unable_to_get_property_for_parameter', |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | * @param mixed current property value |
| 197 | 197 | * @return mixed null if NullValue matches currrent value. |
| 198 | 198 | */ |
| 199 | - protected function nullifyDefaultValue($property,$value) |
|
| 199 | + protected function nullifyDefaultValue($property, $value) |
|
| 200 | 200 | { |
| 201 | - if(($nullValue = $property->getNullValue())!==null) |
|
| 201 | + if(($nullValue=$property->getNullValue())!==null) |
|
| 202 | 202 | { |
| 203 | - if($nullValue === $value) |
|
| 204 | - $value = null; |
|
| 203 | + if($nullValue===$value) |
|
| 204 | + $value=null; |
|
| 205 | 205 | } |
| 206 | 206 | return $value; |
| 207 | 207 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | public function bindColumn($column, &$value, $dataType=null) |
| 64 | 64 | { |
| 65 | 65 | if($dataType===null) |
| 66 | - $this->_statement->bindColumn($column,$value); |
|
| 66 | + $this->_statement->bindColumn($column, $value); |
|
| 67 | 67 | else |
| 68 | - $this->_statement->bindColumn($column,$value,$dataType); |
|
| 68 | + $this->_statement->bindColumn($column, $value, $dataType); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function setFetchMode($mode) |
| 75 | 75 | { |
| 76 | 76 | $params=func_get_args(); |
| 77 | - call_user_func_array(array($this->_statement,'setFetchMode'),$params); |
|
| 77 | + call_user_func_array(array($this->_statement, 'setFetchMode'), $params); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | * @param array list of column names whose values are to be passed as parameters in the constructor of the class being created |
| 103 | 103 | * @return mixed|false the populated object, false if no more row of data available |
| 104 | 104 | */ |
| 105 | - public function readObject($className,$fields) |
|
| 105 | + public function readObject($className, $fields) |
|
| 106 | 106 | { |
| 107 | - return $this->_statement->fetchObject($className,$fields); |
|
| 107 | + return $this->_statement->fetchObject($className, $fields); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function rewind() |
| 173 | 173 | { |
| 174 | - if($this->_index<0) |
|
| 174 | + if($this->_index < 0) |
|
| 175 | 175 | { |
| 176 | 176 | $this->_row=$this->_statement->fetch(); |
| 177 | 177 | $this->_index=0; |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | public function __construct($condition=null, $parameters=array()) |
| 49 | 49 | { |
| 50 | 50 | if(!is_array($parameters) && func_num_args() > 1) |
| 51 | - $parameters = array_slice(func_get_args(),1); |
|
| 51 | + $parameters=array_slice(func_get_args(), 1); |
|
| 52 | 52 | $this->_parameters=new TAttributeCollection; |
| 53 | 53 | $this->_parameters->setCaseSensitive(true); |
| 54 | - $this->_parameters->copyFrom((array)$parameters); |
|
| 54 | + $this->_parameters->copyFrom((array) $parameters); |
|
| 55 | 55 | $this->_ordersBy=new TAttributeCollection; |
| 56 | 56 | $this->_ordersBy->setCaseSensitive(true); |
| 57 | 57 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function setSelect($value) |
| 111 | 111 | { |
| 112 | - $this->_select = $value; |
|
| 112 | + $this->_select=$value; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | if(empty($value)) { |
| 130 | 130 | // reset the condition |
| 131 | - $this->_condition = null; |
|
| 131 | + $this->_condition=null; |
|
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | if(preg_match('/ORDER\s+BY\s+(.*?)(?=LIMIT)|ORDER\s+BY\s+(.*?)$/i', $value, $matches) > 0) { |
| 142 | 142 | // condition contains ORDER BY |
| 143 | - $value = str_replace($matches[0], '', $value); |
|
| 143 | + $value=str_replace($matches[0], '', $value); |
|
| 144 | 144 | if(strlen($matches[1]) > 0) { |
| 145 | 145 | $this->setOrdersBy($matches[1]); |
| 146 | 146 | } else if(strlen($matches[2]) > 0) { |
@@ -150,23 +150,23 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | if(preg_match('/LIMIT\s+([\d\s,]+)/i', $value, $matches) > 0) { |
| 152 | 152 | // condition contains limit |
| 153 | - $value = str_replace($matches[0], '', $value); // remove limit from query |
|
| 153 | + $value=str_replace($matches[0], '', $value); // remove limit from query |
|
| 154 | 154 | if(strpos($matches[1], ',')) { // both offset and limit given |
| 155 | - list($offset, $limit) = explode(',', $matches[1]); |
|
| 156 | - $this->_limit = (int)$limit; |
|
| 157 | - $this->_offset = (int)$offset; |
|
| 155 | + list($offset, $limit)=explode(',', $matches[1]); |
|
| 156 | + $this->_limit=(int) $limit; |
|
| 157 | + $this->_offset=(int) $offset; |
|
| 158 | 158 | } else { // only limit given |
| 159 | - $this->_limit = (int)$matches[1]; |
|
| 159 | + $this->_limit=(int) $matches[1]; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if(preg_match('/OFFSET\s+(\d+)/i', $value, $matches) > 0) { |
| 164 | 164 | // condition contains offset |
| 165 | - $value = str_replace($matches[0], '', $value); // remove offset from query |
|
| 166 | - $this->_offset = (int)$matches[1]; // set offset in criteria |
|
| 165 | + $value=str_replace($matches[0], '', $value); // remove offset from query |
|
| 166 | + $this->_offset=(int) $matches[1]; // set offset in criteria |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $this->_condition = trim($value); |
|
| 169 | + $this->_condition=trim($value); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | $this->_ordersBy->copyFrom($value); |
| 214 | 214 | else |
| 215 | 215 | { |
| 216 | - $value=trim(preg_replace('/\s+/',' ',(string)$value)); |
|
| 216 | + $value=trim(preg_replace('/\s+/', ' ', (string) $value)); |
|
| 217 | 217 | $orderBys=array(); |
| 218 | - foreach(explode(',',$value) as $orderBy) |
|
| 218 | + foreach(explode(',', $value) as $orderBy) |
|
| 219 | 219 | { |
| 220 | - $vs=explode(' ',trim($orderBy)); |
|
| 221 | - $orderBys[$vs[0]]=isset($vs[1])?$vs[1]:'asc'; |
|
| 220 | + $vs=explode(' ', trim($orderBy)); |
|
| 221 | + $orderBys[$vs[0]]=isset($vs[1]) ? $vs[1] : 'asc'; |
|
| 222 | 222 | } |
| 223 | 223 | $this->_ordersBy->copyFrom($orderBys); |
| 224 | 224 | } |
@@ -261,23 +261,23 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | public function __toString() |
| 263 | 263 | { |
| 264 | - $str = ''; |
|
| 265 | - if(strlen((string)$this->getCondition()) > 0) |
|
| 266 | - $str .= '"'.(string)$this->getCondition().'"'; |
|
| 267 | - $params = array(); |
|
| 264 | + $str=''; |
|
| 265 | + if(strlen((string) $this->getCondition()) > 0) |
|
| 266 | + $str.='"'.(string) $this->getCondition().'"'; |
|
| 267 | + $params=array(); |
|
| 268 | 268 | foreach($this->getParameters() as $k=>$v) |
| 269 | - $params[] = "{$k} => ${v}"; |
|
| 269 | + $params[]="{$k} => ${v}"; |
|
| 270 | 270 | if(count($params) > 0) |
| 271 | - $str .= ', "'.implode(', ',$params).'"'; |
|
| 272 | - $orders = array(); |
|
| 271 | + $str.=', "'.implode(', ', $params).'"'; |
|
| 272 | + $orders=array(); |
|
| 273 | 273 | foreach($this->getOrdersBy() as $k=>$v) |
| 274 | - $orders[] = "{$k} => ${v}"; |
|
| 274 | + $orders[]="{$k} => ${v}"; |
|
| 275 | 275 | if(count($orders) > 0) |
| 276 | - $str .= ', "'.implode(', ',$orders).'"'; |
|
| 277 | - if($this->_limit !==null) |
|
| 278 | - $str .= ', '.$this->_limit; |
|
| 279 | - if($this->_offset !== null) |
|
| 280 | - $str .= ', '.$this->_offset; |
|
| 276 | + $str.=', "'.implode(', ', $orders).'"'; |
|
| 277 | + if($this->_limit!==null) |
|
| 278 | + $str.=', '.$this->_limit; |
|
| 279 | + if($this->_offset!==null) |
|
| 280 | + $str.=', '.$this->_offset; |
|
| 281 | 281 | return $str; |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | if(!extension_loaded('apc')) |
| 57 | 57 | throw new TConfigurationException('apccache_extension_required'); |
| 58 | 58 | |
| 59 | - if(ini_get('apc.enabled') == false) |
|
| 59 | + if(ini_get('apc.enabled')==false) |
|
| 60 | 60 | throw new TConfigurationException('apccache_extension_not_enabled'); |
| 61 | 61 | |
| 62 | - if(substr(php_sapi_name(), 0, 3) === 'cli' and ini_get('apc.enable_cli') == false) |
|
| 62 | + if(substr(php_sapi_name(), 0, 3)==='cli' and ini_get('apc.enable_cli')==false) |
|
| 63 | 63 | throw new TConfigurationException('apccache_extension_not_enabled_cli'); |
| 64 | 64 | |
| 65 | 65 | parent::init($config); |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 86 | 86 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 87 | 87 | */ |
| 88 | - protected function setValue($key,$value,$expire) |
|
| 88 | + protected function setValue($key, $value, $expire) |
|
| 89 | 89 | { |
| 90 | - return apc_store($key,$value,$expire); |
|
| 90 | + return apc_store($key, $value, $expire); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 100 | 100 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 101 | 101 | */ |
| 102 | - protected function addValue($key,$value,$expire) |
|
| 102 | + protected function addValue($key, $value, $expire) |
|
| 103 | 103 | { |
| 104 | - return apc_add($key,$value,$expire); |
|
| 104 | + return apc_add($key, $value, $expire); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | if(!function_exists('xcache_isset')) |
| 53 | 53 | throw new TConfigurationException('xcache_extension_required'); |
| 54 | 54 | |
| 55 | - $enabled = (int)ini_get('xcache.cacher') !== 0; |
|
| 56 | - $var_size = (int)ini_get('xcache.var_size'); |
|
| 55 | + $enabled=(int) ini_get('xcache.cacher')!==0; |
|
| 56 | + $var_size=(int) ini_get('xcache.var_size'); |
|
| 57 | 57 | |
| 58 | 58 | if(!($enabled && $var_size > 0)) |
| 59 | 59 | throw new TConfigurationException('xcache_extension_not_enabled'); |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 82 | 82 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 83 | 83 | */ |
| 84 | - protected function setValue($key,$value,$expire) |
|
| 84 | + protected function setValue($key, $value, $expire) |
|
| 85 | 85 | { |
| 86 | - return xcache_set($key,$value,$expire); |
|
| 86 | + return xcache_set($key, $value, $expire); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 96 | 96 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 97 | 97 | */ |
| 98 | - protected function addValue($key,$value,$expire) |
|
| 98 | + protected function addValue($key, $value, $expire) |
|
| 99 | 99 | { |
| 100 | - return !xcache_isset($key) ? $this->setValue($key,$value,$expire) : false; |
|
| 100 | + return !xcache_isset($key) ? $this->setValue($key, $value, $expire) : false; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function flush() |
| 119 | 119 | { |
| 120 | - for($i=0, $max=xcache_count(XC_TYPE_VAR); $i<$max; $i++) |
|
| 120 | + for($i=0, $max=xcache_count(XC_TYPE_VAR); $i < $max; $i++) |
|
| 121 | 121 | { |
| 122 | 122 | if(xcache_clear_cache(XC_TYPE_VAR, $i)===false) |
| 123 | 123 | return false; |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | public function createListItem($index=-1) |
| 39 | 39 | { |
| 40 | 40 | $item=$this->createNewListItem(); |
| 41 | - if($index<0) |
|
| 41 | + if($index < 0) |
|
| 42 | 42 | $this->add($item); |
| 43 | 43 | else |
| 44 | - $this->insertAt($index,$item); |
|
| 44 | + $this->insertAt($index, $item); |
|
| 45 | 45 | return $item; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | protected function createNewListItem($text=null) |
| 52 | 52 | { |
| 53 | - $item = new TListItem; |
|
| 53 | + $item=new TListItem; |
|
| 54 | 54 | if($text!==null) |
| 55 | 55 | $item->setText($text); |
| 56 | 56 | return $item; |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | * @param TListItem the item to be inserted. |
| 64 | 64 | * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem |
| 65 | 65 | */ |
| 66 | - public function insertAt($index,$item) |
|
| 66 | + public function insertAt($index, $item) |
|
| 67 | 67 | { |
| 68 | 68 | if(is_string($item)) |
| 69 | - $item = $this->createNewListItem($item); |
|
| 69 | + $item=$this->createNewListItem($item); |
|
| 70 | 70 | if(!($item instanceof TListItem)) |
| 71 | - throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this)); |
|
| 72 | - parent::insertAt($index,$item); |
|
| 71 | + throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this)); |
|
| 72 | + parent::insertAt($index, $item); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param boolean whether to look for disabled items also |
| 79 | 79 | * @return integer the index of the item found, -1 if not found. |
| 80 | 80 | */ |
| 81 | - public function findIndexByValue($value,$includeDisabled=true) |
|
| 81 | + public function findIndexByValue($value, $includeDisabled=true) |
|
| 82 | 82 | { |
| 83 | 83 | $value=TPropertyValue::ensureString($value); |
| 84 | 84 | $index=0; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param boolean whether to look for disabled items also |
| 98 | 98 | * @return integer the index of the item found, -1 if not found. |
| 99 | 99 | */ |
| 100 | - public function findIndexByText($text,$includeDisabled=true) |
|
| 100 | + public function findIndexByText($text, $includeDisabled=true) |
|
| 101 | 101 | { |
| 102 | 102 | $text=TPropertyValue::ensureString($text); |
| 103 | 103 | $index=0; |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | * @param boolean whether to look for disabled items also |
| 117 | 117 | * @return TListItem the item found, null if not found. |
| 118 | 118 | */ |
| 119 | - public function findItemByValue($value,$includeDisabled=true) |
|
| 119 | + public function findItemByValue($value, $includeDisabled=true) |
|
| 120 | 120 | { |
| 121 | - if(($index=$this->findIndexByValue($value,$includeDisabled))>=0) |
|
| 121 | + if(($index=$this->findIndexByValue($value, $includeDisabled)) >= 0) |
|
| 122 | 122 | return $this->itemAt($index); |
| 123 | 123 | else |
| 124 | 124 | return null; |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | * @param boolean whether to look for disabled items also |
| 131 | 131 | * @return TListItem the item found, null if not found. |
| 132 | 132 | */ |
| 133 | - public function findItemByText($text,$includeDisabled=true) |
|
| 133 | + public function findItemByText($text, $includeDisabled=true) |
|
| 134 | 134 | { |
| 135 | - if(($index=$this->findIndexByText($text,$includeDisabled))>=0) |
|
| 135 | + if(($index=$this->findIndexByText($text, $includeDisabled)) >= 0) |
|
| 136 | 136 | return $this->itemAt($index); |
| 137 | 137 | else |
| 138 | 138 | return null; |
@@ -157,6 +157,6 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function saveState() |
| 159 | 159 | { |
| 160 | - return ($this->getCount()>0) ? $this->toArray() : null; |
|
| 160 | + return ($this->getCount() > 0) ? $this->toArray() : null; |
|
| 161 | 161 | } |
| 162 | 162 | } |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
| 95 | 95 | * @return string URL to the asset path. |
| 96 | 96 | */ |
| 97 | - public function publishAsset($assetPath,$className=null) |
|
| 97 | + public function publishAsset($assetPath, $className=null) |
|
| 98 | 98 | { |
| 99 | 99 | if($className===null) |
| 100 | 100 | $className=get_class($this); |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | if(is_string($this->_userManager)) |
| 95 | 95 | { |
| 96 | 96 | if(($users=$application->getModule($this->_userManager))===null) |
| 97 | - throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager); |
|
| 97 | + throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager); |
|
| 98 | 98 | if(!($users instanceof IUserManager)) |
| 99 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
| 99 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
| 100 | 100 | $this->_userManager=$users; |
| 101 | 101 | } |
| 102 | - $application->attachEventHandler('OnAuthentication',array($this,'doAuthentication')); |
|
| 103 | - $application->attachEventHandler('OnEndRequest',array($this,'leave')); |
|
| 104 | - $application->attachEventHandler('OnAuthorization',array($this,'doAuthorization')); |
|
| 102 | + $application->attachEventHandler('OnAuthentication', array($this, 'doAuthentication')); |
|
| 103 | + $application->attachEventHandler('OnEndRequest', array($this, 'leave')); |
|
| 104 | + $application->attachEventHandler('OnAuthorization', array($this, 'doAuthorization')); |
|
| 105 | 105 | $this->_initialized=true; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | if($this->_initialized) |
| 123 | 123 | throw new TInvalidOperationException('authmanager_usermanager_unchangeable'); |
| 124 | 124 | if(!is_string($provider) && !($provider instanceof IUserManager)) |
| 125 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
| 125 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
| 126 | 126 | $this->_userManager=$provider; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param mixed sender of the Authentication event |
| 153 | 153 | * @param mixed event parameter |
| 154 | 154 | */ |
| 155 | - public function doAuthentication($sender,$param) |
|
| 155 | + public function doAuthentication($sender, $param) |
|
| 156 | 156 | { |
| 157 | 157 | $this->onAuthenticate($param); |
| 158 | 158 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param mixed sender of the Authorization event |
| 169 | 169 | * @param mixed event parameter |
| 170 | 170 | */ |
| 171 | - public function doAuthorization($sender,$param) |
|
| 171 | + public function doAuthorization($sender, $param) |
|
| 172 | 172 | { |
| 173 | 173 | if(!$this->_skipAuthorization) |
| 174 | 174 | { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param mixed sender of the event |
| 184 | 184 | * @param mixed event parameter |
| 185 | 185 | */ |
| 186 | - public function leave($sender,$param) |
|
| 186 | + public function leave($sender, $param) |
|
| 187 | 187 | { |
| 188 | 188 | $application=$this->getApplication(); |
| 189 | 189 | if($application->getResponse()->getStatusCode()===401) |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function setReturnUrl($value) |
| 231 | 231 | { |
| 232 | - $this->getSession()->add($this->getReturnUrlVarName(),$value); |
|
| 232 | + $this->getSession()->add($this->getReturnUrlVarName(), $value); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -288,8 +288,8 @@ discard block |
||
| 288 | 288 | $user=$this->_userManager->getUser(null)->loadFromString($sessionInfo); |
| 289 | 289 | |
| 290 | 290 | // check for authentication expiration |
| 291 | - $isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() && |
|
| 292 | - ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time(); |
|
| 291 | + $isAuthExpired=$this->_authExpire > 0 && !$user->getIsGuest() && |
|
| 292 | + ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime < time(); |
|
| 293 | 293 | |
| 294 | 294 | // try authenticating through cookie if possible |
| 295 | 295 | if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired)) |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | $user=$user2; |
| 303 | 303 | $this->updateSessionUser($user); |
| 304 | 304 | // user is restored from cookie, auth may not expire |
| 305 | - $isAuthExpired = false; |
|
| 305 | + $isAuthExpired=false; |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | // event handler gets a chance to do further auth work |
| 319 | 319 | if($this->hasEventHandler('OnAuthenticate')) |
| 320 | - $this->raiseEvent('OnAuthenticate',$this,$application); |
|
| 320 | + $this->raiseEvent('OnAuthenticate', $this, $application); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | { |
| 330 | 330 | $this->logout(); |
| 331 | 331 | if($this->hasEventHandler('OnAuthExpire')) |
| 332 | - $this->raiseEvent('OnAuthExpire',$this,$param); |
|
| 332 | + $this->raiseEvent('OnAuthExpire', $this, $param); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | { |
| 344 | 344 | $application=$this->getApplication(); |
| 345 | 345 | if($this->hasEventHandler('OnAuthorize')) |
| 346 | - $this->raiseEvent('OnAuthorize',$this,$application); |
|
| 347 | - if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(),$application->getRequest()->getRequestType(),$application->getRequest()->getUserHostAddress())) |
|
| 346 | + $this->raiseEvent('OnAuthorize', $this, $application); |
|
| 347 | + if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress())) |
|
| 348 | 348 | { |
| 349 | 349 | $application->getResponse()->setStatusCode(401); |
| 350 | 350 | $application->completeRequest(); |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | if(($session=$this->getSession())===null) |
| 384 | 384 | throw new TConfigurationException('authmanager_session_required'); |
| 385 | 385 | else |
| 386 | - $session->add($this->getUserKey(),$user->saveToString()); |
|
| 386 | + $session->add($this->getUserKey(), $user->saveToString()); |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | |
@@ -411,19 +411,19 @@ discard block |
||
| 411 | 411 | * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1. |
| 412 | 412 | * @return boolean if login is successful |
| 413 | 413 | */ |
| 414 | - public function login($username,$password,$expire=0) |
|
| 414 | + public function login($username, $password, $expire=0) |
|
| 415 | 415 | { |
| 416 | - if($this->_userManager->validateUser($username,$password)) |
|
| 416 | + if($this->_userManager->validateUser($username, $password)) |
|
| 417 | 417 | { |
| 418 | 418 | if(($user=$this->_userManager->getUser($username))===null) |
| 419 | 419 | return false; |
| 420 | 420 | $this->updateSessionUser($user); |
| 421 | 421 | $this->getApplication()->setUser($user); |
| 422 | 422 | |
| 423 | - if($expire>0) |
|
| 423 | + if($expire > 0) |
|
| 424 | 424 | { |
| 425 | - $cookie=new THttpCookie($this->getUserKey(),''); |
|
| 426 | - $cookie->setExpire(time()+$expire); |
|
| 425 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
| 426 | + $cookie->setExpire(time() + $expire); |
|
| 427 | 427 | $this->_userManager->saveUserToCookie($cookie); |
| 428 | 428 | $this->getResponse()->getCookies()->add($cookie); |
| 429 | 429 | } |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | $session->destroy(); |
| 447 | 447 | if($this->getAllowAutoLogin()) |
| 448 | 448 | { |
| 449 | - $cookie=new THttpCookie($this->getUserKey(),''); |
|
| 449 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
| 450 | 450 | $this->getResponse()->getCookies()->add($cookie); |
| 451 | 451 | } |
| 452 | 452 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function getName() |
| 70 | 70 | { |
| 71 | - return $this->getState('Name',''); |
|
| 71 | + return $this->getState('Name', ''); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function setName($value) |
| 78 | 78 | { |
| 79 | - $this->setState('Name',$value,''); |
|
| 79 | + $this->setState('Name', $value, ''); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function getIsGuest() |
| 86 | 86 | { |
| 87 | - return $this->getState('IsGuest',true); |
|
| 87 | + return $this->getState('IsGuest', true); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $this->setName($this->_manager->getGuestName()); |
| 98 | 98 | $this->setRoles(array()); |
| 99 | 99 | } |
| 100 | - $this->setState('IsGuest',$isGuest); |
|
| 100 | + $this->setState('IsGuest', $isGuest); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function getRoles() |
| 107 | 107 | { |
| 108 | - return $this->getState('Roles',array()); |
|
| 108 | + return $this->getState('Roles', array()); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -114,16 +114,16 @@ discard block |
||
| 114 | 114 | public function setRoles($value) |
| 115 | 115 | { |
| 116 | 116 | if(is_array($value)) |
| 117 | - $this->setState('Roles',$value,array()); |
|
| 117 | + $this->setState('Roles', $value, array()); |
|
| 118 | 118 | else |
| 119 | 119 | { |
| 120 | 120 | $roles=array(); |
| 121 | - foreach(explode(',',$value) as $role) |
|
| 121 | + foreach(explode(',', $value) as $role) |
|
| 122 | 122 | { |
| 123 | 123 | if(($role=trim($role))!=='') |
| 124 | 124 | $roles[]=$role; |
| 125 | 125 | } |
| 126 | - $this->setState('Roles',$roles,array()); |
|
| 126 | + $this->setState('Roles', $roles, array()); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function isInRole($role) |
| 135 | 135 | { |
| 136 | 136 | foreach($this->getRoles() as $r) |
| 137 | - if(strcasecmp($role,$r)===0) |
|
| 137 | + if(strcasecmp($role, $r)===0) |
|
| 138 | 138 | return true; |
| 139 | 139 | return false; |
| 140 | 140 | } |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
| 174 | 174 | * @see setState |
| 175 | 175 | */ |
| 176 | - protected function getState($key,$defaultValue=null) |
|
| 176 | + protected function getState($key, $defaultValue=null) |
|
| 177 | 177 | { |
| 178 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
| 178 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
| 193 | 193 | * @see getState |
| 194 | 194 | */ |
| 195 | - protected function setState($key,$value,$defaultValue=null) |
|
| 195 | + protected function setState($key, $value, $defaultValue=null) |
|
| 196 | 196 | { |
| 197 | 197 | if($value===$defaultValue) |
| 198 | 198 | unset($this->_state[$key]); |