Completed
Push — prado-3.3 ( f4da81...5dd4b5 )
by Fabio
09:03
created
framework/Util/TLogger.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 	 * @param string category of the message
64 64
 	 * @param string|TControl control of the message
65 65
 	 */
66
-	public function log($message,$level,$category='Uncategorized', $ctl=null)
66
+	public function log($message, $level, $category='Uncategorized', $ctl=null)
67 67
 	{
68 68
 		if($ctl) {
69 69
 			if($ctl instanceof TControl)
70
-				$ctl = $ctl->ClientId;
70
+				$ctl=$ctl->ClientId;
71 71
 			else if(!is_string($ctl))
72
-				$ctl = null;
72
+				$ctl=null;
73 73
 		} else
74
-			$ctl = null;
75
-		$this->_logs[]=array($message,$level,$category,microtime(true),memory_get_usage(),$ctl);
74
+			$ctl=null;
75
+		$this->_logs[]=array($message, $level, $category, microtime(true), memory_get_usage(), $ctl);
76 76
 	}
77 77
 
78 78
 	/**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *   [4] => memory in bytes
109 109
 	 *   [5] => control client id
110 110
 	 */
111
-	public function getLogs($levels=null,$categories=null,$controls=null,$timestamp=null)
111
+	public function getLogs($levels=null, $categories=null, $controls=null, $timestamp=null)
112 112
 	{
113 113
 		$this->_levels=$levels;
114 114
 		$this->_categories=$categories;
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 		$this->_timestamp=$timestamp;
117 117
 		if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp))
118 118
 			return $this->_logs;
119
-		$logs = $this->_logs;
119
+		$logs=$this->_logs;
120 120
 		if(!empty($levels))
121
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) ));
121
+			$logs=array_values(array_filter(array_filter($logs, array($this, 'filterByLevels'))));
122 122
 		if(!empty($categories))
123
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) ));
123
+			$logs=array_values(array_filter(array_filter($logs, array($this, 'filterByCategories'))));
124 124
 		if(!empty($controls))
125
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) ));
125
+			$logs=array_values(array_filter(array_filter($logs, array($this, 'filterByControl'))));
126 126
 		if(!is_null($timestamp))
127
-			$logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ));
127
+			$logs=array_values(array_filter(array_filter($logs, array($this, 'filterByTimeStamp'))));
128 128
 		return $logs;
129 129
 	}
130 130
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param array category filter
153 153
 	 * @param array control filter
154 154
 	 */
155
-	public function deleteLogs($levels=null,$categories=null,$controls=null,$timestamp=null)
155
+	public function deleteLogs($levels=null, $categories=null, $controls=null, $timestamp=null)
156 156
 	{
157 157
 		$this->_levels=$levels;
158 158
 		$this->_categories=$categories;
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 			$this->_logs=array();
164 164
 			return;
165 165
 		}
166
-		$logs = $this->_logs;
166
+		$logs=$this->_logs;
167 167
 		if(!empty($levels))
168
-			$logs = array_filter( array_filter($logs,array($this,'filterByLevels')) );
168
+			$logs=array_filter(array_filter($logs, array($this, 'filterByLevels')));
169 169
 		if(!empty($categories))
170
-			$logs = array_filter( array_filter($logs,array($this,'filterByCategories')) );
170
+			$logs=array_filter(array_filter($logs, array($this, 'filterByCategories')));
171 171
 		if(!empty($controls))
172
-			$logs = array_filter( array_filter($logs,array($this,'filterByControl')) );
172
+			$logs=array_filter(array_filter($logs, array($this, 'filterByControl')));
173 173
 		if(!is_null($timestamp))
174
-			$logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) );
175
-		$this->_logs = array_values( array_diff_key($this->_logs, $logs) );
174
+			$logs=array_filter(array_filter($logs, array($this, 'filterByTimeStamp')));
175
+		$this->_logs=array_values(array_diff_key($this->_logs, $logs));
176 176
 	}
177 177
 
178 178
 	/**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		foreach($this->_categories as $category)
185 185
 		{
186 186
 			// element 2 is the category
187
-			if($value[2]===$category || strpos($value[2],$category.'.')===0)
187
+			if($value[2]===$category || strpos($value[2], $category.'.')===0)
188 188
 				return $value;
189 189
 		}
190 190
 		return false;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		// element 5 are the control client ids
213 213
 		foreach($this->_controls as $control)
214 214
 		{
215
-			if($value[5]===$control || strpos($value[5],$control)===0)
215
+			if($value[5]===$control || strpos($value[5], $control)===0)
216 216
 				return $value;
217 217
 		}
218 218
 		return false;
Please login to merge, or discard this patch.
framework/Util/TParameterModule.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
framework/Util/TLogRouter.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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">&nbsp;</td>
726 726
 		<td class="category">{$log[2]}</td>
@@ -732,9 +732,9 @@  discard block
 block discarded – undo
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;">&nbsp;</td>
740 740
 		<td>{$log[2]}</td>
@@ -764,25 +764,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
framework/Util/TVarDumper.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 * @param integer maximum depth that the dumper should go into the variable. Defaults to 10.
41 41
 	 * @return string the string representation of the variable
42 42
 	 */
43
-	public static function dump($var,$depth=10,$highlight=false)
43
+	public static function dump($var, $depth=10, $highlight=false)
44 44
 	{
45 45
 		self::$_output='';
46 46
 		self::$_objects=array();
47 47
 		self::$_depth=$depth;
48
-		self::dumpInternal($var,0);
48
+		self::dumpInternal($var, 0);
49 49
 		if($highlight)
50 50
 		{
51
-			$result=highlight_string("<?php\n".self::$_output,true);
52
-			return preg_replace('/&lt;\\?php<br \\/>/','',$result,1);
51
+			$result=highlight_string("<?php\n".self::$_output, true);
52
+			return preg_replace('/&lt;\\?php<br \\/>/', '', $result, 1);
53 53
 		}
54 54
 		else
55 55
 			return self::$_output;
56 56
 	}
57 57
 
58
-	private static function dumpInternal($var,$level)
58
+	private static function dumpInternal($var, $level)
59 59
 	{
60 60
 		switch(gettype($var))
61 61
 		{
62 62
 			case 'boolean':
63
-				self::$_output.=$var?'true':'false';
63
+				self::$_output.=$var ? 'true' : 'false';
64 64
 				break;
65 65
 			case 'integer':
66 66
 				self::$_output.="$var";
@@ -81,41 +81,41 @@  discard block
 block discarded – undo
81 81
 				self::$_output.='{unknown}';
82 82
 				break;
83 83
 			case 'array':
84
-				if(self::$_depth<=$level)
84
+				if(self::$_depth <= $level)
85 85
 					self::$_output.='array(...)';
86 86
 				else if(empty($var))
87 87
 					self::$_output.='array()';
88 88
 				else
89 89
 				{
90 90
 					$keys=array_keys($var);
91
-					$spaces=str_repeat(' ',$level*4);
91
+					$spaces=str_repeat(' ', $level * 4);
92 92
 					self::$_output.="array\n".$spaces.'(';
93 93
 					foreach($keys as $key)
94 94
 					{
95 95
 						self::$_output.="\n".$spaces."    [$key] => ";
96
-						self::$_output.=self::dumpInternal($var[$key],$level+1);
96
+						self::$_output.=self::dumpInternal($var[$key], $level + 1);
97 97
 					}
98 98
 					self::$_output.="\n".$spaces.')';
99 99
 				}
100 100
 				break;
101 101
 			case 'object':
102
-				if(($id=array_search($var,self::$_objects,true))!==false)
103
-					self::$_output.=get_class($var).'#'.($id+1).'(...)';
104
-				else if(self::$_depth<=$level)
102
+				if(($id=array_search($var, self::$_objects, true))!==false)
103
+					self::$_output.=get_class($var).'#'.($id + 1).'(...)';
104
+				else if(self::$_depth <= $level)
105 105
 					self::$_output.=get_class($var).'(...)';
106 106
 				else
107 107
 				{
108
-					$id=array_push(self::$_objects,$var);
108
+					$id=array_push(self::$_objects, $var);
109 109
 					$className=get_class($var);
110
-					$members=(array)$var;
110
+					$members=(array) $var;
111 111
 					$keys=array_keys($members);
112
-					$spaces=str_repeat(' ',$level*4);
112
+					$spaces=str_repeat(' ', $level * 4);
113 113
 					self::$_output.="$className#$id\n".$spaces.'(';
114 114
 					foreach($keys as $key)
115 115
 					{
116
-						$keyDisplay=strtr(trim($key),array("\0"=>':'));
116
+						$keyDisplay=strtr(trim($key), array("\0"=>':'));
117 117
 						self::$_output.="\n".$spaces."    [$keyDisplay] => ";
118
-						self::$_output.=self::dumpInternal($members[$key],$level+1);
118
+						self::$_output.=self::dumpInternal($members[$key], $level + 1);
119 119
 					}
120 120
 					self::$_output.="\n".$spaces.')';
121 121
 				}
Please login to merge, or discard this patch.
framework/IO/TTarFileExtractor.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
     */
61 61
     public function __construct($p_tarname)
62 62
     {
63
-        $this->_tarname = $p_tarname;
63
+        $this->_tarname=$p_tarname;
64 64
     }
65 65
 
66 66
     public function __destruct()
67 67
     {
68 68
         $this->_close();
69 69
         // ----- Look for a local copy to delete
70
-        if ($this->_temp_tarname != '')
70
+        if($this->_temp_tarname!='')
71 71
             @unlink($this->_temp_tarname);
72 72
     }
73 73
 
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
     */
111 111
     protected function extractModify($p_path, $p_remove_path)
112 112
     {
113
-        $v_result = true;
114
-        $v_list_detail = array();
113
+        $v_result=true;
114
+        $v_list_detail=array();
115 115
 
116
-        if ($v_result = $this->_openRead()) {
117
-            $v_result = $this->_extractList($p_path, $v_list_detail,
116
+        if($v_result=$this->_openRead()) {
117
+            $v_result=$this->_extractList($p_path, $v_list_detail,
118 118
 			                                "complete", 0, $p_remove_path);
119 119
             $this->_close();
120 120
         }
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 
130 130
     private function _isArchive($p_filename=null)
131 131
     {
132
-        if ($p_filename == null) {
133
-            $p_filename = $this->_tarname;
132
+        if($p_filename==null) {
133
+            $p_filename=$this->_tarname;
134 134
         }
135 135
         clearstatcache();
136 136
         return @is_file($p_filename);
@@ -138,39 +138,39 @@  discard block
 block discarded – undo
138 138
 
139 139
     private function _openRead()
140 140
     {
141
-        if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') {
141
+        if(strtolower(substr($this->_tarname, 0, 7))=='http://') {
142 142
 
143 143
           // ----- Look if a local copy need to be done
144
-          if ($this->_temp_tarname == '') {
145
-              $this->_temp_tarname = uniqid('tar').'.tmp';
146
-              if (!$v_file_from = @fopen($this->_tarname, 'rb')) {
144
+          if($this->_temp_tarname=='') {
145
+              $this->_temp_tarname=uniqid('tar').'.tmp';
146
+              if(!$v_file_from=@fopen($this->_tarname, 'rb')) {
147 147
                 $this->_error('Unable to open in read mode \''
148 148
 				              .$this->_tarname.'\'');
149
-                $this->_temp_tarname = '';
149
+                $this->_temp_tarname='';
150 150
                 return false;
151 151
               }
152
-              if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) {
152
+              if(!$v_file_to=@fopen($this->_temp_tarname, 'wb')) {
153 153
                 $this->_error('Unable to open in write mode \''
154 154
 				              .$this->_temp_tarname.'\'');
155
-                $this->_temp_tarname = '';
155
+                $this->_temp_tarname='';
156 156
                 return false;
157 157
               }
158
-              while ($v_data = @fread($v_file_from, 1024))
158
+              while($v_data=@fread($v_file_from, 1024))
159 159
                   @fwrite($v_file_to, $v_data);
160 160
               @fclose($v_file_from);
161 161
               @fclose($v_file_to);
162 162
           }
163 163
 
164 164
           // ----- File to open if the local copy
165
-          $v_filename = $this->_temp_tarname;
165
+          $v_filename=$this->_temp_tarname;
166 166
 
167 167
         } else
168 168
           // ----- File to open if the normal Tar file
169
-          $v_filename = $this->_tarname;
169
+          $v_filename=$this->_tarname;
170 170
 
171
-		$this->_file = @fopen($v_filename, "rb");
171
+		$this->_file=@fopen($v_filename, "rb");
172 172
 
173
-        if ($this->_file == 0) {
173
+        if($this->_file==0) {
174 174
             $this->_error('Unable to open in read mode \''.$v_filename.'\'');
175 175
             return false;
176 176
         }
@@ -181,17 +181,17 @@  discard block
 block discarded – undo
181 181
     private function _close()
182 182
     {
183 183
         //if (isset($this->_file)) {
184
-        if (is_resource($this->_file))
184
+        if(is_resource($this->_file))
185 185
 		{
186 186
                @fclose($this->_file);
187
-            $this->_file = 0;
187
+            $this->_file=0;
188 188
         }
189 189
 
190 190
         // ----- Look if a local copy need to be erase
191 191
         // Note that it might be interesting to keep the url for a time : ToDo
192
-        if ($this->_temp_tarname != '') {
192
+        if($this->_temp_tarname!='') {
193 193
             @unlink($this->_temp_tarname);
194
-            $this->_temp_tarname = '';
194
+            $this->_temp_tarname='';
195 195
         }
196 196
 
197 197
         return true;
@@ -202,76 +202,76 @@  discard block
 block discarded – undo
202 202
         $this->_close();
203 203
 
204 204
         // ----- Look for a local copy
205
-        if ($this->_temp_tarname != '') {
205
+        if($this->_temp_tarname!='') {
206 206
             // ----- Remove the local copy but not the remote tarname
207 207
             @unlink($this->_temp_tarname);
208
-            $this->_temp_tarname = '';
208
+            $this->_temp_tarname='';
209 209
         } else {
210 210
             // ----- Remove the local tarname file
211 211
             @unlink($this->_tarname);
212 212
         }
213
-        $this->_tarname = '';
213
+        $this->_tarname='';
214 214
 
215 215
         return true;
216 216
     }
217 217
 
218 218
     private function _readBlock()
219 219
     {
220
-      $v_block = null;
221
-      if (is_resource($this->_file)) {
222
-              $v_block = @fread($this->_file, 512);
220
+      $v_block=null;
221
+      if(is_resource($this->_file)) {
222
+              $v_block=@fread($this->_file, 512);
223 223
       }
224 224
       return $v_block;
225 225
     }
226 226
 
227 227
     private function _jumpBlock($p_len=null)
228 228
     {
229
-      if (is_resource($this->_file)) {
230
-          if ($p_len === null)
231
-              $p_len = 1;
229
+      if(is_resource($this->_file)) {
230
+          if($p_len===null)
231
+              $p_len=1;
232 232
 
233
-              @fseek($this->_file, @ftell($this->_file)+($p_len*512));
233
+              @fseek($this->_file, @ftell($this->_file) + ($p_len * 512));
234 234
       }
235 235
       return true;
236 236
     }
237 237
 
238 238
     private function _readHeader($v_binary_data, &$v_header)
239 239
     {
240
-        if (strlen($v_binary_data)==0) {
241
-            $v_header['filename'] = '';
240
+        if(strlen($v_binary_data)==0) {
241
+            $v_header['filename']='';
242 242
             return true;
243 243
         }
244 244
 
245
-        if (strlen($v_binary_data) != 512) {
246
-            $v_header['filename'] = '';
245
+        if(strlen($v_binary_data)!=512) {
246
+            $v_header['filename']='';
247 247
             $this->_error('Invalid block size : '.strlen($v_binary_data));
248 248
             return false;
249 249
         }
250 250
 
251 251
         // ----- Calculate the checksum
252
-        $v_checksum = 0;
252
+        $v_checksum=0;
253 253
         // ..... First part of the header
254
-        for ($i=0; $i<148; $i++)
255
-            $v_checksum+=ord(substr($v_binary_data,$i,1));
254
+        for($i=0; $i < 148; $i++)
255
+            $v_checksum+=ord(substr($v_binary_data, $i, 1));
256 256
         // ..... Ignore the checksum value and replace it by ' ' (space)
257
-        for ($i=148; $i<156; $i++)
258
-            $v_checksum += ord(' ');
257
+        for($i=148; $i < 156; $i++)
258
+            $v_checksum+=ord(' ');
259 259
         // ..... Last part of the header
260
-        for ($i=156; $i<512; $i++)
261
-           $v_checksum+=ord(substr($v_binary_data,$i,1));
260
+        for($i=156; $i < 512; $i++)
261
+           $v_checksum+=ord(substr($v_binary_data, $i, 1));
262 262
 
263
-        $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
263
+        $v_data=unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
264 264
 		                 ."a8checksum/a1typeflag/a100link/a6magic/a2version/"
265 265
 						 ."a32uname/a32gname/a8devmajor/a8devminor",
266 266
 						 $v_binary_data);
267 267
 
268 268
         // ----- Extract the checksum
269
-        $v_header['checksum'] = OctDec(trim($v_data['checksum']));
270
-        if ($v_header['checksum'] != $v_checksum) {
271
-            $v_header['filename'] = '';
269
+        $v_header['checksum']=OctDec(trim($v_data['checksum']));
270
+        if($v_header['checksum']!=$v_checksum) {
271
+            $v_header['filename']='';
272 272
 
273 273
             // ----- Look for last block (empty block)
274
-            if (($v_checksum == 256) && ($v_header['checksum'] == 0))
274
+            if(($v_checksum==256) && ($v_header['checksum']==0))
275 275
                 return true;
276 276
 
277 277
             $this->_error('Invalid checksum for file "'.$v_data['filename']
@@ -281,38 +281,38 @@  discard block
 block discarded – undo
281 281
         }
282 282
 
283 283
         // ----- Extract the properties
284
-        $v_header['filename'] = trim($v_data['filename']);
285
-        $v_header['mode'] = OctDec(trim($v_data['mode']));
286
-        $v_header['uid'] = OctDec(trim($v_data['uid']));
287
-        $v_header['gid'] = OctDec(trim($v_data['gid']));
288
-        $v_header['size'] = OctDec(trim($v_data['size']));
289
-        $v_header['mtime'] = OctDec(trim($v_data['mtime']));
290
-        if (($v_header['typeflag'] = $v_data['typeflag']) == "5") {
291
-          $v_header['size'] = 0;
284
+        $v_header['filename']=trim($v_data['filename']);
285
+        $v_header['mode']=OctDec(trim($v_data['mode']));
286
+        $v_header['uid']=OctDec(trim($v_data['uid']));
287
+        $v_header['gid']=OctDec(trim($v_data['gid']));
288
+        $v_header['size']=OctDec(trim($v_data['size']));
289
+        $v_header['mtime']=OctDec(trim($v_data['mtime']));
290
+        if(($v_header['typeflag']=$v_data['typeflag'])=="5") {
291
+          $v_header['size']=0;
292 292
         }
293 293
         return true;
294 294
     }
295 295
 
296 296
     private function _readLongHeader(&$v_header)
297 297
     {
298
-      $v_filename = '';
299
-      $n = floor($v_header['size']/512);
300
-      for ($i=0; $i<$n; $i++) {
301
-        $v_content = $this->_readBlock();
302
-        $v_filename .= $v_content;
298
+      $v_filename='';
299
+      $n=floor($v_header['size'] / 512);
300
+      for($i=0; $i < $n; $i++) {
301
+        $v_content=$this->_readBlock();
302
+        $v_filename.=$v_content;
303 303
       }
304
-      if (($v_header['size'] % 512) != 0) {
305
-        $v_content = $this->_readBlock();
306
-        $v_filename .= $v_content;
304
+      if(($v_header['size'] % 512)!=0) {
305
+        $v_content=$this->_readBlock();
306
+        $v_filename.=$v_content;
307 307
       }
308 308
 
309 309
       // ----- Read the next header
310
-      $v_binary_data = $this->_readBlock();
310
+      $v_binary_data=$this->_readBlock();
311 311
 
312
-      if (!$this->_readHeader($v_binary_data, $v_header))
312
+      if(!$this->_readHeader($v_binary_data, $v_header))
313 313
         return false;
314 314
 
315
-      $v_header['filename'] = $v_filename;
315
+      $v_header['filename']=$v_filename;
316 316
 
317 317
       return true;
318 318
     }
@@ -321,34 +321,34 @@  discard block
 block discarded – undo
321 321
 	                      $p_file_list, $p_remove_path)
322 322
     {
323 323
     $v_result=true;
324
-    $v_nb = 0;
325
-    $v_extract_all = true;
326
-    $v_listing = false;
327
-
328
-    $p_path = $this->_translateWinPath($p_path, false);
329
-    if ($p_path == '' || (substr($p_path, 0, 1) != '/'
330
-	    && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) {
331
-      $p_path = "./".$p_path;
324
+    $v_nb=0;
325
+    $v_extract_all=true;
326
+    $v_listing=false;
327
+
328
+    $p_path=$this->_translateWinPath($p_path, false);
329
+    if($p_path=='' || (substr($p_path, 0, 1)!='/'
330
+	    && substr($p_path, 0, 3)!="../" && !strpos($p_path, ':'))) {
331
+      $p_path="./".$p_path;
332 332
     }
333
-    $p_remove_path = $this->_translateWinPath($p_remove_path);
333
+    $p_remove_path=$this->_translateWinPath($p_remove_path);
334 334
 
335 335
     // ----- Look for path to remove format (should end by /)
336
-    if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/'))
337
-      $p_remove_path .= '/';
338
-    $p_remove_path_size = strlen($p_remove_path);
336
+    if(($p_remove_path!='') && (substr($p_remove_path, -1)!='/'))
337
+      $p_remove_path.='/';
338
+    $p_remove_path_size=strlen($p_remove_path);
339 339
 
340
-    switch ($p_mode) {
340
+    switch($p_mode) {
341 341
       case "complete" :
342
-        $v_extract_all = true;
343
-        $v_listing = false;
342
+        $v_extract_all=true;
343
+        $v_listing=false;
344 344
       break;
345 345
       case "partial" :
346
-          $v_extract_all = false;
347
-          $v_listing = false;
346
+          $v_extract_all=false;
347
+          $v_listing=false;
348 348
       break;
349 349
       case "list" :
350
-          $v_extract_all = false;
351
-          $v_listing = true;
350
+          $v_extract_all=false;
351
+          $v_listing=true;
352 352
       break;
353 353
       default :
354 354
         $this->_error('Invalid extract mode ('.$p_mode.')');
@@ -357,103 +357,103 @@  discard block
 block discarded – undo
357 357
 
358 358
     clearstatcache();
359 359
 
360
-    while (strlen($v_binary_data = $this->_readBlock()) != 0)
360
+    while(strlen($v_binary_data=$this->_readBlock())!=0)
361 361
     {
362
-      $v_extract_file = false;
363
-      $v_extraction_stopped = 0;
362
+      $v_extract_file=false;
363
+      $v_extraction_stopped=0;
364 364
 
365
-      if (!$this->_readHeader($v_binary_data, $v_header))
365
+      if(!$this->_readHeader($v_binary_data, $v_header))
366 366
         return false;
367 367
 
368
-      if ($v_header['filename'] == '') {
368
+      if($v_header['filename']=='') {
369 369
         continue;
370 370
       }
371 371
 
372 372
       // ----- Look for long filename
373
-      if ($v_header['typeflag'] == 'L') {
374
-        if (!$this->_readLongHeader($v_header))
373
+      if($v_header['typeflag']=='L') {
374
+        if(!$this->_readLongHeader($v_header))
375 375
           return false;
376 376
       }
377 377
 
378
-      if ((!$v_extract_all) && (is_array($p_file_list))) {
378
+      if((!$v_extract_all) && (is_array($p_file_list))) {
379 379
         // ----- By default no unzip if the file is not found
380
-        $v_extract_file = false;
380
+        $v_extract_file=false;
381 381
 
382
-        for ($i=0; $i<sizeof($p_file_list); $i++) {
382
+        for($i=0; $i < sizeof($p_file_list); $i++) {
383 383
           // ----- Look if it is a directory
384
-          if (substr($p_file_list[$i], -1) == '/') {
384
+          if(substr($p_file_list[$i], -1)=='/') {
385 385
             // ----- Look if the directory is in the filename path
386
-            if ((strlen($v_header['filename']) > strlen($p_file_list[$i]))
386
+            if((strlen($v_header['filename']) > strlen($p_file_list[$i]))
387 387
 			    && (substr($v_header['filename'], 0, strlen($p_file_list[$i]))
388 388
 				    == $p_file_list[$i])) {
389
-              $v_extract_file = true;
389
+              $v_extract_file=true;
390 390
               break;
391 391
             }
392 392
           }
393 393
 
394 394
           // ----- It is a file, so compare the file names
395
-          elseif ($p_file_list[$i] == $v_header['filename']) {
396
-            $v_extract_file = true;
395
+          elseif($p_file_list[$i]==$v_header['filename']) {
396
+            $v_extract_file=true;
397 397
             break;
398 398
           }
399 399
         }
400 400
       } else {
401
-        $v_extract_file = true;
401
+        $v_extract_file=true;
402 402
       }
403 403
 
404 404
       // ----- Look if this file need to be extracted
405
-      if (($v_extract_file) && (!$v_listing))
405
+      if(($v_extract_file) && (!$v_listing))
406 406
       {
407
-        if (($p_remove_path != '')
407
+        if(($p_remove_path!='')
408 408
             && (substr($v_header['filename'], 0, $p_remove_path_size)
409 409
 			    == $p_remove_path))
410
-          $v_header['filename'] = substr($v_header['filename'],
410
+          $v_header['filename']=substr($v_header['filename'],
411 411
 		                                 $p_remove_path_size);
412
-        if (($p_path != './') && ($p_path != '/')) {
413
-          while (substr($p_path, -1) == '/')
414
-            $p_path = substr($p_path, 0, strlen($p_path)-1);
412
+        if(($p_path!='./') && ($p_path!='/')) {
413
+          while(substr($p_path, -1)=='/')
414
+            $p_path=substr($p_path, 0, strlen($p_path) - 1);
415 415
 
416
-          if (substr($v_header['filename'], 0, 1) == '/')
417
-              $v_header['filename'] = $p_path.$v_header['filename'];
416
+          if(substr($v_header['filename'], 0, 1)=='/')
417
+              $v_header['filename']=$p_path.$v_header['filename'];
418 418
           else
419
-            $v_header['filename'] = $p_path.'/'.$v_header['filename'];
419
+            $v_header['filename']=$p_path.'/'.$v_header['filename'];
420 420
         }
421
-        if (file_exists($v_header['filename'])) {
422
-          if (   (@is_dir($v_header['filename']))
423
-		      && ($v_header['typeflag'] == '')) {
421
+        if(file_exists($v_header['filename'])) {
422
+          if((@is_dir($v_header['filename']))
423
+		      && ($v_header['typeflag']=='')) {
424 424
             $this->_error('File '.$v_header['filename']
425 425
 			              .' already exists as a directory');
426 426
             return false;
427 427
           }
428
-          if (   ($this->_isArchive($v_header['filename']))
429
-		      && ($v_header['typeflag'] == "5")) {
428
+          if(($this->_isArchive($v_header['filename']))
429
+		      && ($v_header['typeflag']=="5")) {
430 430
             $this->_error('Directory '.$v_header['filename']
431 431
 			              .' already exists as a file');
432 432
             return false;
433 433
           }
434
-          if (!is_writeable($v_header['filename'])) {
434
+          if(!is_writeable($v_header['filename'])) {
435 435
             $this->_error('File '.$v_header['filename']
436 436
 			              .' already exists and is write protected');
437 437
             return false;
438 438
           }
439
-          if (filemtime($v_header['filename']) > $v_header['mtime']) {
439
+          if(filemtime($v_header['filename']) > $v_header['mtime']) {
440 440
             // To be completed : An error or silent no replace ?
441 441
           }
442 442
         }
443 443
 
444 444
         // ----- Check the directory availability and create it if necessary
445
-        elseif (($v_result
446
-		         = $this->_dirCheck(($v_header['typeflag'] == "5"
447
-				                    ?$v_header['filename']
448
-									:dirname($v_header['filename'])))) != 1) {
445
+        elseif(($v_result
446
+		         = $this->_dirCheck(($v_header['typeflag']=="5"
447
+				                    ? $v_header['filename']
448
+									:dirname($v_header['filename']))))!=1) {
449 449
             $this->_error('Unable to create path for '.$v_header['filename']);
450 450
             return false;
451 451
         }
452 452
 
453
-        if ($v_extract_file) {
454
-          if ($v_header['typeflag'] == "5") {
455
-            if (!@file_exists($v_header['filename'])) {
456
-                if (!@mkdir($v_header['filename'], PRADO_CHMOD)) {
453
+        if($v_extract_file) {
454
+          if($v_header['typeflag']=="5") {
455
+            if(!@file_exists($v_header['filename'])) {
456
+                if(!@mkdir($v_header['filename'], PRADO_CHMOD)) {
457 457
                     $this->_error('Unable to create directory {'
458 458
 					              .$v_header['filename'].'}');
459 459
                     return false;
@@ -461,18 +461,18 @@  discard block
 block discarded – undo
461 461
                 chmod($v_header['filename'], PRADO_CHMOD);
462 462
             }
463 463
           } else {
464
-              if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) {
464
+              if(($v_dest_file=@fopen($v_header['filename'], "wb"))==0) {
465 465
                   $this->_error('Error while opening {'.$v_header['filename']
466 466
 				                .'} in write binary mode');
467 467
                   return false;
468 468
               } else {
469
-                  $n = floor($v_header['size']/512);
470
-                  for ($i=0; $i<$n; $i++) {
471
-                      $v_content = $this->_readBlock();
469
+                  $n=floor($v_header['size'] / 512);
470
+                  for($i=0; $i < $n; $i++) {
471
+                      $v_content=$this->_readBlock();
472 472
                       fwrite($v_dest_file, $v_content, 512);
473 473
                   }
474
-            if (($v_header['size'] % 512) != 0) {
475
-              $v_content = $this->_readBlock();
474
+            if(($v_header['size'] % 512)!=0) {
475
+              $v_content=$this->_readBlock();
476 476
               fwrite($v_dest_file, $v_content, ($v_header['size'] % 512));
477 477
             }
478 478
 
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 
487 487
           // ----- Check the file size
488 488
           clearstatcache();
489
-          if (filesize($v_header['filename']) != $v_header['size']) {
489
+          if(filesize($v_header['filename'])!=$v_header['size']) {
490 490
               $this->_error('Extracted file '.$v_header['filename']
491 491
 			                .' does not have the correct file size \''
492 492
 							.filesize($v_header['filename'])
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
           }
497 497
           }
498 498
         } else {
499
-          $this->_jumpBlock(ceil(($v_header['size']/512)));
499
+          $this->_jumpBlock(ceil(($v_header['size'] / 512)));
500 500
         }
501 501
       } else {
502
-          $this->_jumpBlock(ceil(($v_header['size']/512)));
502
+          $this->_jumpBlock(ceil(($v_header['size'] / 512)));
503 503
       }
504 504
 
505 505
       /* TBC : Seems to be unused ...
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
         $v_end_of_file = @feof($this->_file);
510 510
         */
511 511
 
512
-      if ($v_listing || $v_extract_file || $v_extraction_stopped) {
512
+      if($v_listing || $v_extract_file || $v_extraction_stopped) {
513 513
         // ----- Log extracted files
514
-        if (($v_file_dir = dirname($v_header['filename']))
514
+        if(($v_file_dir=dirname($v_header['filename']))
515 515
 		    == $v_header['filename'])
516
-          $v_file_dir = '';
517
-        if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == ''))
518
-          $v_file_dir = '/';
516
+          $v_file_dir='';
517
+        if((substr($v_header['filename'], 0, 1)=='/') && ($v_file_dir==''))
518
+          $v_file_dir='/';
519 519
 
520
-        $p_list_detail[$v_nb++] = $v_header;
520
+        $p_list_detail[$v_nb++]=$v_header;
521 521
       }
522 522
     }
523 523
 
@@ -534,36 +534,36 @@  discard block
 block discarded – undo
534 534
      */
535 535
     protected function _dirCheck($p_dir)
536 536
     {
537
-        if ((@is_dir($p_dir)) || ($p_dir == ''))
537
+        if((@is_dir($p_dir)) || ($p_dir==''))
538 538
             return true;
539 539
 
540
-        $p_parent_dir = dirname($p_dir);
540
+        $p_parent_dir=dirname($p_dir);
541 541
 
542
-        if (($p_parent_dir != $p_dir) &&
543
-            ($p_parent_dir != '') &&
542
+        if(($p_parent_dir!=$p_dir) &&
543
+            ($p_parent_dir!='') &&
544 544
             (!$this->_dirCheck($p_parent_dir)))
545 545
              return false;
546 546
 
547
-        if (!@mkdir($p_dir, PRADO_CHMOD)) {
547
+        if(!@mkdir($p_dir, PRADO_CHMOD)) {
548 548
             $this->_error("Unable to create directory '$p_dir'");
549 549
             return false;
550 550
         }
551
-        chmod($p_dir,PRADO_CHMOD);
551
+        chmod($p_dir, PRADO_CHMOD);
552 552
 
553 553
         return true;
554 554
     }
555 555
 
556 556
     protected function _translateWinPath($p_path, $p_remove_disk_letter=true)
557 557
     {
558
-      if (substr(PHP_OS, 0, 3) == 'WIN') {
558
+      if(substr(PHP_OS, 0, 3)=='WIN') {
559 559
           // ----- Look for potential disk letter
560
-          if (   ($p_remove_disk_letter)
561
-		      && (($v_position = strpos($p_path, ':')) != false)) {
562
-              $p_path = substr($p_path, $v_position+1);
560
+          if(($p_remove_disk_letter)
561
+		      && (($v_position=strpos($p_path, ':'))!=false)) {
562
+              $p_path=substr($p_path, $v_position + 1);
563 563
           }
564 564
           // ----- Change potential windows directory separator
565
-          if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
566
-              $p_path = strtr($p_path, '\\', '/');
565
+          if((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1)=='\\')) {
566
+              $p_path=strtr($p_path, '\\', '/');
567 567
           }
568 568
       }
569 569
       return $p_path;
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleCommandBuilder.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleTableColumn.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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))
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleMetaData.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class TOracleMetaData extends TDbMetaData
27 27
 {
28
-	private $_defaultSchema = 'system';
28
+	private $_defaultSchema='system';
29 29
 
30 30
 
31 31
 	/**
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	protected function getSchemaTableName($table)
60 60
 	{
61
-		if(count($parts= explode('.', str_replace('"','',$table))) > 1)
61
+		if(count($parts=explode('.', str_replace('"', '', $table))) > 1)
62 62
 			return array($parts[0], $parts[1]);
63 63
 		else
64
-			return array($this->getDefaultSchema(),$parts[0]);
64
+			return array($this->getDefaultSchema(), $parts[0]);
65 65
 	}
66 66
 
67 67
 	/**
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	protected function createTableInfo($table)
73 73
 	{
74
-		list($schemaName,$tableName) = $this->getSchemaTableName($table);
74
+		list($schemaName, $tableName)=$this->getSchemaTableName($table);
75 75
 
76 76
 		// This query is made much more complex by the addition of the 'attisserial' field.
77 77
 		// The subquery to get that field checks to see if there is an internally dependent
78 78
 		// sequence on the field.
79
-		$sql =
79
+		$sql=
80 80
 <<<EOD
81 81
 		SELECT
82 82
 			a.COLUMN_ID,
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 EOD;
97 97
 		$this->getDbConnection()->setActive(true);
98 98
 		$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
99
-		$command = $this->getDbConnection()->createCommand($sql);
99
+		$command=$this->getDbConnection()->createCommand($sql);
100 100
 		//$command->bindValue(':table', $tableName);
101 101
 		//$command->bindValue(':schema', $schemaName);
102
-		$tableInfo = $this->createNewTableInfo($schemaName, $tableName);
102
+		$tableInfo=$this->createNewTableInfo($schemaName, $tableName);
103 103
 		$index=0;
104 104
 		foreach($command->query() as $col)
105 105
 		{
106
-			$col['index'] = $index++;
106
+			$col['index']=$index++;
107 107
 			$this->processColumn($tableInfo, $col);
108 108
 		}
109 109
 		if($index===0)
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 	 * @param string table name.
117 117
 	 * @return TOracleTableInfo
118 118
 	 */
119
-	protected function createNewTableInfo($schemaName,$tableName)
119
+	protected function createNewTableInfo($schemaName, $tableName)
120 120
 	{
121
-		$info['SchemaName'] = $this->assertIdentifier($schemaName);
122
-		$info['TableName']	= $this->assertIdentifier($tableName);
123
-		$info['IsView'] 	= false;
124
-		if($this->getIsView($schemaName,$tableName)) $info['IsView'] = true;
125
-		list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName);
126
-		$class = $this->getTableInfoClass();
127
-		return new $class($info,$primary,$foreign);
121
+		$info['SchemaName']=$this->assertIdentifier($schemaName);
122
+		$info['TableName']=$this->assertIdentifier($tableName);
123
+		$info['IsView']=false;
124
+		if($this->getIsView($schemaName, $tableName)) $info['IsView']=true;
125
+		list($primary, $foreign)=$this->getConstraintKeys($schemaName, $tableName);
126
+		$class=$this->getTableInfoClass();
127
+		return new $class($info, $primary, $foreign);
128 128
 	}
129 129
 
130 130
 	/**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	{
137 137
 		if(strpos($name, '"')!==false)
138 138
 		{
139
-			$ref = 'http://www.oracle.com';
139
+			$ref='http://www.oracle.com';
140 140
 			throw new TDbException('dbcommon_invalid_identifier_name', $name, $ref);
141 141
 		}
142 142
 		return $name;
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 	 * @param string table name.
148 148
 	 * @return boolean true if the table is a view.
149 149
 	 */
150
-	protected function getIsView($schemaName,$tableName)
150
+	protected function getIsView($schemaName, $tableName)
151 151
 	{
152 152
 		$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
153
-		$sql =
153
+		$sql=
154 154
 <<<EOD
155 155
 		select	OBJECT_TYPE
156 156
 		from 	ALL_OBJECTS
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 		and 	OWNER = '{$schemaName}'
159 159
 EOD;
160 160
 		$this->getDbConnection()->setActive(true);
161
-		$command = $this->getDbConnection()->createCommand($sql);
161
+		$command=$this->getDbConnection()->createCommand($sql);
162 162
 		//$command->bindValue(':schema',$schemaName);
163 163
 		//$command->bindValue(':table', $tableName);
164
-		return intval($command->queryScalar() === 'VIEW');
164
+		return intval($command->queryScalar()==='VIEW');
165 165
 	}
166 166
 
167 167
 	/**
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	protected function processColumn($tableInfo, $col)
172 172
 	{
173
-		$columnId = strtolower($col['attname']); //use column name as column Id
173
+		$columnId=strtolower($col['attname']); //use column name as column Id
174 174
 
175 175
 		//$info['ColumnName'] 	= '"'.$columnId.'"'; //quote the column names!
176
-		$info['ColumnName'] 	= $columnId; //NOT quote the column names!
177
-		$info['ColumnId'] 		= $columnId;
178
-		$info['ColumnIndex'] 	= $col['index'];
179
-		if(! (bool)$col['attnotnull'] ) $info['AllowNull'] = true;
180
-		if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey'] = true;
181
-		if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey'] = true;
182
-		if( (int)$col['atttypmod'] > 0 ) $info['ColumnSize'] =  $col['atttypmod']; // - 4;
183
-		if( (bool)$col['atthasdef'] ) $info['DefaultValue'] = $col['adsrc'];
176
+		$info['ColumnName']=$columnId; //NOT quote the column names!
177
+		$info['ColumnId']=$columnId;
178
+		$info['ColumnIndex']=$col['index'];
179
+		if(!(bool) $col['attnotnull']) $info['AllowNull']=true;
180
+		if(in_array($columnId, $tableInfo->getPrimaryKeys())) $info['IsPrimaryKey']=true;
181
+		if($this->isForeignKeyColumn($columnId, $tableInfo)) $info['IsForeignKey']=true;
182
+		if((int) $col['atttypmod'] > 0) $info['ColumnSize']=$col['atttypmod']; // - 4;
183
+		if((bool) $col['atthasdef']) $info['DefaultValue']=$col['adsrc'];
184 184
 		//
185 185
 		// For a while Oracle Tables has no  associated AutoIncrement Triggers
186 186
 		//
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 			}
195 195
 		}
196 196
 		*/
197
-		$matches = array();
197
+		$matches=array();
198 198
 		if(preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches))
199 199
 		{
200
-			$info['DbType'] = preg_replace('/\(\d+(?:,\d+)?\)/','',$col['type']);
200
+			$info['DbType']=preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']);
201 201
 			if($this->isPrecisionType($info['DbType']))
202 202
 			{
203
-				$info['NumericPrecision'] = intval($matches[1]);
203
+				$info['NumericPrecision']=intval($matches[1]);
204 204
 				if(count($matches) > 2)
205
-					$info['NumericScale'] = intval($matches[2]);
205
+					$info['NumericScale']=intval($matches[2]);
206 206
 			}
207 207
 			else
208
-				$info['ColumnSize'] = intval($matches[1]);
208
+				$info['ColumnSize']=intval($matches[1]);
209 209
 		}
210 210
 		else
211
-			$info['DbType'] = $col['type'];
212
-		$tableInfo->Columns[$columnId] = new TOracleTableColumn($info);
211
+			$info['DbType']=$col['type'];
212
+		$tableInfo->Columns[$columnId]=new TOracleTableColumn($info);
213 213
 	}
214 214
 
215 215
 	/**
216 216
 	 * @return string serial name if found, null otherwise.
217 217
 	 */
218
-	protected function getSequenceName($tableInfo,$src)
218
+	protected function getSequenceName($tableInfo, $src)
219 219
 	{
220
-		$matches = array();
221
-		if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i',$src,$matches))
220
+		$matches=array();
221
+		if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches))
222 222
 		{
223 223
 			if(is_int(strpos($matches[1], '.')))
224 224
 				return $matches[1];
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	protected function isPrecisionType($type)
234 234
 	{
235
-		$type = strtolower(trim($type));
235
+		$type=strtolower(trim($type));
236 236
 		return $type==='number'; // || $type==='interval' || strpos($type, 'time')===0;
237 237
 	}
238 238
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	{
247 247
 		$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
248 248
 //		select decode( a.CONSTRAINT_TYPE, 'P', 'PRIMARY KEY (', 'FOREIGN KEY (' )||b.COLUMN_NAME||')' as consrc,
249
-		$sql =
249
+		$sql=
250 250
 <<<EOD
251 251
 		select b.COLUMN_NAME as consrc,
252 252
 			   a.CONSTRAINT_TYPE as contype
@@ -257,24 +257,24 @@  discard block
 block discarded – undo
257 257
 		and   a.CONSTRAINT_TYPE in ('P','R')
258 258
 EOD;
259 259
 		$this->getDbConnection()->setActive(true);
260
-		$command = $this->getDbConnection()->createCommand($sql);
260
+		$command=$this->getDbConnection()->createCommand($sql);
261 261
 		//$command->bindValue(':table', $tableName);
262 262
 		//$command->bindValue(':schema', $schemaName);
263
-		$primary = array();
264
-		$foreign = array();
263
+		$primary=array();
264
+		$foreign=array();
265 265
 		foreach($command->query() as $row)
266 266
 		{
267
-			switch( strtolower( $row['contype'] ) )
267
+			switch(strtolower($row['contype']))
268 268
 			{
269 269
 				case 'p':
270
-					$primary = array_merge( $primary, array(strtolower( $row['consrc'] )) );
270
+					$primary=array_merge($primary, array(strtolower($row['consrc'])));
271 271
 					/*
272 272
 					$arr = $this->getPrimaryKeys($row['consrc']);
273 273
 					$primary = array_merge( $primary, array(strtolower( $arr[0] )) );
274 274
 					*/
275 275
 					break;
276 276
 				case 'r':
277
-					$foreign = array_merge( $foreign, array(strtolower( $row['consrc'] )) );
277
+					$foreign=array_merge($foreign, array(strtolower($row['consrc'])));
278 278
 					/*
279 279
 					// if(($fkey = $this->getForeignKeys($row['consrc']))!==null)
280 280
 					$fkey = $this->getForeignKeys( $row['consrc'] );
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 					break;
284 284
 			}
285 285
 		}
286
-		return array($primary,$foreign);
286
+		return array($primary, $foreign);
287 287
 	}
288 288
 
289 289
 	/**
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	protected function getPrimaryKeys($src)
295 295
 	{
296
-		$matches = array();
296
+		$matches=array();
297 297
 		if(preg_match('/PRIMARY\s+KEY\s+\(([^\)]+)\)/i', $src, $matches))
298
-			return preg_split('/,\s+/',$matches[1]);
298
+			return preg_split('/,\s+/', $matches[1]);
299 299
 		return array();
300 300
 	}
301 301
 
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	protected function getForeignKeys($src)
308 308
 	{
309
-		$matches = array();
310
-		$brackets = '\(([^\)]+)\)';
311
-		$find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
309
+		$matches=array();
310
+		$brackets='\(([^\)]+)\)';
311
+		$find="/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
312 312
 		if(preg_match($find, $src, $matches))
313 313
 		{
314
-			$keys = preg_split('/,\s+/', $matches[1]);
315
-			$fkeys = array();
314
+			$keys=preg_split('/,\s+/', $matches[1]);
315
+			$fkeys=array();
316 316
 			foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey)
317
-				$fkeys[$keys[$i]] = $fkey;
318
-			return array('table' => str_replace('"','',$matches[2]), 'keys' => $fkeys);
317
+				$fkeys[$keys[$i]]=$fkey;
318
+			return array('table' => str_replace('"', '', $matches[2]), 'keys' => $fkeys);
319 319
 		}
320 320
 	}
321 321
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	{
329 329
 		foreach($tableInfo->getForeignKeys() as $fk)
330 330
 		{
331
-			if( $fk==$columnId )
331
+			if($fk==$columnId)
332 332
 			//if(in_array($columnId, array_keys($fk['keys'])))
333 333
 				return true;
334 334
 		}
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 WHERE object_type = 'TABLE' AND owner=:schema
358 358
 EOD;
359 359
 			$command=$this->getDbConnection()->createCommand($sql);
360
-			$command->bindParam(':schema',$schema);
360
+			$command->bindParam(':schema', $schema);
361 361
 		}
362 362
 
363 363
 		$rows=$command->queryAll();
Please login to merge, or discard this patch.
framework/Data/Common/Oracle/TOracleTableInfo.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * Sets the database table meta data information.
33 33
 	 * @param array table column information.
34 34
 	 */
35
-	public function __construct($tableInfo=array(),$primary=array(),$foreign=array())
35
+	public function __construct($tableInfo=array(), $primary=array(), $foreign=array())
36 36
 	{
37 37
 		$this->_info=$tableInfo;
38 38
 		$this->_primaryKeys=$primary;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	public function createCommandBuilder($connection)
48 48
 	{
49 49
 		Prado::using('System.Data.Common.Oracle.TOracleCommandBuilder');
50
-		return new TOracleCommandBuilder($connection,$this);
50
+		return new TOracleCommandBuilder($connection, $this);
51 51
 	}
52 52
 
53 53
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param mixed default value if information array value is null
56 56
 	 * @return mixed information array value.
57 57
 	 */
58
-	public function getInfo($name,$default=null)
58
+	public function getInfo($name, $default=null)
59 59
 	{
60 60
 		return isset($this->_info[$name]) ? $this->_info[$name] : $default;
61 61
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @param string information array key name
65 65
 	 * @param mixed new information array value.
66 66
 	 */
67
-	protected function setInfo($name,$value)
67
+	protected function setInfo($name, $value)
68 68
 	{
69 69
 		$this->_info[$name]=$value;
70 70
 	}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function getIsView()
92 92
 	{
93
-		return $this->getInfo('IsView',false);
93
+		return $this->getInfo('IsView', false);
94 94
 	}
95 95
 
96 96
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function getColumn($name)
109 109
 	{
110
-		if(($column = $this->_columns->itemAt($name))!==null)
110
+		if(($column=$this->_columns->itemAt($name))!==null)
111 111
 			return $column;
112 112
 		throw new TDbException('dbtableinfo_invalid_column_name', $name, $this->getTableFullName());
113 113
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	public function getColumnNames()
120 120
 	{
121 121
 		foreach($this->getColumns() as $column)
122
-			$names[] = $column->getColumnName();
122
+			$names[]=$column->getColumnName();
123 123
 		return $names;
124 124
 	}
125 125
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		{
149 149
 			$this->_lowercase=array();
150 150
 			foreach($this->getColumns()->getKeys() as $key)
151
-				$this->_lowercase[strtolower($key)] = $key;
151
+				$this->_lowercase[strtolower($key)]=$key;
152 152
 		}
153 153
 		return $this->_lowercase;
154 154
 	}
Please login to merge, or discard this patch.