Completed
Push — scrutinizer ( c2ef4a )
by Fabio
21:50
created
bin/prado-cli.php 2 patches
Doc Comments   +40 added lines patch added patch discarded remove patch
@@ -145,6 +145,10 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public abstract function performAction($args);
147 147
 
148
+	/**
149
+	 * @param string $dir
150
+	 * @param integer $mask
151
+	 */
148 152
 	protected function createDirectory($dir, $mask)
149 153
 	{
150 154
 		if(!is_dir($dir))
@@ -156,6 +160,9 @@  discard block
 block discarded – undo
156 160
 			chmod($dir, $mask);
157 161
 	}
158 162
 
163
+	/**
164
+	 * @param string $filename
165
+	 */
159 166
 	protected function createFile($filename, $content)
160 167
 	{
161 168
 		if(!is_file($filename))
@@ -304,6 +311,9 @@  discard block
 block discarded – undo
304 311
 ';
305 312
 	}
306 313
 
314
+	/**
315
+	 * @param string $appName
316
+	 */
307 317
 	protected function renderConfigFile($appName)
308 318
 	{
309 319
 		return <<<EOD
@@ -500,6 +510,9 @@  discard block
 block discarded – undo
500 510
 		require_once($TEST_TOOLS.'/simpletest/reporter.php');
501 511
 	}
502 512
 
513
+	/**
514
+	 * @param string $dir
515
+	 */
503 516
 	protected function runUnitTests($dir, $args)
504 517
 	{
505 518
 		$app_dir = $this->getAppDir($dir);
@@ -538,6 +551,9 @@  discard block
 block discarded – undo
538 551
 		return realpath($dir.'/tests/unit/');
539 552
 	}
540 553
 
554
+	/**
555
+	 * @param string $dir
556
+	 */
541 557
 	protected function getUnitTestCases($dir,$args)
542 558
 	{
543 559
 		$matches = null;
@@ -549,6 +565,9 @@  discard block
 block discarded – undo
549 565
 		return $test;
550 566
 	}
551 567
 
568
+	/**
569
+	 * @param GroupTest $test
570
+	 */
552 571
 	protected function addTests($test,$path,$recursive=true,$match=null)
553 572
 	{
554 573
 		$dir=opendir($path);
@@ -565,6 +584,9 @@  discard block
 block discarded – undo
565 584
 		closedir($dir);
566 585
 	}
567 586
 
587
+	/**
588
+	 * @param string $entry
589
+	 */
568 590
 	protected function hasMatch($match,$entry)
569 591
 	{
570 592
 		$file = strtolower(substr($entry,0,strrpos($entry,'.')));
@@ -630,6 +652,9 @@  discard block
 block discarded – undo
630 652
 		return false;
631 653
 	}
632 654
 
655
+	/**
656
+	 * @param string $app_dir
657
+	 */
633 658
 	protected function getActiveRecordConfig($app_dir)
634 659
 	{
635 660
 		if(false === ($xml=$this->getXmlFile($app_dir)))
@@ -645,6 +670,9 @@  discard block
 block discarded – undo
645 670
 		return false;
646 671
 	}
647 672
 
673
+	/**
674
+	 * @param string $app_dir
675
+	 */
648 676
 	protected function getOutputFile($app_dir, $namespace)
649 677
 	{
650 678
 		if(is_file($namespace) && strpos($namespace, $app_dir)===0)
@@ -659,6 +687,9 @@  discard block
 block discarded – undo
659 687
 		return false;
660 688
 	}
661 689
 
690
+	/**
691
+	 * @param TActiveRecordConfig $config
692
+	 */
662 693
 	protected function generateActiveRecord($config, $tablename, $output)
663 694
 	{
664 695
 		$manager = TActiveRecordManager::getInstance();
@@ -706,6 +737,9 @@  discard block
 block discarded – undo
706 737
 		return $prop;
707 738
 	}
708 739
 
740
+	/**
741
+	 * @param string $class
742
+	 */
709 743
 	protected function generateClass($properties, $tablename, $class)
710 744
 	{
711 745
 		$props = implode("\n", $properties);
@@ -799,6 +833,9 @@  discard block
 block discarded – undo
799 833
         return false;
800 834
     }
801 835
 
836
+    /**
837
+     * @param string $app_dir
838
+     */
802 839
     protected function getActiveRecordConfig($app_dir) {
803 840
         if (false === ($xml = $this->getXmlFile($app_dir)))
804 841
             return false;
@@ -842,6 +879,9 @@  discard block
 block discarded – undo
842 879
 			}
843 880
 	    }
844 881
 
882
+	    /**
883
+	     * @param string $l
884
+	     */
845 885
 	    public function generate($l)
846 886
 	    {
847 887
 			$input = explode(" ", trim($l));
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
  * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
10 10
  */
11 11
 
12
-if(!isset($_SERVER['argv']) || php_sapi_name()!=='cli')
12
+if (!isset($_SERVER['argv']) || php_sapi_name() !== 'cli')
13 13
 	die('Must be run from the command line');
14 14
 
15
-$frameworkPath = realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR;
15
+$frameworkPath = realpath(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR;
16 16
 
17
-require_once($frameworkPath.'prado.php');
17
+require_once($frameworkPath . 'prado.php');
18 18
 
19 19
 //stub application class
20 20
 class PradoShellApplication extends TApplication
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 restore_exception_handler();
29 29
 
30 30
 //config PHP shell
31
-if(count($_SERVER['argv']) > 1 && strtolower($_SERVER['argv'][1])==='shell')
31
+if (count($_SERVER['argv']) > 1 && strtolower($_SERVER['argv'][1]) === 'shell')
32 32
 {
33
-	function __shell_print_var($shell,$var)
33
+	function __shell_print_var($shell, $var)
34 34
 	{
35
-		if(!$shell->has_semicolon) echo Prado::varDump($var);
35
+		if (!$shell->has_semicolon) echo Prado::varDump($var);
36 36
 	}
37
-	include_once($frameworkPath.'/3rdParty/PhpShell/php-shell-init.php');
37
+	include_once($frameworkPath . '/3rdParty/PhpShell/php-shell-init.php');
38 38
 }
39 39
 
40 40
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	/**
65 65
 	 * @var array command action classes
66 66
 	 */
67
-	protected $_actions=array();
67
+	protected $_actions = array();
68 68
 
69 69
 	/**
70 70
 	 * @param string action class name
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	public static function getInstance()
81 81
 	{
82 82
 		static $instance;
83
-		if($instance === null)
83
+		if ($instance === null)
84 84
 			$instance = new self;
85 85
 		return $instance;
86 86
 	}
87 87
 
88 88
 	public static function printGreeting()
89 89
 	{
90
-		echo "Command line tools for Prado ".Prado::getVersion().".\n";
90
+		echo "Command line tools for Prado " . Prado::getVersion() . ".\n";
91 91
 	}
92 92
 
93 93
 	/**
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function run($args)
98 98
 	{
99
-		if(count($args) > 1)
99
+		if (count($args) > 1)
100 100
 			array_shift($args);
101 101
 		$valid = false;
102
-		foreach($this->_actions as $class => $action)
102
+		foreach ($this->_actions as $class => $action)
103 103
 		{
104
-			if($action->isValidAction($args))
104
+			if ($action->isValidAction($args))
105 105
 			{
106 106
 				$valid |= $action->performAction($args);
107 107
 				break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 				$valid = false;
112 112
 			}
113 113
 		}
114
-		if(!$valid)
114
+		if (!$valid)
115 115
 			$this->printHelp();
116 116
 	}
117 117
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		echo "usage: php prado-cli.php action <parameter> [optional]\n";
126 126
 		echo "example: php prado-cli.php -c mysite\n\n";
127 127
 		echo "actions:\n";
128
-		foreach($this->_actions as $action)
128
+		foreach ($this->_actions as $action)
129 129
 			echo $action->renderHelp();
130 130
 	}
131 131
 }
@@ -147,18 +147,18 @@  discard block
 block discarded – undo
147 147
 
148 148
 	protected function createDirectory($dir, $mask)
149 149
 	{
150
-		if(!is_dir($dir))
150
+		if (!is_dir($dir))
151 151
 		{
152 152
 			mkdir($dir);
153 153
 			echo "creating $dir\n";
154 154
 		}
155
-		if(is_dir($dir))
155
+		if (is_dir($dir))
156 156
 			chmod($dir, $mask);
157 157
 	}
158 158
 
159 159
 	protected function createFile($filename, $content)
160 160
 	{
161
-		if(!is_file($filename))
161
+		if (!is_file($filename))
162 162
 		{
163 163
 			file_put_contents($filename, $content);
164 164
 			echo "creating $filename\n";
@@ -168,22 +168,22 @@  discard block
 block discarded – undo
168 168
 	public function isValidAction($args)
169 169
 	{
170 170
 		return strtolower($args[0]) === $this->action &&
171
-				count($args)-1 >= count($this->parameters);
171
+				count($args) - 1 >= count($this->parameters);
172 172
 	}
173 173
 
174 174
 	public function renderHelp()
175 175
 	{
176 176
 		$params = array();
177
-		foreach($this->parameters as $v)
178
-			$params[] = '<'.$v.'>';
177
+		foreach ($this->parameters as $v)
178
+			$params[] = '<' . $v . '>';
179 179
 		$parameters = join($params, ' ');
180 180
 		$options = array();
181
-		foreach($this->optional as $v)
182
-			$options[] = '['.$v.']';
183
-		$optional = (strlen($parameters) ? ' ' : ''). join($options, ' ');
184
-		$description='';
185
-		foreach(explode("\n", wordwrap($this->description,65)) as $line)
186
-			$description .= '    '.$line."\n";
181
+		foreach ($this->optional as $v)
182
+			$options[] = '[' . $v . ']';
183
+		$optional = (strlen($parameters) ? ' ' : '') . join($options, ' ');
184
+		$description = '';
185
+		foreach (explode("\n", wordwrap($this->description, 65)) as $line)
186
+			$description .= '    ' . $line . "\n";
187 187
 		return <<<EOD
188 188
   {$this->action} {$parameters}{$optional}
189 189
 {$description}
@@ -193,17 +193,17 @@  discard block
 block discarded – undo
193 193
 
194 194
 	protected function initializePradoApplication($directory)
195 195
 	{
196
-		$app_dir = realpath($directory.'/protected/');
197
-		if($app_dir !== false && is_dir($app_dir))
196
+		$app_dir = realpath($directory . '/protected/');
197
+		if ($app_dir !== false && is_dir($app_dir))
198 198
 		{
199
-			if(Prado::getApplication()===null)
199
+			if (Prado::getApplication() === null)
200 200
 			{
201 201
 				$app = new PradoShellApplication($app_dir);
202 202
 				$app->run();
203
-				$dir = substr(str_replace(realpath('./'),'',$app_dir),1);
204
-				$initialized=true;
203
+				$dir = substr(str_replace(realpath('./'), '', $app_dir), 1);
204
+				$initialized = true;
205 205
 				PradoCommandLineInterpreter::printGreeting();
206
-				echo '** Loaded PRADO appplication in directory "'.$dir."\".\n";
206
+				echo '** Loaded PRADO appplication in directory "' . $dir . "\".\n";
207 207
 			}
208 208
 
209 209
 			return Prado::getApplication();
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 		else
212 212
 		{
213 213
 			PradoCommandLineInterpreter::printGreeting();
214
-			echo '+'.str_repeat('-',77)."+\n";
215
-			echo '** Unable to load PRADO application in directory "'.$directory."\".\n";
216
-			echo '+'.str_repeat('-',77)."+\n";
214
+			echo '+' . str_repeat('-', 77) . "+\n";
215
+			echo '** Unable to load PRADO application in directory "' . $directory . "\".\n";
216
+			echo '+' . str_repeat('-', 77) . "+\n";
217 217
 		}
218 218
 		return false;
219 219
 	}
@@ -245,31 +245,31 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	protected function createNewPradoProject($dir)
247 247
 	{
248
-		if(strlen(trim($dir)) == 0)
248
+		if (strlen(trim($dir)) == 0)
249 249
 			return;
250 250
 
251 251
 		$rootPath = realpath(dirname(trim($dir)));
252 252
 
253
-		if(basename($dir)!=='.')
254
-			$basePath = $rootPath.DIRECTORY_SEPARATOR.basename($dir);
253
+		if (basename($dir) !== '.')
254
+			$basePath = $rootPath . DIRECTORY_SEPARATOR . basename($dir);
255 255
 		else
256 256
 			$basePath = $rootPath;
257 257
 		$appName = basename($basePath);
258
-		$assetPath = $basePath.DIRECTORY_SEPARATOR.'assets';
259
-		$protectedPath  = $basePath.DIRECTORY_SEPARATOR.'protected';
260
-		$runtimePath = $basePath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'runtime';
261
-		$pagesPath = $protectedPath.DIRECTORY_SEPARATOR.'pages';
258
+		$assetPath = $basePath . DIRECTORY_SEPARATOR . 'assets';
259
+		$protectedPath = $basePath . DIRECTORY_SEPARATOR . 'protected';
260
+		$runtimePath = $basePath . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'runtime';
261
+		$pagesPath = $protectedPath . DIRECTORY_SEPARATOR . 'pages';
262 262
 
263
-		$indexFile = $basePath.DIRECTORY_SEPARATOR.'index.php';
264
-		$htaccessFile = $protectedPath.DIRECTORY_SEPARATOR.'.htaccess';
265
-		$configFile = $protectedPath.DIRECTORY_SEPARATOR.'application.xml';
266
-		$defaultPageFile = $pagesPath.DIRECTORY_SEPARATOR.'Home.page';
263
+		$indexFile = $basePath . DIRECTORY_SEPARATOR . 'index.php';
264
+		$htaccessFile = $protectedPath . DIRECTORY_SEPARATOR . '.htaccess';
265
+		$configFile = $protectedPath . DIRECTORY_SEPARATOR . 'application.xml';
266
+		$defaultPageFile = $pagesPath . DIRECTORY_SEPARATOR . 'Home.page';
267 267
 
268 268
 		$this->createDirectory($basePath, 0755);
269
-		$this->createDirectory($assetPath,0777);
270
-		$this->createDirectory($protectedPath,0755);
271
-		$this->createDirectory($runtimePath,0777);
272
-		$this->createDirectory($pagesPath,0755);
269
+		$this->createDirectory($assetPath, 0777);
270
+		$this->createDirectory($protectedPath, 0755);
271
+		$this->createDirectory($runtimePath, 0777);
272
+		$this->createDirectory($pagesPath, 0755);
273 273
 
274 274
 		$this->createFile($indexFile, $this->renderIndexFile());
275 275
 		$this->createFile($configFile, $this->renderConfigFile($appName));
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
 
280 280
 	protected function renderIndexFile()
281 281
 	{
282
-		$framework = realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'prado.php';
282
+		$framework = realpath(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'prado.php';
283 283
 return '<?php
284 284
 
285
-$frameworkPath=\''.$framework.'\';
285
+$frameworkPath=\''.$framework . '\';
286 286
 
287 287
 // The following directory checks may be removed if performance is required
288 288
 $basePath=dirname(__FILE__);
@@ -392,22 +392,22 @@  discard block
 block discarded – undo
392 392
 
393 393
 	protected function createTestFixtures($dir)
394 394
 	{
395
-		if(strlen(trim($dir)) == 0)
395
+		if (strlen(trim($dir)) == 0)
396 396
 			return;
397 397
 
398 398
 		$rootPath = realpath(dirname(trim($dir)));
399
-		$basePath = $rootPath.'/'.basename($dir);
399
+		$basePath = $rootPath . '/' . basename($dir);
400 400
 
401
-		$tests = $basePath.'/tests';
402
-		$unit_tests = $tests.'/unit';
403
-		$functional_tests = $tests.'/functional';
401
+		$tests = $basePath . '/tests';
402
+		$unit_tests = $tests . '/unit';
403
+		$functional_tests = $tests . '/functional';
404 404
 
405
-		$this->createDirectory($tests,0755);
406
-		$this->createDirectory($unit_tests,0755);
407
-		$this->createDirectory($functional_tests,0755);
405
+		$this->createDirectory($tests, 0755);
406
+		$this->createDirectory($unit_tests, 0755);
407
+		$this->createDirectory($functional_tests, 0755);
408 408
 
409
-		$unit_test_index = $tests.'/unit.php';
410
-		$functional_test_index = $tests.'/functional.php';
409
+		$unit_test_index = $tests . '/unit.php';
410
+		$functional_test_index = $tests . '/functional.php';
411 411
 
412 412
 		$this->createFile($unit_test_index, $this->renderUnitTestFixture());
413 413
 		$this->createFile($functional_test_index, $this->renderFunctionalTestFixture());
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
 
416 416
 	protected function renderUnitTestFixture()
417 417
 	{
418
-		$tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/unit_tests.php';
418
+		$tester = realpath(dirname(dirname(__FILE__))) . '/tests/test_tools/unit_tests.php';
419 419
 return '<?php
420 420
 
421
-include_once \''.$tester.'\';
421
+include_once \''.$tester . '\';
422 422
 
423 423
 $app_directory = "../protected";
424 424
 $test_cases = dirname(__FILE__)."/unit";
@@ -430,10 +430,10 @@  discard block
 block discarded – undo
430 430
 
431 431
 	protected function renderFunctionalTestFixture()
432 432
 	{
433
-		$tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/functional_tests.php';
433
+		$tester = realpath(dirname(dirname(__FILE__))) . '/tests/test_tools/functional_tests.php';
434 434
 return '<?php
435 435
 
436
-include_once \''.$tester.'\';
436
+include_once \''.$tester . '\';
437 437
 
438 438
 $test_cases = dirname(__FILE__)."/functional";
439 439
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
 	public function performAction($args)
461 461
 	{
462
-		if(count($args) > 1)
462
+		if (count($args) > 1)
463 463
 			$app = $this->initializePradoApplication($args[1]);
464 464
 		return true;
465 465
 	}
@@ -483,94 +483,94 @@  discard block
 block discarded – undo
483 483
 	public function performAction($args)
484 484
 	{
485 485
 		$dir = realpath($args[1]);
486
-		if($dir !== false && is_dir($dir))
487
-			$this->runUnitTests($dir,$args);
486
+		if ($dir !== false && is_dir($dir))
487
+			$this->runUnitTests($dir, $args);
488 488
 		else
489
-			echo '** Unable to find directory "'.$args[1]."\".\n";
489
+			echo '** Unable to find directory "' . $args[1] . "\".\n";
490 490
 		return true;
491 491
 	}
492 492
 
493 493
 	protected function initializeTestRunner()
494 494
 	{
495
-		$TEST_TOOLS = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/';
495
+		$TEST_TOOLS = realpath(dirname(dirname(__FILE__))) . '/tests/test_tools/';
496 496
 
497
-		require_once($TEST_TOOLS.'/simpletest/unit_tester.php');
498
-		require_once($TEST_TOOLS.'/simpletest/web_tester.php');
499
-		require_once($TEST_TOOLS.'/simpletest/mock_objects.php');
500
-		require_once($TEST_TOOLS.'/simpletest/reporter.php');
497
+		require_once($TEST_TOOLS . '/simpletest/unit_tester.php');
498
+		require_once($TEST_TOOLS . '/simpletest/web_tester.php');
499
+		require_once($TEST_TOOLS . '/simpletest/mock_objects.php');
500
+		require_once($TEST_TOOLS . '/simpletest/reporter.php');
501 501
 	}
502 502
 
503 503
 	protected function runUnitTests($dir, $args)
504 504
 	{
505 505
 		$app_dir = $this->getAppDir($dir);
506
-		if($app_dir !== false)
507
-			$this->initializePradoApplication($app_dir.'/../');
506
+		if ($app_dir !== false)
507
+			$this->initializePradoApplication($app_dir . '/../');
508 508
 
509 509
 		$this->initializeTestRunner();
510 510
 		$test_dir = $this->getTestDir($dir);
511
-		if($test_dir !== false)
511
+		if ($test_dir !== false)
512 512
 		{
513
-			$test =$this->getUnitTestCases($test_dir,$args);
514
-			$running_dir = substr(str_replace(realpath('./'),'',$test_dir),1);
515
-			echo 'Running unit tests in directory "'.$running_dir."\":\n";
513
+			$test = $this->getUnitTestCases($test_dir, $args);
514
+			$running_dir = substr(str_replace(realpath('./'), '', $test_dir), 1);
515
+			echo 'Running unit tests in directory "' . $running_dir . "\":\n";
516 516
 			$test->run(new TextReporter());
517 517
 		}
518 518
 		else
519 519
 		{
520
-			$running_dir = substr(str_replace(realpath('./'),'',$dir),1);
521
-			echo '** Unable to find test directory "'.$running_dir.'/unit" or "'.$running_dir.'/tests/unit".'."\n";
520
+			$running_dir = substr(str_replace(realpath('./'), '', $dir), 1);
521
+			echo '** Unable to find test directory "' . $running_dir . '/unit" or "' . $running_dir . '/tests/unit".' . "\n";
522 522
 		}
523 523
 	}
524 524
 
525 525
 	protected function getAppDir($dir)
526 526
 	{
527
-		$app_dir = realpath($dir.'/protected');
528
-		if($app_dir !== false && is_dir($app_dir))
527
+		$app_dir = realpath($dir . '/protected');
528
+		if ($app_dir !== false && is_dir($app_dir))
529 529
 			return $app_dir;
530
-		return realpath($dir.'/../protected');
530
+		return realpath($dir . '/../protected');
531 531
 	}
532 532
 
533 533
 	protected function getTestDir($dir)
534 534
 	{
535
-		$test_dir = realpath($dir.'/unit');
536
-		if($test_dir !== false && is_dir($test_dir))
535
+		$test_dir = realpath($dir . '/unit');
536
+		if ($test_dir !== false && is_dir($test_dir))
537 537
 			return $test_dir;
538
-		return realpath($dir.'/tests/unit/');
538
+		return realpath($dir . '/tests/unit/');
539 539
 	}
540 540
 
541
-	protected function getUnitTestCases($dir,$args)
541
+	protected function getUnitTestCases($dir, $args)
542 542
 	{
543 543
 		$matches = null;
544
-		if(count($args) > 2)
545
-			$matches = array_slice($args,2);
546
-		$test=new GroupTest(' ');
547
-		$this->addTests($test,$dir,true,$matches);
548
-		$test->setLabel(implode(' ',$this->matches));
544
+		if (count($args) > 2)
545
+			$matches = array_slice($args, 2);
546
+		$test = new GroupTest(' ');
547
+		$this->addTests($test, $dir, true, $matches);
548
+		$test->setLabel(implode(' ', $this->matches));
549 549
 		return $test;
550 550
 	}
551 551
 
552
-	protected function addTests($test,$path,$recursive=true,$match=null)
552
+	protected function addTests($test, $path, $recursive = true, $match = null)
553 553
 	{
554
-		$dir=opendir($path);
555
-		while(($entry=readdir($dir))!==false)
554
+		$dir = opendir($path);
555
+		while (($entry = readdir($dir)) !== false)
556 556
 		{
557
-			if(is_file($path.'/'.$entry) && (preg_match('/[^\s]*test[^\s]*\.php/', strtolower($entry))))
557
+			if (is_file($path . '/' . $entry) && (preg_match('/[^\s]*test[^\s]*\.php/', strtolower($entry))))
558 558
 			{
559
-				if($match==null||($match!=null && $this->hasMatch($match,$entry)))
560
-					$test->addTestFile($path.'/'.$entry);
559
+				if ($match == null || ($match != null && $this->hasMatch($match, $entry)))
560
+					$test->addTestFile($path . '/' . $entry);
561 561
 			}
562
-			if($entry!=='.' && $entry!=='..' && is_dir($path.'/'.$entry) && $recursive)
563
-				$this->addTests($test,$path.'/'.$entry,$recursive,$match);
562
+			if ($entry !== '.' && $entry !== '..' && is_dir($path . '/' . $entry) && $recursive)
563
+				$this->addTests($test, $path . '/' . $entry, $recursive, $match);
564 564
 		}
565 565
 		closedir($dir);
566 566
 	}
567 567
 
568
-	protected function hasMatch($match,$entry)
568
+	protected function hasMatch($match, $entry)
569 569
 	{
570
-		$file = strtolower(substr($entry,0,strrpos($entry,'.')));
571
-		foreach($match as $m)
570
+		$file = strtolower(substr($entry, 0, strrpos($entry, '.')));
571
+		foreach ($match as $m)
572 572
 		{
573
-			if(strtolower($m) === $file)
573
+			if (strtolower($m) === $file)
574 574
 			{
575 575
 				$this->matches[] = $m;
576 576
 				return true;
@@ -592,89 +592,89 @@  discard block
 block discarded – undo
592 592
 	protected $parameters = array('table', 'output');
593 593
 	protected $optional = array('directory', 'soap');
594 594
 	protected $description = 'Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.';
595
-	private $_soap=false;
595
+	private $_soap = false;
596 596
 
597 597
 	public function performAction($args)
598 598
 	{
599 599
 		$app_dir = count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir();
600 600
 		$this->_soap = count($args) > 4;
601
-		if($app_dir !== false)
601
+		if ($app_dir !== false)
602 602
 		{
603 603
 			$config = $this->getActiveRecordConfig($app_dir);
604 604
 			$output = $this->getOutputFile($app_dir, $args[2]);
605
-			if(is_file($output))
605
+			if (is_file($output))
606 606
 				echo "** File $output already exists, skiping. \n";
607
-			else if($config !== false && $output !== false)
607
+			else if ($config !== false && $output !== false)
608 608
 				$this->generateActiveRecord($config, $args[1], $output);
609 609
 		}
610 610
 		return true;
611 611
 	}
612 612
 
613
-	protected function getAppDir($dir=".")
613
+	protected function getAppDir($dir = ".")
614 614
 	{
615
-		if(is_dir($dir))
615
+		if (is_dir($dir))
616 616
 			return realpath($dir);
617
-		if(false !== ($app_dir = realpath($dir.'/protected/')) && is_dir($app_dir))
617
+		if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
618 618
 			return $app_dir;
619
-		echo '** Unable to find directory "'.$dir."\".\n";
619
+		echo '** Unable to find directory "' . $dir . "\".\n";
620 620
 		return false;
621 621
 	}
622 622
 
623 623
 	protected function getXmlFile($app_dir)
624 624
 	{
625
-		if(false !== ($xml = realpath($app_dir.'/application.xml')) && is_file($xml))
625
+		if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
626 626
 			return $xml;
627
-		if(false !== ($xml = realpath($app_dir.'/protected/application.xml')) && is_file($xml))
627
+		if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
628 628
 			return $xml;
629
-		echo '** Unable to find application.xml in '.$app_dir."\n";
629
+		echo '** Unable to find application.xml in ' . $app_dir . "\n";
630 630
 		return false;
631 631
 	}
632 632
 
633 633
 	protected function getActiveRecordConfig($app_dir)
634 634
 	{
635
-		if(false === ($xml=$this->getXmlFile($app_dir)))
635
+		if (false === ($xml = $this->getXmlFile($app_dir)))
636 636
 			return false;
637
-		if(false !== ($app=$this->initializePradoApplication($app_dir)))
637
+		if (false !== ($app = $this->initializePradoApplication($app_dir)))
638 638
 		{
639 639
 			Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
640
-			foreach($app->getModules() as $module)
641
-				if($module instanceof TActiveRecordConfig)
640
+			foreach ($app->getModules() as $module)
641
+				if ($module instanceof TActiveRecordConfig)
642 642
 					return $module;
643
-			echo '** Unable to find TActiveRecordConfig module in '.$xml."\n";
643
+			echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
644 644
 		}
645 645
 		return false;
646 646
 	}
647 647
 
648 648
 	protected function getOutputFile($app_dir, $namespace)
649 649
 	{
650
-		if(is_file($namespace) && strpos($namespace, $app_dir)===0)
650
+		if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
651 651
 				return $namespace;
652 652
 		$file = Prado::getPathOfNamespace($namespace, ".php");
653
-		if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path))
653
+		if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path))
654 654
 		{
655
-			if(strpos($path, $app_dir)===0)
655
+			if (strpos($path, $app_dir) === 0)
656 656
 				return $file;
657 657
 		}
658
-		echo '** Output file '.$file.' must be within directory '.$app_dir."\n";
658
+		echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
659 659
 		return false;
660 660
 	}
661 661
 
662 662
 	protected function generateActiveRecord($config, $tablename, $output)
663 663
 	{
664 664
 		$manager = TActiveRecordManager::getInstance();
665
-		if($connection = $manager->getDbConnection()) {
665
+		if ($connection = $manager->getDbConnection()) {
666 666
 			$gateway = $manager->getRecordGateway();
667 667
 			$tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename);
668
-			if(count($tableInfo->getColumns()) === 0)
668
+			if (count($tableInfo->getColumns()) === 0)
669 669
 			{
670
-				echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n";
670
+				echo '** Unable to find table or view "' . $tablename . '" in "' . $manager->getDbConnection()->getConnectionString() . "\".\n";
671 671
 				return false;
672 672
 			}
673 673
 			else
674 674
 			{
675 675
 				$properties = array();
676
-				foreach($tableInfo->getColumns() as $field=>$column)
677
-					$properties[] = $this->generateProperty($field,$column);
676
+				foreach ($tableInfo->getColumns() as $field=>$column)
677
+					$properties[] = $this->generateProperty($field, $column);
678 678
 			}
679 679
 
680 680
 			$classname = basename($output, '.php');
@@ -682,16 +682,16 @@  discard block
 block discarded – undo
682 682
 			echo "  Writing class $classname to file $output\n";
683 683
 			file_put_contents($output, $class);
684 684
 		} else {
685
-			echo '** Unable to connect to database with ConnectionID=\''.$config->getConnectionID()."'. Please check your settings in application.xml and ensure your database connection is set up first.\n";
685
+			echo '** Unable to connect to database with ConnectionID=\'' . $config->getConnectionID() . "'. Please check your settings in application.xml and ensure your database connection is set up first.\n";
686 686
 		}
687 687
 	}
688 688
 
689
-	protected function generateProperty($field,$column)
689
+	protected function generateProperty($field, $column)
690 690
 	{
691 691
 		$prop = '';
692
-		$name = '$'.$field;
692
+		$name = '$' . $field;
693 693
 		$type = $column->getPHPType();
694
-		if($this->_soap)
694
+		if ($this->_soap)
695 695
 		{
696 696
 			$prop .= <<<EOD
697 697
 
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
         return true;
782 782
     }
783 783
 
784
-    protected function getAppDir($dir=".") {
784
+    protected function getAppDir($dir = ".") {
785 785
         if (is_dir($dir))
786 786
             return realpath($dir);
787 787
         if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
@@ -827,17 +827,17 @@  discard block
 block discarded – undo
827 827
 }
828 828
 
829 829
 //run PHP shell
830
-if(class_exists('PHP_Shell_Commands', false))
830
+if (class_exists('PHP_Shell_Commands', false))
831 831
 {
832 832
 	class PHP_Shell_Extensions_ActiveRecord implements PHP_Shell_Extension {
833 833
 	    public function register()
834 834
 	    {
835 835
 
836 836
 	        $cmd = PHP_Shell_Commands::getInstance();
837
-			if(Prado::getApplication() !== null)
837
+			if (Prado::getApplication() !== null)
838 838
 			{
839 839
 		        $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]',
840
-		            'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL.
840
+		            'Generate Active Record skeleton for <table> to <output> file using' . PHP_EOL .
841 841
 		            '    application.xml in [directory]. May also generate [soap] properties.');
842 842
 			}
843 843
 	    }
@@ -845,14 +845,14 @@  discard block
 block discarded – undo
845 845
 	    public function generate($l)
846 846
 	    {
847 847
 			$input = explode(" ", trim($l));
848
-			if(count($input) > 2)
848
+			if (count($input) > 2)
849 849
 			{
850 850
 				$app_dir = '.';
851
-				if(Prado::getApplication()!==null)
851
+				if (Prado::getApplication() !== null)
852 852
 					$app_dir = dirname(Prado::getApplication()->getBasePath());
853
-				$args = array($input[0],$input[1], $input[2],$app_dir);
854
-				if(count($input)>3)
855
-					$args = array($input[0],$input[1], $input[2],$app_dir,'soap');
853
+				$args = array($input[0], $input[1], $input[2], $app_dir);
854
+				if (count($input) > 3)
855
+					$args = array($input[0], $input[1], $input[2], $app_dir, 'soap');
856 856
 				$cmd = new PradoCommandLineActiveRecordGen;
857 857
 				$cmd->performAction($args);
858 858
 			}
@@ -867,5 +867,5 @@  discard block
 block discarded – undo
867 867
 	$__shell_exts->registerExtensions(array(
868 868
 		    "active-record"        => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */
869 869
 
870
-	include_once(realpath(dirname(dirname(__FILE__))).'/framework/3rdParty/PhpShell/php-shell-cmd.php');
870
+	include_once(realpath(dirname(dirname(__FILE__))) . '/framework/3rdParty/PhpShell/php-shell-cmd.php');
871 871
 }
Please login to merge, or discard this patch.
buildscripts/Benchmark/Profiler.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -233,6 +233,7 @@  discard block
 block discarded – undo
233 233
      * Returns formatted profiling information.
234 234
      *
235 235
      * @param  string output format (auto, plain or html), default auto
236
+     * @param string $format
236 237
      * @see    display()
237 238
      * @access private
238 239
      */
@@ -363,6 +364,7 @@  discard block
 block discarded – undo
363 364
      * Enters code section.
364 365
      *
365 366
      * @param  string  name of the code section
367
+     * @param string $name
366 368
      * @see    start(), leaveSection()
367 369
      * @access public
368 370
      */
@@ -398,6 +400,7 @@  discard block
 block discarded – undo
398 400
      * Leaves code section.
399 401
      *
400 402
      * @param  string  name of the marker to be set
403
+     * @param string $name
401 404
      * @see     stop(), enterSection()
402 405
      * @access public
403 406
      */
@@ -436,7 +439,7 @@  discard block
 block discarded – undo
436 439
     /**
437 440
      * Wrapper for microtime().
438 441
      *
439
-     * @return float
442
+     * @return string
440 443
      * @access private
441 444
      * @since  1.3.0
442 445
      */
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
             $informations = array();
193 193
 
194
-            $informations['time']       = $this->_sections[$section];
194
+            $informations['time'] = $this->_sections[$section];
195 195
             if (isset($this->_sections['Global'])) {
196 196
                 $informations['percentage'] = number_format(100 * $this->_sections[$section] / $this->_sections['Global'], 2, '.', '');
197 197
             } else {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     function getAllSectionsInformations() {
223 223
         $informations = array();
224 224
 
225
-        foreach($this->_sections as $section => $time) {
225
+        foreach ($this->_sections as $section => $time) {
226 226
             $informations[$section] = $this->getSectionInformations($section);
227 227
         }
228 228
 
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
         }
263 263
 
264 264
         if ($format == 'html') {
265
-            $out = '<table style="border: 1px solid #000000; ">'."\n";
265
+            $out = '<table style="border: 1px solid #000000; ">' . "\n";
266 266
             $out .=
267
-                '<tr><td>&nbsp;</td><td align="center"><b>total ex. time</b></td>'.
268
-                '<td align="center"><b>netto ex. time</b></td>'.
269
-                '<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>'.
270
-                '<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>'.
267
+                '<tr><td>&nbsp;</td><td align="center"><b>total ex. time</b></td>' .
268
+                '<td align="center"><b>netto ex. time</b></td>' .
269
+                '<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>' .
270
+                '<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>' .
271 271
                 "\n";
272 272
         } else {
273 273
             $dashes = $out = str_pad("\n", ($this->_maxStringLength + 75), '-', STR_PAD_LEFT);
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
             $out .= $dashes;
280 280
         }
281 281
            
282
-        foreach($informations as $name => $values) {
282
+        foreach ($informations as $name => $values) {
283 283
             $percentage = $values['percentage'];
284 284
             $calls_str = "";
285 285
 
286
-            foreach($values['calls'] as $key => $val) {
286
+            foreach ($values['calls'] as $key => $val) {
287 287
                 if ($calls_str) {
288 288
                     $calls_str .= ", ";
289 289
                 }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
             $callers_str = "";
295 295
 
296
-            foreach($values['callers'] as $key => $val) {
296
+            foreach ($values['callers'] as $key => $val) {
297 297
                 if ($callers_str) {
298 298
                     $callers_str .= ", ";
299 299
     		        }
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
                 $out .= str_pad($values['netto_time'], 22);
316 316
                 $out .= str_pad($values['num_calls'], 10);
317 317
                 if (is_numeric($values['percentage'])) {
318
-                    $out .= str_pad($values['percentage']."%\n", 8, ' ', STR_PAD_LEFT);
318
+                    $out .= str_pad($values['percentage'] . "%\n", 8, ' ', STR_PAD_LEFT);
319 319
                 } else {
320
-                    $out .= str_pad($values['percentage']."\n", 8, ' ', STR_PAD_LEFT);
320
+                    $out .= str_pad($values['percentage'] . "\n", 8, ' ', STR_PAD_LEFT);
321 321
                 }
322 322
             }
323 323
         }
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             }
382 382
         } else {
383 383
             if ($name != 'Global') {
384
-                $this->raiseError("tried to enter section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
384
+                $this->raiseError("tried to enter section " . $name . " but profiling was not started\n", NULL, PEAR_ERROR_DIE);
385 385
             }
386 386
         }
387 387
 
@@ -405,13 +405,13 @@  discard block
 block discarded – undo
405 405
         $microtime = $this->_getMicrotime();
406 406
 
407 407
         if (!count($this->_stack)) {
408
-            $this->raiseError("tried to leave section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
408
+            $this->raiseError("tried to leave section " . $name . " but profiling was not started\n", NULL, PEAR_ERROR_DIE);
409 409
         }
410 410
 
411 411
         $x = array_pop($this->_stack);
412 412
 
413 413
         if ($x["name"] != $name) {
414
-            $this->raiseError("reached end of section $name but expecting end of " . $x["name"]."\n", NULL, PEAR_ERROR_DIE);
414
+            $this->raiseError("reached end of section $name but expecting end of " . $x["name"] . "\n", NULL, PEAR_ERROR_DIE);
415 415
         }
416 416
 
417 417
         if (isset($this->_sections[$name])) {
Please login to merge, or discard this patch.
buildscripts/Benchmark/Timer.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@
 block discarded – undo
308 308
     /**
309 309
      * Wrapper for microtime().
310 310
      *
311
-     * @return float
311
+     * @return string
312 312
      * @access private
313 313
      * @since  1.3.0
314 314
      */
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
         $dashes = '';
233 233
 
234 234
         if ($format == 'html') {
235
-            $out = '<table border="1">'."\n";
236
-            $out .= '<tr><td>&nbsp;</td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>'.
235
+            $out = '<table border="1">' . "\n";
236
+            $out .= '<tr><td>&nbsp;</td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>' .
237 237
             ($showTotal ?
238 238
               '<td align="center"><b>elapsed</b></td><td align="center"><b>%</b></td>'
239
-               : '')."</tr>\n";
239
+               : '') . "</tr>\n";
240 240
         } else {
241 241
             $dashes = $out = str_pad("\n",
242 242
                 $this->maxStringLength + ($showTotal ? 70 : 45), '-', STR_PAD_LEFT);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                     str_pad("time index", 22) .
245 245
                     str_pad("ex time", 16) .
246 246
                     str_pad("perct ", 8) .
247
-                    ($showTotal ? ' '.str_pad("elapsed", 16)."perct" : '')."\n" .
247
+                    ($showTotal ? ' ' . str_pad("elapsed", 16) . "perct" : '') . "\n" .
248 248
                     $dashes;
249 249
         }
250 250
 
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
                        "</b></td><td>" . $v['time'] .
258 258
                        "</td><td>" . $v['diff'] .
259 259
                        "</td><td align=\"right\">" . number_format($perc, 2, '.', '') .
260
-                       "%</td>".
260
+                       "%</td>" .
261 261
                        ($showTotal ?
262 262
                             "<td>" . $v['total'] .
263 263
                             "</td><td align=\"right\">" .
264 264
                             number_format($tperc, 2, '.', '') .
265
-                            "%</td>" : '').
265
+                            "%</td>" : '') .
266 266
                        "</tr>\n";
267 267
             } else {
268 268
                 $out .= str_pad($v['name'], $this->maxStringLength, ' ') .
269 269
                         str_pad($v['time'], 22) .
270 270
                         str_pad($v['diff'], 14) .
271
-                        str_pad(number_format($perc, 2, '.', '')."%",8, ' ', STR_PAD_LEFT) .
272
-                        ($showTotal ? '   '.
271
+                        str_pad(number_format($perc, 2, '.', '') . "%", 8, ' ', STR_PAD_LEFT) .
272
+                        ($showTotal ? '   ' .
273 273
                             str_pad($v['total'], 14) .
274
-                            str_pad(number_format($tperc, 2, '.', '')."%",
275
-                                             8, ' ', STR_PAD_LEFT) : '').
274
+                            str_pad(number_format($tperc, 2, '.', '') . "%",
275
+                                             8, ' ', STR_PAD_LEFT) : '') .
276 276
                         "\n";
277 277
             }
278 278
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         }
281 281
 
282 282
         if ($format == 'html') {
283
-            $out .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>".($showTotal ? "<td>-</td><td>-</td>" : "")."</tr>\n";
283
+            $out .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>" . ($showTotal ? "<td>-</td><td>-</td>" : "") . "</tr>\n";
284 284
             $out .= "</table>\n";
285 285
         } else {
286 286
             $out .= str_pad('total', $this->maxStringLength);
Please login to merge, or discard this patch.
buildscripts/classtree/build.php 2 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -67,6 +67,9 @@  discard block
 block discarded – undo
67 67
 		$this->displayTreeInternal(array_keys($this->_baseClasses),0);
68 68
 	}
69 69
 
70
+	/**
71
+	 * @param integer $level
72
+	 */
70 73
 	public function displayTreeInternal($classNames,$level)
71 74
 	{
72 75
 		foreach($classNames as $className)
@@ -153,6 +156,9 @@  discard block
 block discarded – undo
153 156
 		}
154 157
 	}
155 158
 
159
+	/**
160
+	 * @param string $path
161
+	 */
156 162
 	protected function isValidPath($path)
157 163
 	{
158 164
 		if(is_dir($path))
@@ -161,6 +167,9 @@  discard block
 block discarded – undo
161 167
 			return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
162 168
 	}
163 169
 
170
+	/**
171
+	 * @param string $path
172
+	 */
164 173
 	public function getSourceFiles($path)
165 174
 	{
166 175
 		$files=array();
@@ -227,6 +236,9 @@  discard block
 block discarded – undo
227 236
 
228 237
 	}
229 238
 
239
+	/**
240
+	 * @param PradoVTMDocument $doc
241
+	 */
230 242
 	private	function processObjectType($objectType,$objectInfo,$prefix,$doc)
231 243
 	{
232 244
 		foreach($objectInfo['Properties'] as $name=>$property)
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$basePath=dirname(__FILE__);
4
-$frameworkPath=realpath($basePath.'/../../framework');
5
-require_once($frameworkPath.'/prado.php');
6
-require_once($basePath.'/DWExtension.php');
3
+$basePath = dirname(__FILE__);
4
+$frameworkPath = realpath($basePath . '/../../framework');
5
+require_once($frameworkPath . '/prado.php');
6
+require_once($basePath . '/DWExtension.php');
7 7
 
8 8
 //the manager class sets up some dependency paths
9 9
 Prado::using('System.Data.SqlMap.TSqlMapManager');
10 10
 
11
-$exclusions=array(
11
+$exclusions = array(
12 12
 	'pradolite.php',
13 13
 	'prado-cli.php',
14 14
 	'JSMin.php',
@@ -17,93 +17,93 @@  discard block
 block discarded – undo
17 17
 	'/Testing',
18 18
 	'/Web/UI/WebControls/assets',
19 19
 	);
20
-$a=new ClassTreeBuilder($frameworkPath,$exclusions);
20
+$a = new ClassTreeBuilder($frameworkPath, $exclusions);
21 21
 $a->buildTree();
22
-$a->saveToFile($basePath.'/classes.data');
22
+$a->saveToFile($basePath . '/classes.data');
23 23
 $a->saveAsDWExtension($basePath);
24 24
 
25 25
 class ClassTreeBuilder
26 26
 {
27
-	const REGEX_RULES='/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
27
+	const REGEX_RULES = '/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
28 28
 	private $_frameworkPath;
29 29
 	private $_exclusions;
30
-	private $_classes=array();
30
+	private $_classes = array();
31 31
 
32
-	public function __construct($frameworkPath,$exclusions)
32
+	public function __construct($frameworkPath, $exclusions)
33 33
 	{
34
-		$this->_frameworkPath=realpath($frameworkPath);
35
-		$this->_exclusions=array();
36
-		foreach($exclusions as $exclusion)
34
+		$this->_frameworkPath = realpath($frameworkPath);
35
+		$this->_exclusions = array();
36
+		foreach ($exclusions as $exclusion)
37 37
 		{
38
-			if($exclusion[0]==='/')
39
-				$this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
38
+			if ($exclusion[0] === '/')
39
+				$this->_exclusions[realpath($frameworkPath . '/' . $exclusion)] = true;
40 40
 			else
41
-				$this->_exclusions[$exclusion]=true;
41
+				$this->_exclusions[$exclusion] = true;
42 42
 		}
43 43
 	}
44 44
 
45 45
 	public function buildTree()
46 46
 	{
47
-		$sourceFiles=$this->getSourceFiles($this->_frameworkPath);
48
-		foreach($sourceFiles as $sourceFile)
47
+		$sourceFiles = $this->getSourceFiles($this->_frameworkPath);
48
+		foreach ($sourceFiles as $sourceFile)
49 49
 			$this->parseFile($sourceFile);
50 50
 		ksort($this->_classes);
51
-		foreach(array_keys($this->_classes) as $className)
51
+		foreach (array_keys($this->_classes) as $className)
52 52
 		{
53
-			$parentClass=$this->_classes[$className]['ParentClass'];
54
-			if(isset($this->_classes[$parentClass]))
55
-				$this->_classes[$parentClass]['ChildClasses'][]=$className;
53
+			$parentClass = $this->_classes[$className]['ParentClass'];
54
+			if (isset($this->_classes[$parentClass]))
55
+				$this->_classes[$parentClass]['ChildClasses'][] = $className;
56 56
 		}
57
-		echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n";
57
+		echo "\nClass tree built successfully. Total " . count($this->_classes) . " classes found.\n";
58 58
 	}
59 59
 
60 60
 	public function saveToFile($fileName)
61 61
 	{
62
-		file_put_contents($fileName,serialize($this->_classes));
62
+		file_put_contents($fileName, serialize($this->_classes));
63 63
 	}
64 64
 
65 65
 	public function displayTree()
66 66
 	{
67
-		$this->displayTreeInternal(array_keys($this->_baseClasses),0);
67
+		$this->displayTreeInternal(array_keys($this->_baseClasses), 0);
68 68
 	}
69 69
 
70
-	public function displayTreeInternal($classNames,$level)
70
+	public function displayTreeInternal($classNames, $level)
71 71
 	{
72
-		foreach($classNames as $className)
72
+		foreach ($classNames as $className)
73 73
 		{
74
-			echo str_repeat(' ',$level*4);
75
-			echo $className.':'.$this->_classes[$className]->Package."\n";
76
-			$this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses),$level+1);
74
+			echo str_repeat(' ', $level * 4);
75
+			echo $className . ':' . $this->_classes[$className]->Package . "\n";
76
+			$this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses), $level + 1);
77 77
 		}
78 78
 	}
79 79
 
80 80
 	protected function parseFile($sourceFile)
81 81
 	{
82 82
 		include_once($sourceFile);
83
-		$classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
83
+		$classFile = strtr(substr($sourceFile, strlen($this->_frameworkPath)), '\\', '/');
84 84
 		echo "Parsing $classFile...\n";
85
-		$content=file_get_contents($sourceFile);
86
-		if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
87
-			$package=$matches[1];
85
+		$content = file_get_contents($sourceFile);
86
+		if (preg_match('/@package\s+([\w\.]+)\s*/msS', $content, $matches) > 0)
87
+			$package = $matches[1];
88 88
 		else
89
-			$package='';
90
-		$n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER);
91
-		for($i=0;$i<$n;++$i)
89
+			$package = '';
90
+		$n = preg_match_all(self::REGEX_RULES, $content, $matches, PREG_SET_ORDER);
91
+		for ($i = 0; $i < $n; ++$i)
92 92
 		{
93
-			$className=$matches[$i][2];
94
-			if(isset($this->_classes[$className]))
95
-				throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
96
-			$c=new TComponentReflection($className);
97
-			$properties=$c->getProperties();
93
+			$className = $matches[$i][2];
94
+			if (isset($this->_classes[$className]))
95
+				throw new Exception("Class $className is defined in both $sourceFile and " . $this->_classes[$className]->ClassFile);
96
+			$c = new TComponentReflection($className);
97
+			$properties = $c->getProperties();
98 98
 			$this->parseMethodComments($properties);
99
-			$events=$c->getEvents();
99
+			$events = $c->getEvents();
100 100
 			$this->parseMethodComments($events);
101
-			$methods=$c->getMethods();
101
+			$methods = $c->getMethods();
102 102
 			$this->parseMethodComments($methods);
103
-			$this->_classes[$className]=array(
103
+			$this->_classes[$className] = array(
104 104
 				'ClassFile'=>$classFile,
105 105
 				'Package'=>$package,
106
-				'ParentClass'=>isset($matches[$i][4])?$matches[$i][4]:'',
106
+				'ParentClass'=>isset($matches[$i][4]) ? $matches[$i][4] : '',
107 107
 				'ChildClasses'=>array(),
108 108
 				'Properties'=>$properties,
109 109
 				'Events'=>$events,
@@ -113,69 +113,69 @@  discard block
 block discarded – undo
113 113
 
114 114
 	protected function parseMethodComments(&$methods)
115 115
 	{
116
-		foreach(array_keys($methods) as $key)
116
+		foreach (array_keys($methods) as $key)
117 117
 		{
118
-			$method=&$methods[$key];
119
-			$comments=$method['comments'];
120
-			$s='';
121
-			foreach(explode("\n",$comments) as $line)
118
+			$method = &$methods[$key];
119
+			$comments = $method['comments'];
120
+			$s = '';
121
+			foreach (explode("\n", $comments) as $line)
122 122
 			{
123
-				$line=trim($line);
124
-				$line=trim($line,'/*');
125
-				$s.=' '.$line;
123
+				$line = trim($line);
124
+				$line = trim($line, '/*');
125
+				$s .= ' ' . $line;
126 126
 			}
127
-			$s=trim($s);
128
-			$s=preg_replace('/\{@link.*?([\w\(\)]+)\}/i','$1',$s);
129
-			$pos1=strpos($s,'@');
130
-			$pos2=strpos($s,'.');
131
-			if($pos1===false)
127
+			$s = trim($s);
128
+			$s = preg_replace('/\{@link.*?([\w\(\)]+)\}/i', '$1', $s);
129
+			$pos1 = strpos($s, '@');
130
+			$pos2 = strpos($s, '.');
131
+			if ($pos1 === false)
132 132
 			{
133
-				if($pos2!==false)
134
-					$method['comments']=substr($s,0,$pos2);
133
+				if ($pos2 !== false)
134
+					$method['comments'] = substr($s, 0, $pos2);
135 135
 				else
136
-					$method['comments']=$s;
136
+					$method['comments'] = $s;
137 137
 			}
138
-			else if($pos1>0)
138
+			else if ($pos1 > 0)
139 139
 			{
140
-				if($pos2 && $pos2<$pos1)	// use the first line as comment
141
-					$method['comments']=substr($s,0,$pos2);
140
+				if ($pos2 && $pos2 < $pos1)	// use the first line as comment
141
+					$method['comments'] = substr($s, 0, $pos2);
142 142
 				else
143
-					$method['comments']=substr($s,0,$pos1);
143
+					$method['comments'] = substr($s, 0, $pos1);
144 144
 			}
145 145
 			else
146 146
 			{
147
-				$matches=array();
148
-				if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
149
-					$method['comments']=$matches[1];
147
+				$matches = array();
148
+				if (preg_match('/@return\s+[\w\|]+\s+([^\.]*)/', $s, $matches) > 0)
149
+					$method['comments'] = $matches[1];
150 150
 				else
151
-					$method['comments']='';
151
+					$method['comments'] = '';
152 152
 			}
153 153
 		}
154 154
 	}
155 155
 
156 156
 	protected function isValidPath($path)
157 157
 	{
158
-		if(is_dir($path))
158
+		if (is_dir($path))
159 159
 			return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
160 160
 		else
161
-			return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
161
+			return basename($path) !== basename($path, '.php') && !isset($this->_exclusions[basename($path)]);
162 162
 	}
163 163
 
164 164
 	public function getSourceFiles($path)
165 165
 	{
166
-		$files=array();
167
-		$folder=opendir($path);
168
-		while($file=readdir($folder))
166
+		$files = array();
167
+		$folder = opendir($path);
168
+		while ($file = readdir($folder))
169 169
 		{
170
-			if($file==='.' || $file==='..')
170
+			if ($file === '.' || $file === '..')
171 171
 				continue;
172
-			$fullPath=realpath($path.'/'.$file);
173
-			if($this->isValidPath($fullPath))
172
+			$fullPath = realpath($path . '/' . $file);
173
+			if ($this->isValidPath($fullPath))
174 174
 			{
175
-				if(is_file($fullPath))
176
-					$files[]=$fullPath;
175
+				if (is_file($fullPath))
176
+					$files[] = $fullPath;
177 177
 				else
178
-					$files=array_merge($files,$this->getSourceFiles($fullPath));
178
+					$files = array_merge($files, $this->getSourceFiles($fullPath));
179 179
 			}
180 180
 		}
181 181
 		closedir($folder);
@@ -184,71 +184,71 @@  discard block
 block discarded – undo
184 184
 
185 185
 	public function saveAsDWExtension($basePath)
186 186
 	{
187
-		$tagPath=$basePath.'/Configuration/TagLibraries/PRADO';
187
+		$tagPath = $basePath . '/Configuration/TagLibraries/PRADO';
188 188
 
189 189
 		// prepare the directory to save tag lib
190
-		@mkdir($basePath.'/Configuration');
191
-		@mkdir($basePath.'/Configuration/TagLibraries');
192
-		@mkdir($basePath.'/Configuration/TagLibraries/PRADO');
190
+		@mkdir($basePath . '/Configuration');
191
+		@mkdir($basePath . '/Configuration/TagLibraries');
192
+		@mkdir($basePath . '/Configuration/TagLibraries/PRADO');
193 193
 
194 194
 		$docMXI = new PradoMXIDocument(Prado::getVersion());
195 195
 		$tagChooser = new PradoTagChooser;
196 196
 
197 197
 		$controlClass = new ReflectionClass('TControl');
198 198
 
199
-		foreach($this->_classes as $className=>$classInfo)
199
+		foreach ($this->_classes as $className=>$classInfo)
200 200
 		{
201 201
 			$class = new ReflectionClass($className);
202
-			if($class->isInstantiable() && ($className==='TControl' || $class->isSubclassOf($controlClass)))
202
+			if ($class->isInstantiable() && ($className === 'TControl' || $class->isSubclassOf($controlClass)))
203 203
 			{
204 204
 				$docMXI->addTag($className);
205 205
 				$tagChooser->addElement($className);
206 206
 				$docVTM = new PradoVTMDocument($className);
207
-				foreach($classInfo['Properties'] as $name=>$property)
207
+				foreach ($classInfo['Properties'] as $name=>$property)
208 208
 				{
209
-					$type=$property['type'];
210
-					if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle'))
211
-						$this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
212
-					if($property['readonly'] || $property['protected'])
209
+					$type = $property['type'];
210
+					if (isset($this->_classes[$type]) && ($type === 'TFont' || strrpos($type, 'Style') === strlen($type) - 5 && $type !== 'TStyle'))
211
+						$this->processObjectType($type, $this->_classes[$type], $name, $docVTM);
212
+					if ($property['readonly'] || $property['protected'])
213 213
 						continue;
214
-					if(($type=$this->checkType($className,$name,$property['type']))!=='')
215
-						$docVTM->addAttribute($name,$type);
214
+					if (($type = $this->checkType($className, $name, $property['type'])) !== '')
215
+						$docVTM->addAttribute($name, $type);
216 216
 				}
217
-				foreach($classInfo['Events'] as $name=>$event)
217
+				foreach ($classInfo['Events'] as $name=>$event)
218 218
 				{
219 219
 					$docVTM->addEvent($name);
220 220
 				}
221
-				file_put_contents($tagPath.'/'.$className.'.vtm',$docVTM->getXML());
221
+				file_put_contents($tagPath . '/' . $className . '.vtm', $docVTM->getXML());
222 222
 			}
223 223
 		}
224 224
 
225
-		file_put_contents($basePath.'/PRADO.mxi',$docMXI->getXML());
226
-		file_put_contents($tagPath.'/TagChooser.xml',$tagChooser->getXML());
225
+		file_put_contents($basePath . '/PRADO.mxi', $docMXI->getXML());
226
+		file_put_contents($tagPath . '/TagChooser.xml', $tagChooser->getXML());
227 227
 
228 228
 	}
229 229
 
230
-	private	function processObjectType($objectType,$objectInfo,$prefix,$doc)
230
+	private	function processObjectType($objectType, $objectInfo, $prefix, $doc)
231 231
 	{
232
-		foreach($objectInfo['Properties'] as $name=>$property)
232
+		foreach ($objectInfo['Properties'] as $name=>$property)
233 233
 		{
234
-			if($property['type']==='TFont')
235
-				$this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
236
-			if($property['readonly'] || $property['protected'])
234
+			if ($property['type'] === 'TFont')
235
+				$this->processObjectType('TFont', $this->_classes['TFont'], $prefix . '.' . $name, $doc);
236
+			if ($property['readonly'] || $property['protected'])
237 237
 				continue;
238
-			if(($type=$this->checkType($objectType,$name,$property['type']))!=='')
239
-				$doc->addAttribute($prefix.'.'.$name,$type);
238
+			if (($type = $this->checkType($objectType, $name, $property['type'])) !== '')
239
+				$doc->addAttribute($prefix . '.' . $name, $type);
240 240
 		}
241 241
 	}
242 242
 
243
-	private	function checkType($className,$propertyName,$type)
243
+	private	function checkType($className, $propertyName, $type)
244 244
 	{
245
-		if(strrpos($propertyName,'Color')===strlen($propertyName)-5)
245
+		if (strrpos($propertyName, 'Color') === strlen($propertyName) - 5)
246 246
 			return 'color';
247
-		if($propertyName==='Style')
247
+		if ($propertyName === 'Style')
248 248
 			return 'style';
249
-		if($type==='boolean')
250
-			return array('true','false');
251
-		if($type==='string' || $type==='integer' || $type==='ITemplate')
249
+		if ($type === 'boolean')
250
+			return array('true', 'false');
251
+		if ($type === 'string' || $type === 'integer' || $type === 'ITemplate')
252 252
 			return 'text';
253 253
 		return '';
254 254
 	}
Please login to merge, or discard this patch.
buildscripts/classtree/DWExtension.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -100,6 +100,9 @@
 block discarded – undo
100 100
 	private $_filesElement;
101 101
 	private $_document;
102 102
 
103
+	/**
104
+	 * @param string $version
105
+	 */
103 106
 	public function __construct($version)
104 107
 	{
105 108
 		$this->_document = new DOMDocument('1.0', 'utf-8');
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 
24 24
 		//--- add <tag>
25 25
 		$tag = $this->_document->createElement('tag');
26
-		$tag->setAttribute('name',$controlName);
27
-		$tag->setAttribute('casesensitive','yes');
26
+		$tag->setAttribute('name', $controlName);
27
+		$tag->setAttribute('casesensitive', 'yes');
28 28
 		$this->_document->appendChild($tag);
29 29
 
30 30
 		//--- add <tagformat>
31 31
 		$tagFormat = $this->_document->createElement('tagformat');
32
-		$tagFormat->setAttribute('nlbeforetag','1');
33
-		$tagFormat->setAttribute('nlaftertag','1');
34
-		$tagFormat->setAttribute('indentcontents','yes');
32
+		$tagFormat->setAttribute('nlbeforetag', '1');
33
+		$tagFormat->setAttribute('nlaftertag', '1');
34
+		$tagFormat->setAttribute('indentcontents', 'yes');
35 35
 		$tag->appendChild($tagFormat);
36 36
 
37 37
 		//--- add <tagdialog file="Control.htm" />
@@ -52,33 +52,33 @@  discard block
 block discarded – undo
52 52
 	{
53 53
 		//--- add <attrib>
54 54
 		$attrib = $this->_document->createElement('attrib');
55
-		$attrib->setAttribute('name',$attribName);
55
+		$attrib->setAttribute('name', $attribName);
56 56
 		if (is_array($attribType))
57 57
 		{
58
-			$attrib->setAttribute('type','Enumerated');
58
+			$attrib->setAttribute('type', 'Enumerated');
59 59
 			foreach ($attribType as $value)
60 60
 			{
61 61
 				$option = $this->_document->createElement('attriboption');
62
-				$option->setAttribute('value',$value);
63
-				$option->setAttribute('caption','');
62
+				$option->setAttribute('value', $value);
63
+				$option->setAttribute('caption', '');
64 64
 				$attrib->appendChild($option);
65 65
 			}
66 66
 		}
67
-		else if($attribType!=='')
67
+		else if ($attribType !== '')
68 68
 		{
69
-			$attrib->setAttribute('type',$attribType);
69
+			$attrib->setAttribute('type', $attribType);
70 70
 		}
71
-		$attrib->setAttribute('casesensitive','yes');
71
+		$attrib->setAttribute('casesensitive', 'yes');
72 72
 		$this->_attributes->appendChild($attrib);
73 73
 	}
74 74
 
75 75
 	public function addEvent($eventName)
76 76
 	{
77 77
 		//--- add <attrib>
78
-		$this->addAttribute($eventName,'');
78
+		$this->addAttribute($eventName, '');
79 79
 		//--- add <event>
80 80
 		$event = $this->_document->createElement('event');
81
-		$event->setAttribute('name',$eventName);
81
+		$event->setAttribute('name', $eventName);
82 82
 		$this->_attributes->appendChild($event);
83 83
 	}
84 84
 
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 		$this->_document->formatOutput = true;
112 112
 		//--- add root element
113 113
 		$rootElement = $this->_document->createElement('macromedia-extension');
114
-		$rootElement->setAttribute('name','PRADO Taglib');
115
-		$rootElement->setAttribute('version',$version);
116
-		$rootElement->setAttribute('type','Suite');
117
-		$rootElement->setAttribute('requires-restart','true');
114
+		$rootElement->setAttribute('name', 'PRADO Taglib');
115
+		$rootElement->setAttribute('version', $version);
116
+		$rootElement->setAttribute('type', 'Suite');
117
+		$rootElement->setAttribute('requires-restart', 'true');
118 118
 		$this->_document->appendChild($rootElement);
119 119
 		//--- add <author>
120 120
 		$element = $this->_document->createElement('author');
121
-		$element->setAttribute('name','Stanislav Yordanov, Qiang Xue');
121
+		$element->setAttribute('name', 'Stanislav Yordanov, Qiang Xue');
122 122
 		$rootElement->appendChild($element);
123
-		$time = date('F j, Y, h:i:s a',time());
123
+		$time = date('F j, Y, h:i:s a', time());
124 124
 		//--- add <description>
125 125
 		$description = <<<EOD
126 126
 PRADO $version Tag Library
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 		$rootElement->appendChild($productsElement);
139 139
 		//--- add <product>
140 140
 		$product = $this->_document->createElement('product');
141
-		$product->setAttribute('name','Dreamweaver');
142
-		$product->setAttribute('version','6');
143
-		$product->setAttribute('primary','false');
141
+		$product->setAttribute('name', 'Dreamweaver');
142
+		$product->setAttribute('version', '6');
143
+		$product->setAttribute('primary', 'false');
144 144
 		$productsElement->appendChild($product);
145 145
 		//--- add <ui-access>
146 146
 		$element = $this->_document->createElement('ui-access');
@@ -160,29 +160,29 @@  discard block
 block discarded – undo
160 160
 		$tagLibChangeElement->appendChild($tagLibInsertElement);
161 161
 		//--- add <taglibrary>
162 162
 		$this->_tagLibraryElement = $element = $this->_document->createElement('taglibrary');
163
-		$element->setAttribute('doctypes','HTML,DWTemplate');
164
-		$element->setAttribute('id','DWTagLibrary_PRADO_tags');
165
-		$element->setAttribute('name','PRADO tags');
166
-		$element->setAttribute('prefix','<com:');
167
-		$element->setAttribute('tagchooser','PRADO/TagChooser.xml');
163
+		$element->setAttribute('doctypes', 'HTML,DWTemplate');
164
+		$element->setAttribute('id', 'DWTagLibrary_PRADO_tags');
165
+		$element->setAttribute('name', 'PRADO tags');
166
+		$element->setAttribute('prefix', '<com:');
167
+		$element->setAttribute('tagchooser', 'PRADO/TagChooser.xml');
168 168
 		$tagLibInsertElement->appendChild($element);
169 169
 
170 170
 		$element = $this->_document->createElement('file');
171
-		$element->setAttribute('name','Configuration/TagLibraries/PRADO/TagChooser.xml');
172
-		$element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml');
171
+		$element->setAttribute('name', 'Configuration/TagLibraries/PRADO/TagChooser.xml');
172
+		$element->setAttribute('destination', '$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml');
173 173
 		$this->_filesElement->appendChild($element);
174 174
 	}
175 175
 
176 176
 	public function addTag($tagName)
177 177
 	{
178 178
 		$element = $this->_document->createElement('file');
179
-		$element->setAttribute('name','Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
180
-		$element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
179
+		$element->setAttribute('name', 'Configuration/TagLibraries/PRADO/' . $tagName . '.vtm');
180
+		$element->setAttribute('destination', '$dreamweaver/Configuration/TagLibraries/PRADO/' . $tagName . '.vtm');
181 181
 		$this->_filesElement->appendChild($element);
182 182
 
183 183
 		$element = $this->_document->createElement('tagref');
184
-		$element->setAttribute('file','PRADO/'.$tagName.'.vtm');
185
-		$element->setAttribute('name',$tagName);
184
+		$element->setAttribute('file', 'PRADO/' . $tagName . '.vtm');
185
+		$element->setAttribute('name', $tagName);
186 186
 		$this->_tagLibraryElement->appendChild($element);
187 187
 	}
188 188
 
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
 		$this->_document->standalone = true;
221 221
 		$this->_document->formatOutput = true;
222 222
 		$tclibrary = $this->_document->createElement('tclibrary');
223
-		$tclibrary->setAttribute('name','PRADO tags');
224
-		$tclibrary->setAttribute('desc','A collection of all PRADO tags.');
225
-		$tclibrary->setAttribute('reference','PRADO');
223
+		$tclibrary->setAttribute('name', 'PRADO tags');
224
+		$tclibrary->setAttribute('desc', 'A collection of all PRADO tags.');
225
+		$tclibrary->setAttribute('reference', 'PRADO');
226 226
 		$this->_document->appendChild($tclibrary);
227 227
 
228 228
 		$this->_category = $this->_document->createElement('category');
229
-		$this->_category->setAttribute('name','General');
230
-		$this->_category->setAttribute('icon','Configuration/TagLibraries/Icons/Elements.gif');
229
+		$this->_category->setAttribute('name', 'General');
230
+		$this->_category->setAttribute('icon', 'Configuration/TagLibraries/Icons/Elements.gif');
231 231
 		$tclibrary->appendChild($this->_category);
232 232
 	}
233 233
 
234 234
 	public function addElement($elementName)
235 235
 	{
236 236
 		$element = $this->_document->createElement('element');
237
-		$element->setAttribute('name','com:'.$elementName);
238
-		$element->setAttribute('value','<com:'.$elementName.'>');
239
-		$element->setAttribute('reference','PRADO,COM:'.strtoupper($elementName));
237
+		$element->setAttribute('name', 'com:' . $elementName);
238
+		$element->setAttribute('value', '<com:' . $elementName . '>');
239
+		$element->setAttribute('reference', 'PRADO,COM:' . strtoupper($elementName));
240 240
 		$this->_category->appendChild($element);
241 241
 	}
242 242
 
Please login to merge, or discard this patch.
buildscripts/index/api_index.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@
 block discarded – undo
10 10
 	private $_index;	
11 11
 	private $_api;
12 12
 	
13
+	/**
14
+	 * @param string $api
15
+	 */
13 16
 	public function __construct($index_file, $api)
14 17
 	{
15 18
 		$this->_api = $api;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		echo "Building search index...\n";
24 24
 		$files = $this->get_files($this->_api);
25 25
 		$count = 0;
26
-		foreach($files as $file)
26
+		foreach ($files as $file)
27 27
 		{
28 28
 			$content = $this->get_details($file, $this->_api);
29 29
 			
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			
32 32
 			$title = $content['class'];
33 33
 			
34
-			echo "  Adding ".$title."\n";
34
+			echo "  Adding " . $title . "\n";
35 35
 			
36 36
 			//unsearchable text
37 37
 			$doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link']));
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 			//$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content']));
40 40
 			
41 41
 			//searchable
42
-			$body = strtolower($this->sanitize($content['content'])).' '.strtolower($title);			
43
-			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title))));
44
-			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
42
+			$body = strtolower($this->sanitize($content['content'])) . ' ' . strtolower($title);			
43
+			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.', ' ', $title))));
44
+			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $body));
45 45
 			$this->_index->addDocument($doc);
46 46
 			$count++;
47 47
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 	function sanitize($input) 
53 53
 	{
54
-		return htmlentities(strip_tags( $input ));
54
+		return htmlentities(strip_tags($input));
55 55
 	}	
56 56
 
57 57
 	function get_files($path)
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 		$files = array();
62 62
 		while (false !== ($entry = $d->read()))
63 63
 		{
64
-			$filepath = $path.'/'.$entry;
65
-			if(is_file($filepath) && strpos($entry, 'class-')===0)
64
+			$filepath = $path . '/' . $entry;
65
+			if (is_file($filepath) && strpos($entry, 'class-') === 0)
66 66
 				$files[] = realpath($filepath);
67 67
 		}
68 68
 		$d->close();
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 	function get_doc_content($file)
73 73
 	{
74 74
 		$content = file_get_contents($file);
75
-		$html = preg_replace('/<h1>/','~~~', $content);
75
+		$html = preg_replace('/<h1>/', '~~~', $content);
76 76
 		$html = preg_replace('/<![^~]+/m', '', $html);
77 77
 		$html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html);
78
-		$html = preg_replace('/&nbsp;|~+|\s{2,}/',' ',$html);
79
-		$html = preg_replace('/\s{2,}/',' ',$html);
78
+		$html = preg_replace('/&nbsp;|~+|\s{2,}/', ' ', $html);
79
+		$html = preg_replace('/\s{2,}/', ' ', $html);
80 80
 		$text = strip_tags($html);
81
-		$text = str_replace(' , ',', ',$text);
81
+		$text = str_replace(' , ', ', ', $text);
82 82
 		return $text;
83 83
 	}
84 84
 	
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$replace = array('', '', '');
90 90
 		$path = str_replace($find, $replace, $file);
91 91
 		$result['class'] = $path;
92
-		$result['link'] = self::API_URL.$file;
92
+		$result['link'] = self::API_URL . $file;
93 93
 		return $result;
94 94
 	}
95 95
 }
Please login to merge, or discard this patch.
buildscripts/index/quickstart_index.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -8,6 +8,10 @@  discard block
 block discarded – undo
8 8
 	private $_base;
9 9
 	private $_source;
10 10
 
11
+	/**
12
+	 * @param string $base
13
+	 * @param string $source
14
+	 */
11 15
 	public function __construct($index_file, $base, $source)
12 16
 	{
13 17
 		$this->_index = new Zend_Search_Lucene($index_file, true);
@@ -37,6 +41,10 @@  discard block
 block discarded – undo
37 41
 		echo "\n {$count} files indexed.\n";
38 42
 	}
39 43
 
44
+	/**
45
+	 * @param string $content
46
+	 * @param integer $mtime
47
+	 */
40 48
 	public function add($content, $section, $mtime)
41 49
 	{
42 50
 		foreach($this->split_headings($content) as $headers)
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 		echo "Building search index...\n";
22 22
 		$pages = include($this->_source);
23 23
 		$count = 0;
24
-		foreach($pages as $chapter => $sections)
24
+		foreach ($pages as $chapter => $sections)
25 25
 		{
26
-			foreach($sections as $section)
26
+			foreach ($sections as $section)
27 27
 			{
28 28
 				echo "    Adding $section\n";
29
-				$page = $this->_base.'/'.$section;
29
+				$page = $this->_base . '/' . $section;
30 30
 				$file_content = file_get_contents($page);
31
-				$this->add($file_content,$section, filemtime($page));
31
+				$this->add($file_content, $section, filemtime($page));
32 32
 				$count++;
33 33
 			}
34 34
 		}
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function add($content, $section, $mtime)
41 41
 	{
42
-		foreach($this->split_headings($content) as $headers)
42
+		foreach ($this->split_headings($content) as $headers)
43 43
 		{
44 44
 			$doc = new Zend_Search_Lucene_Document();
45
-			$link = "index.php?page=".preg_replace('/\/|\\\/', '.', $section);
46
-			$link = str_replace('.page', '', $link).'#'.$headers['section'];
45
+			$link = "index.php?page=" . preg_replace('/\/|\\\/', '.', $section);
46
+			$link = str_replace('.page', '', $link) . '#' . $headers['section'];
47 47
 
48 48
 			//unsearchable text
49 49
 			$doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $link));
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 
54 54
 			//searchable text
55 55
 			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower($headers['title'])));
56
-			$body = strtolower($this->sanitize($headers['content'])).' '.strtolower($headers['title']);
57
-			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
56
+			$body = strtolower($this->sanitize($headers['content'])) . ' ' . strtolower($headers['title']);
57
+			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $body));
58 58
 			$this->_index->addDocument($doc);
59 59
 		}
60 60
 	}
61 61
 
62 62
 	function sanitize($input)
63 63
 	{
64
-		return htmlentities(strip_tags( $input ));
64
+		return htmlentities(strip_tags($input));
65 65
 	}
66 66
 
67 67
 	public function index()
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 		$html = preg_replace('/<h3([^>]*)>([^<]*)<\/h3>/', '<hh$1>$2</hh>', $html);
83 83
 
84 84
 
85
-		$sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html,-1);
85
+		$sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html, -1);
86 86
 		$headers = array();
87 87
 		preg_match_all('/<hh([^>]*)>([^<]+)<\/hh>/', $html, $headers);
88 88
 		$contents = array();
89
-		for($i = 1, $t = count($sections); $i < $t; $i++)
89
+		for ($i = 1, $t = count($sections); $i < $t; $i++)
90 90
 		{
91
-			$content['title'] = trim($this->sanitize($headers[2][$i-1]));
92
-			$content['section'] = str_replace('"', '',trim($headers[1][$i-1],'"'));
91
+			$content['title'] = trim($this->sanitize($headers[2][$i - 1]));
92
+			$content['section'] = str_replace('"', '', trim($headers[1][$i - 1], '"'));
93 93
 			$content['content'] = trim($this->sanitize($sections[$i]));
94 94
 			$contents[] = $content;
95 95
 		}
Please login to merge, or discard this patch.
buildscripts/texbuilder/Page2Tex.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -71,6 +71,9 @@
 block discarded – undo
71 71
 		}
72 72
 	}
73 73
 
74
+	/**
75
+	 * @param string $filename
76
+	 */
74 77
 	function include_figure($info, $filename)
75 78
 	{
76 79
 		$width = sprintf('%0.2f', $info[0]/(135/2.54));
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 {
5 5
 	private $_current_page;
6 6
 	private static $header_count = 0;
7
-	private static $p_count=0;
8
-	private static $hil_count=0;
9
-	private $page_count=0;
7
+	private static $p_count = 0;
8
+	private static $hil_count = 0;
9
+	private $page_count = 0;
10 10
 	private $_base;
11 11
 	private $_dir;
12 12
 
13
-	private $_verb_find = array('\$','\%', '\{', '\}', "\t",'``','`');
14
-	private $_verb_replace = array('$', '%', '{','}', "     ",'"','\'');
13
+	private $_verb_find = array('\$', '\%', '\{', '\}', "\t", '``', '`');
14
+	private $_verb_replace = array('$', '%', '{', '}', "     ", '"', '\'');
15 15
 
16
-	function __construct($base, $dir, $current='')
16
+	function __construct($base, $dir, $current = '')
17 17
 	{
18 18
 		$this->_base = $base;
19 19
 		$this->_current_page = $current;
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
 
23 23
 	function setCurrentPage($current)
24 24
 	{
25
-		self::$header_count = self::$header_count+1000;
25
+		self::$header_count = self::$header_count + 1000;
26 26
 		$this->_current_page = $current;
27 27
 	}
28 28
 
29 29
 	function escape_verbatim($matches)
30 30
 	{
31
-		return "\begin{small}\begin{verbatim}".
32
-				str_replace($this->_verb_find, $this->_verb_replace, $matches[1]).
33
-				'\end{verbatim}\end{small}'."\n";
31
+		return "\begin{small}\begin{verbatim}" .
32
+				str_replace($this->_verb_find, $this->_verb_replace, $matches[1]) .
33
+				'\end{verbatim}\end{small}' . "\n";
34 34
 	}
35 35
 
36 36
 	function escape_verb($matches)
37 37
 	{
38 38
 		$text = str_replace($this->_verb_find, $this->_verb_replace, $matches[1]);
39
-		return '\begin{small}\verb<'.$text.'< \end{small}';
39
+		return '\begin{small}\verb<' . $text . '< \end{small}';
40 40
 	}
41 41
 
42 42
 	function include_image($matches)
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$current_path = $this->_current_page;
46 46
 
47
-		$image = dirname($current_path).'/'.trim($matches[1]);
47
+		$image = dirname($current_path) . '/' . trim($matches[1]);
48 48
 
49 49
 		$file = realpath($image);
50 50
 		$info = getimagesize($file);
51
-		switch($info[2])
51
+		switch ($info[2])
52 52
 		{
53 53
 			case 1:
54 54
 				$im = imagecreatefromgif($file);
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 		}
59 59
 		$base = $this->_base;
60 60
 
61
-		if(isset($im))
61
+		if (isset($im))
62 62
 		{
63 63
 			$prefix = strtolower(str_replace(realpath($base), '', $file));
64
-			$filename = preg_replace('/\\\|\//', '_', substr($prefix,1));
65
-			$filename = substr($filename, 0, strrpos($filename,'.')).'.png';
66
-			$newfile = $this->_dir.'/'.$filename;
67
-			imagepng($im,$newfile);
64
+			$filename = preg_replace('/\\\|\//', '_', substr($prefix, 1));
65
+			$filename = substr($filename, 0, strrpos($filename, '.')) . '.png';
66
+			$newfile = $this->_dir . '/' . $filename;
67
+			imagepng($im, $newfile);
68 68
 			imagedestroy($im);
69 69
 
70 70
 			return $this->include_figure($info, $filename);
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 
74 74
 	function include_figure($info, $filename)
75 75
 	{
76
-		$width = sprintf('%0.2f', $info[0]/(135/2.54));
76
+		$width = sprintf('%0.2f', $info[0] / (135 / 2.54));
77 77
 		return '
78 78
 	\begin{figure}[!ht]
79 79
 		\centering
80
-			\includegraphics[width='.$width.'cm]{'.$filename.'}
81
-		\label{fig:'.$filename.'}
80
+			\includegraphics[width='.$width . 'cm]{' . $filename . '}
81
+		\label{fig:'.$filename . '}
82 82
 	\end{figure}
83 83
 	';
84 84
 	}
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	function anchor($matches)
87 87
 	{
88 88
 		$page = $this->get_current_path();
89
-		return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}';
89
+		return '\hypertarget{' . $page . '/' . strtolower($matches[1]) . '}{}';
90 90
 	}
91 91
 
92 92
 	function texttt($matches)
93 93
 	{
94
-		$text ='\texttt{'.str_replace(array('#','_','&amp;'),array('\#','\_','\&'), $matches[1]).'}';
94
+		$text = '\texttt{' . str_replace(array('#', '_', '&amp;'), array('\#', '\_', '\&'), $matches[1]) . '}';
95 95
 		//$text = preg_replace('/([^\\\\])&([^;]+)/', '$1\&$2', $text);
96 96
 		return $text;
97 97
 	}
@@ -100,39 +100,39 @@  discard block
 block discarded – undo
100 100
 	{
101 101
 		$current_path = $this->_current_page;
102 102
 		$base = $this->_base;
103
-		$page = strtolower(substr(str_replace($base, '', $current_path),1));
103
+		$page = strtolower(substr(str_replace($base, '', $current_path), 1));
104 104
 		return $page;
105 105
 	}
106 106
 
107 107
 	function make_link($matches)
108 108
 	{
109
-		if(is_int(strpos($matches[1], '#')))
109
+		if (is_int(strpos($matches[1], '#')))
110 110
 		{
111
-			if(strpos($matches[1],'?') ===false)
111
+			if (strpos($matches[1], '?') === false)
112 112
 			{
113
-				if(strpos($matches[1],'http://')===false)
113
+				if (strpos($matches[1], 'http://') === false)
114 114
 				{
115
-					$target = $this->get_current_path().'/'.substr($matches[1],1);
116
-					return '\hyperlink{'.$target.'}{'.$matches[2].'}';
115
+					$target = $this->get_current_path() . '/' . substr($matches[1], 1);
116
+					return '\hyperlink{' . $target . '}{' . $matches[2] . '}';
117 117
 				}
118 118
 			}
119 119
 			else
120 120
 			{
121 121
 				$page = strtolower(str_replace('?page=', '', $matches[1]));
122
-				$page = str_replace('.','/',$page);
123
-				$page = str_replace('#','.page/',$page);
124
-				return '\hyperlink{'.$page.'}{'.$matches[2].'}';
122
+				$page = str_replace('.', '/', $page);
123
+				$page = str_replace('#', '.page/', $page);
124
+				return '\hyperlink{' . $page . '}{' . $matches[2] . '}';
125 125
 			}
126 126
 		}
127
-		else if(is_int(strpos($matches[1],'?')))
127
+		else if (is_int(strpos($matches[1], '?')))
128 128
 		{
129
-			$page = str_replace('?page=','',$matches[1]);
130
-			return '\hyperlink{'.$page.'}{'.$matches[2].'}';
129
+			$page = str_replace('?page=', '', $matches[1]);
130
+			return '\hyperlink{' . $page . '}{' . $matches[2] . '}';
131 131
 		}
132
-		return '\href{'.str_replace('#','\\#',$matches[1]).'}{'.$matches[2].'}';
132
+		return '\href{' . str_replace('#', '\\#', $matches[1]) . '}{' . $matches[2] . '}';
133 133
 	}
134 134
 
135
-	function parse_html($page,$html)
135
+	function parse_html($page, $html)
136 136
 	{
137 137
 		$html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html);
138 138
 		$html = preg_replace('/<\/?p [^>]*>/', '', $html);
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 		//codes
153 153
 		$html = str_replace('$', '\$', $html);
154 154
 
155
-		$html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this,'escape_verbatim'), $html);
155
+		$html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this, 'escape_verbatim'), $html);
156 156
 //		$html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html);
157 157
 //		$html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', array($this,'escape_verbatim'), $html);
158
-		$html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this,'escape_verbatim'), $html);
159
-		$html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html);
158
+		$html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this, 'escape_verbatim'), $html);
159
+		$html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this, 'escape_verbatim'), $html);
160 160
 
161 161
 		//<code>
162
-		$html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this,'escape_verb'), $html);
162
+		$html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this, 'escape_verb'), $html);
163 163
 
164 164
 		//runbar
165 165
 		$html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/',
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 		//text modifiers
176 176
 		$html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
177 177
 		$html = preg_replace('/<i [^>]*>([^<]*)+?<\/i>/', '\emph{$1}', $html);
178
-		$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html);
178
+		$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this, 'texttt'), $html);
179 179
 
180 180
 		//links
181 181
 		$html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
182
-								array($this,'make_link'), $html);
182
+								array($this, 'make_link'), $html);
183 183
 		//anchor
184
-		$html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html);
184
+		$html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this, 'anchor'), $html);
185 185
 
186 186
 		//description <dl>
187 187
 		$html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html);
@@ -230,20 +230,20 @@  discard block
 block discarded – undo
230 230
 	function tabular($matches)
231 231
 	{
232 232
 		$options = array();
233
-		foreach(explode(',', $matches[1]) as $string)
233
+		foreach (explode(',', $matches[1]) as $string)
234 234
 		{
235 235
 			$sub = explode('=', trim($string));
236 236
 			$options[trim($sub[0])] = trim($sub[1]);
237 237
 		}
238 238
 
239
-		$widths = explode(' ',preg_replace('/\(|\)/', '', $options['width']));
239
+		$widths = explode(' ', preg_replace('/\(|\)/', '', $options['width']));
240 240
 		$this->_tabular_widths = $widths;
241 241
 
242 242
 		$this->_tabular_total = count($widths);
243 243
 		$this->_tabular_col = 0;
244 244
 
245
-		$begin = '\begin{table}[!hpt]\centering '."\n".' \begin{tabular}{'.$options['align'].'}\hline';
246
-		$end = '\end{tabular} '."\n".'\end{table}'."\n";
245
+		$begin = '\begin{table}[!hpt]\centering ' . "\n" . ' \begin{tabular}{' . $options['align'] . '}\hline';
246
+		$end = '\end{tabular} ' . "\n" . '\end{table}' . "\n";
247 247
 		$table = preg_replace('/<\/tr>/', '\\\\\\\\ \hline', $matches[2]);
248 248
 		$table = preg_replace('/<tr>/', '', $table);
249 249
 		$table = preg_replace('/<th>([^<]+)<\/th>/', '\textbf{$1} &', $table);
@@ -251,95 +251,95 @@  discard block
 block discarded – undo
251 251
 		$table = preg_replace('/<br \/>/', ' \\\\\\\\', $table);
252 252
 
253 253
 		$table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table);
254
-		return $begin.$table.$end;
254
+		return $begin . $table . $end;
255 255
 	}
256 256
 
257 257
 	function table_column($matches)
258 258
 	{
259 259
 		$width = $this->_tabular_widths[$this->_tabular_col];
260
-		if($this->_tabular_col >= $this->_tabular_total-1)
260
+		if ($this->_tabular_col >= $this->_tabular_total - 1)
261 261
 			$this->_tabular_col = 0;
262 262
 		else
263 263
 			$this->_tabular_col++;
264
-		return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'.
265
-			$matches[1].'\vspace{3mm}\end{minipage} & ';
264
+		return '\begin{minipage}{' . $width . '\textwidth}\vspace{3mm}' .
265
+			$matches[1] . '\vspace{3mm}\end{minipage} & ';
266 266
 	}
267 267
 
268 268
 	function mbox($matches)
269 269
 	{
270
-		return "\n\begin{mybox}\n".$matches[1]."\n".'\end{mybox}'."\n";
270
+		return "\n\begin{mybox}\n" . $matches[1] . "\n" . '\end{mybox}' . "\n";
271 271
 	}
272 272
 
273 273
 	function get_chapter_label($chapter)
274 274
 	{
275
-		return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}';
275
+		return '\hypertarget{' . str_replace(' ', '', $chapter) . '}{}';
276 276
 	}
277 277
 
278 278
 	function get_section_label($section)
279 279
 	{
280 280
 		$section = str_replace('.page', '', $section);
281
-		return '\hypertarget{'.str_replace('/', '.', $section).'}{}';
281
+		return '\hypertarget{' . str_replace('/', '.', $section) . '}{}';
282 282
 	}
283 283
 
284 284
 
285 285
 	function set_header_id($content, $j)
286 286
 	{
287
-		$this->page_count=$j;
288
-		$content = preg_replace_callback('/<h1>/', array($this,"h1"), $content);
289
-		$content = preg_replace_callback('/<h2>/', array($this,"h2"), $content);
290
-		$content = preg_replace_callback('/<h3>/', array($this,"h3"), $content);
287
+		$this->page_count = $j;
288
+		$content = preg_replace_callback('/<h1>/', array($this, "h1"), $content);
289
+		$content = preg_replace_callback('/<h2>/', array($this, "h2"), $content);
290
+		$content = preg_replace_callback('/<h3>/', array($this, "h3"), $content);
291 291
 		$content = $this->set_block_content_id($content);
292 292
 		return $content;
293 293
 	}
294 294
 
295 295
 	function h1($matches)
296 296
 	{
297
-		$page = $this->page_count*1000;
298
-		return "<h1 id=\"".($page + (++self::$header_count))."\">";
297
+		$page = $this->page_count * 1000;
298
+		return "<h1 id=\"" . ($page + (++self::$header_count)) . "\">";
299 299
 	}
300 300
 
301 301
 	function h2($matches)
302 302
 	{
303
-		$page = $this->page_count*1000;
304
-		return "<h2 id=\"".($page + (++self::$header_count))."\">";
303
+		$page = $this->page_count * 1000;
304
+		return "<h2 id=\"" . ($page + (++self::$header_count)) . "\">";
305 305
 	}
306 306
 
307 307
 	function h3($matches)
308 308
 	{
309
-		$page = $this->page_count*1000;
310
-		return "<h3 id=\"".($page + (++self::$header_count))."\">";
309
+		$page = $this->page_count * 1000;
310
+		return "<h3 id=\"" . ($page + (++self::$header_count)) . "\">";
311 311
 	}
312 312
 
313 313
 	function set_block_content_id($content)
314 314
 	{
315
-		$content = preg_replace_callback('/<p>/',  array($this, 'add_p'), $content);
315
+		$content = preg_replace_callback('/<p>/', array($this, 'add_p'), $content);
316 316
 		$content = preg_replace_callback('/<com:TTextHighlighter([^>]+)>/', array($this, 'hil'), $content);
317 317
 		return $content;
318 318
 	}
319 319
 
320 320
 	function hil($matches)
321 321
 	{
322
-		$id = ($this->page_count*10000) + (++self::$hil_count);
323
-		if(preg_match('/id="code-\d+"/i', $matches[1]))
322
+		$id = ($this->page_count * 10000) + (++self::$hil_count);
323
+		if (preg_match('/id="code-\d+"/i', $matches[1]))
324 324
 		{
325 325
 			$code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]);
326 326
 			//var_dump($code);
327 327
 			return $code;
328 328
 		}
329
-		else if(preg_match('/id="[^"]+"/i', $matches[1]))
329
+		else if (preg_match('/id="[^"]+"/i', $matches[1]))
330 330
 		{
331 331
 			return $matches[0];
332 332
 		}
333 333
 		else
334 334
 		{
335
-			$changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]);
335
+			$changes = str_replace('"source"', '"source block-content" id="code-' . $id . '"', $matches[0]);
336 336
 			return $changes;
337 337
 		}
338 338
 	}
339 339
 
340 340
 	function add_p($matches)
341 341
 	{
342
-		 $page = $this->page_count*10000;
343
-		 return "<p id=\"".($page + (++self::$p_count))."\" class=\"block-content\">";
342
+		 $page = $this->page_count * 10000;
343
+		 return "<p id=\"" . ($page + (++self::$p_count)) . "\" class=\"block-content\">";
344 344
 	}
345 345
 }
Please login to merge, or discard this patch.
demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ListPost.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -48,6 +48,7 @@
 block discarded – undo
48 48
 
49 49
 	/**
50 50
 	 * Fetches posts from database with offset and limit.
51
+	 * @param double $offset
51 52
 	 */
52 53
 	protected function getPosts($offset, $limit)
53 54
 	{
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	public function onInit($param)
11 11
 	{
12 12
 		parent::onInit($param);
13
-		if(!$this->IsPostBack)  // if the page is requested the first time
13
+		if (!$this->IsPostBack)  // if the page is requested the first time
14 14
 		{
15 15
 			// get the total number of posts available
16
-			$this->Repeater->VirtualItemCount=PostRecord::finder()->count();
16
+			$this->Repeater->VirtualItemCount = PostRecord::finder()->count();
17 17
 			// populates post data into the repeater
18 18
 			$this->populateData();
19 19
 		}
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 * This method is invoked when the user clicks on a page button
25 25
 	 * and thus changes the page of posts to display.
26 26
 	 */
27
-	public function pageChanged($sender,$param)
27
+	public function pageChanged($sender, $param)
28 28
 	{
29 29
 		// change the current page index to the new one
30
-		$this->Repeater->CurrentPageIndex=$param->NewPageIndex;
30
+		$this->Repeater->CurrentPageIndex = $param->NewPageIndex;
31 31
 		// re-populate data into the repeater
32 32
 		$this->populateData();
33 33
 	}
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	protected function populateData()
40 40
 	{
41
-		$offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
42
-		$limit=$this->Repeater->PageSize;
43
-		if($offset+$limit>$this->Repeater->VirtualItemCount)
44
-			$limit=$this->Repeater->VirtualItemCount-$offset;
45
-		$this->Repeater->DataSource=$this->getPosts($offset,$limit);
41
+		$offset = $this->Repeater->CurrentPageIndex * $this->Repeater->PageSize;
42
+		$limit = $this->Repeater->PageSize;
43
+		if ($offset + $limit > $this->Repeater->VirtualItemCount)
44
+			$limit = $this->Repeater->VirtualItemCount - $offset;
45
+		$this->Repeater->DataSource = $this->getPosts($offset, $limit);
46 46
 		$this->Repeater->dataBind();
47 47
 	}
48 48
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	protected function getPosts($offset, $limit)
53 53
 	{
54 54
 		// Construts a query criteria
55
-		$criteria=new TActiveRecordCriteria;
56
-		$criteria->OrdersBy['create_time']='desc';
57
-		$criteria->Limit=$limit;
58
-		$criteria->Offset=$offset;
55
+		$criteria = new TActiveRecordCriteria;
56
+		$criteria->OrdersBy['create_time'] = 'desc';
57
+		$criteria->Limit = $limit;
58
+		$criteria->Offset = $offset;
59 59
 		// query for the posts with the above criteria and with author information
60 60
 		return PostRecord::finder()->withAuthor()->findAll($criteria);
61 61
 	}
Please login to merge, or discard this patch.