Completed
Push — master ( 334114...36fef0 )
by Fabio
11:57
created
bin/prado-cli.php 1 patch
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 	die('Must be run from the command line');
14 14
 
15 15
 // Locate composer's autoloader
16
-if(file_exists($autoloader = realpath(__DIR__ . '/../vendor/autoload.php')))
16
+if(file_exists($autoloader=realpath(__DIR__.'/../vendor/autoload.php')))
17 17
 {
18 18
 	// if we are running inside a prado repo checkout, get out of bin/
19 19
 	include($autoloader);
20
-} elseif(file_exists($autoloader = realpath(__DIR__ . '/../../../autoload.php'))) {
20
+} elseif(file_exists($autoloader=realpath(__DIR__.'/../../../autoload.php'))) {
21 21
 	// if we are running from inside an application's vendor/ directory, get out of pradosoft/prado/bin/
22 22
 	include($autoloader);
23 23
 }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function addActionClass($class)
71 71
 	{
72
-		$this->_actions[$class] = new $class;
72
+		$this->_actions[$class]=new $class;
73 73
 	}
74 74
 
75 75
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	public static function getInstance()
79 79
 	{
80 80
 		static $instance;
81
-		if($instance === null)
82
-			$instance = new self;
81
+		if($instance===null)
82
+			$instance=new self;
83 83
 		return $instance;
84 84
 	}
85 85
 
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
 	{
97 97
 		if(count($args) > 1)
98 98
 			array_shift($args);
99
-		$valid = false;
99
+		$valid=false;
100 100
 		foreach($this->_actions as $class => $action)
101 101
 		{
102 102
 			if($action->isValidAction($args))
103 103
 			{
104
-				$valid |= $action->performAction($args);
104
+				$valid|=$action->performAction($args);
105 105
 				break;
106 106
 			}
107 107
 			else
108 108
 			{
109
-				$valid = false;
109
+				$valid=false;
110 110
 			}
111 111
 		}
112 112
 		if(!$valid)
@@ -165,23 +165,23 @@  discard block
 block discarded – undo
165 165
 
166 166
 	public function isValidAction($args)
167 167
 	{
168
-		return 0 == strcasecmp($args[0], $this->action) &&
169
-			count($args)-1 >= count($this->parameters);
168
+		return 0==strcasecmp($args[0], $this->action) &&
169
+			count($args) - 1 >= count($this->parameters);
170 170
 	}
171 171
 
172 172
 	public function renderHelp()
173 173
 	{
174
-		$params = array();
174
+		$params=array();
175 175
 		foreach($this->parameters as $v)
176
-			$params[] = '<'.$v.'>';
177
-		$parameters = join($params, ' ');
178
-		$options = array();
176
+			$params[]='<'.$v.'>';
177
+		$parameters=join($params, ' ');
178
+		$options=array();
179 179
 		foreach($this->optional as $v)
180
-			$options[] = '['.$v.']';
181
-		$optional = (strlen($parameters) ? ' ' : ''). join($options, ' ');
180
+			$options[]='['.$v.']';
181
+		$optional=(strlen($parameters) ? ' ' : '').join($options, ' ');
182 182
 		$description='';
183
-		foreach(explode("\n", wordwrap($this->description,65)) as $line)
184
-			$description .= '    '.$line."\n";
183
+		foreach(explode("\n", wordwrap($this->description, 65)) as $line)
184
+			$description.='    '.$line."\n";
185 185
 		return <<<EOD
186 186
   {$this->action} {$parameters}{$optional}
187 187
 {$description}
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
 
192 192
 	protected function initializePradoApplication($directory)
193 193
 	{
194
-		$_SERVER['SCRIPT_FILENAME'] = $directory.'/index.php';
195
-		$app_dir = realpath($directory.'/protected/');
196
-		if($app_dir !== false && is_dir($app_dir))
194
+		$_SERVER['SCRIPT_FILENAME']=$directory.'/index.php';
195
+		$app_dir=realpath($directory.'/protected/');
196
+		if($app_dir!==false && is_dir($app_dir))
197 197
 		{
198 198
 			if(Prado::getApplication()===null)
199 199
 			{
200
-				$app = new PradoShellApplication($app_dir);
200
+				$app=new PradoShellApplication($app_dir);
201 201
 				$app->run();
202
-				$dir = substr(str_replace(realpath('./'),'',$app_dir),1);
202
+				$dir=substr(str_replace(realpath('./'), '', $app_dir), 1);
203 203
 				$initialized=true;
204 204
 				PradoCommandLineInterpreter::printGreeting();
205 205
 				echo '** Loaded PRADO appplication in directory "'.$dir."\".\n";
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 		else
211 211
 		{
212 212
 			PradoCommandLineInterpreter::printGreeting();
213
-			echo '+'.str_repeat('-',77)."+\n";
213
+			echo '+'.str_repeat('-', 77)."+\n";
214 214
 			echo '** Unable to load PRADO application in directory "'.$directory."\".\n";
215
-			echo '+'.str_repeat('-',77)."+\n";
215
+			echo '+'.str_repeat('-', 77)."+\n";
216 216
 		}
217 217
 		return false;
218 218
 	}
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
  */
228 228
 class PradoCommandLineCreateProject extends PradoCommandLineAction
229 229
 {
230
-	protected $action = '-c';
231
-	protected $parameters = array('directory');
232
-	protected $optional = array();
233
-	protected $description = 'Creates a Prado project skeleton for the given <directory>.';
230
+	protected $action='-c';
231
+	protected $parameters=array('directory');
232
+	protected $optional=array();
233
+	protected $description='Creates a Prado project skeleton for the given <directory>.';
234 234
 
235 235
 	public function performAction($args)
236 236
 	{
@@ -244,31 +244,31 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	protected function createNewPradoProject($dir)
246 246
 	{
247
-		if(strlen(trim($dir)) == 0)
247
+		if(strlen(trim($dir))==0)
248 248
 			return;
249 249
 
250
-		$rootPath = realpath(dirname(trim($dir)));
250
+		$rootPath=realpath(dirname(trim($dir)));
251 251
 
252 252
 		if(basename($dir)!=='.')
253
-			$basePath = $rootPath.DIRECTORY_SEPARATOR.basename($dir);
253
+			$basePath=$rootPath.DIRECTORY_SEPARATOR.basename($dir);
254 254
 		else
255
-			$basePath = $rootPath;
256
-		$appName = basename($basePath);
257
-		$assetPath = $basePath.DIRECTORY_SEPARATOR.'assets';
258
-		$protectedPath  = $basePath.DIRECTORY_SEPARATOR.'protected';
259
-		$runtimePath = $basePath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'runtime';
260
-		$pagesPath = $protectedPath.DIRECTORY_SEPARATOR.'pages';
261
-
262
-		$indexFile = $basePath.DIRECTORY_SEPARATOR.'index.php';
263
-		$htaccessFile = $protectedPath.DIRECTORY_SEPARATOR.'.htaccess';
264
-		$configFile = $protectedPath.DIRECTORY_SEPARATOR.'application.xml';
265
-		$defaultPageFile = $pagesPath.DIRECTORY_SEPARATOR.'Home.page';
255
+			$basePath=$rootPath;
256
+		$appName=basename($basePath);
257
+		$assetPath=$basePath.DIRECTORY_SEPARATOR.'assets';
258
+		$protectedPath=$basePath.DIRECTORY_SEPARATOR.'protected';
259
+		$runtimePath=$basePath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'runtime';
260
+		$pagesPath=$protectedPath.DIRECTORY_SEPARATOR.'pages';
261
+
262
+		$indexFile=$basePath.DIRECTORY_SEPARATOR.'index.php';
263
+		$htaccessFile=$protectedPath.DIRECTORY_SEPARATOR.'.htaccess';
264
+		$configFile=$protectedPath.DIRECTORY_SEPARATOR.'application.xml';
265
+		$defaultPageFile=$pagesPath.DIRECTORY_SEPARATOR.'Home.page';
266 266
 
267 267
 		$this->createDirectory($basePath, 0755);
268
-		$this->createDirectory($assetPath,0777);
269
-		$this->createDirectory($protectedPath,0755);
270
-		$this->createDirectory($runtimePath,0777);
271
-		$this->createDirectory($pagesPath,0755);
268
+		$this->createDirectory($assetPath, 0777);
269
+		$this->createDirectory($protectedPath, 0755);
270
+		$this->createDirectory($runtimePath, 0777);
271
+		$this->createDirectory($pagesPath, 0755);
272 272
 
273 273
 		$this->createFile($indexFile, $this->renderIndexFile());
274 274
 		$this->createFile($configFile, $this->renderConfigFile($appName));
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 
279 279
 	protected function renderIndexFile()
280 280
 	{
281
-		$framework = realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'prado.php';
281
+		$framework=realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'prado.php';
282 282
 return '<?php
283 283
 
284 284
 $frameworkPath=\''.$framework.'\';
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
  */
378 378
 class PradoCommandLineCreateTests extends PradoCommandLineAction
379 379
 {
380
-	protected $action = '-t';
381
-	protected $parameters = array('directory');
382
-	protected $optional = array();
383
-	protected $description = 'Create test fixtures in the given <directory>.';
380
+	protected $action='-t';
381
+	protected $parameters=array('directory');
382
+	protected $optional=array();
383
+	protected $description='Create test fixtures in the given <directory>.';
384 384
 
385 385
 	public function performAction($args)
386 386
 	{
@@ -391,22 +391,22 @@  discard block
 block discarded – undo
391 391
 
392 392
 	protected function createTestFixtures($dir)
393 393
 	{
394
-		if(strlen(trim($dir)) == 0)
394
+		if(strlen(trim($dir))==0)
395 395
 			return;
396 396
 
397
-		$rootPath = realpath(dirname(trim($dir)));
398
-		$basePath = $rootPath.'/'.basename($dir);
397
+		$rootPath=realpath(dirname(trim($dir)));
398
+		$basePath=$rootPath.'/'.basename($dir);
399 399
 
400
-		$tests = $basePath.'/tests';
401
-		$unit_tests = $tests.'/unit';
402
-		$functional_tests = $tests.'/functional';
400
+		$tests=$basePath.'/tests';
401
+		$unit_tests=$tests.'/unit';
402
+		$functional_tests=$tests.'/functional';
403 403
 
404
-		$this->createDirectory($tests,0755);
405
-		$this->createDirectory($unit_tests,0755);
406
-		$this->createDirectory($functional_tests,0755);
404
+		$this->createDirectory($tests, 0755);
405
+		$this->createDirectory($unit_tests, 0755);
406
+		$this->createDirectory($functional_tests, 0755);
407 407
 
408
-		$unit_test_index = $tests.'/unit.php';
409
-		$functional_test_index = $tests.'/functional.php';
408
+		$unit_test_index=$tests.'/unit.php';
409
+		$functional_test_index=$tests.'/functional.php';
410 410
 
411 411
 		$this->createFile($unit_test_index, $this->renderUnitTestFixture());
412 412
 		$this->createFile($functional_test_index, $this->renderFunctionalTestFixture());
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
 	protected function renderUnitTestFixture()
416 416
 	{
417
-		$tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/unit_tests.php';
417
+		$tester=realpath(dirname(dirname(__FILE__))).'/tests/test_tools/unit_tests.php';
418 418
 return '<?php
419 419
 
420 420
 include_once \''.$tester.'\';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
 	protected function renderFunctionalTestFixture()
431 431
 	{
432
-		$tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/functional_tests.php';
432
+		$tester=realpath(dirname(dirname(__FILE__))).'/tests/test_tools/functional_tests.php';
433 433
 return '<?php
434 434
 
435 435
 include_once \''.$tester.'\';
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
  */
452 452
 class PradoCommandLinePhpShell extends PradoCommandLineAction
453 453
 {
454
-	protected $action = 'shell';
455
-	protected $parameters = array();
456
-	protected $optional = array('directory');
457
-	protected $description = 'Runs a PHP interactive interpreter. Initializes the Prado application in the given [directory].';
454
+	protected $action='shell';
455
+	protected $parameters=array();
456
+	protected $optional=array('directory');
457
+	protected $description='Runs a PHP interactive interpreter. Initializes the Prado application in the given [directory].';
458 458
 
459 459
 	public function performAction($args)
460 460
 	{
461 461
 		if(count($args) > 1)
462
-			$app = $this->initializePradoApplication($args[1]);
462
+			$app=$this->initializePradoApplication($args[1]);
463 463
 
464 464
 		\Psy\Shell::debug([], Prado::getApplication());
465 465
 		return true;
@@ -474,23 +474,23 @@  discard block
 block discarded – undo
474 474
  */
475 475
 class PradoCommandLineActiveRecordGen extends PradoCommandLineAction
476 476
 {
477
-	protected $action = 'generate';
478
-	protected $parameters = array('table', 'output');
479
-	protected $optional = array('directory', 'soap');
480
-	protected $description = 'Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.';
477
+	protected $action='generate';
478
+	protected $parameters=array('table', 'output');
479
+	protected $optional=array('directory', 'soap');
480
+	protected $description='Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.';
481 481
 	private $_soap=false;
482 482
 
483 483
 	public function performAction($args)
484 484
 	{
485
-		$app_dir = count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir();
486
-		$this->_soap = count($args) > 4;
487
-		if($app_dir !== false)
485
+		$app_dir=count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir();
486
+		$this->_soap=count($args) > 4;
487
+		if($app_dir!==false)
488 488
 		{
489
-			$config = $this->getActiveRecordConfig($app_dir);
490
-			$output = $this->getOutputFile($app_dir, $args[2]);
489
+			$config=$this->getActiveRecordConfig($app_dir);
490
+			$output=$this->getOutputFile($app_dir, $args[2]);
491 491
 			if(is_file($output))
492 492
 				echo "** File $output already exists, skiping. \n";
493
-			else if($config !== false && $output !== false)
493
+			else if($config!==false && $output!==false)
494 494
 				$this->generateActiveRecord($config, $args[1], $output);
495 495
 		}
496 496
 		return true;
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	{
501 501
 		if(is_dir($dir))
502 502
 			return realpath($dir);
503
-		if(false !== ($app_dir = realpath($dir.'/protected/')) && is_dir($app_dir))
503
+		if(false!==($app_dir=realpath($dir.'/protected/')) && is_dir($app_dir))
504 504
 			return $app_dir;
505 505
 		echo '** Unable to find directory "'.$dir."\".\n";
506 506
 		return false;
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 
509 509
 	protected function getXmlFile($app_dir)
510 510
 	{
511
-		if(false !== ($xml = realpath($app_dir.'/application.xml')) && is_file($xml))
511
+		if(false!==($xml=realpath($app_dir.'/application.xml')) && is_file($xml))
512 512
 			return $xml;
513
-		if(false !== ($xml = realpath($app_dir.'/protected/application.xml')) && is_file($xml))
513
+		if(false!==($xml=realpath($app_dir.'/protected/application.xml')) && is_file($xml))
514 514
 			return $xml;
515 515
 		echo '** Unable to find application.xml in '.$app_dir."\n";
516 516
 		return false;
@@ -518,9 +518,9 @@  discard block
 block discarded – undo
518 518
 
519 519
 	protected function getActiveRecordConfig($app_dir)
520 520
 	{
521
-		if(false === ($xml=$this->getXmlFile($app_dir)))
521
+		if(false===($xml=$this->getXmlFile($app_dir)))
522 522
 			return false;
523
-		if(false !== ($app=$this->initializePradoApplication($app_dir)))
523
+		if(false!==($app=$this->initializePradoApplication($app_dir)))
524 524
 		{
525 525
 			Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
526 526
 			foreach($app->getModules() as $module)
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
 	{
536 536
 		if(is_file($namespace) && strpos($namespace, $app_dir)===0)
537 537
 				return $namespace;
538
-		$file = Prado::getPathOfNamespace($namespace, ".php");
539
-		if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path))
538
+		$file=Prado::getPathOfNamespace($namespace, ".php");
539
+		if($file!==null && false!==($path=realpath(dirname($file))) && is_dir($path))
540 540
 		{
541 541
 			if(strpos($path, $app_dir)===0)
542 542
 				return $file;
@@ -547,24 +547,24 @@  discard block
 block discarded – undo
547 547
 
548 548
 	protected function generateActiveRecord($config, $tablename, $output)
549 549
 	{
550
-		$manager = TActiveRecordManager::getInstance();
551
-		if($connection = $manager->getDbConnection()) {
552
-			$gateway = $manager->getRecordGateway();
553
-			$tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename);
554
-			if(count($tableInfo->getColumns()) === 0)
550
+		$manager=TActiveRecordManager::getInstance();
551
+		if($connection=$manager->getDbConnection()) {
552
+			$gateway=$manager->getRecordGateway();
553
+			$tableInfo=$gateway->getTableInfo($manager->getDbConnection(), $tablename);
554
+			if(count($tableInfo->getColumns())===0)
555 555
 			{
556 556
 				echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n";
557 557
 				return false;
558 558
 			}
559 559
 			else
560 560
 			{
561
-				$properties = array();
561
+				$properties=array();
562 562
 				foreach($tableInfo->getColumns() as $field=>$column)
563
-					$properties[] = $this->generateProperty($field,$column);
563
+					$properties[]=$this->generateProperty($field, $column);
564 564
 			}
565 565
 
566
-			$classname = basename($output, '.php');
567
-			$class = $this->generateClass($properties, $tablename, $classname);
566
+			$classname=basename($output, '.php');
567
+			$class=$this->generateClass($properties, $tablename, $classname);
568 568
 			echo "  Writing class $classname to file $output\n";
569 569
 			file_put_contents($output, $class);
570 570
 		} else {
@@ -572,14 +572,14 @@  discard block
 block discarded – undo
572 572
 		}
573 573
 	}
574 574
 
575
-	protected function generateProperty($field,$column)
575
+	protected function generateProperty($field, $column)
576 576
 	{
577
-		$prop = '';
578
-		$name = '$'.$field;
579
-		$type = $column->getPHPType();
577
+		$prop='';
578
+		$name='$'.$field;
579
+		$type=$column->getPHPType();
580 580
 		if($this->_soap)
581 581
 		{
582
-			$prop .= <<<EOD
582
+			$prop.=<<<EOD
583 583
 
584 584
 	/**
585 585
 	 * @var $type $name
@@ -588,14 +588,14 @@  discard block
 block discarded – undo
588 588
 
589 589
 EOD;
590 590
 		}
591
-		$prop .= "\tpublic $name;";
591
+		$prop.="\tpublic $name;";
592 592
 		return $prop;
593 593
 	}
594 594
 
595 595
 	protected function generateClass($properties, $tablename, $class)
596 596
 	{
597
-		$props = implode("\n", $properties);
598
-		$date = date('Y-m-d h:i:s');
597
+		$props=implode("\n", $properties);
598
+		$date=date('Y-m-d h:i:s');
599 599
 return <<<EOD
600 600
 <?php
601 601
 /**
@@ -626,38 +626,38 @@  discard block
 block discarded – undo
626 626
  */
627 627
 class PradoCommandLineActiveRecordGenAll extends PradoCommandLineAction
628 628
 {
629
-    protected $action = 'generateAll';
630
-    protected $parameters = array('output');
631
-    protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix');
632
-    protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files.";
633
-    private $_soap = false;
634
-    private $_prefix = '';
635
-    private $_postfix = '';
636
-    private $_overwrite = false;
629
+    protected $action='generateAll';
630
+    protected $parameters=array('output');
631
+    protected $optional=array('directory', 'soap', 'overwrite', 'prefix', 'postfix');
632
+    protected $description="Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files.";
633
+    private $_soap=false;
634
+    private $_prefix='';
635
+    private $_postfix='';
636
+    private $_overwrite=false;
637 637
 
638 638
     public function performAction($args) {
639
-        $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir();
640
-        $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false;
641
-        $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false;
642
-        $this->_prefix = count($args) > 5 ? $args[5] : '';
643
-        $this->_postfix = count($args) > 6 ? $args[6] : '';
639
+        $app_dir=count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir();
640
+        $this->_soap=count($args) > 3 ? ($args[3]=="soap" || $args[3]=="true" ? true : false) : false;
641
+        $this->_overwrite=count($args) > 4 ? ($args[4]=="overwrite" || $args[4]=="true" ? true : false) : false;
642
+        $this->_prefix=count($args) > 5 ? $args[5] : '';
643
+        $this->_postfix=count($args) > 6 ? $args[6] : '';
644 644
 
645
-        if ($app_dir !== false) {
646
-            $config = $this->getActiveRecordConfig($app_dir);
645
+        if($app_dir!==false) {
646
+            $config=$this->getActiveRecordConfig($app_dir);
647 647
 
648
-            $manager = TActiveRecordManager::getInstance();
649
-            $con = $manager->getDbConnection();
650
-            $con->Active = true;
648
+            $manager=TActiveRecordManager::getInstance();
649
+            $con=$manager->getDbConnection();
650
+            $con->Active=true;
651 651
 
652 652
             switch($con->getDriverName())
653 653
            	{
654 654
 				case 'mysqli':
655 655
 				case 'mysql':
656
-					$command = $con->createCommand("SHOW TABLES");
656
+					$command=$con->createCommand("SHOW TABLES");
657 657
 					break;
658 658
 				case 'sqlite': //sqlite 3
659 659
 				case 'sqlite2': //sqlite 2
660
-					$command = $con->createCommand("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'");
660
+					$command=$con->createCommand("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'");
661 661
 					break;
662 662
 				case 'pgsql':
663 663
 				case 'mssql': // Mssql driver on windows hosts
@@ -670,17 +670,17 @@  discard block
 block discarded – undo
670 670
 					
671 671
            	}
672 672
 
673
-            $dataReader = $command->query();
673
+            $dataReader=$command->query();
674 674
             $dataReader->bindColumn(1, $table);
675
-            $tables = array();
676
-            while ($dataReader->read() !== false) {
677
-                $tables[] = $table;
675
+            $tables=array();
676
+            while($dataReader->read()!==false) {
677
+                $tables[]=$table;
678 678
             }
679
-            $con->Active = False;
680
-            foreach ($tables as $key => $table) {
681
-                $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix;
682
-                if ($config !== false && $output !== false) {
683
-                    $this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite);
679
+            $con->Active=False;
680
+            foreach($tables as $key => $table) {
681
+                $output=$args[1].".".$this->_prefix.ucfirst($table).$this->_postfix;
682
+                if($config!==false && $output!==false) {
683
+                    $this->generate("generate ".$table." ".$output." ".$this->_soap." ".$this->_overwrite);
684 684
                 }
685 685
             }
686 686
         }
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
 
690 690
     public function generate($l)
691 691
     {
692
-		$input = explode(" ", trim($l));
692
+		$input=explode(" ", trim($l));
693 693
 		if(count($input) > 2)
694 694
 		{
695
-			$app_dir = '.';
695
+			$app_dir='.';
696 696
 			if(Prado::getApplication()!==null)
697
-				$app_dir = dirname(Prado::getApplication()->getBasePath());
698
-			$args = array($input[0],$input[1], $input[2],$app_dir);
699
-			if(count($input)>3)
700
-				$args = array($input[0],$input[1], $input[2],$app_dir,'soap');
701
-			$cmd = new PradoCommandLineActiveRecordGen;
697
+				$app_dir=dirname(Prado::getApplication()->getBasePath());
698
+			$args=array($input[0], $input[1], $input[2], $app_dir);
699
+			if(count($input) > 3)
700
+				$args=array($input[0], $input[1], $input[2], $app_dir, 'soap');
701
+			$cmd=new PradoCommandLineActiveRecordGen;
702 702
 			$cmd->performAction($args);
703 703
 		}
704 704
 		else
@@ -708,45 +708,45 @@  discard block
 block discarded – undo
708 708
     }
709 709
 
710 710
     protected function getAppDir($dir=".") {
711
-        if (is_dir($dir))
711
+        if(is_dir($dir))
712 712
             return realpath($dir);
713
-        if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
713
+        if(false!==($app_dir=realpath($dir.'/protected/')) && is_dir($app_dir))
714 714
             return $app_dir;
715
-        echo '** Unable to find directory "' . $dir . "\".\n";
715
+        echo '** Unable to find directory "'.$dir."\".\n";
716 716
         return false;
717 717
     }
718 718
 
719 719
     protected function getXmlFile($app_dir) {
720
-        if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
720
+        if(false!==($xml=realpath($app_dir.'/application.xml')) && is_file($xml))
721 721
             return $xml;
722
-        if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
722
+        if(false!==($xml=realpath($app_dir.'/protected/application.xml')) && is_file($xml))
723 723
             return $xml;
724
-        echo '** Unable to find application.xml in ' . $app_dir . "\n";
724
+        echo '** Unable to find application.xml in '.$app_dir."\n";
725 725
         return false;
726 726
     }
727 727
 
728 728
     protected function getActiveRecordConfig($app_dir) {
729
-        if (false === ($xml = $this->getXmlFile($app_dir)))
729
+        if(false===($xml=$this->getXmlFile($app_dir)))
730 730
             return false;
731
-        if (false !== ($app = $this->initializePradoApplication($app_dir))) {
731
+        if(false!==($app=$this->initializePradoApplication($app_dir))) {
732 732
             Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
733
-            foreach ($app->getModules() as $module)
734
-                if ($module instanceof TActiveRecordConfig)
733
+            foreach($app->getModules() as $module)
734
+                if($module instanceof TActiveRecordConfig)
735 735
                     return $module;
736
-            echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
736
+            echo '** Unable to find TActiveRecordConfig module in '.$xml."\n";
737 737
         }
738 738
         return false;
739 739
     }
740 740
 
741 741
     protected function getOutputFile($app_dir, $namespace) {
742
-        if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
742
+        if(is_file($namespace) && strpos($namespace, $app_dir)===0)
743 743
             return $namespace;
744
-        $file = Prado::getPathOfNamespace($namespace, "");
745
-        if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) {
746
-            if (strpos($path, $app_dir) === 0)
744
+        $file=Prado::getPathOfNamespace($namespace, "");
745
+        if($file!==null && false!==($path=realpath(dirname($file))) && is_dir($path)) {
746
+            if(strpos($path, $app_dir)===0)
747 747
                 return $file;
748 748
         }
749
-        echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
749
+        echo '** Output file '.$file.' must be within directory '.$app_dir."\n";
750 750
         return false;
751 751
     }
752 752
 
Please login to merge, or discard this patch.