@@ -335,12 +335,12 @@ |
||
| 335 | 335 | return false; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - /** |
|
| 339 | - * Returns all table names in the database. |
|
| 340 | - * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 341 | - * If not empty, the returned table names will be prefixed with the schema name. |
|
| 342 | - * @return array all table names in the database. |
|
| 343 | - */ |
|
| 338 | + /** |
|
| 339 | + * Returns all table names in the database. |
|
| 340 | + * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 341 | + * If not empty, the returned table names will be prefixed with the schema name. |
|
| 342 | + * @return array all table names in the database. |
|
| 343 | + */ |
|
| 344 | 344 | public function findTableNames($schema='') |
| 345 | 345 | { |
| 346 | 346 | if($schema==='') |
@@ -259,15 +259,15 @@ |
||
| 259 | 259 | return false; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * Returns all table names in the database. |
|
| 264 | - * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 265 | - * If not empty, the returned table names will be prefixed with the schema name. |
|
| 266 | - * @return array all table names in the database. |
|
| 267 | - */ |
|
| 262 | + /** |
|
| 263 | + * Returns all table names in the database. |
|
| 264 | + * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 265 | + * If not empty, the returned table names will be prefixed with the schema name. |
|
| 266 | + * @return array all table names in the database. |
|
| 267 | + */ |
|
| 268 | 268 | public function findTableNames($schema='dbo') |
| 269 | 269 | { |
| 270 | - $condition="TABLE_TYPE='BASE TABLE'"; |
|
| 270 | + $condition="TABLE_TYPE='BASE TABLE'"; |
|
| 271 | 271 | $sql=<<<EOD |
| 272 | 272 | SELECT TABLE_NAME, TABLE_SCHEMA FROM [INFORMATION_SCHEMA].[TABLES] |
| 273 | 273 | WHERE TABLE_SCHEMA=:schema AND $condition |
@@ -417,12 +417,12 @@ |
||
| 417 | 417 | return false; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - /** |
|
| 421 | - * Returns all table names in the database. |
|
| 422 | - * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 423 | - * If not empty, the returned table names will be prefixed with the schema name. |
|
| 424 | - * @return array all table names in the database. |
|
| 425 | - */ |
|
| 420 | + /** |
|
| 421 | + * Returns all table names in the database. |
|
| 422 | + * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 423 | + * If not empty, the returned table names will be prefixed with the schema name. |
|
| 424 | + * @return array all table names in the database. |
|
| 425 | + */ |
|
| 426 | 426 | public function findTableNames($schema='public') |
| 427 | 427 | { |
| 428 | 428 | if($schema==='') |
@@ -189,11 +189,11 @@ |
||
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Returns all table names in the database. |
|
| 194 | - * @param string $schema the schema of the tables. This is not used for sqlite database. |
|
| 195 | - * @return array all table names in the database. |
|
| 196 | - */ |
|
| 192 | + /** |
|
| 193 | + * Returns all table names in the database. |
|
| 194 | + * @param string $schema the schema of the tables. This is not used for sqlite database. |
|
| 195 | + * @return array all table names in the database. |
|
| 196 | + */ |
|
| 197 | 197 | public function findTableNames($schema='') |
| 198 | 198 | { |
| 199 | 199 | $sql="SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'"; |
@@ -179,14 +179,14 @@ |
||
| 179 | 179 | return $lft . str_replace(self::$delimiterIdentifier, '', $name) . $rgt; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Returns all table names in the database. |
|
| 184 | - * This method should be overridden by child classes in order to support this feature |
|
| 185 | - * because the default implementation simply throws an exception. |
|
| 186 | - * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 187 | - * If not empty, the returned table names will be prefixed with the schema name. |
|
| 188 | - * @return array all table names in the database. |
|
| 189 | - */ |
|
| 182 | + /** |
|
| 183 | + * Returns all table names in the database. |
|
| 184 | + * This method should be overridden by child classes in order to support this feature |
|
| 185 | + * because the default implementation simply throws an exception. |
|
| 186 | + * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. |
|
| 187 | + * If not empty, the returned table names will be prefixed with the schema name. |
|
| 188 | + * @return array all table names in the database. |
|
| 189 | + */ |
|
| 190 | 190 | abstract public function findTableNames($schema=''); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -36,46 +36,46 @@ |
||
| 36 | 36 | class TWsatService extends TPageService |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - private $_pass = ''; |
|
| 39 | + private $_pass = ''; |
|
| 40 | 40 | |
| 41 | - public function init($config) |
|
| 42 | - { |
|
| 43 | - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
| 44 | - throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
|
| 41 | + public function init($config) |
|
| 42 | + { |
|
| 43 | + if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
| 44 | + throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
|
| 45 | 45 | |
| 46 | - if (empty($this->_pass)) |
|
| 47 | - throw new TConfigurationException("You need to specify the Password attribute."); |
|
| 46 | + if (empty($this->_pass)) |
|
| 47 | + throw new TConfigurationException("You need to specify the Password attribute."); |
|
| 48 | 48 | |
| 49 | - $this->setDefaultPage("TWsatHome"); |
|
| 50 | - $this->_startThemeManager(); |
|
| 51 | - parent::init($config); |
|
| 52 | - } |
|
| 49 | + $this->setDefaultPage("TWsatHome"); |
|
| 50 | + $this->_startThemeManager(); |
|
| 51 | + parent::init($config); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getBasePath() |
|
| 55 | - { |
|
| 56 | - $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
| 57 | - return realpath($basePath); |
|
| 58 | - } |
|
| 54 | + public function getBasePath() |
|
| 55 | + { |
|
| 56 | + $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
| 57 | + return realpath($basePath); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - private function _startThemeManager() |
|
| 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"; |
|
| 60 | + private function _startThemeManager() |
|
| 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"; |
|
| 66 | 66 | |
| 67 | - $themeManager->init(null); |
|
| 68 | - $this->setThemeManager($themeManager); |
|
| 69 | - } |
|
| 67 | + $themeManager->init(null); |
|
| 68 | + $this->setThemeManager($themeManager); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function getPassword() |
|
| 72 | - { |
|
| 73 | - return $this->_pass; |
|
| 74 | - } |
|
| 71 | + public function getPassword() |
|
| 72 | + { |
|
| 73 | + return $this->_pass; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public function setPassword($_pass) |
|
| 77 | - { |
|
| 78 | - $this->_pass = $_pass; |
|
| 79 | - } |
|
| 76 | + public function setPassword($_pass) |
|
| 77 | + { |
|
| 78 | + $this->_pass = $_pass; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -14,138 +14,138 @@ discard block |
||
| 14 | 14 | class TWsatScaffoldingGenerator extends TWsatBaseGenerator |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Const View Types for generation |
|
| 19 | - */ |
|
| 20 | - const LIST_TYPE = 0; |
|
| 21 | - const ADD_TYPE = 1; |
|
| 22 | - const SHOW_TYPE = 2; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Bootstrap option |
|
| 26 | - */ |
|
| 27 | - private $_bootstrap; |
|
| 28 | - |
|
| 29 | - function __construct() |
|
| 30 | - { |
|
| 31 | - parent::__construct(); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Generates CRUD Operations for a single DB table |
|
| 36 | - * @param type $tableName |
|
| 37 | - */ |
|
| 38 | - public function generateCRUD($tableName) |
|
| 39 | - { |
|
| 40 | - $this->generate($tableName, self::ADD_TYPE); |
|
| 41 | - $this->generate($tableName, self::LIST_TYPE); |
|
| 42 | - $this->generate($tableName, self::SHOW_TYPE); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - //--------------------------------------------------------------------- |
|
| 46 | - // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
|
| 47 | - public function generate($tableName, $viewType) |
|
| 48 | - { |
|
| 49 | - switch ($viewType) |
|
| 50 | - { |
|
| 51 | - default: |
|
| 52 | - case self::LIST_TYPE: |
|
| 53 | - $unitName = "list" . ucfirst($tableName); |
|
| 54 | - break; |
|
| 55 | - |
|
| 56 | - case self::ADD_TYPE: |
|
| 57 | - $unitName = "add" . ucfirst($tableName); |
|
| 58 | - break; |
|
| 59 | - |
|
| 60 | - case self::SHOW_TYPE: |
|
| 61 | - $unitName = "show" . ucfirst($tableName); |
|
| 62 | - break; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $class = $this->generateClass($unitName); |
|
| 66 | - $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
| 67 | - file_put_contents($outputClass, $class); |
|
| 68 | - |
|
| 69 | - $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
| 70 | - $page = $this->generatePage($tableName, $viewType); |
|
| 71 | - file_put_contents($outputPage, $page); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - private function generatePage($tableName, $type, $tContentId = "Content") |
|
| 75 | - { |
|
| 76 | - $pageContent = $this->getPageContent($tableName, $type); |
|
| 77 | - return <<<EOD |
|
| 17 | + /** |
|
| 18 | + * Const View Types for generation |
|
| 19 | + */ |
|
| 20 | + const LIST_TYPE = 0; |
|
| 21 | + const ADD_TYPE = 1; |
|
| 22 | + const SHOW_TYPE = 2; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Bootstrap option |
|
| 26 | + */ |
|
| 27 | + private $_bootstrap; |
|
| 28 | + |
|
| 29 | + function __construct() |
|
| 30 | + { |
|
| 31 | + parent::__construct(); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Generates CRUD Operations for a single DB table |
|
| 36 | + * @param type $tableName |
|
| 37 | + */ |
|
| 38 | + public function generateCRUD($tableName) |
|
| 39 | + { |
|
| 40 | + $this->generate($tableName, self::ADD_TYPE); |
|
| 41 | + $this->generate($tableName, self::LIST_TYPE); |
|
| 42 | + $this->generate($tableName, self::SHOW_TYPE); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + //--------------------------------------------------------------------- |
|
| 46 | + // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
|
| 47 | + public function generate($tableName, $viewType) |
|
| 48 | + { |
|
| 49 | + switch ($viewType) |
|
| 50 | + { |
|
| 51 | + default: |
|
| 52 | + case self::LIST_TYPE: |
|
| 53 | + $unitName = "list" . ucfirst($tableName); |
|
| 54 | + break; |
|
| 55 | + |
|
| 56 | + case self::ADD_TYPE: |
|
| 57 | + $unitName = "add" . ucfirst($tableName); |
|
| 58 | + break; |
|
| 59 | + |
|
| 60 | + case self::SHOW_TYPE: |
|
| 61 | + $unitName = "show" . ucfirst($tableName); |
|
| 62 | + break; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $class = $this->generateClass($unitName); |
|
| 66 | + $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
| 67 | + file_put_contents($outputClass, $class); |
|
| 68 | + |
|
| 69 | + $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
| 70 | + $page = $this->generatePage($tableName, $viewType); |
|
| 71 | + file_put_contents($outputPage, $page); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + private function generatePage($tableName, $type, $tContentId = "Content") |
|
| 75 | + { |
|
| 76 | + $pageContent = $this->getPageContent($tableName, $type); |
|
| 77 | + return <<<EOD |
|
| 78 | 78 | <com:TContent ID="$tContentId"> |
| 79 | 79 | |
| 80 | 80 | $pageContent |
| 81 | 81 | |
| 82 | 82 | </com:TContent> |
| 83 | 83 | EOD; |
| 84 | - } |
|
| 85 | - |
|
| 86 | - private function getPageContent($tableName, $type) |
|
| 87 | - { |
|
| 88 | - $code = ""; |
|
| 89 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
| 90 | - switch ($type) |
|
| 91 | - { |
|
| 92 | - case self::LIST_TYPE: |
|
| 93 | - break; |
|
| 94 | - case self::ADD_TYPE: |
|
| 95 | - foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
| 96 | - { |
|
| 97 | - if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
| 98 | - { |
|
| 99 | - $code .= $this->generateControl($colMetadata); |
|
| 100 | - $code .= $this->generateValidators($colMetadata); |
|
| 101 | - $code .= "\n"; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
| 105 | - { |
|
| 106 | - $colField = $this->eq($colMetadata["table"]); |
|
| 107 | - $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
| 108 | - $code .= "\n"; |
|
| 109 | - // TWsatBaseGenerator::pr($tableInfo); |
|
| 110 | - } |
|
| 111 | - $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
| 112 | - |
|
| 113 | - case self::SHOW_TYPE: |
|
| 114 | - break; |
|
| 115 | - } |
|
| 116 | - return $code; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - private function generateControl($colMetadata) |
|
| 120 | - { |
|
| 121 | - $controlType = "TTextBox"; |
|
| 122 | - switch ($colMetadata->DbType) |
|
| 123 | - { |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + private function getPageContent($tableName, $type) |
|
| 87 | + { |
|
| 88 | + $code = ""; |
|
| 89 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
| 90 | + switch ($type) |
|
| 91 | + { |
|
| 92 | + case self::LIST_TYPE: |
|
| 93 | + break; |
|
| 94 | + case self::ADD_TYPE: |
|
| 95 | + foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
| 96 | + { |
|
| 97 | + if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
| 98 | + { |
|
| 99 | + $code .= $this->generateControl($colMetadata); |
|
| 100 | + $code .= $this->generateValidators($colMetadata); |
|
| 101 | + $code .= "\n"; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
| 105 | + { |
|
| 106 | + $colField = $this->eq($colMetadata["table"]); |
|
| 107 | + $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
| 108 | + $code .= "\n"; |
|
| 109 | + // TWsatBaseGenerator::pr($tableInfo); |
|
| 110 | + } |
|
| 111 | + $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
| 112 | + |
|
| 113 | + case self::SHOW_TYPE: |
|
| 114 | + break; |
|
| 115 | + } |
|
| 116 | + return $code; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + private function generateControl($colMetadata) |
|
| 120 | + { |
|
| 121 | + $controlType = "TTextBox"; |
|
| 122 | + switch ($colMetadata->DbType) |
|
| 123 | + { |
|
| 124 | 124 | |
| 125 | - } |
|
| 126 | - $controlId = $colMetadata->ColumnId; |
|
| 127 | - return "\t<com:$controlType ID=\"$controlId\" />\n"; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - private function generateValidators($colMetadata) |
|
| 131 | - { |
|
| 132 | - $controlId = $colMetadata->ColumnId; |
|
| 133 | - $code = ""; |
|
| 134 | - if (!$colMetadata->AllowNull) |
|
| 135 | - { |
|
| 136 | - $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
| 137 | - } |
|
| 138 | - return $code; |
|
| 139 | - } |
|
| 125 | + } |
|
| 126 | + $controlId = $colMetadata->ColumnId; |
|
| 127 | + return "\t<com:$controlType ID=\"$controlId\" />\n"; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + private function generateValidators($colMetadata) |
|
| 131 | + { |
|
| 132 | + $controlId = $colMetadata->ColumnId; |
|
| 133 | + $code = ""; |
|
| 134 | + if (!$colMetadata->AllowNull) |
|
| 135 | + { |
|
| 136 | + $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
| 137 | + } |
|
| 138 | + return $code; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | // </editor-fold> |
| 142 | - //--------------------------------------------------------------------- |
|
| 143 | - // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
|
| 144 | - private function generateClass($classname) |
|
| 145 | - { |
|
| 146 | - $date = date('Y-m-d h:i:s'); |
|
| 147 | - $env_user = getenv("username"); |
|
| 148 | - return <<<EOD |
|
| 142 | + //--------------------------------------------------------------------- |
|
| 143 | + // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
|
| 144 | + private function generateClass($classname) |
|
| 145 | + { |
|
| 146 | + $date = date('Y-m-d h:i:s'); |
|
| 147 | + $env_user = getenv("username"); |
|
| 148 | + return <<<EOD |
|
| 149 | 149 | <?php |
| 150 | 150 | /** |
| 151 | 151 | * Auto generated by PRADO - WSAT on $date. |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | EOD; |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | // </editor-fold> |
| 162 | 162 | } |
@@ -14,69 +14,69 @@ |
||
| 14 | 14 | class TWsatBaseGenerator |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @return TDbMetaData for retrieving metadata information, such as |
|
| 19 | - * table and columns information, from a database connection. |
|
| 20 | - */ |
|
| 21 | - protected $_dbMetaData; |
|
| 17 | + /** |
|
| 18 | + * @return TDbMetaData for retrieving metadata information, such as |
|
| 19 | + * table and columns information, from a database connection. |
|
| 20 | + */ |
|
| 21 | + protected $_dbMetaData; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Output folder where AR classes will be saved. |
|
| 25 | - */ |
|
| 26 | - protected $_opFile; |
|
| 23 | + /** |
|
| 24 | + * Output folder where AR classes will be saved. |
|
| 25 | + */ |
|
| 26 | + protected $_opFile; |
|
| 27 | 27 | |
| 28 | - function __construct() |
|
| 29 | - { |
|
| 30 | - if (!class_exists("TActiveRecordManager", false)) |
|
| 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); |
|
| 36 | - } |
|
| 28 | + function __construct() |
|
| 29 | + { |
|
| 30 | + if (!class_exists("TActiveRecordManager", false)) |
|
| 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); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function setOpFile($op_file_namespace) |
|
| 39 | - { |
|
| 40 | - $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
| 41 | - if (empty($op_file)) |
|
| 42 | - throw new Exception("You need to fix your output folder namespace."); |
|
| 43 | - if (!is_dir($op_file)) |
|
| 44 | - mkdir($op_file, 0777, true); |
|
| 45 | - $this->_opFile = $op_file; |
|
| 46 | - } |
|
| 38 | + public function setOpFile($op_file_namespace) |
|
| 39 | + { |
|
| 40 | + $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
| 41 | + if (empty($op_file)) |
|
| 42 | + throw new Exception("You need to fix your output folder namespace."); |
|
| 43 | + if (!is_dir($op_file)) |
|
| 44 | + mkdir($op_file, 0777, true); |
|
| 45 | + $this->_opFile = $op_file; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function renderAllTablesInformation() |
|
| 49 | - { |
|
| 50 | - foreach ($this->getAllTableNames() as $table_name) |
|
| 51 | - { |
|
| 52 | - echo $table_name . "<br>"; |
|
| 53 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
| 54 | - echo "Table info:" . "<br>"; |
|
| 55 | - echo "<pre>"; |
|
| 56 | - print_r($tableInfo); |
|
| 57 | - echo "</pre>"; |
|
| 58 | - } |
|
| 59 | - } |
|
| 48 | + public function renderAllTablesInformation() |
|
| 49 | + { |
|
| 50 | + foreach ($this->getAllTableNames() as $table_name) |
|
| 51 | + { |
|
| 52 | + echo $table_name . "<br>"; |
|
| 53 | + $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
| 54 | + echo "Table info:" . "<br>"; |
|
| 55 | + echo "<pre>"; |
|
| 56 | + print_r($tableInfo); |
|
| 57 | + echo "</pre>"; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function getAllTableNames() |
|
| 62 | - { |
|
| 63 | - $tableNames = $this->_dbMetaData->findTableNames(); |
|
| 64 | - $index = array_search('pradocache', $tableNames); |
|
| 65 | - if ($index) |
|
| 66 | - array_splice($tableNames, $index, 1); |
|
| 67 | - return $tableNames; |
|
| 68 | - } |
|
| 61 | + public function getAllTableNames() |
|
| 62 | + { |
|
| 63 | + $tableNames = $this->_dbMetaData->findTableNames(); |
|
| 64 | + $index = array_search('pradocache', $tableNames); |
|
| 65 | + if ($index) |
|
| 66 | + array_splice($tableNames, $index, 1); |
|
| 67 | + return $tableNames; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public static function pr($data) |
|
| 71 | - { |
|
| 72 | - echo "<pre>"; |
|
| 73 | - print_r($data); |
|
| 74 | - echo "</pre>"; |
|
| 75 | - } |
|
| 70 | + public static function pr($data) |
|
| 71 | + { |
|
| 72 | + echo "<pre>"; |
|
| 73 | + print_r($data); |
|
| 74 | + echo "</pre>"; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - protected function eq($data) |
|
| 78 | - { |
|
| 79 | - return '"' . $data . '"'; |
|
| 80 | - } |
|
| 77 | + protected function eq($data) |
|
| 78 | + { |
|
| 79 | + return '"' . $data . '"'; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | } |
@@ -14,59 +14,59 @@ |
||
| 14 | 14 | class TWsatScaffolding extends TPage |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - public function onInit($param) |
|
| 18 | - { |
|
| 19 | - parent::onInit($param); |
|
| 20 | - $this->startVisual(); |
|
| 21 | - } |
|
| 17 | + public function onInit($param) |
|
| 18 | + { |
|
| 19 | + parent::onInit($param); |
|
| 20 | + $this->startVisual(); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - private function startVisual() |
|
| 24 | - { |
|
| 25 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
| 26 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
| 27 | - { |
|
| 28 | - $dynChb = new TCheckBox(); |
|
| 29 | - $dynChb->ID = "cb_$tableName"; |
|
| 30 | - $dynChb->Text = ucfirst($tableName); |
|
| 31 | - $dynChb->Checked = true; |
|
| 32 | - $this->registerObject("cb_$tableName", $dynChb); |
|
| 33 | - $this->tableNames->getControls()->add($dynChb); |
|
| 34 | - $this->tableNames->getControls()->add("</br>"); |
|
| 35 | - } |
|
| 36 | - } |
|
| 23 | + private function startVisual() |
|
| 24 | + { |
|
| 25 | + $scf_generator = new TWsatScaffoldingGenerator(); |
|
| 26 | + foreach ($scf_generator->getAllTableNames() as $tableName) |
|
| 27 | + { |
|
| 28 | + $dynChb = new TCheckBox(); |
|
| 29 | + $dynChb->ID = "cb_$tableName"; |
|
| 30 | + $dynChb->Text = ucfirst($tableName); |
|
| 31 | + $dynChb->Checked = true; |
|
| 32 | + $this->registerObject("cb_$tableName", $dynChb); |
|
| 33 | + $this->tableNames->getControls()->add($dynChb); |
|
| 34 | + $this->tableNames->getControls()->add("</br>"); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Generate Scaffolding code for selected tables |
|
| 40 | - * @param type $sender |
|
| 41 | - */ |
|
| 42 | - public function generate($sender) |
|
| 43 | - { |
|
| 44 | - if ($this->IsValid) |
|
| 45 | - { |
|
| 46 | - try |
|
| 47 | - { |
|
| 48 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
| 49 | - $scf_generator->setOpFile($this->output_folder->Text); |
|
| 50 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
| 51 | - { |
|
| 52 | - $id = "cb_$tableName"; |
|
| 53 | - $obj = $this->tableNames->findControl($id); |
|
| 54 | - if($obj!==null && $obj->Checked) |
|
| 55 | - { |
|
| 56 | - $scf_generator->generateCRUD($tableName); |
|
| 57 | - } |
|
| 58 | - } |
|
| 38 | + /** |
|
| 39 | + * Generate Scaffolding code for selected tables |
|
| 40 | + * @param type $sender |
|
| 41 | + */ |
|
| 42 | + public function generate($sender) |
|
| 43 | + { |
|
| 44 | + if ($this->IsValid) |
|
| 45 | + { |
|
| 46 | + try |
|
| 47 | + { |
|
| 48 | + $scf_generator = new TWsatScaffoldingGenerator(); |
|
| 49 | + $scf_generator->setOpFile($this->output_folder->Text); |
|
| 50 | + foreach ($scf_generator->getAllTableNames() as $tableName) |
|
| 51 | + { |
|
| 52 | + $id = "cb_$tableName"; |
|
| 53 | + $obj = $this->tableNames->findControl($id); |
|
| 54 | + if($obj!==null && $obj->Checked) |
|
| 55 | + { |
|
| 56 | + $scf_generator->generateCRUD($tableName); |
|
| 57 | + } |
|
| 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) |
|
| 63 | - { |
|
| 64 | - $this->feedback_panel->CssClass = "red_panel"; |
|
| 65 | - $this->generation_msg->Text = $ex->getMessage(); |
|
| 66 | - } |
|
| 67 | - $this->feedback_panel->Visible = true; |
|
| 68 | - } |
|
| 60 | + $this->feedback_panel->CssClass = "green_panel"; |
|
| 61 | + $this->generation_msg->Text = "The code has been generated successfully."; |
|
| 62 | + } catch (Exception $ex) |
|
| 63 | + { |
|
| 64 | + $this->feedback_panel->CssClass = "red_panel"; |
|
| 65 | + $this->generation_msg->Text = $ex->getMessage(); |
|
| 66 | + } |
|
| 67 | + $this->feedback_panel->Visible = true; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - // $scf_generator->renderAllTablesInformation(); |
|
| 71 | - } |
|
| 70 | + // $scf_generator->renderAllTablesInformation(); |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file |