@@ -602,7 +602,7 @@ |
||
| 602 | 602 | |
| 603 | 603 | /** |
| 604 | 604 | * @param string the application configuration type. 'xml' and 'php' are valid values |
| 605 | - */ |
|
| 605 | + */ |
|
| 606 | 606 | public function setConfigurationType($value) |
| 607 | 607 | { |
| 608 | 608 | $this->_configType = $value; |
@@ -90,10 +90,10 @@ |
||
| 90 | 90 | private $_association_columns=array(); |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | - * Get the foreign key index values from the results and make calls to the |
|
| 94 | - * database to find the corresponding foreign objects using association table. |
|
| 95 | - * @param array original results. |
|
| 96 | - */ |
|
| 93 | + * Get the foreign key index values from the results and make calls to the |
|
| 94 | + * database to find the corresponding foreign objects using association table. |
|
| 95 | + * @param array original results. |
|
| 96 | + */ |
|
| 97 | 97 | protected function collectForeignObjects(&$results) |
| 98 | 98 | { |
| 99 | 99 | list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys(); |
@@ -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 | } |