@@ -62,31 +62,31 @@ |
||
62 | 62 | class_exists("DOMDocument",false), |
63 | 63 | 'DOM extension check', |
64 | 64 | 'DOM extension required'), |
65 | - array( |
|
66 | - true, |
|
67 | - extension_loaded("SPL"), |
|
68 | - 'SPL extension check', |
|
69 | - 'SPL extension required'), |
|
70 | - array( |
|
71 | - true, |
|
72 | - extension_loaded("CType"), |
|
73 | - 'CType extension check', |
|
74 | - 'CType extension required'), |
|
75 | - array( |
|
76 | - true, |
|
77 | - extension_loaded("pcre"), |
|
78 | - 'PCRE extension check', |
|
79 | - 'PCRE extension required'), |
|
80 | - array( |
|
81 | - true, |
|
82 | - extension_loaded("json"), |
|
83 | - 'JSON extension check', |
|
84 | - 'JSON extension required'), |
|
85 | - array( |
|
86 | - false, |
|
87 | - class_exists("PDO",false), |
|
88 | - 'PDO extension check', |
|
89 | - 'PDO extension optional'), |
|
65 | + array( |
|
66 | + true, |
|
67 | + extension_loaded("SPL"), |
|
68 | + 'SPL extension check', |
|
69 | + 'SPL extension required'), |
|
70 | + array( |
|
71 | + true, |
|
72 | + extension_loaded("CType"), |
|
73 | + 'CType extension check', |
|
74 | + 'CType extension required'), |
|
75 | + array( |
|
76 | + true, |
|
77 | + extension_loaded("pcre"), |
|
78 | + 'PCRE extension check', |
|
79 | + 'PCRE extension required'), |
|
80 | + array( |
|
81 | + true, |
|
82 | + extension_loaded("json"), |
|
83 | + 'JSON extension check', |
|
84 | + 'JSON extension required'), |
|
85 | + array( |
|
86 | + false, |
|
87 | + class_exists("PDO",false), |
|
88 | + 'PDO extension check', |
|
89 | + 'PDO extension optional'), |
|
90 | 90 | array( |
91 | 91 | false, |
92 | 92 | function_exists("iconv"), |
@@ -70,8 +70,7 @@ |
||
70 | 70 | |
71 | 71 | echo "\n\n** PDF file quickstart.pdf created **\n\n"; |
72 | 72 | |
73 | - } |
|
74 | - else |
|
73 | + } else |
|
75 | 74 | { |
76 | 75 | echo " Unable to find pdfLatex executable $pdflatexExec"; |
77 | 76 | } |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @var array List of requirements (required or not, check item, hint) |
29 | 29 | */ |
30 | -$requirements = array( |
|
30 | +$requirements=array( |
|
31 | 31 | array( |
32 | 32 | true, |
33 | - version_compare(PHP_VERSION,"5.3.3",">="), |
|
34 | - 'PHP version check','PHP 5.3.3 or higher required'), |
|
33 | + version_compare(PHP_VERSION, "5.3.3", ">="), |
|
34 | + 'PHP version check', 'PHP 5.3.3 or higher required'), |
|
35 | 35 | array( |
36 | 36 | true, |
37 | 37 | isset($_SERVER["HTTP_ACCEPT"]), |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | 'REQUEST_URI required'), |
50 | 50 | array( |
51 | 51 | true, |
52 | - isset($_SERVER["PATH_INFO"]) || strpos($_SERVER["PHP_SELF"],$_SERVER["SCRIPT_NAME"])===0, |
|
52 | + isset($_SERVER["PATH_INFO"]) || strpos($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"])===0, |
|
53 | 53 | '$_SERVER["PATH_INFO"] check', |
54 | 54 | 'PATH_INFO required'), |
55 | 55 | array( |
56 | 56 | true, |
57 | - class_exists('Reflection',false), |
|
57 | + class_exists('Reflection', false), |
|
58 | 58 | 'Reflection extension check', |
59 | 59 | 'Reflection extension required'), |
60 | 60 | array( |
61 | 61 | true, |
62 | - class_exists("DOMDocument",false), |
|
62 | + class_exists("DOMDocument", false), |
|
63 | 63 | 'DOM extension check', |
64 | 64 | 'DOM extension required'), |
65 | 65 | array( |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'JSON extension required'), |
85 | 85 | array( |
86 | 86 | false, |
87 | - class_exists("PDO",false), |
|
87 | + class_exists("PDO", false), |
|
88 | 88 | 'PDO extension check', |
89 | 89 | 'PDO extension optional'), |
90 | 90 | array( |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | 'SOAP extension optional'), |
150 | 150 | ); |
151 | 151 | |
152 | -$results = "<table class=\"result\">\n"; |
|
153 | -$conclusion = 0; |
|
152 | +$results="<table class=\"result\">\n"; |
|
153 | +$conclusion=0; |
|
154 | 154 | foreach($requirements as $requirement) |
155 | 155 | { |
156 | - list($required,$expression,$aspect,$hint)=$requirement; |
|
156 | + list($required, $expression, $aspect, $hint)=$requirement; |
|
157 | 157 | //eval('$ret='.$expression.';'); |
158 | 158 | $ret=$expression; |
159 | 159 | if($required) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | $results.="<tr class=\"$ret\"><td class=\"$ret\">".lmessage($aspect)."</td><td class=\"$ret\">".lmessage($hint)."</td></tr>\n"; |
181 | 181 | } |
182 | -$results .= '</table>'; |
|
182 | +$results.='</table>'; |
|
183 | 183 | if($conclusion===0) |
184 | 184 | $conclusion=lmessage('all passed'); |
185 | 185 | else if($conclusion===1) |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | else |
188 | 188 | $conclusion=lmessage('passed with warnings'); |
189 | 189 | |
190 | -$tokens = array( |
|
190 | +$tokens=array( |
|
191 | 191 | '%%Conclusion%%' => $conclusion, |
192 | 192 | '%%Details%%' => $results, |
193 | 193 | '%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.getPradoVersion(), |
194 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%m',time()), |
|
194 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%m', time()), |
|
195 | 195 | ); |
196 | 196 | |
197 | 197 | $lang=getPreferredLanguage(); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | die("Unable to open template file '$templateFile'."); |
203 | 203 | |
204 | 204 | header('Content-Type: text/html; charset=UTF-8'); |
205 | -echo strtr($content,$tokens); |
|
205 | +echo strtr($content, $tokens); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Returns a localized message according to user preferred language. |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | static $messages=null; |
215 | 215 | if($messages===null) |
216 | 216 | { |
217 | - $lang = getPreferredLanguage(); |
|
217 | + $lang=getPreferredLanguage(); |
|
218 | 218 | $msgFile=dirname(__FILE__)."/messages-$lang.txt"; |
219 | 219 | if(!is_file($msgFile)) |
220 | 220 | $msgFile=dirname(__FILE__).'/messages.txt'; |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | { |
223 | 223 | foreach($entries as $entry) |
224 | 224 | { |
225 | - @list($code,$message)=explode('=',$entry,2); |
|
225 | + @list($code, $message)=explode('=', $entry, 2); |
|
226 | 226 | $messages[trim($code)]=trim($message); |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | - return isset($messages[$token])?$messages[$token]:$token; |
|
230 | + return isset($messages[$token]) ? $messages[$token] : $token; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | if($languages===null) |
244 | 244 | { |
245 | 245 | $languages=array(); |
246 | - foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
246 | + foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
247 | 247 | { |
248 | - $array=explode(';q=',trim($language)); |
|
249 | - $languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0; |
|
248 | + $array=explode(';q=', trim($language)); |
|
249 | + $languages[trim($array[0])]=isset($array[1]) ? (float) $array[1] : 1.0; |
|
250 | 250 | } |
251 | 251 | arsort($languages); |
252 | 252 | $languages=array_keys($languages); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | if($language===null) |
267 | 267 | { |
268 | 268 | $langs=getUserLanguages(); |
269 | - $lang=explode('-',$langs[0]); |
|
269 | + $lang=explode('-', $langs[0]); |
|
270 | 270 | if(empty($lang[0]) || !function_exists('ctype_alpha') || !ctype_alpha($lang[0])) |
271 | 271 | $language='en'; |
272 | 272 | else |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | { |
286 | 286 | $contents=file_get_contents($coreFile); |
287 | 287 | $matches=array(); |
288 | - if(preg_match('/public static function getVersion.*?return \'(.*?)\'/ms',$contents,$matches)>0) |
|
288 | + if(preg_match('/public static function getVersion.*?return \'(.*?)\'/ms', $contents, $matches) > 0) |
|
289 | 289 | return $matches[1]; |
290 | 290 | } |
291 | 291 | return ''; |
@@ -740,89 +740,89 @@ 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; |
|
751 | - |
|
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(); |
|
767 | - $dataReader->bindColumn(1, $table); |
|
768 | - $generator = new PHP_Shell_Extensions_ActiveRecord(); |
|
769 | - $tables = array(); |
|
770 | - while ($dataReader->read() !== false) { |
|
771 | - $tables[] = $table; |
|
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); |
|
778 | - } |
|
779 | - } |
|
780 | - } |
|
781 | - return true; |
|
782 | - } |
|
783 | - |
|
784 | - protected function getAppDir($dir=".") { |
|
785 | - if (is_dir($dir)) |
|
786 | - return realpath($dir); |
|
787 | - if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
788 | - return $app_dir; |
|
789 | - echo '** Unable to find directory "' . $dir . "\".\n"; |
|
790 | - return false; |
|
791 | - } |
|
792 | - |
|
793 | - protected function getXmlFile($app_dir) { |
|
794 | - if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
795 | - return $xml; |
|
796 | - if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
797 | - return $xml; |
|
798 | - echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
799 | - return false; |
|
800 | - } |
|
801 | - |
|
802 | - protected function getActiveRecordConfig($app_dir) { |
|
803 | - if (false === ($xml = $this->getXmlFile($app_dir))) |
|
804 | - return false; |
|
805 | - if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
806 | - Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
|
807 | - foreach ($app->getModules() as $module) |
|
808 | - if ($module instanceof TActiveRecordConfig) |
|
809 | - return $module; |
|
810 | - echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
811 | - } |
|
812 | - return false; |
|
813 | - } |
|
814 | - |
|
815 | - protected function getOutputFile($app_dir, $namespace) { |
|
816 | - if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
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) |
|
821 | - return $file; |
|
822 | - } |
|
823 | - echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
824 | - return false; |
|
825 | - } |
|
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 | + |
|
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(); |
|
767 | + $dataReader->bindColumn(1, $table); |
|
768 | + $generator = new PHP_Shell_Extensions_ActiveRecord(); |
|
769 | + $tables = array(); |
|
770 | + while ($dataReader->read() !== false) { |
|
771 | + $tables[] = $table; |
|
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); |
|
778 | + } |
|
779 | + } |
|
780 | + } |
|
781 | + return true; |
|
782 | + } |
|
783 | + |
|
784 | + protected function getAppDir($dir=".") { |
|
785 | + if (is_dir($dir)) |
|
786 | + return realpath($dir); |
|
787 | + if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) |
|
788 | + return $app_dir; |
|
789 | + echo '** Unable to find directory "' . $dir . "\".\n"; |
|
790 | + return false; |
|
791 | + } |
|
792 | + |
|
793 | + protected function getXmlFile($app_dir) { |
|
794 | + if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) |
|
795 | + return $xml; |
|
796 | + if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) |
|
797 | + return $xml; |
|
798 | + echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
|
799 | + return false; |
|
800 | + } |
|
801 | + |
|
802 | + protected function getActiveRecordConfig($app_dir) { |
|
803 | + if (false === ($xml = $this->getXmlFile($app_dir))) |
|
804 | + return false; |
|
805 | + if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
806 | + Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
|
807 | + foreach ($app->getModules() as $module) |
|
808 | + if ($module instanceof TActiveRecordConfig) |
|
809 | + return $module; |
|
810 | + echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n"; |
|
811 | + } |
|
812 | + return false; |
|
813 | + } |
|
814 | + |
|
815 | + protected function getOutputFile($app_dir, $namespace) { |
|
816 | + if (is_file($namespace) && strpos($namespace, $app_dir) === 0) |
|
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) |
|
821 | + return $file; |
|
822 | + } |
|
823 | + echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n"; |
|
824 | + return false; |
|
825 | + } |
|
826 | 826 | |
827 | 827 | } |
828 | 828 | |
@@ -830,20 +830,20 @@ discard block |
||
830 | 830 | if(class_exists('PHP_Shell_Commands', false)) |
831 | 831 | { |
832 | 832 | class PHP_Shell_Extensions_ActiveRecord implements PHP_Shell_Extension { |
833 | - public function register() |
|
834 | - { |
|
833 | + public function register() |
|
834 | + { |
|
835 | 835 | |
836 | - $cmd = PHP_Shell_Commands::getInstance(); |
|
836 | + $cmd = PHP_Shell_Commands::getInstance(); |
|
837 | 837 | if(Prado::getApplication() !== null) |
838 | 838 | { |
839 | - $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]', |
|
840 | - 'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL. |
|
841 | - ' application.xml in [directory]. May also generate [soap] properties.'); |
|
839 | + $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]', |
|
840 | + 'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL. |
|
841 | + ' application.xml in [directory]. May also generate [soap] properties.'); |
|
842 | 842 | } |
843 | - } |
|
843 | + } |
|
844 | 844 | |
845 | - public function generate($l) |
|
846 | - { |
|
845 | + public function generate($l) |
|
846 | + { |
|
847 | 847 | $input = explode(" ", trim($l)); |
848 | 848 | if(count($input) > 2) |
849 | 849 | { |
@@ -860,12 +860,12 @@ discard block |
||
860 | 860 | { |
861 | 861 | echo "\n Usage: generate table_name Application.pages.RecordClassName\n"; |
862 | 862 | } |
863 | - } |
|
863 | + } |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | $__shell_exts = PHP_Shell_Extensions::getInstance(); |
867 | 867 | $__shell_exts->registerExtensions(array( |
868 | - "active-record" => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */ |
|
868 | + "active-record" => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */ |
|
869 | 869 | |
870 | 870 | include_once(realpath(dirname(dirname(__FILE__))).'/framework/3rdParty/PhpShell/php-shell-cmd.php'); |
871 | 871 | } |
@@ -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 |
@@ -105,8 +105,7 @@ discard block |
||
105 | 105 | { |
106 | 106 | $valid |= $action->performAction($args); |
107 | 107 | break; |
108 | - } |
|
109 | - else |
|
108 | + } else |
|
110 | 109 | { |
111 | 110 | $valid = false; |
112 | 111 | } |
@@ -207,8 +206,7 @@ discard block |
||
207 | 206 | } |
208 | 207 | |
209 | 208 | return Prado::getApplication(); |
210 | - } |
|
211 | - else |
|
209 | + } else |
|
212 | 210 | { |
213 | 211 | PradoCommandLineInterpreter::printGreeting(); |
214 | 212 | echo '+'.str_repeat('-',77)."+\n"; |
@@ -514,8 +512,7 @@ discard block |
||
514 | 512 | $running_dir = substr(str_replace(realpath('./'),'',$test_dir),1); |
515 | 513 | echo 'Running unit tests in directory "'.$running_dir."\":\n"; |
516 | 514 | $test->run(new TextReporter()); |
517 | - } |
|
518 | - else |
|
515 | + } else |
|
519 | 516 | { |
520 | 517 | $running_dir = substr(str_replace(realpath('./'),'',$dir),1); |
521 | 518 | echo '** Unable to find test directory "'.$running_dir.'/unit" or "'.$running_dir.'/tests/unit".'."\n"; |
@@ -669,8 +666,7 @@ discard block |
||
669 | 666 | { |
670 | 667 | echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n"; |
671 | 668 | return false; |
672 | - } |
|
673 | - else |
|
669 | + } else |
|
674 | 670 | { |
675 | 671 | $properties = array(); |
676 | 672 | foreach($tableInfo->getColumns() as $field=>$column) |
@@ -855,8 +851,7 @@ discard block |
||
855 | 851 | $args = array($input[0],$input[1], $input[2],$app_dir,'soap'); |
856 | 852 | $cmd = new PradoCommandLineActiveRecordGen; |
857 | 853 | $cmd->performAction($args); |
858 | - } |
|
859 | - else |
|
854 | + } else |
|
860 | 855 | { |
861 | 856 | echo "\n Usage: generate table_name Application.pages.RecordClassName\n"; |
862 | 857 | } |
@@ -145,6 +145,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -565,6 +581,9 @@ discard block |
||
565 | 581 | closedir($dir); |
566 | 582 | } |
567 | 583 | |
584 | + /** |
|
585 | + * @param string $entry |
|
586 | + */ |
|
568 | 587 | protected function hasMatch($match,$entry) |
569 | 588 | { |
570 | 589 | $file = strtolower(substr($entry,0,strrpos($entry,'.'))); |
@@ -630,6 +649,9 @@ discard block |
||
630 | 649 | return false; |
631 | 650 | } |
632 | 651 | |
652 | + /** |
|
653 | + * @param string $app_dir |
|
654 | + */ |
|
633 | 655 | protected function getActiveRecordConfig($app_dir) |
634 | 656 | { |
635 | 657 | if(false === ($xml=$this->getXmlFile($app_dir))) |
@@ -645,6 +667,9 @@ discard block |
||
645 | 667 | return false; |
646 | 668 | } |
647 | 669 | |
670 | + /** |
|
671 | + * @param string $app_dir |
|
672 | + */ |
|
648 | 673 | protected function getOutputFile($app_dir, $namespace) |
649 | 674 | { |
650 | 675 | if(is_file($namespace) && strpos($namespace, $app_dir)===0) |
@@ -706,6 +731,9 @@ discard block |
||
706 | 731 | return $prop; |
707 | 732 | } |
708 | 733 | |
734 | + /** |
|
735 | + * @param string $class |
|
736 | + */ |
|
709 | 737 | protected function generateClass($properties, $tablename, $class) |
710 | 738 | { |
711 | 739 | $props = implode("\n", $properties); |
@@ -799,6 +827,9 @@ discard block |
||
799 | 827 | return false; |
800 | 828 | } |
801 | 829 | |
830 | + /** |
|
831 | + * @param string $app_dir |
|
832 | + */ |
|
802 | 833 | protected function getActiveRecordConfig($app_dir) { |
803 | 834 | if (false === ($xml = $this->getXmlFile($app_dir))) |
804 | 835 | return false; |
@@ -842,6 +873,9 @@ discard block |
||
842 | 873 | } |
843 | 874 | } |
844 | 875 | |
876 | + /** |
|
877 | + * @param string $l |
|
878 | + */ |
|
845 | 879 | public function generate($l) |
846 | 880 | { |
847 | 881 | $input = explode(" ", trim($l)); |
@@ -136,6 +136,7 @@ |
||
136 | 136 | * @param mixed Name of the PHP variable to bind to the SQL statement parameter |
137 | 137 | * @param int SQL data type of the parameter |
138 | 138 | * @param int length of the data type |
139 | + * @param string $name |
|
139 | 140 | * @see http://www.php.net/manual/en/function.PDOStatement-bindParam.php |
140 | 141 | */ |
141 | 142 | public function bindParameter($name, &$value, $dataType=null, $length=null) |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class TDbTableColumn extends TComponent |
20 | 20 | { |
21 | - const UNDEFINED_VALUE= INF; //use infinity for undefined value |
|
21 | + const UNDEFINED_VALUE=INF; //use infinity for undefined value |
|
22 | 22 | |
23 | 23 | private $_info=array(); |
24 | 24 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param mixed default value if information array value is null |
37 | 37 | * @return mixed information array value. |
38 | 38 | */ |
39 | - protected function getInfo($name,$default=null) |
|
39 | + protected function getInfo($name, $default=null) |
|
40 | 40 | { |
41 | 41 | return isset($this->_info[$name]) ? $this->_info[$name] : $default; |
42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string information array key name |
46 | 46 | * @param mixed new information array value. |
47 | 47 | */ |
48 | - protected function setInfo($name,$value) |
|
48 | + protected function setInfo($name, $value) |
|
49 | 49 | { |
50 | 50 | $this->_info[$name]=$value; |
51 | 51 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function getAllowNull() |
120 | 120 | { |
121 | - return $this->getInfo('AllowNull',false); |
|
121 | + return $this->getInfo('AllowNull', false); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | if(($precision=$this->getNumericPrecision())!==null) |
151 | 151 | { |
152 | 152 | $scale=$this->getNumericScale(); |
153 | - return $scale===null ? pow(10,$precision) : pow(10,$precision-$scale); |
|
153 | + return $scale===null ? pow(10, $precision) : pow(10, $precision - $scale); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function getIsPrimaryKey() |
161 | 161 | { |
162 | - return $this->getInfo('IsPrimaryKey',false); |
|
162 | + return $this->getInfo('IsPrimaryKey', false); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getIsForeignKey() |
169 | 169 | { |
170 | - return $this->getInfo('IsForeignKey',false); |
|
170 | + return $this->getInfo('IsForeignKey', false); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -113,6 +113,7 @@ |
||
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @param string button caption |
116 | + * @param string $value |
|
116 | 117 | */ |
117 | 118 | public function setButtonText($value) |
118 | 119 | { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function setTypeHandler($value) |
51 | 51 | { |
52 | - $this->_typeHandler = $value; |
|
52 | + $this->_typeHandler=$value; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function setType($value) |
67 | 67 | { |
68 | - $this->_type = $value; |
|
68 | + $this->_type=$value; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setColumn($value) |
83 | 83 | { |
84 | - $this->_column = $value; |
|
84 | + $this->_column=$value; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function setDbType($value) |
99 | 99 | { |
100 | - $this->_dbType = $value; |
|
100 | + $this->_dbType=$value; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function setProperty($value) |
115 | 115 | { |
116 | - $this->_property = $value; |
|
116 | + $this->_property=$value; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function setNullValue($value) |
132 | 132 | { |
133 | - $this->_nullValue = $value; |
|
133 | + $this->_nullValue=$value; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function __sleep() |
137 | 137 | { |
138 | - $exprops = array(); $cn = 'TParameterProperty'; |
|
139 | - if ($this->_typeHandler===null) $exprops[] = "\0$cn\0_typeHandler"; |
|
140 | - if ($this->_type===null) $exprops[] = "\0$cn\0_type"; |
|
141 | - if ($this->_column===null) $exprops[] = "\0$cn\0_column"; |
|
142 | - if ($this->_dbType===null) $exprops[] = "\0$cn\0_dbType"; |
|
143 | - if ($this->_property===null) $exprops[] = "\0$cn\0_property"; |
|
144 | - if ($this->_nullValue===null) $exprops[] = "\0$cn\0_nullValue"; |
|
145 | - return array_diff(parent::__sleep(),$exprops); |
|
138 | + $exprops=array(); $cn='TParameterProperty'; |
|
139 | + if($this->_typeHandler===null) $exprops[]="\0$cn\0_typeHandler"; |
|
140 | + if($this->_type===null) $exprops[]="\0$cn\0_type"; |
|
141 | + if($this->_column===null) $exprops[]="\0$cn\0_column"; |
|
142 | + if($this->_dbType===null) $exprops[]="\0$cn\0_dbType"; |
|
143 | + if($this->_property===null) $exprops[]="\0$cn\0_property"; |
|
144 | + if($this->_nullValue===null) $exprops[]="\0$cn\0_nullValue"; |
|
145 | + return array_diff(parent::__sleep(), $exprops); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -113,6 +113,7 @@ |
||
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @param string button caption |
116 | + * @param string $value |
|
116 | 117 | */ |
117 | 118 | public function setButtonText($value) |
118 | 119 | { |
@@ -113,6 +113,7 @@ |
||
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @param string button caption |
116 | + * @param string $value |
|
116 | 117 | */ |
117 | 118 | public function setButtonText($value) |
118 | 119 | { |
@@ -78,8 +78,8 @@ |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * Publish the ajax script |
|
82 | - */ |
|
81 | + * Publish the ajax script |
|
82 | + */ |
|
83 | 83 | public function onPreRender($param) |
84 | 84 | { |
85 | 85 | parent::onPreRender($param); |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | if($type===null) |
74 | 74 | { |
75 | 75 | if($this->getControl() instanceof ICallbackEventHandler) |
76 | - $this->_activeControlType = 'Prado\\Web\UI\\ActiveControls\\TBaseActiveCallbackControl'; |
|
76 | + $this->_activeControlType='Prado\\Web\UI\\ActiveControls\\TBaseActiveCallbackControl'; |
|
77 | 77 | else |
78 | - $this->_activeControlType = 'Prado\\Web\UI\\ActiveControls\\TBaseActiveControl'; |
|
78 | + $this->_activeControlType='Prado\\Web\UI\\ActiveControls\\TBaseActiveControl'; |
|
79 | 79 | } |
80 | 80 | else |
81 | - $this->_activeControlType = $type; |
|
81 | + $this->_activeControlType=$type; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | { |
119 | 119 | if($this->_baseActiveControl===null) |
120 | 120 | { |
121 | - $type = $this->_activeControlType; |
|
122 | - $this->_baseActiveControl = new $type($this->getControl()); |
|
121 | + $type=$this->_activeControlType; |
|
122 | + $this->_baseActiveControl=new $type($this->getControl()); |
|
123 | 123 | } |
124 | 124 | return $this->_baseActiveControl; |
125 | 125 | } |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | { |
132 | 132 | if($this->getPage()->getIsCallback()) |
133 | 133 | { |
134 | - $target = $this->getPage()->getCallbackEventTarget(); |
|
134 | + $target=$this->getPage()->getCallbackEventTarget(); |
|
135 | 135 | if($target instanceof ICallbackEventHandler) |
136 | 136 | { |
137 | - $client = $target->getActiveControl()->getClientSide(); |
|
137 | + $client=$target->getActiveControl()->getClientSide(); |
|
138 | 138 | return $client->getEnablePageStateUpdate(); |
139 | 139 | } |
140 | 140 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | { |
149 | 149 | if($this->getIsTrackingPageState()) |
150 | 150 | { |
151 | - $stateTrackerClass = $this->_stateTrackerClass; |
|
152 | - $this->_stateTracker = new $stateTrackerClass($this->getControl()); |
|
151 | + $stateTrackerClass=$this->_stateTrackerClass; |
|
152 | + $this->_stateTracker=new $stateTrackerClass($this->getControl()); |
|
153 | 153 | $this->_stateTracker->trackChanges(); |
154 | 154 | } |
155 | 155 | parent::onLoad($param); |
@@ -182,6 +182,6 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function setStateTracker($value) |
184 | 184 | { |
185 | - $this->_stateTrackerClass = TPropertyValue::ensureString($value); |
|
185 | + $this->_stateTrackerClass=TPropertyValue::ensureString($value); |
|
186 | 186 | } |
187 | 187 | } |
@@ -58,8 +58,7 @@ |
||
58 | 58 | if ($this->sourcepath === NULL) |
59 | 59 | { |
60 | 60 | $this->sourcepath = $sourcepath; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->sourcepath->append($sourcepath); |
65 | 64 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | /** |
71 | 71 | * Javascript client class for this control. |
72 | 72 | * This method overrides the parent implementation. |
73 | - * @return null no javascript class name. |
|
73 | + * @return string no javascript class name. |
|
74 | 74 | */ |
75 | 75 | protected function getClientClassName() |
76 | 76 | { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected function createListItemCollection() |
84 | 84 | { |
85 | - $collection = new TActiveListItemCollection; |
|
85 | + $collection=new TActiveListItemCollection; |
|
86 | 86 | $collection->setControl($this); |
87 | 87 | return $collection; |
88 | 88 | } |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | protected function addAttributesToRender($writer) |
103 | 103 | { |
104 | 104 | parent::addAttributesToRender($writer); |
105 | - $writer->addAttribute('id',$this->getClientID()); |
|
106 | - if ($this->getAutoPostBack()) |
|
105 | + $writer->addAttribute('id', $this->getClientID()); |
|
106 | + if($this->getAutoPostBack()) |
|
107 | 107 | $this->getActiveControl()->registerCallbackClientScript( |
108 | 108 | $this->getClientClassName(), $this->getPostBackOptions()); |
109 | 109 | } |
@@ -113,6 +113,7 @@ |
||
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @param string button caption |
116 | + * @param string $value |
|
116 | 117 | */ |
117 | 118 | public function setButtonText($value) |
118 | 119 | { |
@@ -124,9 +124,9 @@ |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * Sets the date format for a date validation |
|
128 | - * @param string the date format value |
|
129 | - */ |
|
127 | + * Sets the date format for a date validation |
|
128 | + * @param string the date format value |
|
129 | + */ |
|
130 | 130 | public function setDateFormat($value) |
131 | 131 | { |
132 | 132 | $this->setViewState('DateFormat', $value, ''); |
@@ -70,8 +70,7 @@ |
||
70 | 70 | { |
71 | 71 | $domain=substr($value,$pos+1); |
72 | 72 | return $domain===''?false:checkdnsrr($domain,'MX'); |
73 | - } |
|
74 | - else |
|
73 | + } else |
|
75 | 74 | return false; |
76 | 75 | } |
77 | 76 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function getDataType() |
51 | 51 | { |
52 | - return $this->getViewState('DataType','String'); |
|
52 | + return $this->getViewState('DataType', 'String'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setDataType($value) |
60 | 60 | { |
61 | - $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TValidationDataType'),TValidationDataType::String); |
|
61 | + $this->setViewState('DataType', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TValidationDataType'), TValidationDataType::String); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | switch($this->getDataType()) |
93 | 93 | { |
94 | 94 | case TValidationDataType::Integer: |
95 | - return preg_match('/^[-+]?[0-9]+$/',trim($value)); |
|
95 | + return preg_match('/^[-+]?[0-9]+$/', trim($value)); |
|
96 | 96 | case TValidationDataType::Float: |
97 | - return preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value)); |
|
97 | + return preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/', trim($value)); |
|
98 | 98 | case TValidationDataType::Date: |
99 | - $dateFormat = $this->getDateFormat(); |
|
99 | + $dateFormat=$this->getDateFormat(); |
|
100 | 100 | if(strlen($dateFormat)) |
101 | 101 | { |
102 | - $formatter = new TSimpleDateFormatter($dateFormat); |
|
102 | + $formatter=new TSimpleDateFormatter($dateFormat); |
|
103 | 103 | return $formatter->isValidDate($value); |
104 | 104 | } |
105 | 105 | else |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function getClientScriptOptions() |
116 | 116 | { |
117 | - $options = parent::getClientScriptOptions(); |
|
117 | + $options=parent::getClientScriptOptions(); |
|
118 | 118 | $options['DataType']=$this->getDataType(); |
119 | 119 | if(($dateFormat=$this->getDateFormat())!=='') |
120 | 120 | $options['DateFormat']=$dateFormat; |
@@ -213,7 +213,7 @@ |
||
213 | 213 | /** |
214 | 214 | * Returns the value to be validated. |
215 | 215 | * This methid is required by IValidatable interface. |
216 | - * @return mixed the value of the property to be validated. |
|
216 | + * @return string the value of the property to be validated. |
|
217 | 217 | */ |
218 | 218 | public function getValidationPropertyValue() |
219 | 219 | { |
@@ -463,14 +463,14 @@ |
||
463 | 463 | */ |
464 | 464 | public function getIsValid() |
465 | 465 | { |
466 | - return $this->_isValid; |
|
466 | + return $this->_isValid; |
|
467 | 467 | } |
468 | 468 | /** |
469 | 469 | * @param bool wether this control is valid. |
470 | 470 | */ |
471 | 471 | public function setIsValid($value) |
472 | 472 | { |
473 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
473 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function addAttributesToRender($writer) |
54 | 54 | { |
55 | - $writer->addAttribute('name',$this->getUniqueID()); |
|
55 | + $writer->addAttribute('name', $this->getUniqueID()); |
|
56 | 56 | parent::addAttributesToRender($writer); |
57 | 57 | } |
58 | 58 | |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | * @param array the input data collection |
74 | 74 | * @return boolean whether the data of the component has been changed |
75 | 75 | */ |
76 | - public function loadPostData($key,$values) |
|
76 | + public function loadPostData($key, $values) |
|
77 | 77 | { |
78 | 78 | if(!$this->getEnabled(true)) |
79 | 79 | return false; |
80 | 80 | $this->ensureDataBound(); |
81 | - $selection=isset($values[$key])?$values[$key]:null; |
|
81 | + $selection=isset($values[$key]) ? $values[$key] : null; |
|
82 | 82 | if($selection!==null) |
83 | 83 | { |
84 | - $index=$this->getItems()->findIndexByValue($selection,false); |
|
84 | + $index=$this->getItems()->findIndexByValue($selection, false); |
|
85 | 85 | if($this->getSelectedIndex()!==$index) |
86 | 86 | { |
87 | 87 | $this->setSelectedIndex($index); |