@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * unquote chars |
| 34 | 34 | * @var array |
| 35 | 35 | */ |
| 36 | - private $uqChars = array('[', ']', '"', '`', "'"); |
|
| 36 | + private $uqChars=array('[', ']', '"', '`', "'"); |
|
| 37 | 37 | |
| 38 | 38 | function __construct() |
| 39 | 39 | { |
@@ -42,31 +42,31 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function setClasPrefix($_clas_prefix) |
| 44 | 44 | { |
| 45 | - $this->_clasPrefix = $_clas_prefix; |
|
| 45 | + $this->_clasPrefix=$_clas_prefix; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function setClassSufix($_clas_sufix) |
| 49 | 49 | { |
| 50 | - $this->_classSufix = $_clas_sufix; |
|
| 50 | + $this->_classSufix=$_clas_sufix; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | //----------------------------------------------------------------------------- |
| 54 | 54 | // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
| 55 | 55 | public function generate($tableName) |
| 56 | 56 | { |
| 57 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
| 57 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
| 58 | 58 | $this->_commonGenerate($tableName, $tableInfo); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function generateAll() |
| 62 | 62 | { |
| 63 | - foreach ($this->getAllTableNames() as $tableName) |
|
| 63 | + foreach($this->getAllTableNames() as $tableName) |
|
| 64 | 64 | { |
| 65 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
| 66 | - if (!empty($this->_relations)) |
|
| 65 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
| 66 | + if(!empty($this->_relations)) |
|
| 67 | 67 | { |
| 68 | 68 | // Cancel generation of M-M relationships middle table |
| 69 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
| 69 | + if(count($tableInfo->getPrimaryKeys())===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
| 70 | 70 | continue; |
| 71 | 71 | } |
| 72 | 72 | $this->_commonGenerate($tableName, $tableInfo); |
@@ -75,26 +75,26 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function buildRelations() |
| 77 | 77 | { |
| 78 | - $this->_relations = array(); |
|
| 79 | - foreach ($this->getAllTableNames() as $table_name) |
|
| 78 | + $this->_relations=array(); |
|
| 79 | + foreach($this->getAllTableNames() as $table_name) |
|
| 80 | 80 | { |
| 81 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
| 82 | - $pks = $tableInfo->getPrimaryKeys(); |
|
| 83 | - $fks = $tableInfo->getForeignKeys(); |
|
| 81 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
| 82 | + $pks=$tableInfo->getPrimaryKeys(); |
|
| 83 | + $fks=$tableInfo->getForeignKeys(); |
|
| 84 | 84 | |
| 85 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
| 85 | + if(count($pks)===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
| 86 | 86 | { |
| 87 | - $table_name_mm = $fks[0]["table"]; |
|
| 88 | - $table_name_mm2 = $fks[1]["table"]; |
|
| 87 | + $table_name_mm=$fks[0]["table"]; |
|
| 88 | + $table_name_mm2=$fks[1]["table"]; |
|
| 89 | 89 | |
| 90 | - $this->_relations[$table_name_mm][] = array( |
|
| 90 | + $this->_relations[$table_name_mm][]=array( |
|
| 91 | 91 | "prop_name" => strtolower($table_name_mm2), |
| 92 | 92 | "rel_type" => "self::MANY_TO_MANY", |
| 93 | 93 | "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
| 94 | 94 | "prop_ref" => $table_name |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | - $this->_relations[$table_name_mm2][] = array( |
|
| 97 | + $this->_relations[$table_name_mm2][]=array( |
|
| 98 | 98 | "prop_name" => strtolower($table_name_mm), |
| 99 | 99 | "rel_type" => "self::MANY_TO_MANY", |
| 100 | 100 | "ref_class_name" => $this->_getProperClassName($table_name_mm), |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | ); |
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | - foreach ($fks as $fk_data)//1-M relationships |
|
| 105 | + foreach($fks as $fk_data)//1-M relationships |
|
| 106 | 106 | { |
| 107 | - $owner_table = $fk_data["table"]; |
|
| 108 | - $slave_table = $table_name; |
|
| 109 | - $fk_prop = key($fk_data["keys"]); |
|
| 107 | + $owner_table=$fk_data["table"]; |
|
| 108 | + $slave_table=$table_name; |
|
| 109 | + $fk_prop=key($fk_data["keys"]); |
|
| 110 | 110 | |
| 111 | - $this->_relations[$owner_table][] = array( |
|
| 111 | + $this->_relations[$owner_table][]=array( |
|
| 112 | 112 | "prop_name" => strtolower($slave_table), |
| 113 | 113 | "rel_type" => "self::HAS_MANY", |
| 114 | 114 | "ref_class_name" => $this->_getProperClassName($slave_table), |
| 115 | 115 | "prop_ref" => $fk_prop |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $this->_relations[$slave_table][] = array( |
|
| 118 | + $this->_relations[$slave_table][]=array( |
|
| 119 | 119 | "prop_name" => strtolower($owner_table), |
| 120 | 120 | "rel_type" => "self::BELONGS_TO", |
| 121 | 121 | "ref_class_name" => $this->_getProperClassName($owner_table), |
@@ -131,88 +131,88 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | private function _commonGenerate($tableName, $tableInfo) |
| 133 | 133 | { |
| 134 | - if (count($tableInfo->getColumns()) === 0) |
|
| 135 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
| 134 | + if(count($tableInfo->getColumns())===0) |
|
| 135 | + throw new Exception("Unable to find table or view $tableName in ".$this->_dbMetaData->getDbConnection()->getConnectionString()."."); |
|
| 136 | 136 | else |
| 137 | 137 | { |
| 138 | - $properties = array(); |
|
| 139 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
| 140 | - $properties[] = $this->generateProperty($field, $metadata); |
|
| 141 | - $toString = $this->_buildSmartToString($tableInfo); |
|
| 138 | + $properties=array(); |
|
| 139 | + foreach($tableInfo->getColumns() as $field => $metadata) |
|
| 140 | + $properties[]=$this->generateProperty($field, $metadata); |
|
| 141 | + $toString=$this->_buildSmartToString($tableInfo); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $clasName = $this->_getProperClassName($tableName); |
|
| 145 | - $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
| 146 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
| 144 | + $clasName=$this->_getProperClassName($tableName); |
|
| 145 | + $class=$this->generateClass($properties, $tableName, $clasName, $toString); |
|
| 146 | + $output=$this->_opFile.DIRECTORY_SEPARATOR.$clasName.".php"; |
|
| 147 | 147 | file_put_contents($output, $class); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | private function _getProperClassName($tableName) |
| 151 | 151 | { |
| 152 | - $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
| 153 | - $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
| 154 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
| 152 | + $table_name_words=str_replace("_", " ", strtolower($tableName)); |
|
| 153 | + $final_conversion=str_replace(" ", "", ucwords($table_name_words)); |
|
| 154 | + return $this->_clasPrefix.$final_conversion.$this->_classSufix; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | //----------------------------------------------------------------------------- |
| 158 | 158 | |
| 159 | 159 | protected function generateProperty($field, $metadata) |
| 160 | 160 | { |
| 161 | - $prop = ''; |
|
| 162 | - $name = '$' . $field; |
|
| 161 | + $prop=''; |
|
| 162 | + $name='$'.$field; |
|
| 163 | 163 | |
| 164 | 164 | /* TODO use in version 2.0 */ |
| 165 | 165 | // $type = $column->getPHPType(); |
| 166 | 166 | |
| 167 | - $prop .= "\tpublic $name;"; |
|
| 167 | + $prop.="\tpublic $name;"; |
|
| 168 | 168 | return $prop; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | private function _renderRelations($tablename) |
| 172 | 172 | { |
| 173 | - if (!isset($this->_relations[$tablename])) |
|
| 173 | + if(!isset($this->_relations[$tablename])) |
|
| 174 | 174 | return ""; |
| 175 | 175 | |
| 176 | - $code = "\tpublic static \$RELATIONS = array ("; |
|
| 177 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
| 178 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
| 176 | + $code="\tpublic static \$RELATIONS = array ("; |
|
| 177 | + foreach($this->_relations[$tablename] as $rel_data) |
|
| 178 | + $code.="\n\t\t'".$rel_data["prop_name"]."' => array(".$rel_data["rel_type"].", '".$rel_data["ref_class_name"]."', '".$rel_data["prop_ref"]."'),"; |
|
| 179 | 179 | |
| 180 | - $code = substr($code, 0, -1); |
|
| 181 | - $code .= "\n\t);"; |
|
| 180 | + $code=substr($code, 0, -1); |
|
| 181 | + $code.="\n\t);"; |
|
| 182 | 182 | return $code; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | private function _buildSmartToString($tableInfo) |
| 186 | 186 | { |
| 187 | - $code = "\tpublic function __toString() {"; |
|
| 188 | - $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
| 187 | + $code="\tpublic function __toString() {"; |
|
| 188 | + $property="throw new THttpException(500, 'Not implemented yet.');"; |
|
| 189 | 189 | try |
| 190 | 190 | { |
| 191 | - foreach ($tableInfo->getColumns() as $column) |
|
| 191 | + foreach($tableInfo->getColumns() as $column) |
|
| 192 | 192 | { |
| 193 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
| 194 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
| 195 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
| 193 | + if(isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
| 194 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
| 195 | + elseif($column->PdoType==PDO::PARAM_STR && $column->DBType!="date") |
|
| 196 | 196 | { |
| 197 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
| 197 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
| 198 | 198 | break; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | - } catch (Exception $ex) |
|
| 201 | + } catch(Exception $ex) |
|
| 202 | 202 | { |
| 203 | 203 | Prado::trace($ex->getMessage()); |
| 204 | 204 | } |
| 205 | - $code .= "\n\t\treturn \$this->$property;"; |
|
| 206 | - $code .= "\n\t}"; |
|
| 205 | + $code.="\n\t\treturn \$this->$property;"; |
|
| 206 | + $code.="\n\t}"; |
|
| 207 | 207 | return $code; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | protected function generateClass($properties, $tablename, $classname, $toString) |
| 211 | 211 | { |
| 212 | - $props = implode("\n", $properties); |
|
| 213 | - $relations = $this->_renderRelations($tablename); |
|
| 214 | - $date = date('Y-m-d h:i:s'); |
|
| 215 | - $env_user = getenv("username"); |
|
| 212 | + $props=implode("\n", $properties); |
|
| 213 | + $relations=$this->_renderRelations($tablename); |
|
| 214 | + $date=date('Y-m-d h:i:s'); |
|
| 215 | + $env_user=getenv("username"); |
|
| 216 | 216 | return <<<EOD |
| 217 | 217 | <?php |
| 218 | 218 | /** |
@@ -27,31 +27,31 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | function __construct() |
| 29 | 29 | { |
| 30 | - if (!class_exists("TActiveRecordManager", false)) |
|
| 30 | + if(!class_exists("TActiveRecordManager", false)) |
|
| 31 | 31 | throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
| 32 | - $ar_manager = TActiveRecordManager::getInstance(); |
|
| 33 | - $_conn = $ar_manager->getDbConnection(); |
|
| 34 | - $_conn->Active = true; |
|
| 35 | - $this->_dbMetaData = TDbMetaData::getInstance($_conn); |
|
| 32 | + $ar_manager=TActiveRecordManager::getInstance(); |
|
| 33 | + $_conn=$ar_manager->getDbConnection(); |
|
| 34 | + $_conn->Active=true; |
|
| 35 | + $this->_dbMetaData=TDbMetaData::getInstance($_conn); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function setOpFile($op_file_namespace) |
| 39 | 39 | { |
| 40 | - $op_file = Prado::getPathOfNamespace($op_file_namespace); |
|
| 41 | - if (empty($op_file)) |
|
| 40 | + $op_file=Prado::getPathOfNamespace($op_file_namespace); |
|
| 41 | + if(empty($op_file)) |
|
| 42 | 42 | throw new Exception("You need to fix your output folder namespace."); |
| 43 | - if (!is_dir($op_file)) |
|
| 43 | + if(!is_dir($op_file)) |
|
| 44 | 44 | mkdir($op_file, 0777, true); |
| 45 | - $this->_opFile = $op_file; |
|
| 45 | + $this->_opFile=$op_file; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function renderAllTablesInformation() |
| 49 | 49 | { |
| 50 | - foreach ($this->getAllTableNames() as $table_name) |
|
| 50 | + foreach($this->getAllTableNames() as $table_name) |
|
| 51 | 51 | { |
| 52 | - echo $table_name . "<br>"; |
|
| 53 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
| 54 | - echo "Table info:" . "<br>"; |
|
| 52 | + echo $table_name."<br>"; |
|
| 53 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
| 54 | + echo "Table info:"."<br>"; |
|
| 55 | 55 | echo "<pre>"; |
| 56 | 56 | print_r($tableInfo); |
| 57 | 57 | echo "</pre>"; |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | public function getAllTableNames() |
| 62 | 62 | { |
| 63 | - $tableNames = $this->_dbMetaData->findTableNames(); |
|
| 64 | - $index = array_search('pradocache', $tableNames); |
|
| 65 | - if ($index) |
|
| 63 | + $tableNames=$this->_dbMetaData->findTableNames(); |
|
| 64 | + $index=array_search('pradocache', $tableNames); |
|
| 65 | + if($index) |
|
| 66 | 66 | array_splice($tableNames, $index, 1); |
| 67 | 67 | return $tableNames; |
| 68 | 68 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | protected function eq($data) |
| 78 | 78 | { |
| 79 | - return '"' . $data . '"'; |
|
| 79 | + return '"'.$data.'"'; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | } |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * Const View Types for generation |
| 19 | 19 | */ |
| 20 | - const LIST_TYPE = 0; |
|
| 21 | - const ADD_TYPE = 1; |
|
| 22 | - const SHOW_TYPE = 2; |
|
| 20 | + const LIST_TYPE=0; |
|
| 21 | + const ADD_TYPE=1; |
|
| 22 | + const SHOW_TYPE=2; |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * Bootstrap option |
@@ -46,34 +46,34 @@ discard block |
||
| 46 | 46 | // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
| 47 | 47 | public function generate($tableName, $viewType) |
| 48 | 48 | { |
| 49 | - switch ($viewType) |
|
| 49 | + switch($viewType) |
|
| 50 | 50 | { |
| 51 | 51 | default: |
| 52 | 52 | case self::LIST_TYPE: |
| 53 | - $unitName = "list" . ucfirst($tableName); |
|
| 53 | + $unitName="list".ucfirst($tableName); |
|
| 54 | 54 | break; |
| 55 | 55 | |
| 56 | 56 | case self::ADD_TYPE: |
| 57 | - $unitName = "add" . ucfirst($tableName); |
|
| 57 | + $unitName="add".ucfirst($tableName); |
|
| 58 | 58 | break; |
| 59 | 59 | |
| 60 | 60 | case self::SHOW_TYPE: |
| 61 | - $unitName = "show" . ucfirst($tableName); |
|
| 61 | + $unitName="show".ucfirst($tableName); |
|
| 62 | 62 | break; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $class = $this->generateClass($unitName); |
|
| 66 | - $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
| 65 | + $class=$this->generateClass($unitName); |
|
| 66 | + $outputClass=$this->_opFile.DIRECTORY_SEPARATOR.$unitName.".php"; |
|
| 67 | 67 | file_put_contents($outputClass, $class); |
| 68 | 68 | |
| 69 | - $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
| 70 | - $page = $this->generatePage($tableName, $viewType); |
|
| 69 | + $outputPage=$this->_opFile.DIRECTORY_SEPARATOR.$unitName.".page"; |
|
| 70 | + $page=$this->generatePage($tableName, $viewType); |
|
| 71 | 71 | file_put_contents($outputPage, $page); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - private function generatePage($tableName, $type, $tContentId = "Content") |
|
| 74 | + private function generatePage($tableName, $type, $tContentId="Content") |
|
| 75 | 75 | { |
| 76 | - $pageContent = $this->getPageContent($tableName, $type); |
|
| 76 | + $pageContent=$this->getPageContent($tableName, $type); |
|
| 77 | 77 | return <<<EOD |
| 78 | 78 | <com:TContent ID="$tContentId"> |
| 79 | 79 | |
@@ -85,30 +85,30 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | private function getPageContent($tableName, $type) |
| 87 | 87 | { |
| 88 | - $code = ""; |
|
| 89 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
| 90 | - switch ($type) |
|
| 88 | + $code=""; |
|
| 89 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
| 90 | + switch($type) |
|
| 91 | 91 | { |
| 92 | 92 | case self::LIST_TYPE: |
| 93 | 93 | break; |
| 94 | 94 | case self::ADD_TYPE: |
| 95 | - foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
| 95 | + foreach($tableInfo->getColumns() as $colField => $colMetadata) |
|
| 96 | 96 | { |
| 97 | - if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
| 97 | + if(!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
| 98 | 98 | { |
| 99 | - $code .= $this->generateControl($colMetadata); |
|
| 100 | - $code .= $this->generateValidators($colMetadata); |
|
| 101 | - $code .= "\n"; |
|
| 99 | + $code.=$this->generateControl($colMetadata); |
|
| 100 | + $code.=$this->generateValidators($colMetadata); |
|
| 101 | + $code.="\n"; |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | - foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
| 104 | + foreach($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
| 105 | 105 | { |
| 106 | - $colField = $this->eq($colMetadata["table"]); |
|
| 107 | - $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
| 108 | - $code .= "\n"; |
|
| 106 | + $colField=$this->eq($colMetadata["table"]); |
|
| 107 | + $code.="\t<com:TTextBox ID=$colField />\n"; |
|
| 108 | + $code.="\n"; |
|
| 109 | 109 | // TWsatBaseGenerator::pr($tableInfo); |
| 110 | 110 | } |
| 111 | - $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
| 111 | + $code.="\t<com:TButton Text=\"Accept\" />\n"; |
|
| 112 | 112 | |
| 113 | 113 | case self::SHOW_TYPE: |
| 114 | 114 | break; |
@@ -118,22 +118,22 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | private function generateControl($colMetadata) |
| 120 | 120 | { |
| 121 | - $controlType = "TTextBox"; |
|
| 122 | - switch ($colMetadata->DbType) |
|
| 121 | + $controlType="TTextBox"; |
|
| 122 | + switch($colMetadata->DbType) |
|
| 123 | 123 | { |
| 124 | 124 | |
| 125 | 125 | } |
| 126 | - $controlId = $colMetadata->ColumnId; |
|
| 126 | + $controlId=$colMetadata->ColumnId; |
|
| 127 | 127 | return "\t<com:$controlType ID=\"$controlId\" />\n"; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | private function generateValidators($colMetadata) |
| 131 | 131 | { |
| 132 | - $controlId = $colMetadata->ColumnId; |
|
| 133 | - $code = ""; |
|
| 134 | - if (!$colMetadata->AllowNull) |
|
| 132 | + $controlId=$colMetadata->ColumnId; |
|
| 133 | + $code=""; |
|
| 134 | + if(!$colMetadata->AllowNull) |
|
| 135 | 135 | { |
| 136 | - $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
| 136 | + $code.="\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
| 137 | 137 | } |
| 138 | 138 | return $code; |
| 139 | 139 | } |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
| 144 | 144 | private function generateClass($classname) |
| 145 | 145 | { |
| 146 | - $date = date('Y-m-d h:i:s'); |
|
| 147 | - $env_user = getenv("username"); |
|
| 146 | + $date=date('Y-m-d h:i:s'); |
|
| 147 | + $env_user=getenv("username"); |
|
| 148 | 148 | return <<<EOD |
| 149 | 149 | <?php |
| 150 | 150 | /** |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | private function validateSecurity() |
| 18 | 18 | { |
| 19 | - if ($this->Session["wsat_password"] !== $this->getService()->getPassword()) |
|
| 19 | + if($this->Session["wsat_password"]!==$this->getService()->getPassword()) |
|
| 20 | 20 | { |
| 21 | - if (!$this->getPage() instanceof TWsatLogin) |
|
| 21 | + if(!$this->getPage() instanceof TWsatLogin) |
|
| 22 | 22 | { |
| 23 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
| 23 | + $url=$this->Service->constructUrl('TWsatLogin'); |
|
| 24 | 24 | $this->Response->redirect($url); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function logout() |
| 30 | 30 | { |
| 31 | - $this->Session["wsat_password"] = ""; |
|
| 32 | - $url = $this->Service->constructUrl('TWsatLogin'); |
|
| 31 | + $this->Session["wsat_password"]=""; |
|
| 32 | + $url=$this->Service->constructUrl('TWsatLogin'); |
|
| 33 | 33 | $this->Response->redirect($url); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -14,19 +14,19 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function login() |
| 16 | 16 | { |
| 17 | - if ($this->IsValid) |
|
| 17 | + if($this->IsValid) |
|
| 18 | 18 | { |
| 19 | - $this->Session["wsat_password"] = $this->getService()->getPassword(); |
|
| 20 | - $url = $this->Service->constructUrl('TWsatHome'); |
|
| 19 | + $this->Session["wsat_password"]=$this->getService()->getPassword(); |
|
| 20 | + $url=$this->Service->constructUrl('TWsatHome'); |
|
| 21 | 21 | $this->Response->redirect($url); |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function validatePassword($sender, $param) |
| 26 | 26 | { |
| 27 | - $config_pass = $this->Service->Password; |
|
| 28 | - $user_pass = $this->password->Text; |
|
| 29 | - $param->IsValid = $user_pass === $config_pass; |
|
| 27 | + $config_pass=$this->Service->Password; |
|
| 28 | + $user_pass=$this->password->Text; |
|
| 29 | + $param->IsValid=$user_pass===$config_pass; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | private function startVisual() |
| 24 | 24 | { |
| 25 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
| 26 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
| 25 | + $scf_generator=new TWsatScaffoldingGenerator(); |
|
| 26 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
| 27 | 27 | { |
| 28 | - $dynChb = new TCheckBox(); |
|
| 29 | - $dynChb->ID = "cb_$tableName"; |
|
| 30 | - $dynChb->Text = ucfirst($tableName); |
|
| 31 | - $dynChb->Checked = true; |
|
| 28 | + $dynChb=new TCheckBox(); |
|
| 29 | + $dynChb->ID="cb_$tableName"; |
|
| 30 | + $dynChb->Text=ucfirst($tableName); |
|
| 31 | + $dynChb->Checked=true; |
|
| 32 | 32 | $this->registerObject("cb_$tableName", $dynChb); |
| 33 | 33 | $this->tableNames->getControls()->add($dynChb); |
| 34 | 34 | $this->tableNames->getControls()->add("</br>"); |
@@ -41,30 +41,30 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function generate($sender) |
| 43 | 43 | { |
| 44 | - if ($this->IsValid) |
|
| 44 | + if($this->IsValid) |
|
| 45 | 45 | { |
| 46 | 46 | try |
| 47 | 47 | { |
| 48 | - $scf_generator = new TWsatScaffoldingGenerator(); |
|
| 48 | + $scf_generator=new TWsatScaffoldingGenerator(); |
|
| 49 | 49 | $scf_generator->setOpFile($this->output_folder->Text); |
| 50 | - foreach ($scf_generator->getAllTableNames() as $tableName) |
|
| 50 | + foreach($scf_generator->getAllTableNames() as $tableName) |
|
| 51 | 51 | { |
| 52 | - $id = "cb_$tableName"; |
|
| 53 | - $obj = $this->tableNames->findControl($id); |
|
| 52 | + $id="cb_$tableName"; |
|
| 53 | + $obj=$this->tableNames->findControl($id); |
|
| 54 | 54 | if($obj!==null && $obj->Checked) |
| 55 | 55 | { |
| 56 | 56 | $scf_generator->generateCRUD($tableName); |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $this->feedback_panel->CssClass = "green_panel"; |
|
| 61 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
| 62 | - } catch (Exception $ex) |
|
| 60 | + $this->feedback_panel->CssClass="green_panel"; |
|
| 61 | + $this->generation_msg->Text="The code has been generated successfully."; |
|
| 62 | + } catch(Exception $ex) |
|
| 63 | 63 | { |
| 64 | - $this->feedback_panel->CssClass = "red_panel"; |
|
| 65 | - $this->generation_msg->Text = $ex->getMessage(); |
|
| 64 | + $this->feedback_panel->CssClass="red_panel"; |
|
| 65 | + $this->generation_msg->Text=$ex->getMessage(); |
|
| 66 | 66 | } |
| 67 | - $this->feedback_panel->Visible = true; |
|
| 67 | + $this->feedback_panel->Visible=true; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // $scf_generator->renderAllTablesInformation(); |
@@ -16,36 +16,36 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function generate($sender) |
| 18 | 18 | { |
| 19 | - if ($this->IsValid) |
|
| 19 | + if($this->IsValid) |
|
| 20 | 20 | { |
| 21 | - $tableName = $this->table_name->Text; |
|
| 22 | - $outputFolderNs = $this->output_folder->Text; |
|
| 23 | - $classPrefix = $this->class_prefix->Text; |
|
| 24 | - $classSuffix = $this->class_suffix->Text; |
|
| 21 | + $tableName=$this->table_name->Text; |
|
| 22 | + $outputFolderNs=$this->output_folder->Text; |
|
| 23 | + $classPrefix=$this->class_prefix->Text; |
|
| 24 | + $classSuffix=$this->class_suffix->Text; |
|
| 25 | 25 | |
| 26 | 26 | try |
| 27 | 27 | { |
| 28 | - $ar_generator = new TWsatARGenerator(); |
|
| 28 | + $ar_generator=new TWsatARGenerator(); |
|
| 29 | 29 | $ar_generator->setOpFile($outputFolderNs); |
| 30 | 30 | $ar_generator->setClasPrefix($classPrefix); |
| 31 | 31 | $ar_generator->setClassSufix($classSuffix); |
| 32 | 32 | |
| 33 | - if ($this->build_rel->Checked) |
|
| 33 | + if($this->build_rel->Checked) |
|
| 34 | 34 | $ar_generator->buildRelations(); |
| 35 | 35 | |
| 36 | - if ($tableName != "*") |
|
| 36 | + if($tableName!="*") |
|
| 37 | 37 | $ar_generator->generate($tableName); |
| 38 | 38 | else |
| 39 | 39 | $ar_generator->generateAll(); |
| 40 | 40 | |
| 41 | - $this->feedback_panel->CssClass = "green_panel"; |
|
| 42 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
| 43 | - } catch (Exception $ex) |
|
| 41 | + $this->feedback_panel->CssClass="green_panel"; |
|
| 42 | + $this->generation_msg->Text="The code has been generated successfully."; |
|
| 43 | + } catch(Exception $ex) |
|
| 44 | 44 | { |
| 45 | - $this->feedback_panel->CssClass = "red_panel"; |
|
| 46 | - $this->generation_msg->Text = $ex->getMessage(); |
|
| 45 | + $this->feedback_panel->CssClass="red_panel"; |
|
| 46 | + $this->generation_msg->Text=$ex->getMessage(); |
|
| 47 | 47 | } |
| 48 | - $this->feedback_panel->Visible = true; |
|
| 48 | + $this->feedback_panel->Visible=true; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | class TWsatService extends TPageService |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - private $_pass = ''; |
|
| 39 | + private $_pass=''; |
|
| 40 | 40 | |
| 41 | 41 | public function init($config) |
| 42 | 42 | { |
| 43 | - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
| 43 | + if($this->getApplication()->getMode()===TApplicationMode::Performance || $this->getApplication()->getMode()===TApplicationMode::Normal) |
|
| 44 | 44 | throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
| 45 | 45 | |
| 46 | - if (empty($this->_pass)) |
|
| 46 | + if(empty($this->_pass)) |
|
| 47 | 47 | throw new TConfigurationException("You need to specify the Password attribute."); |
| 48 | 48 | |
| 49 | 49 | $this->setDefaultPage("TWsatHome"); |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function getBasePath() |
| 55 | 55 | { |
| 56 | - $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); |
|
| 56 | + $basePath=Prado::getPathOfNamespace("System.Wsat.pages"); |
|
| 57 | 57 | return realpath($basePath); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | private function _startThemeManager() |
| 61 | 61 | { |
| 62 | - $themeManager = new TThemeManager; |
|
| 63 | - $themeManager->BasePath = "System.Wsat.themes"; |
|
| 64 | - $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
| 65 | - $themeManager->BaseUrl = "$url/themes"; |
|
| 62 | + $themeManager=new TThemeManager; |
|
| 63 | + $themeManager->BasePath="System.Wsat.themes"; |
|
| 64 | + $url=Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); |
|
| 65 | + $themeManager->BaseUrl="$url/themes"; |
|
| 66 | 66 | |
| 67 | 67 | $themeManager->init(null); |
| 68 | 68 | $this->setThemeManager($themeManager); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function setPassword($_pass) |
| 77 | 77 | { |
| 78 | - $this->_pass = $_pass; |
|
| 78 | + $this->_pass=$_pass; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | */ |
| 72 | 72 | public function createNewHtmlWriter($type, $writer) |
| 73 | 73 | { |
| 74 | - return $this->_response->createNewHtmlWriter($type,$writer); |
|
| 74 | + return $this->_response->createNewHtmlWriter($type, $writer); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |