@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | $this->_connection->getPdoInstance()->commit(); |
| 65 | 65 | $this->_active=false; |
| 66 | - } |
|
| 67 | - else |
|
| 66 | + } else |
|
| 68 | 67 | throw new TDbException('dbtransaction_transaction_inactive'); |
| 69 | 68 | } |
| 70 | 69 | |
@@ -78,8 +77,7 @@ discard block |
||
| 78 | 77 | { |
| 79 | 78 | $this->_connection->getPdoInstance()->rollBack(); |
| 80 | 79 | $this->_active=false; |
| 81 | - } |
|
| 82 | - else |
|
| 80 | + } else |
|
| 83 | 81 | throw new TDbException('dbtransaction_transaction_inactive'); |
| 84 | 82 | } |
| 85 | 83 | |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | $manager->configureXml($file); |
| 69 | 69 | $this->cacheSqlMapManager($manager); |
| 70 | 70 | } |
| 71 | - } |
|
| 72 | - elseif($this->getConnectionID() !== '') { |
|
| 71 | + } elseif($this->getConnectionID() !== '') { |
|
| 73 | 72 | $manager->setDbConnection($this->getDbConnection()); |
| 74 | 73 | } |
| 75 | 74 | return $manager; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | private function getCacheKey() |
| 45 | 45 | { |
| 46 | - return $this->getID() . $this->getConfigFile(); |
|
| 46 | + return $this->getID().$this->getConfigFile(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function clearCache() |
| 53 | 53 | { |
| 54 | - $cache = $this->getApplication()->getCache(); |
|
| 55 | - if($cache !== null) { |
|
| 54 | + $cache=$this->getApplication()->getCache(); |
|
| 55 | + if($cache!==null) { |
|
| 56 | 56 | $cache->delete($this->getCacheKey()); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | * @since 3.1.7 |
| 67 | 67 | */ |
| 68 | 68 | public function getSqlMapManager() { |
| 69 | - if(($manager = $this->loadCachedSqlMapManager())===null) |
|
| 69 | + if(($manager=$this->loadCachedSqlMapManager())===null) |
|
| 70 | 70 | { |
| 71 | - $manager = new TSqlMapManager($this->getDbConnection()); |
|
| 71 | + $manager=new TSqlMapManager($this->getDbConnection()); |
|
| 72 | 72 | if(strlen($file=$this->getConfigFile()) > 0) |
| 73 | 73 | { |
| 74 | 74 | $manager->configureXml($file); |
| 75 | 75 | $this->cacheSqlMapManager($manager); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | - elseif($this->getConnectionID() !== '') { |
|
| 78 | + elseif($this->getConnectionID()!=='') { |
|
| 79 | 79 | $manager->setDbConnection($this->getDbConnection()); |
| 80 | 80 | } |
| 81 | 81 | return $manager; |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | if($this->getEnableCache()) |
| 91 | 91 | { |
| 92 | - $cache = $this->getApplication()->getCache(); |
|
| 93 | - if($cache !== null) { |
|
| 94 | - $dependencies = null; |
|
| 95 | - if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
| 96 | - $dependencies = $manager->getCacheDependencies(); |
|
| 92 | + $cache=$this->getApplication()->getCache(); |
|
| 93 | + if($cache!==null) { |
|
| 94 | + $dependencies=null; |
|
| 95 | + if($this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
| 96 | + $dependencies=$manager->getCacheDependencies(); |
|
| 97 | 97 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | if($this->getEnableCache()) |
| 110 | 110 | { |
| 111 | - $cache = $this->getApplication()->getCache(); |
|
| 112 | - if($cache !== null) |
|
| 111 | + $cache=$this->getApplication()->getCache(); |
|
| 112 | + if($cache!==null) |
|
| 113 | 113 | { |
| 114 | - $manager = $cache->get($this->getCacheKey()); |
|
| 114 | + $manager=$cache->get($this->getCacheKey()); |
|
| 115 | 115 | if($manager instanceof TSqlMapManager) |
| 116 | 116 | return $manager; |
| 117 | 117 | } |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | $this->_configFile=$value; |
| 139 | 139 | else |
| 140 | 140 | { |
| 141 | - $file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
| 142 | - if($file === null || !is_file($file)) |
|
| 141 | + $file=Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
|
| 142 | + if($file===null || !is_file($file)) |
|
| 143 | 143 | throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
| 144 | 144 | else |
| 145 | - $this->_configFile = $file; |
|
| 145 | + $this->_configFile=$file; |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function setEnableCache($value) |
| 154 | 154 | { |
| 155 | - $this->_enableCache = TPropertyValue::ensureBoolean($value); |
|
| 155 | + $this->_enableCache=TPropertyValue::ensureBoolean($value); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -177,8 +177,7 @@ |
||
| 177 | 177 | try |
| 178 | 178 | { |
| 179 | 179 | return TPropertyAccess::get($object, $property->getProperty()); |
| 180 | - } |
|
| 181 | - catch (TInvalidPropertyException $e) |
|
| 180 | + } catch (TInvalidPropertyException $e) |
|
| 182 | 181 | { |
| 183 | 182 | throw new TSqlMapException( |
| 184 | 183 | 'sqlmap_unable_to_get_property_for_parameter', |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function __construct() |
| 52 | 52 | { |
| 53 | - $this->_properties = new TList; |
|
| 54 | - $this->_propertyMap = new TMap; |
|
| 53 | + $this->_properties=new TList; |
|
| 54 | + $this->_propertyMap=new TMap; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function setExtends($value) |
| 93 | 93 | { |
| 94 | - $this->_extend = $value; |
|
| 94 | + $this->_extend=$value; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function getPropertyValue($registry, $property, $parameterValue) |
| 147 | 147 | { |
| 148 | - $value = $this->getObjectValue($parameterValue, $property); |
|
| 148 | + $value=$this->getObjectValue($parameterValue, $property); |
|
| 149 | 149 | |
| 150 | 150 | if(($handler=$this->createTypeHandler($property, $registry))!==null) |
| 151 | - $value = $handler->getParameter($value); |
|
| 151 | + $value=$handler->getParameter($value); |
|
| 152 | 152 | |
| 153 | - $value = $this->nullifyDefaultValue($property, $value); |
|
| 153 | + $value=$this->nullifyDefaultValue($property, $value); |
|
| 154 | 154 | |
| 155 | - if(($type = $property->getType())!==null) |
|
| 156 | - $value = $registry->convertToType($type, $value); |
|
| 155 | + if(($type=$property->getType())!==null) |
|
| 156 | + $value=$registry->convertToType($type, $value); |
|
| 157 | 157 | |
| 158 | 158 | return $value; |
| 159 | 159 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $type=$property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
| 171 | 171 | $handler=$registry->getTypeHandler($type); |
| 172 | 172 | if($handler===null && $property->getTypeHandler()) |
| 173 | - $handler = Prado::createComponent($type); |
|
| 173 | + $handler=Prado::createComponent($type); |
|
| 174 | 174 | return $handler; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | return TPropertyAccess::get($object, $property->getProperty()); |
| 189 | 189 | } |
| 190 | - catch (TInvalidPropertyException $e) |
|
| 190 | + catch(TInvalidPropertyException $e) |
|
| 191 | 191 | { |
| 192 | 192 | throw new TSqlMapException( |
| 193 | 193 | 'sqlmap_unable_to_get_property_for_parameter', |
@@ -207,10 +207,10 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | protected function nullifyDefaultValue($property, $value) |
| 209 | 209 | { |
| 210 | - if(($nullValue = $property->getNullValue())!==null) |
|
| 210 | + if(($nullValue=$property->getNullValue())!==null) |
|
| 211 | 211 | { |
| 212 | - if($nullValue === $value) |
|
| 213 | - $value = null; |
|
| 212 | + if($nullValue===$value) |
|
| 213 | + $value=null; |
|
| 214 | 214 | } |
| 215 | 215 | return $value; |
| 216 | 216 | } |
@@ -164,8 +164,7 @@ |
||
| 164 | 164 | return $handler->createNewInstance(); |
| 165 | 165 | else |
| 166 | 166 | return $registry->createInstanceOf($this->getClass()); |
| 167 | - } |
|
| 168 | - catch (TSqlMapException $e) |
|
| 167 | + } catch (TSqlMapException $e) |
|
| 169 | 168 | { |
| 170 | 169 | throw new TSqlMapException( |
| 171 | 170 | 'sqlmap_unable_to_create_new_instance', |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function setClass($value) |
| 88 | 88 | { |
| 89 | - $this->_class = $value; |
|
| 89 | + $this->_class=$value; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function setExtends($value) |
| 112 | 112 | { |
| 113 | - $this->_extends = $value; |
|
| 113 | + $this->_extends=$value; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function setGroupBy($value) |
| 128 | 128 | { |
| 129 | - $this->_groupBy = $value; |
|
| 129 | + $this->_groupBy=$value; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function setDiscriminator(TDiscriminator $value) |
| 144 | 144 | { |
| 145 | - $this->_discriminator = $value; |
|
| 145 | + $this->_discriminator=$value; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function addResultProperty(TResultProperty $property) |
| 153 | 153 | { |
| 154 | - $this->_columns[$property->getProperty()] = $property; |
|
| 154 | + $this->_columns[$property->getProperty()]=$property; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function createInstanceOfResult($registry) |
| 164 | 164 | { |
| 165 | - $handler = $registry->getTypeHandler($this->getClass()); |
|
| 165 | + $handler=$registry->getTypeHandler($this->getClass()); |
|
| 166 | 166 | try |
| 167 | 167 | { |
| 168 | 168 | if($handler!==null) |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | else |
| 171 | 171 | return $registry->createInstanceOf($this->getClass()); |
| 172 | 172 | } |
| 173 | - catch (TSqlMapException $e) |
|
| 173 | + catch(TSqlMapException $e) |
|
| 174 | 174 | { |
| 175 | 175 | throw new TSqlMapException( |
| 176 | 176 | 'sqlmap_unable_to_create_new_instance', |
@@ -186,16 +186,16 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function resolveSubMap($registry, $row) |
| 188 | 188 | { |
| 189 | - $subMap = $this; |
|
| 190 | - if(($disc = $this->getDiscriminator())!==null) |
|
| 189 | + $subMap=$this; |
|
| 190 | + if(($disc=$this->getDiscriminator())!==null) |
|
| 191 | 191 | { |
| 192 | - $value = $disc->getMapping()->getPropertyValue($registry, $row); |
|
| 193 | - $subMap = $disc->getSubMap((string)$value); |
|
| 192 | + $value=$disc->getMapping()->getPropertyValue($registry, $row); |
|
| 193 | + $subMap=$disc->getSubMap((string) $value); |
|
| 194 | 194 | |
| 195 | 195 | if($subMap===null) |
| 196 | - $subMap = $this; |
|
| 197 | - elseif($subMap !== $this) |
|
| 198 | - $subMap = $subMap->resolveSubMap($registry, $row); |
|
| 196 | + $subMap=$this; |
|
| 197 | + elseif($subMap!==$this) |
|
| 198 | + $subMap=$subMap->resolveSubMap($registry, $row); |
|
| 199 | 199 | } |
| 200 | 200 | return $subMap; |
| 201 | 201 | } |
@@ -113,8 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $userFile = include $this->_userFile; |
| 115 | 115 | $this->loadUserDataFromPhp($userFile); |
| 116 | - } |
|
| 117 | - else |
|
| 116 | + } else |
|
| 118 | 117 | { |
| 119 | 118 | $dom=new TXmlDocument; |
| 120 | 119 | $dom->loadFromFile($this->_userFile); |
@@ -310,8 +309,7 @@ discard block |
||
| 310 | 309 | $user=new TUser($this); |
| 311 | 310 | $user->setIsGuest(true); |
| 312 | 311 | return $user; |
| 313 | - } |
|
| 314 | - else |
|
| 312 | + } else |
|
| 315 | 313 | { |
| 316 | 314 | $username=strtolower($username); |
| 317 | 315 | if(isset($this->_users[$username])) |
@@ -322,8 +320,7 @@ discard block |
||
| 322 | 320 | if(isset($this->_roles[$username])) |
| 323 | 321 | $user->setRoles($this->_roles[$username]); |
| 324 | 322 | return $user; |
| 325 | - } |
|
| 326 | - else |
|
| 323 | + } else |
|
| 327 | 324 | return null; |
| 328 | 325 | } |
| 329 | 326 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
| 117 | 117 | { |
| 118 | - $userFile = include $this->_userFile; |
|
| 118 | + $userFile=include $this->_userFile; |
|
| 119 | 119 | $this->loadUserDataFromPhp($userFile); |
| 120 | 120 | } |
| 121 | 121 | else |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | foreach($config['users'] as $user) |
| 152 | 152 | { |
| 153 | - $name = trim(strtolower(isset($user['name'])?$user['name']:'')); |
|
| 154 | - $password = isset($user['password'])?$user['password']:''; |
|
| 155 | - $this->_users[$name] = $password; |
|
| 156 | - $roles = isset($user['roles'])?$user['roles']:''; |
|
| 153 | + $name=trim(strtolower(isset($user['name']) ? $user['name'] : '')); |
|
| 154 | + $password=isset($user['password']) ? $user['password'] : ''; |
|
| 155 | + $this->_users[$name]=$password; |
|
| 156 | + $roles=isset($user['roles']) ? $user['roles'] : ''; |
|
| 157 | 157 | if($roles!=='') |
| 158 | 158 | { |
| 159 | 159 | foreach(explode(',', $roles) as $role) |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | foreach($config['roles'] as $role) |
| 170 | 170 | { |
| 171 | - $name = isset($role['name'])?$role['name']:''; |
|
| 172 | - $users = isset($role['users'])?$role['users']:''; |
|
| 171 | + $name=isset($role['name']) ? $role['name'] : ''; |
|
| 172 | + $users=isset($role['users']) ? $role['users'] : ''; |
|
| 173 | 173 | foreach(explode(',', $users) as $user) |
| 174 | 174 | { |
| 175 | 175 | if(($user=trim($user))!=='') |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | if(is_array($data) && count($data)===2) |
| 347 | 347 | { |
| 348 | 348 | list($username, $token)=$data; |
| 349 | - if(isset($this->_users[$username]) && $token===md5($username . $this->_users[$username])) |
|
| 349 | + if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username])) |
|
| 350 | 350 | return $this->getUser($username); |
| 351 | 351 | } |
| 352 | 352 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $username=strtolower($user->getName()); |
| 365 | 365 | if(isset($this->_users[$username])) |
| 366 | 366 | { |
| 367 | - $data=[$username,md5($username . $this->_users[$username])]; |
|
| 367 | + $data=[$username, md5($username.$this->_users[$username])]; |
|
| 368 | 368 | $cookie->setValue(serialize($data)); |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -112,8 +112,7 @@ |
||
| 112 | 112 | && strlen($datetime[1]) == 1) |
| 113 | 113 | { |
| 114 | 114 | $pattern = $datetime; |
| 115 | - } |
|
| 116 | - else //no subpattern, try the presets |
|
| 115 | + } else //no subpattern, try the presets |
|
| 117 | 116 | $pattern = $this->getPreset($string); |
| 118 | 117 | |
| 119 | 118 | //no presets found, use the string as the pattern |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | * A set of pattern presets and their respective formatting shorthand. |
| 73 | 73 | * @var array |
| 74 | 74 | */ |
| 75 | - private static $_patternPresets = [ |
|
| 76 | - 'fulldate'=>'P','full'=>'P', |
|
| 77 | - 'longdate'=>'D','long'=>'d', |
|
| 78 | - 'mediumdate'=>'p','medium'=>'p', |
|
| 79 | - 'shortdate'=>'d','short'=>'d', |
|
| 75 | + private static $_patternPresets=[ |
|
| 76 | + 'fulldate'=>'P', 'full'=>'P', |
|
| 77 | + 'longdate'=>'D', 'long'=>'d', |
|
| 78 | + 'mediumdate'=>'p', 'medium'=>'p', |
|
| 79 | + 'shortdate'=>'d', 'short'=>'d', |
|
| 80 | 80 | 'fulltime'=>'Q', 'longtime'=>'T', |
| 81 | 81 | 'mediumtime'=>'q', 'shorttime'=>'t']; |
| 82 | 82 | |
@@ -95,35 +95,35 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function getPattern() |
| 97 | 97 | { |
| 98 | - $string = $this->getViewState('Pattern', ''); |
|
| 98 | + $string=$this->getViewState('Pattern', ''); |
|
| 99 | 99 | |
| 100 | - $pattern = null; |
|
| 100 | + $pattern=null; |
|
| 101 | 101 | |
| 102 | 102 | //try the subpattern of "date time" presets |
| 103 | - $subpatterns = explode(' ', $string, 2); |
|
| 104 | - $datetime = []; |
|
| 103 | + $subpatterns=explode(' ', $string, 2); |
|
| 104 | + $datetime=[]; |
|
| 105 | 105 | if(count($subpatterns)==2) |
| 106 | 106 | { |
| 107 | - $datetime[] = $this->getPreset($subpatterns[0]); |
|
| 108 | - $datetime[] = $this->getPreset($subpatterns[1]); |
|
| 107 | + $datetime[]=$this->getPreset($subpatterns[0]); |
|
| 108 | + $datetime[]=$this->getPreset($subpatterns[1]); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | //we have a good subpattern |
| 112 | - if(count($datetime) == 2 |
|
| 113 | - && strlen($datetime[0]) == 1 |
|
| 114 | - && strlen($datetime[1]) == 1) |
|
| 112 | + if(count($datetime)==2 |
|
| 113 | + && strlen($datetime[0])==1 |
|
| 114 | + && strlen($datetime[1])==1) |
|
| 115 | 115 | { |
| 116 | - $pattern = $datetime; |
|
| 116 | + $pattern=$datetime; |
|
| 117 | 117 | } |
| 118 | 118 | else //no subpattern, try the presets |
| 119 | - $pattern = $this->getPreset($string); |
|
| 119 | + $pattern=$this->getPreset($string); |
|
| 120 | 120 | |
| 121 | 121 | //no presets found, use the string as the pattern |
| 122 | 122 | //and let the DateFormat handle it. |
| 123 | 123 | if($pattern===null) |
| 124 | - $pattern = $string; |
|
| 125 | - if (!is_array($pattern) && strlen($pattern) == 0) |
|
| 126 | - $pattern = null; |
|
| 124 | + $pattern=$string; |
|
| 125 | + if(!is_array($pattern) && strlen($pattern)==0) |
|
| 126 | + $pattern=null; |
|
| 127 | 127 | return $pattern; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function getPreset($string) |
| 136 | 136 | { |
| 137 | - $string = strtolower($string); |
|
| 137 | + $string=strtolower($string); |
|
| 138 | 138 | foreach(self::$_patternPresets as $pattern => $preset) |
| 139 | 139 | { |
| 140 | - if($string == $pattern) |
|
| 140 | + if($string==$pattern) |
|
| 141 | 141 | return $preset; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function getValue() |
| 150 | 150 | { |
| 151 | - $value = $this->getViewState('Value', ''); |
|
| 151 | + $value=$this->getViewState('Value', ''); |
|
| 152 | 152 | if(empty($value)) |
| 153 | 153 | { |
| 154 | - $defaultText = $this->getDefaultText(); |
|
| 154 | + $defaultText=$this->getDefaultText(); |
|
| 155 | 155 | if(empty($defaultText)) |
| 156 | 156 | return time(); |
| 157 | 157 | } |
@@ -219,29 +219,29 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function getFormattedDate() |
| 221 | 221 | { |
| 222 | - $value = $this->getValue(); |
|
| 223 | - $defaultText = $this->getDefaultText(); |
|
| 222 | + $value=$this->getValue(); |
|
| 223 | + $defaultText=$this->getDefaultText(); |
|
| 224 | 224 | if(empty($value) && !empty($defaultText)) |
| 225 | 225 | return $this->getDefaultText(); |
| 226 | 226 | |
| 227 | - $app = $this->getApplication()->getGlobalization(); |
|
| 227 | + $app=$this->getApplication()->getGlobalization(); |
|
| 228 | 228 | |
| 229 | 229 | //initialized the default class wide formatter |
| 230 | 230 | if(self::$formatter===null) |
| 231 | - self::$formatter = new DateFormat($app->getCulture()); |
|
| 231 | + self::$formatter=new DateFormat($app->getCulture()); |
|
| 232 | 232 | |
| 233 | - $culture = $this->getCulture(); |
|
| 233 | + $culture=$this->getCulture(); |
|
| 234 | 234 | |
| 235 | 235 | //return the specific cultural formatted date time |
| 236 | - if(strlen($culture) && $app->getCulture() !== $culture) |
|
| 236 | + if(strlen($culture) && $app->getCulture()!==$culture) |
|
| 237 | 237 | { |
| 238 | - $formatter = new DateFormat($culture); |
|
| 238 | + $formatter=new DateFormat($culture); |
|
| 239 | 239 | return $formatter->format($value, |
| 240 | 240 | $this->getPattern(), |
| 241 | 241 | $this->getCharset()); |
| 242 | 242 | } |
| 243 | 243 | //return the application wide culture formatted date time. |
| 244 | - $result = self::$formatter->format($value, |
|
| 244 | + $result=self::$formatter->format($value, |
|
| 245 | 245 | $this->getPattern(), |
| 246 | 246 | $this->getCharset()); |
| 247 | 247 | return $result; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $status=TPropertyValue::ensureInteger($status); |
| 282 | 282 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
| 283 | 283 | $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
| 284 | - }else{ |
|
| 284 | + } else{ |
|
| 285 | 285 | if($reason===null || $reason==='') { |
| 286 | 286 | throw new TInvalidDataValueException("response_status_reason_missing"); |
| 287 | 287 | } |
@@ -377,8 +377,7 @@ discard block |
||
| 377 | 377 | { |
| 378 | 378 | foreach($headers as $h) |
| 379 | 379 | header($h); |
| 380 | - } |
|
| 381 | - else |
|
| 380 | + } else |
|
| 382 | 381 | { |
| 383 | 382 | header('Pragma: public'); |
| 384 | 383 | header('Expires: 0'); |
@@ -488,13 +487,11 @@ discard block |
||
| 488 | 487 | { |
| 489 | 488 | $this->_bufferOutput = false; |
| 490 | 489 | ob_end_flush(); |
| 491 | - } |
|
| 492 | - else |
|
| 490 | + } else |
|
| 493 | 491 | ob_flush(); |
| 494 | 492 | flush(); |
| 495 | 493 | } |
| 496 | - } |
|
| 497 | - else |
|
| 494 | + } else |
|
| 498 | 495 | flush(); |
| 499 | 496 | } |
| 500 | 497 | |
@@ -645,8 +642,7 @@ discard block |
||
| 645 | 642 | $cookie->getSecure(), |
| 646 | 643 | $cookie->getHttpOnly() |
| 647 | 644 | ); |
| 648 | - } |
|
| 649 | - else { |
|
| 645 | + } else { |
|
| 650 | 646 | setcookie( |
| 651 | 647 | $cookie->getName(), |
| 652 | 648 | $cookie->getValue(), |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | class THttpResponse extends \Prado\TModule implements \Prado\IO\ITextWriter |
| 68 | 68 | { |
| 69 | - const DEFAULT_CONTENTTYPE = 'text/html'; |
|
| 70 | - const DEFAULT_CHARSET = 'UTF-8'; |
|
| 69 | + const DEFAULT_CONTENTTYPE='text/html'; |
|
| 70 | + const DEFAULT_CHARSET='UTF-8'; |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * @var The differents defined status code by RFC 2616 {@link http://www.faqs.org/rfcs/rfc2616} |
| 74 | 74 | */ |
| 75 | - private static $HTTP_STATUS_CODES = [ |
|
| 75 | + private static $HTTP_STATUS_CODES=[ |
|
| 76 | 76 | 100 => 'Continue', 101 => 'Switching Protocols', |
| 77 | 77 | 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |
| 78 | 78 | 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function setCacheControl($value) |
| 205 | 205 | { |
| 206 | - session_cache_limiter(TPropertyValue::ensureEnum($value, ['none','nocache','private','private_no_expire','public'])); |
|
| 206 | + session_cache_limiter(TPropertyValue::ensureEnum($value, ['none', 'nocache', 'private', 'private_no_expire', 'public'])); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function setContentType($type) |
| 213 | 213 | { |
| 214 | - if ($this->_contentTypeHeaderSent) |
|
| 214 | + if($this->_contentTypeHeaderSent) |
|
| 215 | 215 | throw new \Exception('Unable to alter content-type as it has been already sent'); |
| 216 | - $this->_contentType = $type; |
|
| 216 | + $this->_contentType=$type; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setCharset($charset) |
| 239 | 239 | { |
| 240 | - $this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset; |
|
| 240 | + $this->_charset=(strToLower($charset)==='false') ? false : (string) $charset; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function setStatusCode($status, $reason=null) |
| 280 | 280 | { |
| 281 | - if ($this->_httpHeaderSent) |
|
| 281 | + if($this->_httpHeaderSent) |
|
| 282 | 282 | throw new \Exception('Unable to alter response as HTTP header already sent'); |
| 283 | 283 | $status=TPropertyValue::ensureInteger($status); |
| 284 | 284 | if(isset(self::$HTTP_STATUS_CODES[$status])) { |
| 285 | 285 | $this->_reason=self::$HTTP_STATUS_CODES[$status]; |
| 286 | - }else{ |
|
| 286 | + } else { |
|
| 287 | 287 | if($reason===null || $reason==='') { |
| 288 | 288 | throw new TInvalidDataValueException("response_status_reason_missing"); |
| 289 | 289 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | public function write($str) |
| 322 | 322 | { |
| 323 | 323 | // when starting output make sure we send the headers first |
| 324 | - if (!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
| 324 | + if(!$this->_bufferOutput and !$this->_httpHeaderSent) |
|
| 325 | 325 | $this->ensureHeadersSent(); |
| 326 | 326 | echo $str; |
| 327 | 327 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $clientFileName=basename($clientFileName); |
| 373 | 373 | |
| 374 | 374 | if($fileSize===null || $fileSize < 0) |
| 375 | - $fileSize = ($content===null?filesize($fileName):strlen($content)); |
|
| 375 | + $fileSize=($content===null ?filesize($fileName) : strlen($content)); |
|
| 376 | 376 | |
| 377 | 377 | $this->sendHttpHeader(); |
| 378 | 378 | if(is_array($headers)) |
@@ -386,11 +386,11 @@ discard block |
||
| 386 | 386 | header('Expires: 0'); |
| 387 | 387 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 388 | 388 | header("Content-Type: $mimeType"); |
| 389 | - $this->_contentTypeHeaderSent = true; |
|
| 389 | + $this->_contentTypeHeaderSent=true; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - header('Content-Length: ' . $fileSize); |
|
| 393 | - header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\""); |
|
| 392 | + header('Content-Length: '.$fileSize); |
|
| 393 | + header("Content-Disposition: ".($forceDownload ? 'attachment' : 'inline')."; filename=\"$clientFileName\""); |
|
| 394 | 394 | header('Content-Transfer-Encoding: binary'); |
| 395 | 395 | if($content===null) |
| 396 | 396 | readfile($fileName); |
@@ -430,25 +430,25 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | // Under IIS, explicitly send an HTTP response including the status code |
| 432 | 432 | // this is handled automatically by PHP on Apache and others |
| 433 | - $isIIS = (stripos($this->getRequest()->getServerSoftware(), "microsoft-iis") !== false); |
|
| 433 | + $isIIS=(stripos($this->getRequest()->getServerSoftware(), "microsoft-iis")!==false); |
|
| 434 | 434 | if($url[0]==='/') |
| 435 | - $url=$this->getRequest()->getBaseUrl() . $url; |
|
| 436 | - if ($this->_status >= 300 && $this->_status < 400) |
|
| 435 | + $url=$this->getRequest()->getBaseUrl().$url; |
|
| 436 | + if($this->_status >= 300 && $this->_status < 400) |
|
| 437 | 437 | { |
| 438 | 438 | // The status code has been modified to a valid redirection status, send it |
| 439 | 439 | if($isIIS) |
| 440 | 440 | { |
| 441 | - header('HTTP/1.1 ' . $this->_status . ' ' . self::$HTTP_STATUS_CODES[ |
|
| 441 | + header('HTTP/1.1 '.$this->_status.' '.self::$HTTP_STATUS_CODES[ |
|
| 442 | 442 | array_key_exists($this->_status, self::$HTTP_STATUS_CODES) |
| 443 | 443 | ? $this->_status |
| 444 | 444 | : 302 |
| 445 | 445 | ]); |
| 446 | 446 | } |
| 447 | - header('Location: ' . str_replace('&', '&', $url), true, $this->_status); |
|
| 447 | + header('Location: '.str_replace('&', '&', $url), true, $this->_status); |
|
| 448 | 448 | } else { |
| 449 | 449 | if($isIIS) |
| 450 | - header('HTTP/1.1 302 ' . self::$HTTP_STATUS_CODES[302]); |
|
| 451 | - header('Location: ' . str_replace('&', '&', $url)); |
|
| 450 | + header('HTTP/1.1 302 '.self::$HTTP_STATUS_CODES[302]); |
|
| 451 | + header('Location: '.str_replace('&', '&', $url)); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | if(!$this->getApplication()->getRequestCompleted()) |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | /** |
| 471 | 471 | * Flush the response contents and headers. |
| 472 | 472 | */ |
| 473 | - public function flush($continueBuffering = true) |
|
| 473 | + public function flush($continueBuffering=true) |
|
| 474 | 474 | { |
| 475 | 475 | if($this->getHasAdapter()) |
| 476 | 476 | $this->_adapter->flushContent($continueBuffering); |
@@ -492,18 +492,18 @@ discard block |
||
| 492 | 492 | * This method is used internally. Please use {@link flush} instead. |
| 493 | 493 | * @param boolean whether to continue buffering after flush if buffering was active |
| 494 | 494 | */ |
| 495 | - public function flushContent($continueBuffering = true) |
|
| 495 | + public function flushContent($continueBuffering=true) |
|
| 496 | 496 | { |
| 497 | 497 | Prado::trace("Flushing output", 'Prado\Web\THttpResponse'); |
| 498 | 498 | $this->ensureHeadersSent(); |
| 499 | 499 | if($this->_bufferOutput) |
| 500 | 500 | { |
| 501 | 501 | // avoid forced send of http headers (ob_flush() does that) if there's no output yet |
| 502 | - if (ob_get_length()>0) |
|
| 502 | + if(ob_get_length() > 0) |
|
| 503 | 503 | { |
| 504 | - if (!$continueBuffering) |
|
| 504 | + if(!$continueBuffering) |
|
| 505 | 505 | { |
| 506 | - $this->_bufferOutput = false; |
|
| 506 | + $this->_bufferOutput=false; |
|
| 507 | 507 | ob_end_flush(); |
| 508 | 508 | } |
| 509 | 509 | else |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | */ |
| 521 | 521 | protected function ensureHttpHeaderSent() |
| 522 | 522 | { |
| 523 | - if (!$this->_httpHeaderSent) |
|
| 523 | + if(!$this->_httpHeaderSent) |
|
| 524 | 524 | $this->sendHttpHeader(); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -530,12 +530,12 @@ discard block |
||
| 530 | 530 | protected function sendHttpHeader() |
| 531 | 531 | { |
| 532 | 532 | $protocol=$this->getRequest()->getHttpProtocolVersion(); |
| 533 | - if($this->getRequest()->getHttpProtocolVersion() === null) |
|
| 533 | + if($this->getRequest()->getHttpProtocolVersion()===null) |
|
| 534 | 534 | $protocol='HTTP/1.1'; |
| 535 | 535 | |
| 536 | - header($protocol . ' ' . $this->_status . ' ' . $this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 536 | + header($protocol.' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status)); |
|
| 537 | 537 | |
| 538 | - $this->_httpHeaderSent = true; |
|
| 538 | + $this->_httpHeaderSent=true; |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | protected function ensureContentTypeHeaderSent() |
| 545 | 545 | { |
| 546 | - if (!$this->_contentTypeHeaderSent) |
|
| 546 | + if(!$this->_contentTypeHeaderSent) |
|
| 547 | 547 | $this->sendContentTypeHeader(); |
| 548 | 548 | } |
| 549 | 549 | |
@@ -552,20 +552,20 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | protected function sendContentTypeHeader() |
| 554 | 554 | { |
| 555 | - $contentType=$this->_contentType===null?self::DEFAULT_CONTENTTYPE:$this->_contentType; |
|
| 555 | + $contentType=$this->_contentType===null ?self::DEFAULT_CONTENTTYPE : $this->_contentType; |
|
| 556 | 556 | $charset=$this->getCharset(); |
| 557 | - if($charset === false) { |
|
| 558 | - $this->appendHeader('Content-Type: ' . $contentType); |
|
| 557 | + if($charset===false) { |
|
| 558 | + $this->appendHeader('Content-Type: '.$contentType); |
|
| 559 | 559 | return; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) |
| 563 | 563 | $charset=$globalization->getCharset(); |
| 564 | 564 | |
| 565 | - if($charset==='') $charset = self::DEFAULT_CHARSET; |
|
| 566 | - $this->appendHeader('Content-Type: ' . $contentType . ';charset=' . $charset); |
|
| 565 | + if($charset==='') $charset=self::DEFAULT_CHARSET; |
|
| 566 | + $this->appendHeader('Content-Type: '.$contentType.';charset='.$charset); |
|
| 567 | 567 | |
| 568 | - $this->_contentTypeHeaderSent = true; |
|
| 568 | + $this->_contentTypeHeaderSent=true; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | public function getContents() |
| 578 | 578 | { |
| 579 | 579 | Prado::trace("Retrieving output", 'Prado\Web\THttpResponse'); |
| 580 | - return $this->_bufferOutput?ob_get_contents():''; |
|
| 580 | + return $this->_bufferOutput ?ob_get_contents() : ''; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
@@ -596,19 +596,19 @@ discard block |
||
| 596 | 596 | */ |
| 597 | 597 | public function getHeaders($case=null) |
| 598 | 598 | { |
| 599 | - $result = []; |
|
| 600 | - $headers = headers_list(); |
|
| 599 | + $result=[]; |
|
| 600 | + $headers=headers_list(); |
|
| 601 | 601 | foreach($headers as $header) { |
| 602 | - $tmp = explode(':', $header); |
|
| 603 | - $key = trim(array_shift($tmp)); |
|
| 604 | - $value = trim(implode(':', $tmp)); |
|
| 602 | + $tmp=explode(':', $header); |
|
| 603 | + $key=trim(array_shift($tmp)); |
|
| 604 | + $value=trim(implode(':', $tmp)); |
|
| 605 | 605 | if(isset($result[$key])) |
| 606 | - $result[$key] .= ', ' . $value; |
|
| 606 | + $result[$key].=', '.$value; |
|
| 607 | 607 | else |
| 608 | - $result[$key] = $value; |
|
| 608 | + $result[$key]=$value; |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if($case !== null) |
|
| 611 | + if($case!==null) |
|
| 612 | 612 | return array_change_key_case($result, $case); |
| 613 | 613 | |
| 614 | 614 | return $result; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function setDecayRate($value) |
| 81 | 81 | { |
| 82 | - $decay = TPropertyValue::ensureFloat($value); |
|
| 82 | + $decay=TPropertyValue::ensureFloat($value); |
|
| 83 | 83 | if($decay < 0) |
| 84 | 84 | throw new TConfigurationException('callback_decay_be_not_negative', $this->getID()); |
| 85 | 85 | $this->setViewState('Decay', $decay); |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | protected function getTriggerOptions() |
| 92 | 92 | { |
| 93 | - $options = parent::getTriggerOptions(); |
|
| 94 | - $options['PropertyName'] = $this->getPropertyName(); |
|
| 95 | - $options['Interval'] = $this->getInterval(); |
|
| 96 | - $options['Decay'] = $this->getDecayRate(); |
|
| 93 | + $options=parent::getTriggerOptions(); |
|
| 94 | + $options['PropertyName']=$this->getPropertyName(); |
|
| 95 | + $options['Interval']=$this->getInterval(); |
|
| 96 | + $options['Decay']=$this->getDecayRate(); |
|
| 97 | 97 | return $options; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | public function getClientSide() |
| 37 | 37 | { |
| 38 | 38 | if($this->_clientSide===null) |
| 39 | - $this->_clientSide = $this->createClientSide(); |
|
| 39 | + $this->_clientSide=$this->createClientSide(); |
|
| 40 | 40 | return $this->_clientSide; |
| 41 | 41 | } |
| 42 | 42 | |