From 227ef973f923ec201a1ece197f6242b3248c66ae Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 25 Nov 2013 12:49:07 -0500 Subject: WSAT beta release with doc. --- framework/Wsat/TWsatARGenerator.php | 33 +++++++++++++++++----- framework/Wsat/TWsatService.php | 28 ++++++++++++++---- framework/Wsat/TWsatUserManager.php | 18 ------------ framework/Wsat/pages/TWsatGenerateAR.page | 47 +++++++++++++++++++++++-------- framework/Wsat/pages/TWsatGenerateAR.php | 22 +++++++++------ framework/Wsat/pages/TWsatHome.page | 16 +++++++++-- framework/Wsat/pages/TWsatHome.php | 33 +++++++++++++--------- framework/Wsat/pages/TWsatLogin.page | 8 +++--- framework/Wsat/pages/TWsatLogin.php | 11 ++++++-- framework/Wsat/pages/TWsatScaffolding.php | 33 +++++++++++++--------- framework/Wsat/themes/PradoSoft/main.css | 5 ++-- 11 files changed, 164 insertions(+), 90 deletions(-) delete mode 100644 framework/Wsat/TWsatUserManager.php diff --git a/framework/Wsat/TWsatARGenerator.php b/framework/Wsat/TWsatARGenerator.php index 433e1640..ed873358 100644 --- a/framework/Wsat/TWsatARGenerator.php +++ b/framework/Wsat/TWsatARGenerator.php @@ -1,9 +1,13 @@ + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2013 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @since 3.3 + * @package Wsat */ class TWsatARGenerator { @@ -29,11 +33,22 @@ class TWsatARGenerator { */ private $_clas_prefix; + /** + * Class name sufix + */ + private $_class_sufix; + /** * all table relations array */ private $_relations; + /** + * unquote chars + * @var array + */ + private $uq_chars = array('[', ']', '"', '`', "'"); + function __construct() { $ar_manager = TActiveRecordManager::getInstance(); $this->_conn = $ar_manager->getDbConnection(); @@ -65,6 +80,10 @@ class TWsatARGenerator { $this->_clas_prefix = $_clas_prefix; } + public function setClassSufix($_clas_sufix) { + $this->_class_sufix = $_clas_sufix; + } + //----------------------------------------------------------------------------- // public function generate($tableName) { @@ -137,7 +156,7 @@ class TWsatARGenerator { private function _getProperClassName($tableName) { $table_name_words = str_replace("_", " ", strtolower($tableName)); $final_conversion = str_replace(" ", "", ucwords($table_name_words)); - return $this->_clas_prefix . $final_conversion; + return $this->_clas_prefix . $final_conversion . $this->_class_sufix; } public function renderAllTablesInformation() { @@ -184,9 +203,9 @@ class TWsatARGenerator { try { foreach ($tableInfo->getColumns() as $column) { if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) { - $property = str_replace(array("`", "'", '"'), "", $column->ColumnName); - } elseif ($column->DbType == "varchar") { - $property = str_replace(array("`", "'", '"'), "", $column->ColumnName); + $property = str_replace($this->uq_chars, "", $column->ColumnName); + } elseif ($column->PHPType == "string" && $column->DBType != "date") { + $property = str_replace($this->uq_chars, "", $column->ColumnName); break; } } diff --git a/framework/Wsat/TWsatService.php b/framework/Wsat/TWsatService.php index 3af34d49..f2d852ea 100644 --- a/framework/Wsat/TWsatService.php +++ b/framework/Wsat/TWsatService.php @@ -1,11 +1,25 @@ + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2013 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @since 3.3 + * @package Wsat + */ + +/** + * TWsatService class + * + * Wsat is inspired in both Asp.Net - Web Site Administration Tool(WSAT) and Yii's Gii. + * Wsat enables you to generate code saving your time in too many tedious tasks in a GUI fashion. + * + * Current options: + * 1- Generate one or all Active Record Classes from your DataBase. + * 1.1- Automatically generate all relations between the AR Classes (new). + * 1.2- Automatically generate the __toString() magic method in a smart way (new). * * To use TWsatService, configure it in the application configuration file like following: * @@ -16,6 +30,8 @@ * * ...and then you need to go to http://localhost/yoursite/index.php?wsat=TWsatLogin * and generate code and configure your site. + * + * Warning: You should only use Wsat in development mode. */ class TWsatService extends TPageService { @@ -43,7 +59,7 @@ class TWsatService extends TPageService { $themeManager = new TThemeManager; $themeManager->BasePath = "System.Wsat.themes"; $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); - $themeManager->BaseUrl = $url . DIRECTORY_SEPARATOR . "themes"; + $themeManager->BaseUrl = $url . "/themes"; $themeManager->init(null); $this->setThemeManager($themeManager); diff --git a/framework/Wsat/TWsatUserManager.php b/framework/Wsat/TWsatUserManager.php deleted file mode 100644 index b9a9eb8b..00000000 --- a/framework/Wsat/TWsatUserManager.php +++ /dev/null @@ -1,18 +0,0 @@ - diff --git a/framework/Wsat/pages/TWsatGenerateAR.page b/framework/Wsat/pages/TWsatGenerateAR.page index acd456fd..b1cd98aa 100644 --- a/framework/Wsat/pages/TWsatGenerateAR.page +++ b/framework/Wsat/pages/TWsatGenerateAR.page @@ -1,33 +1,56 @@ -
+
Active Record Classes Generator
+
+
+ +
+
+
    +
  • If you want to generate all AR Classes, keep the "Table Name" field as appears by default.
  • +
  • "Output Folder" field refers to the directory that the new AR class file should be generated under... where Application refers to the protected folder of your project. You can let this default field value and PRADO will create the proper folders for you.
  • +
+
+
+ +
- - - + + + +
+ +
+ + + + +
+
+
- - + +
- +
- - - + + +
-
+
- + diff --git a/framework/Wsat/pages/TWsatGenerateAR.php b/framework/Wsat/pages/TWsatGenerateAR.php index 3d4291e2..d5934686 100644 --- a/framework/Wsat/pages/TWsatGenerateAR.php +++ b/framework/Wsat/pages/TWsatGenerateAR.php @@ -1,9 +1,13 @@ + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2013 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @since 3.3 + * @package Wsat.pages */ Prado::using("System.Wsat.TWsatARGenerator"); @@ -12,13 +16,15 @@ class TWsatGenerateAR extends TPage { public function generate($sender) { if ($this->IsValid) { $table_name = $this->table_name->Text; - $class_prefix = $this->class_prefix->Text; $output_folder_ns = $this->output_folder->Text; + $class_prefix = $this->class_prefix->Text; + $class_sufix = $this->class_sufix->Text; try { $ar_generator = new TWsatARGenerator(); $ar_generator->setOpFile($output_folder_ns); $ar_generator->setClasPrefix($class_prefix); + $ar_generator->setClassSufix($class_sufix); if ($this->build_rel->Checked) { $ar_generator->buildRelations(); @@ -28,20 +34,20 @@ class TWsatGenerateAR extends TPage { } else { $ar_generator->generateAll(); } - $this->success_panel->CssClass = "success_panel"; + $this->feedback_panel->CssClass = "green_panel"; $this->generation_msg->Text = "The code has been generated successfully."; } catch (Exception $ex) { - $this->success_panel->CssClass = "exception_panel"; + $this->feedback_panel->CssClass = "red_panel"; $this->generation_msg->Text = $ex->getMessage(); } - $this->success_panel->Visible = true; + $this->feedback_panel->Visible = true; } } public function preview($sender) { // $ar_generator = new TWsatARGenerator(); // $ar_generator->renderAllTablesInformation(); - throw new THttpException(500, "Not implemented yet."); + throw new THttpException(500, "Not implemented yet."); } } diff --git a/framework/Wsat/pages/TWsatHome.page b/framework/Wsat/pages/TWsatHome.page index 16aa3669..e8796ccd 100644 --- a/framework/Wsat/pages/TWsatHome.page +++ b/framework/Wsat/pages/TWsatHome.page @@ -1,5 +1,17 @@ - - + +
Application Dir: <%= Prado::getPathOfNamespace('Application') %>
+ +
+ + + + + +
+ + + Enables you to generate all Active Record Classes with relations included. +
diff --git a/framework/Wsat/pages/TWsatHome.php b/framework/Wsat/pages/TWsatHome.php index 3c1358e1..035dd7c6 100644 --- a/framework/Wsat/pages/TWsatHome.php +++ b/framework/Wsat/pages/TWsatHome.php @@ -1,15 +1,20 @@ - + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2013 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @since 3.3 + * @package Wsat.pages + */ + +Prado::using("System.Wsat.TWsatARGenerator"); + +class TWsatHome extends TPage { + + +} + ?> \ No newline at end of file diff --git a/framework/Wsat/pages/TWsatLogin.page b/framework/Wsat/pages/TWsatLogin.page index d0a94f2a..79578f59 100644 --- a/framework/Wsat/pages/TWsatLogin.page +++ b/framework/Wsat/pages/TWsatLogin.page @@ -29,10 +29,10 @@