diff options
author | Daniel <darthdaniel85@gmail.com> | 2014-10-24 13:11:17 -0500 |
---|---|---|
committer | Daniel <darthdaniel85@gmail.com> | 2014-10-24 13:11:17 -0500 |
commit | a7d2609ab842b9002c6225fb54462d416e0b9673 (patch) | |
tree | 4ae7d06a8587dcc77a3f665bd70670e3484e4c1b /framework | |
parent | a31c1f2ff0f4c996e0b90b1743b775af4cf58e6a (diff) |
Scaffolding 12%
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Wsat/TWsatScaffoldingGenerator.php | 41 | ||||
-rw-r--r-- | framework/Wsat/pages/TWsatScaffolding.page | 4 | ||||
-rw-r--r-- | framework/Wsat/pages/TWsatScaffolding.php | 19 |
3 files changed, 59 insertions, 5 deletions
diff --git a/framework/Wsat/TWsatScaffoldingGenerator.php b/framework/Wsat/TWsatScaffoldingGenerator.php index 37b8ae00..7986793d 100644 --- a/framework/Wsat/TWsatScaffoldingGenerator.php +++ b/framework/Wsat/TWsatScaffoldingGenerator.php @@ -9,7 +9,6 @@ * @since 3.3 * @package Wsat */ - Prado::using("System.Wsat.TWsatBaseGenerator"); class TWsatScaffoldingGenerator extends TWsatBaseGenerator @@ -20,6 +19,46 @@ class TWsatScaffoldingGenerator extends TWsatBaseGenerator parent::__construct(); } + public function generate() + { + $unitName = "Example"; + $class = $this->generateClass($unitName); + $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; + file_put_contents($outputClass, $class); + + $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; + $page = $this->generatePage($unitName); + file_put_contents($outputPage, $page); + } + + // <editor-fold defaultstate="collapsed" desc="Generate Sigle Page"> + private function generatePage($fileName, $tContentId = "Content") + { + return <<<EOD +<com:TContent ID="Content"> + +</com:TContent> +EOD; + } + + private function generateClass($classname) + { + $date = date('Y-m-d h:i:s'); + $env_user = getenv("username"); + return <<<EOD +<?php +/** + * Auto generated by PRADO - WSAT on $date. + * @author $env_user + */ +class $classname extends TPage +{ + +} +EOD; + } + +// </editor-fold> } ?> diff --git a/framework/Wsat/pages/TWsatScaffolding.page b/framework/Wsat/pages/TWsatScaffolding.page index a3ebffd5..f3e53df3 100644 --- a/framework/Wsat/pages/TWsatScaffolding.page +++ b/framework/Wsat/pages/TWsatScaffolding.page @@ -12,6 +12,10 @@ <com:TRequiredFieldValidator ControlToValidate="output_folder" Text="Output folder cannot be blank." Display="Dynamic" /> </div> + <com:TPanel ID="feedback_panel" Visible="false" style="width: 400px"> + <com:TLabel ID="generation_msg" /> + </com:TPanel> + <div style="text-align: center; width: 400px"> <com:TButton Text="Preview" OnClick="preview" Visible="false" /> <com:TButton Text="Generate" OnClick="generate" /> diff --git a/framework/Wsat/pages/TWsatScaffolding.php b/framework/Wsat/pages/TWsatScaffolding.php index 9bbeec3a..2dc7d288 100644 --- a/framework/Wsat/pages/TWsatScaffolding.php +++ b/framework/Wsat/pages/TWsatScaffolding.php @@ -39,10 +39,21 @@ class TWsatScaffolding extends TPage { if ($this->IsValid) { - $scf_generator = new TWsatScaffoldingGenerator(); - // echo $this->cb_student->Text; - // $scf_generator->renderAllTablesInformation(); + try + { + $scf_generator = new TWsatScaffoldingGenerator(); + $scf_generator->setOpFile($this->output_folder->Text); + $scf_generator->generate(); + $this->feedback_panel->CssClass = "green_panel"; + $this->generation_msg->Text = "The code has been generated successfully."; + } catch (Exception $ex) + { + $this->feedback_panel->CssClass = "red_panel"; + $this->generation_msg->Text = $ex->getMessage(); + } + $this->feedback_panel->Visible = true; } - } + // $scf_generator->renderAllTablesInformation(); + } }
\ No newline at end of file |