@@ -12,7 +12,7 @@ discard block |
||
12 | 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 | 17 | require_once($frameworkPath.'prado.php'); |
18 | 18 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | //config PHP shell |
31 | 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 | 35 | if(!$shell->has_semicolon) echo Prado::varDump($var); |
36 | 36 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function addActionClass($class) |
73 | 73 | { |
74 | - $this->_actions[$class] = new $class; |
|
74 | + $this->_actions[$class]=new $class; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | public static function getInstance() |
81 | 81 | { |
82 | 82 | static $instance; |
83 | - if($instance === null) |
|
84 | - $instance = new self; |
|
83 | + if($instance===null) |
|
84 | + $instance=new self; |
|
85 | 85 | return $instance; |
86 | 86 | } |
87 | 87 | |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | { |
99 | 99 | if(count($args) > 1) |
100 | 100 | array_shift($args); |
101 | - $valid = false; |
|
101 | + $valid=false; |
|
102 | 102 | foreach($this->_actions as $class => $action) |
103 | 103 | { |
104 | 104 | if($action->isValidAction($args)) |
105 | 105 | { |
106 | - $valid |= $action->performAction($args); |
|
106 | + $valid|=$action->performAction($args); |
|
107 | 107 | break; |
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | - $valid = false; |
|
111 | + $valid=false; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | if(!$valid) |
@@ -167,23 +167,23 @@ discard block |
||
167 | 167 | |
168 | 168 | public function isValidAction($args) |
169 | 169 | { |
170 | - return strtolower($args[0]) === $this->action && |
|
171 | - count($args)-1 >= count($this->parameters); |
|
170 | + return strtolower($args[0])===$this->action && |
|
171 | + count($args) - 1 >= count($this->parameters); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | public function renderHelp() |
175 | 175 | { |
176 | - $params = array(); |
|
176 | + $params=array(); |
|
177 | 177 | foreach($this->parameters as $v) |
178 | - $params[] = '<'.$v.'>'; |
|
179 | - $parameters = join($params, ' '); |
|
180 | - $options = array(); |
|
178 | + $params[]='<'.$v.'>'; |
|
179 | + $parameters=join($params, ' '); |
|
180 | + $options=array(); |
|
181 | 181 | foreach($this->optional as $v) |
182 | - $options[] = '['.$v.']'; |
|
183 | - $optional = (strlen($parameters) ? ' ' : ''). join($options, ' '); |
|
182 | + $options[]='['.$v.']'; |
|
183 | + $optional=(strlen($parameters) ? ' ' : '').join($options, ' '); |
|
184 | 184 | $description=''; |
185 | - foreach(explode("\n", wordwrap($this->description,65)) as $line) |
|
186 | - $description .= ' '.$line."\n"; |
|
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,14 +193,14 @@ discard block |
||
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 | 199 | if(Prado::getApplication()===null) |
200 | 200 | { |
201 | - $app = new PradoShellApplication($app_dir); |
|
201 | + $app=new PradoShellApplication($app_dir); |
|
202 | 202 | $app->run(); |
203 | - $dir = substr(str_replace(realpath('./'),'',$app_dir),1); |
|
203 | + $dir=substr(str_replace(realpath('./'), '', $app_dir), 1); |
|
204 | 204 | $initialized=true; |
205 | 205 | PradoCommandLineInterpreter::printGreeting(); |
206 | 206 | echo '** Loaded PRADO appplication in directory "'.$dir."\".\n"; |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | else |
212 | 212 | { |
213 | 213 | PradoCommandLineInterpreter::printGreeting(); |
214 | - echo '+'.str_repeat('-',77)."+\n"; |
|
214 | + echo '+'.str_repeat('-', 77)."+\n"; |
|
215 | 215 | echo '** Unable to load PRADO application in directory "'.$directory."\".\n"; |
216 | - echo '+'.str_repeat('-',77)."+\n"; |
|
216 | + echo '+'.str_repeat('-', 77)."+\n"; |
|
217 | 217 | } |
218 | 218 | return false; |
219 | 219 | } |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | */ |
229 | 229 | class PradoCommandLineCreateProject extends PradoCommandLineAction |
230 | 230 | { |
231 | - protected $action = '-c'; |
|
232 | - protected $parameters = array('directory'); |
|
233 | - protected $optional = array(); |
|
234 | - protected $description = 'Creates a Prado project skeleton for the given <directory>.'; |
|
231 | + protected $action='-c'; |
|
232 | + protected $parameters=array('directory'); |
|
233 | + protected $optional=array(); |
|
234 | + protected $description='Creates a Prado project skeleton for the given <directory>.'; |
|
235 | 235 | |
236 | 236 | public function performAction($args) |
237 | 237 | { |
@@ -245,31 +245,31 @@ discard block |
||
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 | - $rootPath = realpath(dirname(trim($dir))); |
|
251 | + $rootPath=realpath(dirname(trim($dir))); |
|
252 | 252 | |
253 | 253 | if(basename($dir)!=='.') |
254 | - $basePath = $rootPath.DIRECTORY_SEPARATOR.basename($dir); |
|
254 | + $basePath=$rootPath.DIRECTORY_SEPARATOR.basename($dir); |
|
255 | 255 | else |
256 | - $basePath = $rootPath; |
|
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'; |
|
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'; |
|
256 | + $basePath=$rootPath; |
|
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'; |
|
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'; |
|
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,7 +279,7 @@ discard block |
||
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 | 285 | $frameworkPath=\''.$framework.'\'; |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | */ |
379 | 379 | class PradoCommandLineCreateTests extends PradoCommandLineAction |
380 | 380 | { |
381 | - protected $action = '-t'; |
|
382 | - protected $parameters = array('directory'); |
|
383 | - protected $optional = array(); |
|
384 | - protected $description = 'Create test fixtures in the given <directory>.'; |
|
381 | + protected $action='-t'; |
|
382 | + protected $parameters=array('directory'); |
|
383 | + protected $optional=array(); |
|
384 | + protected $description='Create test fixtures in the given <directory>.'; |
|
385 | 385 | |
386 | 386 | public function performAction($args) |
387 | 387 | { |
@@ -392,22 +392,22 @@ discard block |
||
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 | - $rootPath = realpath(dirname(trim($dir))); |
|
399 | - $basePath = $rootPath.'/'.basename($dir); |
|
398 | + $rootPath=realpath(dirname(trim($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,7 +415,7 @@ discard block |
||
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 | 421 | include_once \''.$tester.'\'; |
@@ -430,7 +430,7 @@ discard block |
||
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 | 436 | include_once \''.$tester.'\'; |
@@ -452,15 +452,15 @@ discard block |
||
452 | 452 | */ |
453 | 453 | class PradoCommandLinePhpShell extends PradoCommandLineAction |
454 | 454 | { |
455 | - protected $action = 'shell'; |
|
456 | - protected $parameters = array(); |
|
457 | - protected $optional = array('directory'); |
|
458 | - protected $description = 'Runs a PHP interactive interpreter. Initializes the Prado application in the given [directory].'; |
|
455 | + protected $action='shell'; |
|
456 | + protected $parameters=array(); |
|
457 | + protected $optional=array('directory'); |
|
458 | + protected $description='Runs a PHP interactive interpreter. Initializes the Prado application in the given [directory].'; |
|
459 | 459 | |
460 | 460 | public function performAction($args) |
461 | 461 | { |
462 | 462 | if(count($args) > 1) |
463 | - $app = $this->initializePradoApplication($args[1]); |
|
463 | + $app=$this->initializePradoApplication($args[1]); |
|
464 | 464 | return true; |
465 | 465 | } |
466 | 466 | } |
@@ -473,18 +473,18 @@ discard block |
||
473 | 473 | */ |
474 | 474 | class PradoCommandLineUnitTest extends PradoCommandLineAction |
475 | 475 | { |
476 | - protected $action = 'test'; |
|
477 | - protected $parameters = array('directory'); |
|
478 | - protected $optional = array('testcase ...'); |
|
479 | - protected $description = 'Runs all unit test cases in the given <directory>. Use [testcase] option to run specific test cases.'; |
|
476 | + protected $action='test'; |
|
477 | + protected $parameters=array('directory'); |
|
478 | + protected $optional=array('testcase ...'); |
|
479 | + protected $description='Runs all unit test cases in the given <directory>. Use [testcase] option to run specific test cases.'; |
|
480 | 480 | |
481 | - protected $matches = array(); |
|
481 | + protected $matches=array(); |
|
482 | 482 | |
483 | 483 | public function performAction($args) |
484 | 484 | { |
485 | - $dir = realpath($args[1]); |
|
486 | - if($dir !== false && is_dir($dir)) |
|
487 | - $this->runUnitTests($dir,$args); |
|
485 | + $dir=realpath($args[1]); |
|
486 | + if($dir!==false && is_dir($dir)) |
|
487 | + $this->runUnitTests($dir, $args); |
|
488 | 488 | else |
489 | 489 | echo '** Unable to find directory "'.$args[1]."\".\n"; |
490 | 490 | return true; |
@@ -492,7 +492,7 @@ discard block |
||
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 | 497 | require_once($TEST_TOOLS.'/simpletest/unit_tester.php'); |
498 | 498 | require_once($TEST_TOOLS.'/simpletest/web_tester.php'); |
@@ -502,77 +502,77 @@ discard block |
||
502 | 502 | |
503 | 503 | protected function runUnitTests($dir, $args) |
504 | 504 | { |
505 | - $app_dir = $this->getAppDir($dir); |
|
506 | - if($app_dir !== false) |
|
505 | + $app_dir=$this->getAppDir($dir); |
|
506 | + if($app_dir!==false) |
|
507 | 507 | $this->initializePradoApplication($app_dir.'/../'); |
508 | 508 | |
509 | 509 | $this->initializeTestRunner(); |
510 | - $test_dir = $this->getTestDir($dir); |
|
511 | - if($test_dir !== false) |
|
510 | + $test_dir=$this->getTestDir($dir); |
|
511 | + if($test_dir!==false) |
|
512 | 512 | { |
513 | - $test =$this->getUnitTestCases($test_dir,$args); |
|
514 | - $running_dir = substr(str_replace(realpath('./'),'',$test_dir),1); |
|
513 | + $test=$this->getUnitTestCases($test_dir, $args); |
|
514 | + $running_dir=substr(str_replace(realpath('./'), '', $test_dir), 1); |
|
515 | 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); |
|
520 | + $running_dir=substr(str_replace(realpath('./'), '', $dir), 1); |
|
521 | 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 | 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 | 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 | - $matches = null; |
|
543 | + $matches=null; |
|
544 | 544 | if(count($args) > 2) |
545 | - $matches = array_slice($args,2); |
|
545 | + $matches=array_slice($args, 2); |
|
546 | 546 | $test=new GroupTest(' '); |
547 | - $this->addTests($test,$dir,true,$matches); |
|
548 | - $test->setLabel(implode(' ',$this->matches)); |
|
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 | 554 | $dir=opendir($path); |
555 | 555 | while(($entry=readdir($dir))!==false) |
556 | 556 | { |
557 | 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))) |
|
559 | + if($match==null || ($match!=null && $this->hasMatch($match, $entry))) |
|
560 | 560 | $test->addTestFile($path.'/'.$entry); |
561 | 561 | } |
562 | 562 | if($entry!=='.' && $entry!=='..' && is_dir($path.'/'.$entry) && $recursive) |
563 | - $this->addTests($test,$path.'/'.$entry,$recursive,$match); |
|
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,'.'))); |
|
570 | + $file=strtolower(substr($entry, 0, strrpos($entry, '.'))); |
|
571 | 571 | foreach($match as $m) |
572 | 572 | { |
573 | - if(strtolower($m) === $file) |
|
573 | + if(strtolower($m)===$file) |
|
574 | 574 | { |
575 | - $this->matches[] = $m; |
|
575 | + $this->matches[]=$m; |
|
576 | 576 | return true; |
577 | 577 | } |
578 | 578 | } |
@@ -588,23 +588,23 @@ discard block |
||
588 | 588 | */ |
589 | 589 | class PradoCommandLineActiveRecordGen extends PradoCommandLineAction |
590 | 590 | { |
591 | - protected $action = 'generate'; |
|
592 | - protected $parameters = array('table', 'output'); |
|
593 | - protected $optional = array('directory', 'soap'); |
|
594 | - protected $description = 'Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.'; |
|
591 | + protected $action='generate'; |
|
592 | + protected $parameters=array('table', 'output'); |
|
593 | + protected $optional=array('directory', 'soap'); |
|
594 | + protected $description='Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.'; |
|
595 | 595 | private $_soap=false; |
596 | 596 | |
597 | 597 | public function performAction($args) |
598 | 598 | { |
599 | - $app_dir = count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir(); |
|
600 | - $this->_soap = count($args) > 4; |
|
601 | - if($app_dir !== false) |
|
599 | + $app_dir=count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir(); |
|
600 | + $this->_soap=count($args) > 4; |
|
601 | + if($app_dir!==false) |
|
602 | 602 | { |
603 | - $config = $this->getActiveRecordConfig($app_dir); |
|
604 | - $output = $this->getOutputFile($app_dir, $args[2]); |
|
603 | + $config=$this->getActiveRecordConfig($app_dir); |
|
604 | + $output=$this->getOutputFile($app_dir, $args[2]); |
|
605 | 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; |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | { |
615 | 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 | 619 | echo '** Unable to find directory "'.$dir."\".\n"; |
620 | 620 | return false; |
@@ -622,9 +622,9 @@ discard block |
||
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 | 629 | echo '** Unable to find application.xml in '.$app_dir."\n"; |
630 | 630 | return false; |
@@ -632,9 +632,9 @@ discard block |
||
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 | 640 | foreach($app->getModules() as $module) |
@@ -649,8 +649,8 @@ discard block |
||
649 | 649 | { |
650 | 650 | if(is_file($namespace) && strpos($namespace, $app_dir)===0) |
651 | 651 | return $namespace; |
652 | - $file = Prado::getPathOfNamespace($namespace, ".php"); |
|
653 | - if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) |
|
652 | + $file=Prado::getPathOfNamespace($namespace, ".php"); |
|
653 | + if($file!==null && false!==($path=realpath(dirname($file))) && is_dir($path)) |
|
654 | 654 | { |
655 | 655 | if(strpos($path, $app_dir)===0) |
656 | 656 | return $file; |
@@ -661,24 +661,24 @@ discard block |
||
661 | 661 | |
662 | 662 | protected function generateActiveRecord($config, $tablename, $output) |
663 | 663 | { |
664 | - $manager = TActiveRecordManager::getInstance(); |
|
665 | - if($connection = $manager->getDbConnection()) { |
|
666 | - $gateway = $manager->getRecordGateway(); |
|
667 | - $tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename); |
|
668 | - if(count($tableInfo->getColumns()) === 0) |
|
664 | + $manager=TActiveRecordManager::getInstance(); |
|
665 | + if($connection=$manager->getDbConnection()) { |
|
666 | + $gateway=$manager->getRecordGateway(); |
|
667 | + $tableInfo=$gateway->getTableInfo($manager->getDbConnection(), $tablename); |
|
668 | + if(count($tableInfo->getColumns())===0) |
|
669 | 669 | { |
670 | 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 | - $properties = array(); |
|
675 | + $properties=array(); |
|
676 | 676 | foreach($tableInfo->getColumns() as $field=>$column) |
677 | - $properties[] = $this->generateProperty($field,$column); |
|
677 | + $properties[]=$this->generateProperty($field, $column); |
|
678 | 678 | } |
679 | 679 | |
680 | - $classname = basename($output, '.php'); |
|
681 | - $class = $this->generateClass($properties, $tablename, $classname); |
|
680 | + $classname=basename($output, '.php'); |
|
681 | + $class=$this->generateClass($properties, $tablename, $classname); |
|
682 | 682 | echo " Writing class $classname to file $output\n"; |
683 | 683 | file_put_contents($output, $class); |
684 | 684 | } else { |
@@ -686,14 +686,14 @@ discard block |
||
686 | 686 | } |
687 | 687 | } |
688 | 688 | |
689 | - protected function generateProperty($field,$column) |
|
689 | + protected function generateProperty($field, $column) |
|
690 | 690 | { |
691 | - $prop = ''; |
|
692 | - $name = '$'.$field; |
|
693 | - $type = $column->getPHPType(); |
|
691 | + $prop=''; |
|
692 | + $name='$'.$field; |
|
693 | + $type=$column->getPHPType(); |
|
694 | 694 | if($this->_soap) |
695 | 695 | { |
696 | - $prop .= <<<EOD |
|
696 | + $prop.=<<<EOD |
|
697 | 697 | |
698 | 698 | /** |
699 | 699 | * @var $type $name |
@@ -702,14 +702,14 @@ discard block |
||
702 | 702 | |
703 | 703 | EOD; |
704 | 704 | } |
705 | - $prop .= "\tpublic $name;"; |
|
705 | + $prop.="\tpublic $name;"; |
|
706 | 706 | return $prop; |
707 | 707 | } |
708 | 708 | |
709 | 709 | protected function generateClass($properties, $tablename, $class) |
710 | 710 | { |
711 | - $props = implode("\n", $properties); |
|
712 | - $date = date('Y-m-d h:i:s'); |
|
711 | + $props=implode("\n", $properties); |
|
712 | + $date=date('Y-m-d h:i:s'); |
|
713 | 713 | return <<<EOD |
714 | 714 | <?php |
715 | 715 | /** |
@@ -740,41 +740,41 @@ discard block |
||
740 | 740 | */ |
741 | 741 | class PradoCommandLineActiveRecordGenAll extends PradoCommandLineAction { |
742 | 742 | |
743 | - protected $action = 'generateAll'; |
|
744 | - protected $parameters = array('output'); |
|
745 | - protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
746 | - 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."; |
|
747 | - private $_soap = false; |
|
748 | - private $_prefix = ''; |
|
749 | - private $_postfix = ''; |
|
750 | - private $_overwrite = false; |
|
743 | + protected $action='generateAll'; |
|
744 | + protected $parameters=array('output'); |
|
745 | + protected $optional=array('directory', 'soap', 'overwrite', 'prefix', 'postfix'); |
|
746 | + 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."; |
|
747 | + private $_soap=false; |
|
748 | + private $_prefix=''; |
|
749 | + private $_postfix=''; |
|
750 | + private $_overwrite=false; |
|
751 | 751 | |
752 | 752 | public function performAction($args) { |
753 | - $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
754 | - $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false; |
|
755 | - $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false; |
|
756 | - $this->_prefix = count($args) > 5 ? $args[5] : ''; |
|
757 | - $this->_postfix = count($args) > 6 ? $args[6] : ''; |
|
758 | - |
|
759 | - if ($app_dir !== false) { |
|
760 | - $config = $this->getActiveRecordConfig($app_dir); |
|
761 | - |
|
762 | - $manager = TActiveRecordManager::getInstance(); |
|
763 | - $con = $manager->getDbConnection(); |
|
764 | - $con->Active = true; |
|
765 | - $command = $con->createCommand("Show Tables"); |
|
766 | - $dataReader = $command->query(); |
|
753 | + $app_dir=count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir(); |
|
754 | + $this->_soap=count($args) > 3 ? ($args[3]=="soap" || $args[3]=="true" ? true : false) : false; |
|
755 | + $this->_overwrite=count($args) > 4 ? ($args[4]=="overwrite" || $args[4]=="true" ? true : false) : false; |
|
756 | + $this->_prefix=count($args) > 5 ? $args[5] : ''; |
|
757 | + $this->_postfix=count($args) > 6 ? $args[6] : ''; |
|
758 | + |
|
759 | + if($app_dir!==false) { |
|
760 | + $config=$this->getActiveRecordConfig($app_dir); |
|
761 | + |
|
762 | + $manager=TActiveRecordManager::getInstance(); |
|
763 | + $con=$manager->getDbConnection(); |
|
764 | + $con->Active=true; |
|
765 | + $command=$con->createCommand("Show Tables"); |
|
766 | + $dataReader=$command->query(); |
|
767 | 767 | $dataReader->bindColumn(1, $table); |
768 | - $generator = new PHP_Shell_Extensions_ActiveRecord(); |
|
769 | - $tables = array(); |
|
770 | - while ($dataReader->read() !== false) { |
|
771 | - $tables[] = $table; |
|
768 | + $generator=new PHP_Shell_Extensions_ActiveRecord(); |
|
769 | + $tables=array(); |
|
770 | + while($dataReader->read()!==false) { |
|
771 | + $tables[]=$table; |
|
772 | 772 | } |
773 | - $con->Active = False; |
|
774 | - foreach ($tables as $key => $table) { |
|
775 | - $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
|
776 | - if ($config !== false && $output !== false) { |
|
777 | - $generator->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
|
773 | + $con->Active=False; |
|
774 | + foreach($tables as $key => $table) { |
|
775 | + $output=$args[1].".".$this->_prefix.ucfirst($table).$this->_postfix; |
|
776 | + if($config!==false && $output!==false) { |
|
777 | + $generator->generate("generate ".$table." ".$output." ".$this->_soap." ".$this->_overwrite); |
|
778 | 778 | } |
779 | 779 | } |
780 | 780 | } |
@@ -782,45 +782,45 @@ discard block |
||
782 | 782 | } |
783 | 783 | |
784 | 784 | protected function getAppDir($dir=".") { |
785 | - if (is_dir($dir)) |
|
785 | + if(is_dir($dir)) |
|
786 | 786 | return realpath($dir); |
787 | - if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
787 | + if(false!==($app_dir=realpath($dir.'/protected/')) && is_dir($app_dir)) |
|
788 | 788 | return $app_dir; |
789 | - echo '** Unable to find directory "' . $dir . "\".\n"; |
|
789 | + echo '** Unable to find directory "'.$dir."\".\n"; |
|
790 | 790 | return false; |
791 | 791 | } |
792 | 792 | |
793 | 793 | protected function getXmlFile($app_dir) { |
794 | - if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
794 | + if(false!==($xml=realpath($app_dir.'/application.xml')) && is_file($xml)) |
|
795 | 795 | return $xml; |
796 | - if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
796 | + if(false!==($xml=realpath($app_dir.'/protected/application.xml')) && is_file($xml)) |
|
797 | 797 | return $xml; |
798 | - echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
798 | + echo '** Unable to find application.xml in '.$app_dir."\n"; |
|
799 | 799 | return false; |
800 | 800 | } |
801 | 801 | |
802 | 802 | protected function getActiveRecordConfig($app_dir) { |
803 | - if (false === ($xml = $this->getXmlFile($app_dir))) |
|
803 | + if(false===($xml=$this->getXmlFile($app_dir))) |
|
804 | 804 | return false; |
805 | - if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
805 | + if(false!==($app=$this->initializePradoApplication($app_dir))) { |
|
806 | 806 | Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
807 | - foreach ($app->getModules() as $module) |
|
808 | - if ($module instanceof TActiveRecordConfig) |
|
807 | + foreach($app->getModules() as $module) |
|
808 | + if($module instanceof TActiveRecordConfig) |
|
809 | 809 | return $module; |
810 | - echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
810 | + echo '** Unable to find TActiveRecordConfig module in '.$xml."\n"; |
|
811 | 811 | } |
812 | 812 | return false; |
813 | 813 | } |
814 | 814 | |
815 | 815 | protected function getOutputFile($app_dir, $namespace) { |
816 | - if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
816 | + if(is_file($namespace) && strpos($namespace, $app_dir)===0) |
|
817 | 817 | return $namespace; |
818 | - $file = Prado::getPathOfNamespace($namespace, ""); |
|
819 | - if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
820 | - if (strpos($path, $app_dir) === 0) |
|
818 | + $file=Prado::getPathOfNamespace($namespace, ""); |
|
819 | + if($file!==null && false!==($path=realpath(dirname($file))) && is_dir($path)) { |
|
820 | + if(strpos($path, $app_dir)===0) |
|
821 | 821 | return $file; |
822 | 822 | } |
823 | - echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
823 | + echo '** Output file '.$file.' must be within directory '.$app_dir."\n"; |
|
824 | 824 | return false; |
825 | 825 | } |
826 | 826 | |
@@ -833,8 +833,8 @@ discard block |
||
833 | 833 | public function register() |
834 | 834 | { |
835 | 835 | |
836 | - $cmd = PHP_Shell_Commands::getInstance(); |
|
837 | - if(Prado::getApplication() !== null) |
|
836 | + $cmd=PHP_Shell_Commands::getInstance(); |
|
837 | + if(Prado::getApplication()!==null) |
|
838 | 838 | { |
839 | 839 | $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]', |
840 | 840 | 'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL. |
@@ -844,16 +844,16 @@ discard block |
||
844 | 844 | |
845 | 845 | public function generate($l) |
846 | 846 | { |
847 | - $input = explode(" ", trim($l)); |
|
847 | + $input=explode(" ", trim($l)); |
|
848 | 848 | if(count($input) > 2) |
849 | 849 | { |
850 | - $app_dir = '.'; |
|
850 | + $app_dir='.'; |
|
851 | 851 | if(Prado::getApplication()!==null) |
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'); |
|
856 | - $cmd = new PradoCommandLineActiveRecordGen; |
|
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'); |
|
856 | + $cmd=new PradoCommandLineActiveRecordGen; |
|
857 | 857 | $cmd->performAction($args); |
858 | 858 | } |
859 | 859 | else |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
866 | - $__shell_exts = PHP_Shell_Extensions::getInstance(); |
|
866 | + $__shell_exts=PHP_Shell_Extensions::getInstance(); |
|
867 | 867 | $__shell_exts->registerExtensions(array( |
868 | 868 | "active-record" => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */ |
869 | 869 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * unquote chars |
34 | 34 | * @var array |
35 | 35 | */ |
36 | - private $uqChars = array('[', ']', '"', '`', "'"); |
|
36 | + private $uqChars=array('[', ']', '"', '`', "'"); |
|
37 | 37 | |
38 | 38 | function __construct() |
39 | 39 | { |
@@ -42,31 +42,31 @@ discard block |
||
42 | 42 | |
43 | 43 | public function setClasPrefix($_clas_prefix) |
44 | 44 | { |
45 | - $this->_clasPrefix = $_clas_prefix; |
|
45 | + $this->_clasPrefix=$_clas_prefix; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function setClassSufix($_clas_sufix) |
49 | 49 | { |
50 | - $this->_classSufix = $_clas_sufix; |
|
50 | + $this->_classSufix=$_clas_sufix; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | //----------------------------------------------------------------------------- |
54 | 54 | // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
55 | 55 | public function generate($tableName) |
56 | 56 | { |
57 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
57 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
58 | 58 | $this->_commonGenerate($tableName, $tableInfo); |
59 | 59 | } |
60 | 60 | |
61 | 61 | public function generateAll() |
62 | 62 | { |
63 | - foreach ($this->getAllTableNames() as $tableName) |
|
63 | + foreach($this->getAllTableNames() as $tableName) |
|
64 | 64 | { |
65 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | - if (!empty($this->_relations)) |
|
65 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
66 | + if(!empty($this->_relations)) |
|
67 | 67 | { |
68 | 68 | // Cancel generation of M-M relationships middle table |
69 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
69 | + if(count($tableInfo->getPrimaryKeys())===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | $this->_commonGenerate($tableName, $tableInfo); |
@@ -75,26 +75,26 @@ discard block |
||
75 | 75 | |
76 | 76 | public function buildRelations() |
77 | 77 | { |
78 | - $this->_relations = array(); |
|
79 | - foreach ($this->getAllTableNames() as $table_name) |
|
78 | + $this->_relations=array(); |
|
79 | + foreach($this->getAllTableNames() as $table_name) |
|
80 | 80 | { |
81 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | - $pks = $tableInfo->getPrimaryKeys(); |
|
83 | - $fks = $tableInfo->getForeignKeys(); |
|
81 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
82 | + $pks=$tableInfo->getPrimaryKeys(); |
|
83 | + $fks=$tableInfo->getForeignKeys(); |
|
84 | 84 | |
85 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
85 | + if(count($pks)===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
86 | 86 | { |
87 | - $table_name_mm = $fks[0]["table"]; |
|
88 | - $table_name_mm2 = $fks[1]["table"]; |
|
87 | + $table_name_mm=$fks[0]["table"]; |
|
88 | + $table_name_mm2=$fks[1]["table"]; |
|
89 | 89 | |
90 | - $this->_relations[$table_name_mm][] = array( |
|
90 | + $this->_relations[$table_name_mm][]=array( |
|
91 | 91 | "prop_name" => strtolower($table_name_mm2), |
92 | 92 | "rel_type" => "self::MANY_TO_MANY", |
93 | 93 | "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
94 | 94 | "prop_ref" => $table_name |
95 | 95 | ); |
96 | 96 | |
97 | - $this->_relations[$table_name_mm2][] = array( |
|
97 | + $this->_relations[$table_name_mm2][]=array( |
|
98 | 98 | "prop_name" => strtolower($table_name_mm), |
99 | 99 | "rel_type" => "self::MANY_TO_MANY", |
100 | 100 | "ref_class_name" => $this->_getProperClassName($table_name_mm), |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | ); |
103 | 103 | continue; |
104 | 104 | } |
105 | - foreach ($fks as $fk_data)//1-M relationships |
|
105 | + foreach($fks as $fk_data)//1-M relationships |
|
106 | 106 | { |
107 | - $owner_table = $fk_data["table"]; |
|
108 | - $slave_table = $table_name; |
|
109 | - $fk_prop = key($fk_data["keys"]); |
|
107 | + $owner_table=$fk_data["table"]; |
|
108 | + $slave_table=$table_name; |
|
109 | + $fk_prop=key($fk_data["keys"]); |
|
110 | 110 | |
111 | - $this->_relations[$owner_table][] = array( |
|
111 | + $this->_relations[$owner_table][]=array( |
|
112 | 112 | "prop_name" => strtolower($slave_table), |
113 | 113 | "rel_type" => "self::HAS_MANY", |
114 | 114 | "ref_class_name" => $this->_getProperClassName($slave_table), |
115 | 115 | "prop_ref" => $fk_prop |
116 | 116 | ); |
117 | 117 | |
118 | - $this->_relations[$slave_table][] = array( |
|
118 | + $this->_relations[$slave_table][]=array( |
|
119 | 119 | "prop_name" => strtolower($owner_table), |
120 | 120 | "rel_type" => "self::BELONGS_TO", |
121 | 121 | "ref_class_name" => $this->_getProperClassName($owner_table), |
@@ -131,88 +131,88 @@ discard block |
||
131 | 131 | |
132 | 132 | private function _commonGenerate($tableName, $tableInfo) |
133 | 133 | { |
134 | - if (count($tableInfo->getColumns()) === 0) |
|
135 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
134 | + if(count($tableInfo->getColumns())===0) |
|
135 | + throw new Exception("Unable to find table or view $tableName in ".$this->_dbMetaData->getDbConnection()->getConnectionString()."."); |
|
136 | 136 | else |
137 | 137 | { |
138 | - $properties = array(); |
|
139 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | - $properties[] = $this->generateProperty($field, $metadata); |
|
141 | - $toString = $this->_buildSmartToString($tableInfo); |
|
138 | + $properties=array(); |
|
139 | + foreach($tableInfo->getColumns() as $field => $metadata) |
|
140 | + $properties[]=$this->generateProperty($field, $metadata); |
|
141 | + $toString=$this->_buildSmartToString($tableInfo); |
|
142 | 142 | } |
143 | 143 | |
144 | - $clasName = $this->_getProperClassName($tableName); |
|
145 | - $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
144 | + $clasName=$this->_getProperClassName($tableName); |
|
145 | + $class=$this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | + $output=$this->_opFile.DIRECTORY_SEPARATOR.$clasName.".php"; |
|
147 | 147 | file_put_contents($output, $class); |
148 | 148 | } |
149 | 149 | |
150 | 150 | private function _getProperClassName($tableName) |
151 | 151 | { |
152 | - $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | - $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
152 | + $table_name_words=str_replace("_", " ", strtolower($tableName)); |
|
153 | + $final_conversion=str_replace(" ", "", ucwords($table_name_words)); |
|
154 | + return $this->_clasPrefix.$final_conversion.$this->_classSufix; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | //----------------------------------------------------------------------------- |
158 | 158 | |
159 | 159 | protected function generateProperty($field, $metadata) |
160 | 160 | { |
161 | - $prop = ''; |
|
162 | - $name = '$' . $field; |
|
161 | + $prop=''; |
|
162 | + $name='$'.$field; |
|
163 | 163 | |
164 | 164 | /* TODO use in version 2.0 */ |
165 | 165 | // $type = $column->getPHPType(); |
166 | 166 | |
167 | - $prop .= "\tpublic $name;"; |
|
167 | + $prop.="\tpublic $name;"; |
|
168 | 168 | return $prop; |
169 | 169 | } |
170 | 170 | |
171 | 171 | private function _renderRelations($tablename) |
172 | 172 | { |
173 | - if (!isset($this->_relations[$tablename])) |
|
173 | + if(!isset($this->_relations[$tablename])) |
|
174 | 174 | return ""; |
175 | 175 | |
176 | - $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
176 | + $code="\tpublic static \$RELATIONS = array ("; |
|
177 | + foreach($this->_relations[$tablename] as $rel_data) |
|
178 | + $code.="\n\t\t'".$rel_data["prop_name"]."' => array(".$rel_data["rel_type"].", '".$rel_data["ref_class_name"]."', '".$rel_data["prop_ref"]."'),"; |
|
179 | 179 | |
180 | - $code = substr($code, 0, -1); |
|
181 | - $code .= "\n\t);"; |
|
180 | + $code=substr($code, 0, -1); |
|
181 | + $code.="\n\t);"; |
|
182 | 182 | return $code; |
183 | 183 | } |
184 | 184 | |
185 | 185 | private function _buildSmartToString($tableInfo) |
186 | 186 | { |
187 | - $code = "\tpublic function __toString() {"; |
|
188 | - $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
187 | + $code="\tpublic function __toString() {"; |
|
188 | + $property="throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | 189 | try |
190 | 190 | { |
191 | - foreach ($tableInfo->getColumns() as $column) |
|
191 | + foreach($tableInfo->getColumns() as $column) |
|
192 | 192 | { |
193 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
193 | + if(isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | + elseif($column->PdoType==PDO::PARAM_STR && $column->DBType!="date") |
|
196 | 196 | { |
197 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
197 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | 198 | break; |
199 | 199 | } |
200 | 200 | } |
201 | - } catch (Exception $ex) |
|
201 | + } catch(Exception $ex) |
|
202 | 202 | { |
203 | 203 | Prado::trace($ex->getMessage()); |
204 | 204 | } |
205 | - $code .= "\n\t\treturn \$this->$property;"; |
|
206 | - $code .= "\n\t}"; |
|
205 | + $code.="\n\t\treturn \$this->$property;"; |
|
206 | + $code.="\n\t}"; |
|
207 | 207 | return $code; |
208 | 208 | } |
209 | 209 | |
210 | 210 | protected function generateClass($properties, $tablename, $classname, $toString) |
211 | 211 | { |
212 | - $props = implode("\n", $properties); |
|
213 | - $relations = $this->_renderRelations($tablename); |
|
214 | - $date = date('Y-m-d h:i:s'); |
|
215 | - $env_user = getenv("username"); |
|
212 | + $props=implode("\n", $properties); |
|
213 | + $relations=$this->_renderRelations($tablename); |
|
214 | + $date=date('Y-m-d h:i:s'); |
|
215 | + $env_user=getenv("username"); |
|
216 | 216 | return <<<EOD |
217 | 217 | <?php |
218 | 218 | /** |
@@ -27,31 +27,31 @@ discard block |
||
27 | 27 | |
28 | 28 | function __construct() |
29 | 29 | { |
30 | - if (!class_exists("TActiveRecordManager", false)) |
|
30 | + if(!class_exists("TActiveRecordManager", false)) |
|
31 | 31 | throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
32 | - $ar_manager = TActiveRecordManager::getInstance(); |
|
33 | - $_conn = $ar_manager->getDbConnection(); |
|
34 | - $_conn->Active = true; |
|
35 | - $this->_dbMetaData = TDbMetaData::getInstance($_conn); |
|
32 | + $ar_manager=TActiveRecordManager::getInstance(); |
|
33 | + $_conn=$ar_manager->getDbConnection(); |
|
34 | + $_conn->Active=true; |
|
35 | + $this->_dbMetaData=TDbMetaData::getInstance($_conn); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function setOpFile($op_file_namespace) |
39 | 39 | { |
40 | - $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
41 | - if (empty($op_file)) |
|
40 | + $op_file=Prado::getPathOfNamespace($op_file_namespace); |
|
41 | + if(empty($op_file)) |
|
42 | 42 | throw new Exception("You need to fix your output folder namespace."); |
43 | - if (!is_dir($op_file)) |
|
43 | + if(!is_dir($op_file)) |
|
44 | 44 | mkdir($op_file, 0777, true); |
45 | - $this->_opFile = $op_file; |
|
45 | + $this->_opFile=$op_file; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function renderAllTablesInformation() |
49 | 49 | { |
50 | - foreach ($this->getAllTableNames() as $table_name) |
|
50 | + foreach($this->getAllTableNames() as $table_name) |
|
51 | 51 | { |
52 | - echo $table_name . "<br>"; |
|
53 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
54 | - echo "Table info:" . "<br>"; |
|
52 | + echo $table_name."<br>"; |
|
53 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
54 | + echo "Table info:"."<br>"; |
|
55 | 55 | echo "<pre>"; |
56 | 56 | print_r($tableInfo); |
57 | 57 | echo "</pre>"; |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | |
61 | 61 | public function getAllTableNames() |
62 | 62 | { |
63 | - $tableNames = $this->_dbMetaData->findTableNames(); |
|
64 | - $index = array_search('pradocache', $tableNames); |
|
65 | - if ($index) |
|
63 | + $tableNames=$this->_dbMetaData->findTableNames(); |
|
64 | + $index=array_search('pradocache', $tableNames); |
|
65 | + if($index) |
|
66 | 66 | array_splice($tableNames, $index, 1); |
67 | 67 | return $tableNames; |
68 | 68 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | protected function eq($data) |
78 | 78 | { |
79 | - return '"' . $data . '"'; |
|
79 | + return '"'.$data.'"'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | } |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Const View Types for generation |
19 | 19 | */ |
20 | - const LIST_TYPE = 0; |
|
21 | - const ADD_TYPE = 1; |
|
22 | - const SHOW_TYPE = 2; |
|
20 | + const LIST_TYPE=0; |
|
21 | + const ADD_TYPE=1; |
|
22 | + const SHOW_TYPE=2; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Bootstrap option |
@@ -46,34 +46,34 @@ discard block |
||
46 | 46 | // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
47 | 47 | public function generate($tableName, $viewType) |
48 | 48 | { |
49 | - switch ($viewType) |
|
49 | + switch($viewType) |
|
50 | 50 | { |
51 | 51 | default: |
52 | 52 | case self::LIST_TYPE: |
53 | - $unitName = "list" . ucfirst($tableName); |
|
53 | + $unitName="list".ucfirst($tableName); |
|
54 | 54 | break; |
55 | 55 | |
56 | 56 | case self::ADD_TYPE: |
57 | - $unitName = "add" . ucfirst($tableName); |
|
57 | + $unitName="add".ucfirst($tableName); |
|
58 | 58 | break; |
59 | 59 | |
60 | 60 | case self::SHOW_TYPE: |
61 | - $unitName = "show" . ucfirst($tableName); |
|
61 | + $unitName="show".ucfirst($tableName); |
|
62 | 62 | break; |
63 | 63 | } |
64 | 64 | |
65 | - $class = $this->generateClass($unitName); |
|
66 | - $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
65 | + $class=$this->generateClass($unitName); |
|
66 | + $outputClass=$this->_opFile.DIRECTORY_SEPARATOR.$unitName.".php"; |
|
67 | 67 | file_put_contents($outputClass, $class); |
68 | 68 | |
69 | - $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
70 | - $page = $this->generatePage($tableName, $viewType); |
|
69 | + $outputPage=$this->_opFile.DIRECTORY_SEPARATOR.$unitName.".page"; |
|
70 | + $page=$this->generatePage($tableName, $viewType); |
|
71 | 71 | file_put_contents($outputPage, $page); |
72 | 72 | } |
73 | 73 | |
74 | - private function generatePage($tableName, $type, $tContentId = "Content") |
|
74 | + private function generatePage($tableName, $type, $tContentId="Content") |
|
75 | 75 | { |
76 | - $pageContent = $this->getPageContent($tableName, $type); |
|
76 | + $pageContent=$this->getPageContent($tableName, $type); |
|
77 | 77 | return <<<EOD |
78 | 78 | <com:TContent ID="$tContentId"> |
79 | 79 | |
@@ -85,30 +85,30 @@ discard block |
||
85 | 85 | |
86 | 86 | private function getPageContent($tableName, $type) |
87 | 87 | { |
88 | - $code = ""; |
|
89 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
90 | - switch ($type) |
|
88 | + $code=""; |
|
89 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
90 | + switch($type) |
|
91 | 91 | { |
92 | 92 | case self::LIST_TYPE: |
93 | 93 | break; |
94 | 94 | case self::ADD_TYPE: |
95 | - foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
95 | + foreach($tableInfo->getColumns() as $colField => $colMetadata) |
|
96 | 96 | { |
97 | - if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
97 | + if(!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
98 | 98 | { |
99 | - $code .= $this->generateControl($colMetadata); |
|
100 | - $code .= $this->generateValidators($colMetadata); |
|
101 | - $code .= "\n"; |
|
99 | + $code.=$this->generateControl($colMetadata); |
|
100 | + $code.=$this->generateValidators($colMetadata); |
|
101 | + $code.="\n"; |
|
102 | 102 | } |
103 | 103 | } |
104 | - foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
104 | + foreach($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
105 | 105 | { |
106 | - $colField = $this->eq($colMetadata["table"]); |
|
107 | - $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
108 | - $code .= "\n"; |
|
106 | + $colField=$this->eq($colMetadata["table"]); |
|
107 | + $code.="\t<com:TTextBox ID=$colField />\n"; |
|
108 | + $code.="\n"; |
|
109 | 109 | // TWsatBaseGenerator::pr($tableInfo); |
110 | 110 | } |
111 | - $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
111 | + $code.="\t<com:TButton Text=\"Accept\" />\n"; |
|
112 | 112 | |
113 | 113 | case self::SHOW_TYPE: |
114 | 114 | break; |
@@ -118,22 +118,22 @@ discard block |
||
118 | 118 | |
119 | 119 | private function generateControl($colMetadata) |
120 | 120 | { |
121 | - $controlType = "TTextBox"; |
|
122 | - switch ($colMetadata->DbType) |
|
121 | + $controlType="TTextBox"; |
|
122 | + switch($colMetadata->DbType) |
|
123 | 123 | { |
124 | 124 | |
125 | 125 | } |
126 | - $controlId = $colMetadata->ColumnId; |
|
126 | + $controlId=$colMetadata->ColumnId; |
|
127 | 127 | return "\t<com:$controlType ID=\"$controlId\" />\n"; |
128 | 128 | } |
129 | 129 | |
130 | 130 | private function generateValidators($colMetadata) |
131 | 131 | { |
132 | - $controlId = $colMetadata->ColumnId; |
|
133 | - $code = ""; |
|
134 | - if (!$colMetadata->AllowNull) |
|
132 | + $controlId=$colMetadata->ColumnId; |
|
133 | + $code=""; |
|
134 | + if(!$colMetadata->AllowNull) |
|
135 | 135 | { |
136 | - $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
136 | + $code.="\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
137 | 137 | } |
138 | 138 | return $code; |
139 | 139 | } |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
144 | 144 | private function generateClass($classname) |
145 | 145 | { |
146 | - $date = date('Y-m-d h:i:s'); |
|
147 | - $env_user = getenv("username"); |
|
146 | + $date=date('Y-m-d h:i:s'); |
|
147 | + $env_user=getenv("username"); |
|
148 | 148 | return <<<EOD |
149 | 149 | <?php |
150 | 150 | /** |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | |
17 | 17 | private function validateSecurity() |
18 | 18 | { |
19 | - if ($this->Session["wsat_password"] !== $this->getService()->getPassword()) |
|
19 | + if($this->Session["wsat_password"]!==$this->getService()->getPassword()) |
|
20 | 20 | { |
21 | - if (!$this->getPage() instanceof TWsatLogin) |
|
21 | + if(!$this->getPage() instanceof TWsatLogin) |
|
22 | 22 | { |
23 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
23 | + $url=$this->Service->constructUrl('TWsatLogin'); |
|
24 | 24 | $this->Response->redirect($url); |
25 | 25 | } |
26 | 26 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | public function logout() |
30 | 30 | { |
31 | - $this->Session["wsat_password"] = ""; |
|
32 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
31 | + $this->Session["wsat_password"]=""; |
|
32 | + $url=$this->Service->constructUrl('TWsatLogin'); |
|
33 | 33 | $this->Response->redirect($url); |
34 | 34 | } |
35 | 35 |
@@ -14,19 +14,19 @@ |
||
14 | 14 | |
15 | 15 | public function login() |
16 | 16 | { |
17 | - if ($this->IsValid) |
|
17 | + if($this->IsValid) |
|
18 | 18 | { |
19 | - $this->Session["wsat_password"] = $this->getService()->getPassword(); |
|
20 | - $url = $this->Service->constructUrl('TWsatHome'); |
|
19 | + $this->Session["wsat_password"]=$this->getService()->getPassword(); |
|
20 | + $url=$this->Service->constructUrl('TWsatHome'); |
|
21 | 21 | $this->Response->redirect($url); |
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function validatePassword($sender, $param) |
26 | 26 | { |
27 | - $config_pass = $this->Service->Password; |
|
28 | - $user_pass = $this->password->Text; |
|
29 | - $param->IsValid = $user_pass === $config_pass; |
|
27 | + $config_pass=$this->Service->Password; |
|
28 | + $user_pass=$this->password->Text; |
|
29 | + $param->IsValid=$user_pass===$config_pass; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | |
23 | 23 | private function startVisual() |
24 | 24 | { |
25 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
26 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
25 | + $scf_generator=new TWsatScaffoldingGenerator(); |
|
26 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
27 | 27 | { |
28 | - $dynChb = new TCheckBox(); |
|
29 | - $dynChb->ID = "cb_$tableName"; |
|
30 | - $dynChb->Text = ucfirst($tableName); |
|
31 | - $dynChb->Checked = true; |
|
28 | + $dynChb=new TCheckBox(); |
|
29 | + $dynChb->ID="cb_$tableName"; |
|
30 | + $dynChb->Text=ucfirst($tableName); |
|
31 | + $dynChb->Checked=true; |
|
32 | 32 | $this->registerObject("cb_$tableName", $dynChb); |
33 | 33 | $this->tableNames->getControls()->add($dynChb); |
34 | 34 | $this->tableNames->getControls()->add("</br>"); |
@@ -41,30 +41,30 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function generate($sender) |
43 | 43 | { |
44 | - if ($this->IsValid) |
|
44 | + if($this->IsValid) |
|
45 | 45 | { |
46 | 46 | try |
47 | 47 | { |
48 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
48 | + $scf_generator=new TWsatScaffoldingGenerator(); |
|
49 | 49 | $scf_generator->setOpFile($this->output_folder->Text); |
50 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
50 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
51 | 51 | { |
52 | - $id = "cb_$tableName"; |
|
53 | - $obj = $this->tableNames->findControl($id); |
|
52 | + $id="cb_$tableName"; |
|
53 | + $obj=$this->tableNames->findControl($id); |
|
54 | 54 | if($obj!==null && $obj->Checked) |
55 | 55 | { |
56 | 56 | $scf_generator->generateCRUD($tableName); |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - $this->feedback_panel->CssClass = "green_panel"; |
|
61 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
62 | - } catch (Exception $ex) |
|
60 | + $this->feedback_panel->CssClass="green_panel"; |
|
61 | + $this->generation_msg->Text="The code has been generated successfully."; |
|
62 | + } catch(Exception $ex) |
|
63 | 63 | { |
64 | - $this->feedback_panel->CssClass = "red_panel"; |
|
65 | - $this->generation_msg->Text = $ex->getMessage(); |
|
64 | + $this->feedback_panel->CssClass="red_panel"; |
|
65 | + $this->generation_msg->Text=$ex->getMessage(); |
|
66 | 66 | } |
67 | - $this->feedback_panel->Visible = true; |
|
67 | + $this->feedback_panel->Visible=true; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // $scf_generator->renderAllTablesInformation(); |
@@ -16,36 +16,36 @@ |
||
16 | 16 | |
17 | 17 | public function generate($sender) |
18 | 18 | { |
19 | - if ($this->IsValid) |
|
19 | + if($this->IsValid) |
|
20 | 20 | { |
21 | - $tableName = $this->table_name->Text; |
|
22 | - $outputFolderNs = $this->output_folder->Text; |
|
23 | - $classPrefix = $this->class_prefix->Text; |
|
24 | - $classSuffix = $this->class_suffix->Text; |
|
21 | + $tableName=$this->table_name->Text; |
|
22 | + $outputFolderNs=$this->output_folder->Text; |
|
23 | + $classPrefix=$this->class_prefix->Text; |
|
24 | + $classSuffix=$this->class_suffix->Text; |
|
25 | 25 | |
26 | 26 | try |
27 | 27 | { |
28 | - $ar_generator = new TWsatARGenerator(); |
|
28 | + $ar_generator=new TWsatARGenerator(); |
|
29 | 29 | $ar_generator->setOpFile($outputFolderNs); |
30 | 30 | $ar_generator->setClasPrefix($classPrefix); |
31 | 31 | $ar_generator->setClassSufix($classSuffix); |
32 | 32 | |
33 | - if ($this->build_rel->Checked) |
|
33 | + if($this->build_rel->Checked) |
|
34 | 34 | $ar_generator->buildRelations(); |
35 | 35 | |
36 | - if ($tableName != "*") |
|
36 | + if($tableName!="*") |
|
37 | 37 | $ar_generator->generate($tableName); |
38 | 38 | else |
39 | 39 | $ar_generator->generateAll(); |
40 | 40 | |
41 | - $this->feedback_panel->CssClass = "green_panel"; |
|
42 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
43 | - } catch (Exception $ex) |
|
41 | + $this->feedback_panel->CssClass="green_panel"; |
|
42 | + $this->generation_msg->Text="The code has been generated successfully."; |
|
43 | + } catch(Exception $ex) |
|
44 | 44 | { |
45 | - $this->feedback_panel->CssClass = "red_panel"; |
|
46 | - $this->generation_msg->Text = $ex->getMessage(); |
|
45 | + $this->feedback_panel->CssClass="red_panel"; |
|
46 | + $this->generation_msg->Text=$ex->getMessage(); |
|
47 | 47 | } |
48 | - $this->feedback_panel->Visible = true; |
|
48 | + $this->feedback_panel->Visible=true; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | class TWsatService extends TPageService |
37 | 37 | { |
38 | 38 | |
39 | - private $_pass = ''; |
|
39 | + private $_pass=''; |
|
40 | 40 | |
41 | 41 | public function init($config) |
42 | 42 | { |
43 | - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
43 | + if($this->getApplication()->getMode()===TApplicationMode::Performance || $this->getApplication()->getMode()===TApplicationMode::Normal) |
|
44 | 44 | throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
45 | 45 | |
46 | - if (empty($this->_pass)) |
|
46 | + if(empty($this->_pass)) |
|
47 | 47 | throw new TConfigurationException("You need to specify the Password attribute."); |
48 | 48 | |
49 | 49 | $this->setDefaultPage("TWsatHome"); |
@@ -53,16 +53,16 @@ discard block |
||
53 | 53 | |
54 | 54 | public function getBasePath() |
55 | 55 | { |
56 | - $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
56 | + $basePath=Prado::getPathOfNamespace("System.Wsat.pages"); |
|
57 | 57 | return realpath($basePath); |
58 | 58 | } |
59 | 59 | |
60 | 60 | private function _startThemeManager() |
61 | 61 | { |
62 | - $themeManager = new TThemeManager; |
|
63 | - $themeManager->BasePath = "System.Wsat.themes"; |
|
64 | - $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
65 | - $themeManager->BaseUrl = "$url/themes"; |
|
62 | + $themeManager=new TThemeManager; |
|
63 | + $themeManager->BasePath="System.Wsat.themes"; |
|
64 | + $url=Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
65 | + $themeManager->BaseUrl="$url/themes"; |
|
66 | 66 | |
67 | 67 | $themeManager->init(null); |
68 | 68 | $this->setThemeManager($themeManager); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function setPassword($_pass) |
77 | 77 | { |
78 | - $this->_pass = $_pass; |
|
78 | + $this->_pass=$_pass; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |