@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function save($state) |
52 | 52 | { |
53 | - $this->_page->setClientState(TPageStateFormatter::serialize($this->_page,$state)); |
|
53 | + $this->_page->setClientState(TPageStateFormatter::serialize($this->_page, $state)); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function load() |
62 | 62 | { |
63 | - if(($data=TPageStateFormatter::unserialize($this->_page,$this->_page->getRequestClientState()))!==null) |
|
63 | + if(($data=TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState()))!==null) |
|
64 | 64 | return $data; |
65 | 65 | else |
66 | - throw new THttpException(400,'pagestatepersister_pagestate_corrupted'); |
|
66 | + throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class THttpUtility |
20 | 20 | { |
21 | - private static $_encodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
22 | - private static $_decodeTable=array('<'=>'<','>'=>'>','"'=>'"'); |
|
23 | - private static $_stripTable=array('<'=>'','>'=>'','"'=>''); |
|
21 | + private static $_encodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
22 | + private static $_decodeTable=array('<'=>'<', '>'=>'>', '"'=>'"'); |
|
23 | + private static $_stripTable=array('<'=>'', '>'=>'', '"'=>''); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * HTML-encodes a string. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function htmlEncode($s) |
34 | 34 | { |
35 | - return strtr($s,self::$_encodeTable); |
|
35 | + return strtr($s, self::$_encodeTable); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function htmlDecode($s) |
45 | 45 | { |
46 | - return strtr($s,self::$_decodeTable); |
|
46 | + return strtr($s, self::$_decodeTable); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public static function htmlStrip($s) |
56 | 56 | { |
57 | - return strtr($s,self::$_stripTable); |
|
57 | + return strtr($s, self::$_stripTable); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Defines Prado class if not defined. |
27 | 27 | */ |
28 | -if(!class_exists('Prado',false)) |
|
28 | +if(!class_exists('Prado', false)) |
|
29 | 29 | { |
30 | 30 | /** |
31 | 31 | * Prado class. |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * cannot be found, if you have multiple autoloaders, Prado::autoload |
46 | 46 | * should be registered in the last. |
47 | 47 | */ |
48 | -spl_autoload_register(array('Prado','autoload')); |
|
48 | +spl_autoload_register(array('Prado', 'autoload')); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Initializes error and exception handlers |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * the object and method name as string |
45 | 45 | * @param array The array of arguments to the function call chain |
46 | 46 | */ |
47 | - public function addCall($method,$args) |
|
47 | + public function addCall($method, $args) |
|
48 | 48 | { |
49 | - $this->add(array($method,$args)); |
|
49 | + $this->add(array($method, $args)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $args=func_get_args(); |
94 | 94 | if($this->getCount()===0) |
95 | - return isset($args[0])?$args[0]:null; |
|
95 | + return isset($args[0]) ? $args[0] : null; |
|
96 | 96 | |
97 | 97 | if(!$this->_iterator) |
98 | 98 | { |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | do { |
104 | 104 | $handler=$this->_iterator->current(); |
105 | 105 | $this->_iterator->next(); |
106 | - if(is_array($handler[0])&&$handler[0][0] instanceof IClassBehavior) |
|
107 | - array_splice($handler[1],1,count($args),$args); |
|
106 | + if(is_array($handler[0]) && $handler[0][0] instanceof IClassBehavior) |
|
107 | + array_splice($handler[1], 1, count($args), $args); |
|
108 | 108 | else |
109 | - array_splice($handler[1],0,count($args),$args); |
|
109 | + array_splice($handler[1], 0, count($args), $args); |
|
110 | 110 | $handler[1][]=$this; |
111 | - $result=call_user_func_array($handler[0],$handler[1]); |
|
111 | + $result=call_user_func_array($handler[0], $handler[1]); |
|
112 | 112 | } while($this->_iterator->valid()); |
113 | 113 | else |
114 | - $result = $args[0]; |
|
114 | + $result=$args[0]; |
|
115 | 115 | return $result; |
116 | 116 | } |
117 | 117 | |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param string method name of the unspecified object method |
138 | 138 | * @param array arguments to the unspecified object method |
139 | 139 | */ |
140 | - public function __dycall($method,$args) |
|
140 | + public function __dycall($method, $args) |
|
141 | 141 | { |
142 | 142 | if($this->_method==$method) |
143 | - return call_user_func_array(array($this,'call'),$args); |
|
143 | + return call_user_func_array(array($this, 'call'), $args); |
|
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | $this->_owner=$owner; |
45 | 45 | foreach($this->events() as $event=>$handler) |
46 | - $owner->attachEventHandler($event,array($this,$handler)); |
|
46 | + $owner->attachEventHandler($event, array($this, $handler)); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function detach($owner) |
57 | 57 | { |
58 | 58 | foreach($this->events() as $event=>$handler) |
59 | - $owner->detachEventHandler($event,array($this,$handler)); |
|
59 | + $owner->detachEventHandler($event, array($this, $handler)); |
|
60 | 60 | $this->_owner=null; |
61 | 61 | } |
62 | 62 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $this->loadParameters($config); |
62 | 62 | if($this->_paramFile!==null) |
63 | 63 | { |
64 | - $configFile = null; |
|
64 | + $configFile=null; |
|
65 | 65 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_XML && ($cache=$this->getApplication()->getCache())!==null) |
66 | 66 | { |
67 | 67 | $cacheKey='TParameterModule:'.$this->_paramFile; |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | { |
70 | 70 | $configFile=new TXmlDocument; |
71 | 71 | $configFile->loadFromFile($this->_paramFile); |
72 | - $cache->set($cacheKey,$configFile,0,new TFileCacheDependency($this->_paramFile)); |
|
72 | + $cache->set($cacheKey, $configFile, 0, new TFileCacheDependency($this->_paramFile)); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | else |
76 | 76 | { |
77 | 77 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
78 | 78 | { |
79 | - $configFile = include $this->_paramFile; |
|
79 | + $configFile=include $this->_paramFile; |
|
80 | 80 | } |
81 | 81 | else |
82 | 82 | { |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | { |
104 | 104 | if(is_array($parameter) && isset($parameter['class'])) |
105 | 105 | { |
106 | - $properties = isset($parameter['properties'])?$parameter['properties']:array(); |
|
107 | - $parameters[$id]=array($parameter['class'],$properties); |
|
106 | + $properties=isset($parameter['properties']) ? $parameter['properties'] : array(); |
|
107 | + $parameters[$id]=array($parameter['class'], $properties); |
|
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | - $parameters[$id] = $parameter; |
|
111 | + $parameters[$id]=$parameter; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $parameters[$id]=$value; |
128 | 128 | } |
129 | 129 | else |
130 | - $parameters[$id]=array($type,$properties->toArray()); |
|
130 | + $parameters[$id]=array($type, $properties->toArray()); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | { |
139 | 139 | $component=Prado::createComponent($parameter[0]); |
140 | 140 | foreach($parameter[1] as $name=>$value) |
141 | - $component->setSubProperty($name,$value); |
|
142 | - $appParams->add($id,$component); |
|
141 | + $component->setSubProperty($name, $value); |
|
142 | + $appParams->add($id, $component); |
|
143 | 143 | } |
144 | 144 | else |
145 | - $appParams->add($id,$parameter); |
|
145 | + $appParams->add($id, $parameter); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | { |
165 | 165 | if($this->_initialized) |
166 | 166 | throw new TInvalidOperationException('parametermodule_parameterfile_unchangeable'); |
167 | - else if(($this->_paramFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null || !is_file($this->_paramFile)) |
|
168 | - throw new TConfigurationException('parametermodule_parameterfile_invalid',$value); |
|
167 | + else if(($this->_paramFile=Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt()))===null || !is_file($this->_paramFile)) |
|
168 | + throw new TConfigurationException('parametermodule_parameterfile_invalid', $value); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |
@@ -71,14 +71,12 @@ discard block |
||
71 | 71 | $configFile->loadFromFile($this->_paramFile); |
72 | 72 | $cache->set($cacheKey,$configFile,0,new TFileCacheDependency($this->_paramFile)); |
73 | 73 | } |
74 | - } |
|
75 | - else |
|
74 | + } else |
|
76 | 75 | { |
77 | 76 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
78 | 77 | { |
79 | 78 | $configFile = include $this->_paramFile; |
80 | - } |
|
81 | - else |
|
79 | + } else |
|
82 | 80 | { |
83 | 81 | $configFile=new TXmlDocument; |
84 | 82 | $configFile->loadFromFile($this->_paramFile); |
@@ -105,14 +103,12 @@ discard block |
||
105 | 103 | { |
106 | 104 | $properties = isset($parameter['properties'])?$parameter['properties']:array(); |
107 | 105 | $parameters[$id]=array($parameter['class'],$properties); |
108 | - } |
|
109 | - else |
|
106 | + } else |
|
110 | 107 | { |
111 | 108 | $parameters[$id] = $parameter; |
112 | 109 | } |
113 | 110 | } |
114 | - } |
|
115 | - else if($config instanceof TXmlElement) |
|
111 | + } else if($config instanceof TXmlElement) |
|
116 | 112 | { |
117 | 113 | foreach($config->getElementsByTagName('parameter') as $node) |
118 | 114 | { |
@@ -125,8 +121,7 @@ discard block |
||
125 | 121 | $parameters[$id]=$node; |
126 | 122 | else |
127 | 123 | $parameters[$id]=$value; |
128 | - } |
|
129 | - else |
|
124 | + } else |
|
130 | 125 | $parameters[$id]=array($type,$properties->toArray()); |
131 | 126 | } |
132 | 127 | } |
@@ -140,8 +135,7 @@ discard block |
||
140 | 135 | foreach($parameter[1] as $name=>$value) |
141 | 136 | $component->setSubProperty($name,$value); |
142 | 137 | $appParams->add($id,$component); |
143 | - } |
|
144 | - else |
|
138 | + } else |
|
145 | 139 | $appParams->add($id,$parameter); |
146 | 140 | } |
147 | 141 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) |
65 | 65 | { |
66 | - $phpConfig = include $this->_configFile; |
|
66 | + $phpConfig=include $this->_configFile; |
|
67 | 67 | $this->loadConfig($phpConfig); |
68 | 68 | } |
69 | 69 | else |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | } |
75 | 75 | } |
76 | 76 | else |
77 | - throw new TConfigurationException('logrouter_configfile_invalid',$this->_configFile); |
|
77 | + throw new TConfigurationException('logrouter_configfile_invalid', $this->_configFile); |
|
78 | 78 | } |
79 | 79 | $this->loadConfig($config); |
80 | - $this->getApplication()->attachEventHandler('OnEndRequest',array($this,'collectLogs')); |
|
80 | + $this->getApplication()->attachEventHandler('OnEndRequest', array($this, 'collectLogs')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | { |
94 | 94 | foreach($config['routes'] as $route) |
95 | 95 | { |
96 | - $properties = isset($route['properties'])?$route['properties']:array(); |
|
96 | + $properties=isset($route['properties']) ? $route['properties'] : array(); |
|
97 | 97 | if(!isset($route['class'])) |
98 | 98 | throw new TConfigurationException('logrouter_routeclass_required'); |
99 | 99 | $route=Prado::createComponent($route['class']); |
100 | 100 | if(!($route instanceof TLogRoute)) |
101 | 101 | throw new TConfigurationException('logrouter_routetype_invalid'); |
102 | 102 | foreach($properties as $name=>$value) |
103 | - $route->setSubproperty($name,$value); |
|
103 | + $route->setSubproperty($name, $value); |
|
104 | 104 | $this->_routes[]=$route; |
105 | 105 | $route->init($route); |
106 | 106 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if(!($route instanceof TLogRoute)) |
118 | 118 | throw new TConfigurationException('logrouter_routetype_invalid'); |
119 | 119 | foreach($properties as $name=>$value) |
120 | - $route->setSubproperty($name,$value); |
|
120 | + $route->setSubproperty($name, $value); |
|
121 | 121 | $this->_routes[]=$route; |
122 | 122 | $route->init($routeConfig); |
123 | 123 | } |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function setConfigFile($value) |
155 | 155 | { |
156 | - if(($this->_configFile=Prado::getPathOfNamespace($value,$this->getApplication()->getConfigurationFileExt()))===null) |
|
157 | - throw new TConfigurationException('logrouter_configfile_invalid',$value); |
|
156 | + if(($this->_configFile=Prado::getPathOfNamespace($value, $this->getApplication()->getConfigurationFileExt()))===null) |
|
157 | + throw new TConfigurationException('logrouter_configfile_invalid', $value); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | { |
256 | 256 | $this->_levels=null; |
257 | 257 | $levels=strtolower($levels); |
258 | - foreach(explode(',',$levels) as $level) |
|
258 | + foreach(explode(',', $levels) as $level) |
|
259 | 259 | { |
260 | 260 | $level=trim($level); |
261 | 261 | if(isset(self::$_levelValues[$level])) |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | else |
284 | 284 | { |
285 | 285 | $this->_categories=null; |
286 | - foreach(explode(',',$categories) as $category) |
|
286 | + foreach(explode(',', $categories) as $category) |
|
287 | 287 | { |
288 | 288 | if(($category=trim($category))!=='') |
289 | 289 | $this->_categories[]=$category; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | protected function getLevelName($level) |
299 | 299 | { |
300 | - return isset(self::$_levelNames[$level])?self::$_levelNames[$level]:'Unknown'; |
|
300 | + return isset(self::$_levelNames[$level]) ? self::$_levelNames[$level] : 'Unknown'; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | */ |
307 | 307 | protected function getLevelValue($level) |
308 | 308 | { |
309 | - return isset(self::$_levelValues[$level])?self::$_levelValues[$level]:0; |
|
309 | + return isset(self::$_levelValues[$level]) ? self::$_levelValues[$level] : 0; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @param integer timestamp |
318 | 318 | * @return string formatted message |
319 | 319 | */ |
320 | - protected function formatLogMessage($message,$level,$category,$time) |
|
320 | + protected function formatLogMessage($message, $level, $category, $time) |
|
321 | 321 | { |
322 | - return @date('M d H:i:s',$time).' ['.$this->getLevelName($level).'] ['.$category.'] '.$message."\n"; |
|
322 | + return @date('M d H:i:s', $time).' ['.$this->getLevelName($level).'] ['.$category.'] '.$message."\n"; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | public function collectLogs(TLogger $logger) |
330 | 330 | { |
331 | - $logs=$logger->getLogs($this->getLevels(),$this->getCategories()); |
|
331 | + $logs=$logger->getLogs($this->getLevels(), $this->getCategories()); |
|
332 | 332 | if(!empty($logs)) |
333 | 333 | $this->processLogs($logs); |
334 | 334 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | public function setLogPath($value) |
400 | 400 | { |
401 | 401 | if(($this->_logPath=Prado::getPathOfNamespace($value))===null || !is_dir($this->_logPath) || !is_writable($this->_logPath)) |
402 | - throw new TConfigurationException('filelogroute_logpath_invalid',$value); |
|
402 | + throw new TConfigurationException('filelogroute_logpath_invalid', $value); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | public function setMaxFileSize($value) |
434 | 434 | { |
435 | 435 | $this->_maxFileSize=TPropertyValue::ensureInteger($value); |
436 | - if($this->_maxFileSize<=0) |
|
436 | + if($this->_maxFileSize <= 0) |
|
437 | 437 | throw new TInvalidDataValueException('filelogroute_maxfilesize_invalid'); |
438 | 438 | } |
439 | 439 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | public function setMaxLogFiles($value) |
452 | 452 | { |
453 | 453 | $this->_maxLogFiles=TPropertyValue::ensureInteger($value); |
454 | - if($this->_maxLogFiles<1) |
|
454 | + if($this->_maxLogFiles < 1) |
|
455 | 455 | throw new TInvalidDataValueException('filelogroute_maxlogfiles_invalid'); |
456 | 456 | } |
457 | 457 | |
@@ -462,10 +462,10 @@ discard block |
||
462 | 462 | protected function processLogs($logs) |
463 | 463 | { |
464 | 464 | $logFile=$this->getLogPath().DIRECTORY_SEPARATOR.$this->getLogFile(); |
465 | - if(@filesize($logFile)>$this->_maxFileSize*1024) |
|
465 | + if(@filesize($logFile) > $this->_maxFileSize * 1024) |
|
466 | 466 | $this->rotateFiles(); |
467 | 467 | foreach($logs as $log) |
468 | - error_log($this->formatLogMessage($log[0],$log[1],$log[2],$log[3]),3,$logFile); |
|
468 | + error_log($this->formatLogMessage($log[0], $log[1], $log[2], $log[3]), 3, $logFile); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | protected function rotateFiles() |
475 | 475 | { |
476 | 476 | $file=$this->getLogPath().DIRECTORY_SEPARATOR.$this->getLogFile(); |
477 | - for($i=$this->_maxLogFiles;$i>0;--$i) |
|
477 | + for($i=$this->_maxLogFiles; $i > 0; --$i) |
|
478 | 478 | { |
479 | 479 | $rotateFile=$file.'.'.$i; |
480 | 480 | if(is_file($rotateFile)) |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | if($i===$this->_maxLogFiles) |
483 | 483 | unlink($rotateFile); |
484 | 484 | else |
485 | - rename($rotateFile,$file.'.'.($i+1)); |
|
485 | + rename($rotateFile, $file.'.'.($i + 1)); |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | if(is_file($file)) |
489 | - rename($file,$file.'.1'); |
|
489 | + rename($file, $file.'.1'); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | { |
548 | 548 | $message=''; |
549 | 549 | foreach($logs as $log) |
550 | - $message.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]); |
|
551 | - $message=wordwrap($message,70); |
|
552 | - $returnPath = ini_get('sendmail_path') ? "Return-Path:{$this->_from}\r\n" : ''; |
|
550 | + $message.=$this->formatLogMessage($log[0], $log[1], $log[2], $log[3]); |
|
551 | + $message=wordwrap($message, 70); |
|
552 | + $returnPath=ini_get('sendmail_path') ? "Return-Path:{$this->_from}\r\n" : ''; |
|
553 | 553 | foreach($this->_emails as $email) |
554 | - mail($email,$this->getSubject(),$message,"From:{$this->_from}\r\n{$returnPath}"); |
|
554 | + mail($email, $this->getSubject(), $message, "From:{$this->_from}\r\n{$returnPath}"); |
|
555 | 555 | |
556 | 556 | } |
557 | 557 | |
@@ -574,10 +574,10 @@ discard block |
||
574 | 574 | else |
575 | 575 | { |
576 | 576 | $this->_emails=array(); |
577 | - foreach(explode(',',$emails) as $email) |
|
577 | + foreach(explode(',', $emails) as $email) |
|
578 | 578 | { |
579 | 579 | $email=trim($email); |
580 | - if(preg_match(self::EMAIL_PATTERN,$email)) |
|
580 | + if(preg_match(self::EMAIL_PATTERN, $email)) |
|
581 | 581 | $this->_emails[]=$email; |
582 | 582 | } |
583 | 583 | } |
@@ -637,24 +637,24 @@ discard block |
||
637 | 637 | public function processLogs($logs) |
638 | 638 | { |
639 | 639 | if(empty($logs) || $this->getApplication()->getMode()==='Performance') return; |
640 | - $first = $logs[0][3]; |
|
641 | - $even = true; |
|
642 | - $response = $this->getApplication()->getResponse(); |
|
640 | + $first=$logs[0][3]; |
|
641 | + $even=true; |
|
642 | + $response=$this->getApplication()->getResponse(); |
|
643 | 643 | $response->write($this->renderHeader()); |
644 | - for($i=0,$n=count($logs);$i<$n;++$i) |
|
644 | + for($i=0, $n=count($logs); $i < $n; ++$i) |
|
645 | 645 | { |
646 | - if ($i<$n-1) |
|
646 | + if($i < $n - 1) |
|
647 | 647 | { |
648 | - $timing['delta'] = $logs[$i+1][3] - $logs[$i][3]; |
|
649 | - $timing['total'] = $logs[$i+1][3] - $first; |
|
648 | + $timing['delta']=$logs[$i + 1][3] - $logs[$i][3]; |
|
649 | + $timing['total']=$logs[$i + 1][3] - $first; |
|
650 | 650 | } |
651 | 651 | else |
652 | 652 | { |
653 | - $timing['delta'] = '?'; |
|
654 | - $timing['total'] = $logs[$i][3] - $first; |
|
653 | + $timing['delta']='?'; |
|
654 | + $timing['total']=$logs[$i][3] - $first; |
|
655 | 655 | } |
656 | - $timing['even'] = !($even = !$even); |
|
657 | - $response->write($this->renderMessage($logs[$i],$timing)); |
|
656 | + $timing['even']=!($even=!$even); |
|
657 | + $response->write($this->renderMessage($logs[$i], $timing)); |
|
658 | 658 | } |
659 | 659 | $response->write($this->renderFooter()); |
660 | 660 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | */ |
665 | 665 | public function setCssClass($value) |
666 | 666 | { |
667 | - $this->_cssClass = TPropertyValue::ensureString($value); |
|
667 | + $this->_cssClass=TPropertyValue::ensureString($value); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
@@ -677,10 +677,10 @@ discard block |
||
677 | 677 | |
678 | 678 | protected function renderHeader() |
679 | 679 | { |
680 | - $string = ''; |
|
680 | + $string=''; |
|
681 | 681 | if($className=$this->getCssClass()) |
682 | 682 | { |
683 | - $string = <<<EOD |
|
683 | + $string=<<<EOD |
|
684 | 684 | <table class="$className"> |
685 | 685 | <tr class="header"> |
686 | 686 | <th colspan="5"> |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | } |
695 | 695 | else |
696 | 696 | { |
697 | - $string = <<<EOD |
|
697 | + $string=<<<EOD |
|
698 | 698 | <table cellspacing="0" cellpadding="2" border="0" width="100%" style="table-layout:auto"> |
699 | 699 | <tr> |
700 | 700 | <th style="background-color: black; color:white;" colspan="5"> |
@@ -711,16 +711,16 @@ discard block |
||
711 | 711 | |
712 | 712 | protected function renderMessage($log, $info) |
713 | 713 | { |
714 | - $string = ''; |
|
715 | - $total = sprintf('%0.6f', $info['total']); |
|
716 | - $delta = sprintf('%0.6f', $info['delta']); |
|
717 | - $msg = preg_replace('/\(line[^\)]+\)$/','',$log[0]); //remove line number info |
|
718 | - $msg = THttpUtility::htmlEncode($msg); |
|
714 | + $string=''; |
|
715 | + $total=sprintf('%0.6f', $info['total']); |
|
716 | + $delta=sprintf('%0.6f', $info['delta']); |
|
717 | + $msg=preg_replace('/\(line[^\)]+\)$/', '', $log[0]); //remove line number info |
|
718 | + $msg=THttpUtility::htmlEncode($msg); |
|
719 | 719 | if($this->getCssClass()) |
720 | 720 | { |
721 | - $colorCssClass = $log[1]; |
|
722 | - $messageCssClass = $info['even'] ? 'even' : 'odd'; |
|
723 | - $string = <<<EOD |
|
721 | + $colorCssClass=$log[1]; |
|
722 | + $messageCssClass=$info['even'] ? 'even' : 'odd'; |
|
723 | + $string=<<<EOD |
|
724 | 724 | <tr class="message level$colorCssClass $messageCssClass"> |
725 | 725 | <td class="code"> </td> |
726 | 726 | <td class="category">{$log[2]}</td> |
@@ -732,9 +732,9 @@ discard block |
||
732 | 732 | } |
733 | 733 | else |
734 | 734 | { |
735 | - $bgcolor = $info['even'] ? "#fff" : "#eee"; |
|
736 | - $color = $this->getColorLevel($log[1]); |
|
737 | - $string = <<<EOD |
|
735 | + $bgcolor=$info['even'] ? "#fff" : "#eee"; |
|
736 | + $color=$this->getColorLevel($log[1]); |
|
737 | + $string=<<<EOD |
|
738 | 738 | <tr style="background-color: {$bgcolor}; color:#000"> |
739 | 739 | <td style="border:1px solid silver;background-color: $color;"> </td> |
740 | 740 | <td>{$log[2]}</td> |
@@ -764,25 +764,25 @@ discard block |
||
764 | 764 | |
765 | 765 | protected function renderFooter() |
766 | 766 | { |
767 | - $string = ''; |
|
767 | + $string=''; |
|
768 | 768 | if($this->getCssClass()) |
769 | 769 | { |
770 | - $string .= '<tr class="footer"><td colspan="5">'; |
|
770 | + $string.='<tr class="footer"><td colspan="5">'; |
|
771 | 771 | foreach(self::$_levelValues as $name => $level) |
772 | 772 | { |
773 | - $string .= '<span class="level'.$level.'">'.strtoupper($name)."</span>"; |
|
773 | + $string.='<span class="level'.$level.'">'.strtoupper($name)."</span>"; |
|
774 | 774 | } |
775 | 775 | } |
776 | 776 | else |
777 | 777 | { |
778 | - $string .= "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">"; |
|
778 | + $string.="<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">"; |
|
779 | 779 | foreach(self::$_levelValues as $name => $level) |
780 | 780 | { |
781 | - $string .= "<span style=\"color:white; border:1px solid white; background-color:".$this->getColorLevel($level); |
|
782 | - $string .= ";margin: 0.5em; padding:0.01em;\">".strtoupper($name)."</span>"; |
|
781 | + $string.="<span style=\"color:white; border:1px solid white; background-color:".$this->getColorLevel($level); |
|
782 | + $string.=";margin: 0.5em; padding:0.01em;\">".strtoupper($name)."</span>"; |
|
783 | 783 | } |
784 | 784 | } |
785 | - $string .= '</td></tr></table>'; |
|
785 | + $string.='</td></tr></table>'; |
|
786 | 786 | return $string; |
787 | 787 | } |
788 | 788 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | if($this->_autoCreate) |
866 | 866 | $this->createDbTable(); |
867 | 867 | else |
868 | - throw new TConfigurationException('db_logtable_inexistent',$this->_logTable); |
|
868 | + throw new TConfigurationException('db_logtable_inexistent', $this->_logTable); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | parent::init($config); |
@@ -881,10 +881,10 @@ discard block |
||
881 | 881 | $command=$this->getDbConnection()->createCommand($sql); |
882 | 882 | foreach($logs as $log) |
883 | 883 | { |
884 | - $command->bindValue(':message',$log[0]); |
|
885 | - $command->bindValue(':level',$log[1]); |
|
886 | - $command->bindValue(':category',$log[2]); |
|
887 | - $command->bindValue(':logtime',$log[3]); |
|
884 | + $command->bindValue(':message', $log[0]); |
|
885 | + $command->bindValue(':level', $log[1]); |
|
886 | + $command->bindValue(':category', $log[2]); |
|
887 | + $command->bindValue(':logtime', $log[3]); |
|
888 | 888 | $command->execute(); |
889 | 889 | } |
890 | 890 | } |
@@ -895,14 +895,14 @@ discard block |
||
895 | 895 | */ |
896 | 896 | protected function createDbTable() |
897 | 897 | { |
898 | - $db = $this->getDbConnection(); |
|
898 | + $db=$this->getDbConnection(); |
|
899 | 899 | $driver=$db->getDriverName(); |
900 | - $autoidAttributes = ''; |
|
900 | + $autoidAttributes=''; |
|
901 | 901 | if($driver==='mysql') |
902 | - $autoidAttributes = 'AUTO_INCREMENT'; |
|
902 | + $autoidAttributes='AUTO_INCREMENT'; |
|
903 | 903 | |
904 | 904 | $sql='CREATE TABLE '.$this->_logTable.' ( |
905 | - log_id INTEGER NOT NULL PRIMARY KEY ' . $autoidAttributes . ', |
|
905 | + log_id INTEGER NOT NULL PRIMARY KEY ' . $autoidAttributes.', |
|
906 | 906 | level INTEGER, |
907 | 907 | category VARCHAR(128), |
908 | 908 | logtime VARCHAR(20), |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | if($config instanceof TDataSourceConfig) |
925 | 925 | return $config->getDbConnection(); |
926 | 926 | else |
927 | - throw new TConfigurationException('dblogroute_connectionid_invalid',$this->_connID); |
|
927 | + throw new TConfigurationException('dblogroute_connectionid_invalid', $this->_connID); |
|
928 | 928 | } |
929 | 929 | else |
930 | 930 | { |
@@ -1020,9 +1020,9 @@ discard block |
||
1020 | 1020 | */ |
1021 | 1021 | class TFirebugLogRoute extends TBrowserLogRoute |
1022 | 1022 | { |
1023 | - protected function renderHeader () |
|
1023 | + protected function renderHeader() |
|
1024 | 1024 | { |
1025 | - $string = <<<EOD |
|
1025 | + $string=<<<EOD |
|
1026 | 1026 | |
1027 | 1027 | <script type="text/javascript"> |
1028 | 1028 | /*<![CDATA[*/ |
@@ -1035,23 +1035,23 @@ discard block |
||
1035 | 1035 | return $string; |
1036 | 1036 | } |
1037 | 1037 | |
1038 | - protected function renderMessage ($log, $info) |
|
1038 | + protected function renderMessage($log, $info) |
|
1039 | 1039 | { |
1040 | - $logfunc = $this->getFirebugLoggingFunction($log[1]); |
|
1041 | - $total = sprintf('%0.6f', $info['total']); |
|
1042 | - $delta = sprintf('%0.6f', $info['delta']); |
|
1043 | - $msg = trim($this->formatLogMessage($log[0], $log[1], $log[2], '')); |
|
1044 | - $msg = preg_replace('/\(line[^\)]+\)$/', '', $msg); //remove line number info |
|
1045 | - $msg = "[{$total}] [{$delta}] ".$msg; // Add time spent and cumulated time spent |
|
1046 | - $string = $logfunc . '(\'' . addslashes($msg) . '\');' . "\n"; |
|
1040 | + $logfunc=$this->getFirebugLoggingFunction($log[1]); |
|
1041 | + $total=sprintf('%0.6f', $info['total']); |
|
1042 | + $delta=sprintf('%0.6f', $info['delta']); |
|
1043 | + $msg=trim($this->formatLogMessage($log[0], $log[1], $log[2], '')); |
|
1044 | + $msg=preg_replace('/\(line[^\)]+\)$/', '', $msg); //remove line number info |
|
1045 | + $msg="[{$total}] [{$delta}] ".$msg; // Add time spent and cumulated time spent |
|
1046 | + $string=$logfunc.'(\''.addslashes($msg).'\');'."\n"; |
|
1047 | 1047 | |
1048 | 1048 | return $string; |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | |
1052 | - protected function renderFooter () |
|
1052 | + protected function renderFooter() |
|
1053 | 1053 | { |
1054 | - $string = <<<EOD |
|
1054 | + $string=<<<EOD |
|
1055 | 1055 | |
1056 | 1056 | } |
1057 | 1057 | </script> |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | |
1064 | 1064 | protected function getFirebugLoggingFunction($level) |
1065 | 1065 | { |
1066 | - switch ($level) |
|
1066 | + switch($level) |
|
1067 | 1067 | { |
1068 | 1068 | case TLogger::DEBUG: |
1069 | 1069 | case TLogger::INFO: |
@@ -1099,9 +1099,9 @@ discard block |
||
1099 | 1099 | /** |
1100 | 1100 | * Default group label |
1101 | 1101 | */ |
1102 | - const DEFAULT_LABEL = 'System.Util.TLogRouter(TFirePhpLogRoute)'; |
|
1102 | + const DEFAULT_LABEL='System.Util.TLogRouter(TFirePhpLogRoute)'; |
|
1103 | 1103 | |
1104 | - private $_groupLabel = null; |
|
1104 | + private $_groupLabel=null; |
|
1105 | 1105 | |
1106 | 1106 | public function processLogs($logs) |
1107 | 1107 | { |
@@ -1111,41 +1111,41 @@ discard block |
||
1111 | 1111 | if(headers_sent()) { |
1112 | 1112 | echo ' |
1113 | 1113 | <div style="width:100%; background-color:darkred; color:#FFF; padding:2px"> |
1114 | - TFirePhpLogRoute.GroupLabel "<i>' . $this -> getGroupLabel() . '</i>" - |
|
1114 | + TFirePhpLogRoute.GroupLabel "<i>' . $this -> getGroupLabel().'</i>" - |
|
1115 | 1115 | Routing to FirePHP impossible, because headers already sent! |
1116 | 1116 | </div> |
1117 | 1117 | '; |
1118 | - $fallback = new TBrowserLogRoute(); |
|
1118 | + $fallback=new TBrowserLogRoute(); |
|
1119 | 1119 | $fallback->processLogs($logs); |
1120 | 1120 | return; |
1121 | 1121 | } |
1122 | 1122 | |
1123 | - require_once Prado::getPathOfNamespace('System.3rdParty.FirePHPCore') . '/FirePHP.class.php'; |
|
1124 | - $firephp = FirePHP::getInstance(true); |
|
1123 | + require_once Prado::getPathOfNamespace('System.3rdParty.FirePHPCore').'/FirePHP.class.php'; |
|
1124 | + $firephp=FirePHP::getInstance(true); |
|
1125 | 1125 | $firephp->setOptions(array('useNativeJsonEncode' => false)); |
1126 | 1126 | $firephp->group($this->getGroupLabel(), array('Collapsed' => true)); |
1127 | 1127 | $firephp->log('Time, Message'); |
1128 | 1128 | |
1129 | - $first = $logs[0][3]; |
|
1130 | - $c = count($logs); |
|
1131 | - for($i=0,$n=$c;$i<$n;++$i) |
|
1129 | + $first=$logs[0][3]; |
|
1130 | + $c=count($logs); |
|
1131 | + for($i=0, $n=$c; $i < $n; ++$i) |
|
1132 | 1132 | { |
1133 | - $message = $logs[$i][0]; |
|
1134 | - $level = $logs[$i][1]; |
|
1135 | - $category = $logs[$i][2]; |
|
1133 | + $message=$logs[$i][0]; |
|
1134 | + $level=$logs[$i][1]; |
|
1135 | + $category=$logs[$i][2]; |
|
1136 | 1136 | |
1137 | - if ($i<$n-1) |
|
1137 | + if($i < $n - 1) |
|
1138 | 1138 | { |
1139 | - $delta = $logs[$i+1][3] - $logs[$i][3]; |
|
1140 | - $total = $logs[$i+1][3] - $first; |
|
1139 | + $delta=$logs[$i + 1][3] - $logs[$i][3]; |
|
1140 | + $total=$logs[$i + 1][3] - $first; |
|
1141 | 1141 | } |
1142 | 1142 | else |
1143 | 1143 | { |
1144 | - $delta = '?'; |
|
1145 | - $total = $logs[$i][3] - $first; |
|
1144 | + $delta='?'; |
|
1145 | + $total=$logs[$i][3] - $first; |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | - $message = sPrintF('+%0.6f: %s', $delta, preg_replace('/\(line[^\)]+\)$/', '', $message)); |
|
1148 | + $message=sPrintF('+%0.6f: %s', $delta, preg_replace('/\(line[^\)]+\)$/', '', $message)); |
|
1149 | 1149 | $firephp->fb($message, $category, self::translateLogLevel($level)); |
1150 | 1150 | } |
1151 | 1151 | $firephp->log(sPrintF('%0.6f', $total), 'Cumulated Time'); |
@@ -65,15 +65,13 @@ discard block |
||
65 | 65 | { |
66 | 66 | $phpConfig = include $this->_configFile; |
67 | 67 | $this->loadConfig($phpConfig); |
68 | - } |
|
69 | - else |
|
68 | + } else |
|
70 | 69 | { |
71 | 70 | $dom=new TXmlDocument; |
72 | 71 | $dom->loadFromFile($this->_configFile); |
73 | 72 | $this->loadConfig($dom); |
74 | 73 | } |
75 | - } |
|
76 | - else |
|
74 | + } else |
|
77 | 75 | throw new TConfigurationException('logrouter_configfile_invalid',$this->_configFile); |
78 | 76 | } |
79 | 77 | $this->loadConfig($config); |
@@ -105,8 +103,7 @@ discard block |
||
105 | 103 | $route->init($route); |
106 | 104 | } |
107 | 105 | } |
108 | - } |
|
109 | - else |
|
106 | + } else |
|
110 | 107 | { |
111 | 108 | foreach($config->getElementsByTagName('route') as $routeConfig) |
112 | 109 | { |
@@ -647,8 +644,7 @@ discard block |
||
647 | 644 | { |
648 | 645 | $timing['delta'] = $logs[$i+1][3] - $logs[$i][3]; |
649 | 646 | $timing['total'] = $logs[$i+1][3] - $first; |
650 | - } |
|
651 | - else |
|
647 | + } else |
|
652 | 648 | { |
653 | 649 | $timing['delta'] = '?'; |
654 | 650 | $timing['total'] = $logs[$i][3] - $first; |
@@ -691,8 +687,7 @@ discard block |
||
691 | 687 | <th>Category</th><th>Message</th><th>Time Spent (s)</th><th>Cumulated Time Spent (s)</th> |
692 | 688 | </tr> |
693 | 689 | EOD; |
694 | - } |
|
695 | - else |
|
690 | + } else |
|
696 | 691 | { |
697 | 692 | $string = <<<EOD |
698 | 693 | <table cellspacing="0" cellpadding="2" border="0" width="100%" style="table-layout:auto"> |
@@ -729,8 +724,7 @@ discard block |
||
729 | 724 | <td class="cumulatedtime">{$total}</td> |
730 | 725 | </tr> |
731 | 726 | EOD; |
732 | - } |
|
733 | - else |
|
727 | + } else |
|
734 | 728 | { |
735 | 729 | $bgcolor = $info['even'] ? "#fff" : "#eee"; |
736 | 730 | $color = $this->getColorLevel($log[1]); |
@@ -772,8 +766,7 @@ discard block |
||
772 | 766 | { |
773 | 767 | $string .= '<span class="level'.$level.'">'.strtoupper($name)."</span>"; |
774 | 768 | } |
775 | - } |
|
776 | - else |
|
769 | + } else |
|
777 | 770 | { |
778 | 771 | $string .= "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">"; |
779 | 772 | foreach(self::$_levelValues as $name => $level) |
@@ -858,8 +851,7 @@ discard block |
||
858 | 851 | try |
859 | 852 | { |
860 | 853 | $db->createCommand($sql)->query()->close(); |
861 | - } |
|
862 | - catch(Exception $e) |
|
854 | + } catch(Exception $e) |
|
863 | 855 | { |
864 | 856 | // DB table not exists |
865 | 857 | if($this->_autoCreate) |
@@ -925,8 +917,7 @@ discard block |
||
925 | 917 | return $config->getDbConnection(); |
926 | 918 | else |
927 | 919 | throw new TConfigurationException('dblogroute_connectionid_invalid',$this->_connID); |
928 | - } |
|
929 | - else |
|
920 | + } else |
|
930 | 921 | { |
931 | 922 | $db=new TDbConnection; |
932 | 923 | // default to SQLite3 database |
@@ -1138,8 +1129,7 @@ discard block |
||
1138 | 1129 | { |
1139 | 1130 | $delta = $logs[$i+1][3] - $logs[$i][3]; |
1140 | 1131 | $total = $logs[$i+1][3] - $first; |
1141 | - } |
|
1142 | - else |
|
1132 | + } else |
|
1143 | 1133 | { |
1144 | 1134 | $delta = '?'; |
1145 | 1135 | $total = $logs[$i][3] - $first; |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | * @return string SQL search condition matching on a set of columns. |
31 | 31 | */ |
32 | 32 | public function getSearchExpression($fields, $keywords) { |
33 | - $columns = array (); |
|
34 | - foreach ($fields as $field) { |
|
35 | - if ($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) |
|
36 | - $columns[] = $field; |
|
33 | + $columns=array(); |
|
34 | + foreach($fields as $field) { |
|
35 | + if($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) |
|
36 | + $columns[]=$field; |
|
37 | 37 | } |
38 | 38 | return parent :: getSearchExpression($columns, $keywords); |
39 | 39 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @return boolean true if column can be used for LIKE searching. |
43 | 43 | */ |
44 | 44 | protected function isSearchableColumn($column) { |
45 | - $type = strtolower($column->getDbType()); |
|
46 | - return $type === 'character varying' || $type === 'varchar2' || $type === 'character' || $type === 'char' || $type === 'text'; |
|
45 | + $type=strtolower($column->getDbType()); |
|
46 | + return $type==='character varying' || $type==='varchar2' || $type==='character' || $type==='char' || $type==='text'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -72,59 +72,59 @@ discard block |
||
72 | 72 | * @param integer row offset, -1 to ignore offset. |
73 | 73 | * @return string SQL with limit and offset in Oracle way. |
74 | 74 | */ |
75 | - public function applyLimitOffset($sql, $limit = -1, $offset = -1) { |
|
76 | - if ((int) $limit <= 0 && (int) $offset <= 0) |
|
75 | + public function applyLimitOffset($sql, $limit=-1, $offset=-1) { |
|
76 | + if((int) $limit <= 0 && (int) $offset <= 0) |
|
77 | 77 | return $sql; |
78 | 78 | |
79 | - $pradoNUMLIN = 'pradoNUMLIN'; |
|
80 | - $fieldsALIAS = 'xyz'; |
|
79 | + $pradoNUMLIN='pradoNUMLIN'; |
|
80 | + $fieldsALIAS='xyz'; |
|
81 | 81 | |
82 | - $nfimDaSQL = strlen($sql); |
|
83 | - $nfimDoWhere = (strpos($sql, 'ORDER') !== false ? strpos($sql, 'ORDER') : $nfimDaSQL); |
|
84 | - $niniDoSelect = strpos($sql, 'SELECT') + 6; |
|
85 | - $nfimDoSelect = (strpos($sql, 'FROM') !== false ? strpos($sql, 'FROM') : $nfimDaSQL); |
|
82 | + $nfimDaSQL=strlen($sql); |
|
83 | + $nfimDoWhere=(strpos($sql, 'ORDER')!==false ? strpos($sql, 'ORDER') : $nfimDaSQL); |
|
84 | + $niniDoSelect=strpos($sql, 'SELECT') + 6; |
|
85 | + $nfimDoSelect=(strpos($sql, 'FROM')!==false ? strpos($sql, 'FROM') : $nfimDaSQL); |
|
86 | 86 | |
87 | 87 | $WhereInSubSelect=""; |
88 | 88 | if(strpos($sql, 'WHERE')!==false) |
89 | - $WhereInSubSelect = "WHERE " .substr($sql, strpos($sql, 'WHERE')+5, $nfimDoWhere - $niniDoWhere); |
|
89 | + $WhereInSubSelect="WHERE ".substr($sql, strpos($sql, 'WHERE') + 5, $nfimDoWhere - $niniDoWhere); |
|
90 | 90 | |
91 | - $sORDERBY = ''; |
|
92 | - if (stripos($sql, 'ORDER') !== false) { |
|
93 | - $p = stripos($sql, 'ORDER'); |
|
94 | - $sORDERBY = substr($sql, $p +8); |
|
91 | + $sORDERBY=''; |
|
92 | + if(stripos($sql, 'ORDER')!==false) { |
|
93 | + $p=stripos($sql, 'ORDER'); |
|
94 | + $sORDERBY=substr($sql, $p + 8); |
|
95 | 95 | } |
96 | 96 | |
97 | - $fields = substr($sql, 0, $nfimDoSelect); |
|
98 | - $fields = trim(substr($fields, $niniDoSelect)); |
|
99 | - $aliasedFields = ', '; |
|
97 | + $fields=substr($sql, 0, $nfimDoSelect); |
|
98 | + $fields=trim(substr($fields, $niniDoSelect)); |
|
99 | + $aliasedFields=', '; |
|
100 | 100 | |
101 | - if (trim($fields) == '*') { |
|
102 | - $aliasedFields = ", {$fieldsALIAS}.{$fields}"; |
|
103 | - $fields = ''; |
|
104 | - $arr = $this->getTableInfo()->getColumns(); |
|
105 | - foreach ($arr as $field) { |
|
106 | - $fields .= strtolower($field->getColumnName()) . ', '; |
|
101 | + if(trim($fields)=='*') { |
|
102 | + $aliasedFields=", {$fieldsALIAS}.{$fields}"; |
|
103 | + $fields=''; |
|
104 | + $arr=$this->getTableInfo()->getColumns(); |
|
105 | + foreach($arr as $field) { |
|
106 | + $fields.=strtolower($field->getColumnName()).', '; |
|
107 | 107 | } |
108 | - $fields = str_replace('"', '', $fields); |
|
109 | - $fields = trim($fields); |
|
110 | - $fields = substr($fields, 0, strlen($fields) - 1); |
|
108 | + $fields=str_replace('"', '', $fields); |
|
109 | + $fields=trim($fields); |
|
110 | + $fields=substr($fields, 0, strlen($fields) - 1); |
|
111 | 111 | } else { |
112 | - if (strpos($fields, ',') !== false) { |
|
113 | - $arr = $this->getTableInfo()->getColumns(); |
|
114 | - foreach ($arr as $field) { |
|
115 | - $field = strtolower($field); |
|
116 | - $existAS = str_ireplace(' as ', '-as-', $field); |
|
117 | - if (strpos($existAS, '-as-') === false) |
|
118 | - $aliasedFields .= "{$fieldsALIAS}." . trim($field) . ", "; |
|
112 | + if(strpos($fields, ',')!==false) { |
|
113 | + $arr=$this->getTableInfo()->getColumns(); |
|
114 | + foreach($arr as $field) { |
|
115 | + $field=strtolower($field); |
|
116 | + $existAS=str_ireplace(' as ', '-as-', $field); |
|
117 | + if(strpos($existAS, '-as-')===false) |
|
118 | + $aliasedFields.="{$fieldsALIAS}.".trim($field).", "; |
|
119 | 119 | else |
120 | - $aliasedFields .= "{$field}, "; |
|
120 | + $aliasedFields.="{$field}, "; |
|
121 | 121 | } |
122 | - $aliasedFields = trim($aliasedFields); |
|
123 | - $aliasedFields = substr($aliasedFields, 0, strlen($aliasedFields) - 1); |
|
122 | + $aliasedFields=trim($aliasedFields); |
|
123 | + $aliasedFields=substr($aliasedFields, 0, strlen($aliasedFields) - 1); |
|
124 | 124 | } |
125 | 125 | } |
126 | - if ($aliasedFields == ', ') |
|
127 | - $aliasedFields = " , $fieldsALIAS.* "; |
|
126 | + if($aliasedFields==', ') |
|
127 | + $aliasedFields=" , $fieldsALIAS.* "; |
|
128 | 128 | |
129 | 129 | /* ************************ |
130 | 130 | $newSql = " SELECT $fields FROM ". |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | ") WHERE {$pradoNUMLIN} >= {$offset} "; |
135 | 135 | |
136 | 136 | ************************* */ |
137 | - $offset=(int)$offset; |
|
138 | - $toReg = $offset + $limit ; |
|
139 | - $fullTableName = $this->getTableInfo()->getTableFullName(); |
|
140 | - if (empty ($sORDERBY)) |
|
137 | + $offset=(int) $offset; |
|
138 | + $toReg=$offset + $limit; |
|
139 | + $fullTableName=$this->getTableInfo()->getTableFullName(); |
|
140 | + if(empty ($sORDERBY)) |
|
141 | 141 | $sORDERBY="ROWNUM"; |
142 | 142 | |
143 | - $newSql = " SELECT $fields FROM " . |
|
144 | - "( " . |
|
145 | - " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} " . |
|
146 | - " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect" . |
|
147 | - ") nn " . |
|
143 | + $newSql=" SELECT $fields FROM ". |
|
144 | + "( ". |
|
145 | + " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} ". |
|
146 | + " FROM {$fullTableName} {$fieldsALIAS} $WhereInSubSelect". |
|
147 | + ") nn ". |
|
148 | 148 | " WHERE nn.{$pradoNUMLIN} >= {$offset} AND nn.{$pradoNUMLIN} < {$toReg} "; |
149 | 149 | //echo $newSql."\n<br>\n"; |
150 | 150 | return $newSql; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | class TOracleTableColumn extends TDbTableColumn |
25 | 25 | { |
26 | 26 | private static $types=array( |
27 | - 'numeric' => array( 'numeric' ) |
|
27 | + 'numeric' => array('numeric') |
|
28 | 28 | // 'integer' => array('bit', 'bit varying', 'real', 'serial', 'int', 'integer'), |
29 | 29 | // 'boolean' => array('boolean'), |
30 | 30 | // 'float' => array('bigint', 'bigserial', 'double precision', 'money', 'numeric') |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getPHPType() |
38 | 38 | { |
39 | - $dbtype = strtolower($this->getDbType()); |
|
39 | + $dbtype=strtolower($this->getDbType()); |
|
40 | 40 | foreach(self::$types as $type => $dbtypes) |
41 | 41 | { |
42 | 42 | if(in_array($dbtype, $dbtypes)) |