summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/Wsat/TWsatARGenerator.php33
-rw-r--r--framework/Wsat/TWsatService.php28
-rw-r--r--framework/Wsat/TWsatUserManager.php18
-rw-r--r--framework/Wsat/pages/TWsatGenerateAR.page47
-rw-r--r--framework/Wsat/pages/TWsatGenerateAR.php22
-rw-r--r--framework/Wsat/pages/TWsatHome.page16
-rw-r--r--framework/Wsat/pages/TWsatHome.php33
-rw-r--r--framework/Wsat/pages/TWsatLogin.page8
-rw-r--r--framework/Wsat/pages/TWsatLogin.php11
-rw-r--r--framework/Wsat/pages/TWsatScaffolding.php33
-rw-r--r--framework/Wsat/themes/PradoSoft/main.css5
11 files changed, 164 insertions, 90 deletions
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 @@
<?php
/**
- * Description of TWsatARGenerator
- *
- * @author Daniel
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2013 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat
*/
class TWsatARGenerator {
@@ -30,10 +34,21 @@ 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;
+ }
+
//-----------------------------------------------------------------------------
// <editor-fold defaultstate="collapsed" desc="Main APIs">
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 @@
<?php
/**
- * Description of TWsat
- * Inspired in both Microsoft Web Site Administration Tool(WSAT) and Yii's Gii.
- * @version 1.0
- * @author Daniel Sampedro darthdaniel85@gmail.com
- * @since Prado 3.3
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 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:
* <code>
@@ -16,6 +30,8 @@
* </code>
* ...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 @@
-<?php
-
-Prado::using('System.Security.TUserManager');
-
-/**
- * Description of TWsatUserManager
- *
- * @author Daniel
- */
-class TWsatUserManager extends TUserManager {
-
- public function init($config) {
- parent::init($config);
- }
-
-}
-
-?>
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 @@
<com:TContent ID="Content">
- <div style="margin-left: 220px; font-size: 14px">
+ <div style="margin: 10px; font-size: 16px; font-weight: bold">Active Record Classes Generator</div>
+ <div class="green_panel" style="text-align: left; font-size: 14px; margin: 15px 5px">
+ <label>This generator generates an AR class for the specified database table.</label><br/>
+ <label>Fields with <b style="color: red">*</b> are required.</label>
+ <hr/>
+ <div style="font-size: 12px; font-style: italic">
+ <ul>
+ <li>If you want to generate all AR Classes, keep the "Table Name" field as appears by default.</li>
+ <li>"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.</li>
+ </ul>
+ </div>
+ </div>
+
+ <div style="font-size: 14px">
<div class="form_row">
- <com:TLabel Text="Table Name:" ForControl="table_name" style="margin-right: 24px" />
- <com:TTextBox ID="table_name" Text="*" CssClass="in_text" />
- <com:TRequiredFieldValidator ControlToValidate="table_name" Text="Table name cannot be blank." Display="Dynamic" />
+ <com:TLabel Text="Table Name:" ForControl="table_name" style="margin-right: 24px" />
+ <com:TTextBox ID="table_name" Text="*" CssClass="in_text" />
+ <label style="color: red">*</label>
+ <com:TRequiredFieldValidator ControlToValidate="table_name" Text="Table name cannot be blank." Display="Dynamic" />
</div>
+
+ <div class="form_row">
+ <com:TLabel Text="Output Folder:" ForControl="output_folder" style="margin-right: 8px"/>
+ <com:TTextBox ID="output_folder" Text="Application.App_Data.AR_Classes" CssClass="in_text" />
+ <label style="color: red">*</label>
+ <com:TRequiredFieldValidator ControlToValidate="output_folder" Text="Output folder cannot be blank." Display="Dynamic" />
+ </div>
+
<div class="form_row">
<com:TLabel Text="Class Prefix:" ForControl="class_prefix" style="margin-right: 25px"/>
<com:TTextBox ID="class_prefix" Text="AR_" CssClass="in_text" />
</div>
+
<div class="form_row">
- <com:TLabel Text="Output Folder:" ForControl="output_folder" style="margin-right: 8px"/>
- <com:TTextBox ID="output_folder" Text="Application.App_Data.AR_Classes" CssClass="in_text" />
+ <com:TLabel Text="Class Sufix:" ForControl="class_sufix" style="margin-right: 27px"/>
+ <com:TTextBox ID="class_sufix" CssClass="in_text" />
</div>
-
+
<div class="form_row">
<com:TLabel Text="Build Relations:" ForControl="build_rel"/>
<com:TCheckBox ID="build_rel" Checked="true" />
</div>
-
- <com:TPanel ID="success_panel" Visible="false">
- <com:TLabel ID="generation_msg" />
+
+ <com:TPanel ID="feedback_panel" Visible="false" style="width: 400px">
+ <com:TLabel ID="generation_msg" />
</com:TPanel>
<br/>
- <div style="text-align: center">
+ <div style="text-align: center; width: 400px">
<com:TButton Text="Preview" OnClick="preview" Visible="false" />
<com:TButton Text="Generate" OnClick="generate" />
</div>
</div>
-
+
</com:TContent>
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 @@
<?php
/**
- * Description of Inicio
- *
- * @author daniels
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 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 @@
<com:TContent ID="Content">
- <label style="font-size: 18px; font-weight: bold">Welcome to Web Site Administration Tool</label>
-
+ <label style="font-size: 18px; font-weight: bold">Welcome to the Web Site Administration Tool</label>
+
<div style="margin-top: 25px"><b>Application Dir:</b> <%= Prado::getPathOfNamespace('Application') %></div>
+
+ <br/>
+ <table>
+ <tr style="background-color: #cccccc">
+ <td style="padding: 5px; width: 100px">
+ <com:THyperLink NavigateUrl="<%= $this->Service->constructUrl('TWsatGenerateAR') %>" Text="AR Classes" />
+ </td>
+ <td style="padding: 5px">
+ Enables you to generate all Active Record Classes with relations included.
+ </td>
+ </tr>
+ </table>
</com:TContent>
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 @@
-<?php
-
-/**
- * Description of Inicio
- *
- * @author daniels
- */
-Prado::using("System.Wsat.TWsatARGenerator");
-
-class TWsatHome extends TPage {
-
-
-}
-
+<?php
+
+/**
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 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 @@
<div class="login_form">
<com:TLabel Text="Please enter your password:" ForControl="password"/><br/>
<com:TTextBox ID="password" TextMode="Password" style="margin: 5px" /><br/>
- <com:TRequiredFieldValidator ControlToValidate="password" ValidationGroup="loginGroup" Text="Password cannot be blank." /><br/>
- <com:TCustomValidator ControlToValidate="password" ValidationGroup="loginGroup" OnServerValidate="validatePassword" Text="Incorrect password." />
-
- <com:TButton Text="Enter" ValidationGroup="loginGroup" OnClick="login" />
+ <com:TRequiredFieldValidator ControlToValidate="password" ValidationGroup="loginGroup" Text="Password cannot be blank." Display="Dynamic" /><br/>
+ <com:TCustomValidator ControlToValidate="password" ValidationGroup="loginGroup" OnServerValidate="validatePassword" Text="Incorrect password." Display="Dynamic" />
+
+ <div><com:TButton Text="Enter" ValidationGroup="loginGroup" OnClick="login" /></div>
</div>
<div id="footer">
diff --git a/framework/Wsat/pages/TWsatLogin.php b/framework/Wsat/pages/TWsatLogin.php
index 0bbdc53f..7c4570af 100644
--- a/framework/Wsat/pages/TWsatLogin.php
+++ b/framework/Wsat/pages/TWsatLogin.php
@@ -1,10 +1,15 @@
<?php
/**
- * Description of Inicio
- *
- * @author daniels
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2013 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat.pages
*/
+
class TWsatLogin extends TPage {
public function login() {
diff --git a/framework/Wsat/pages/TWsatScaffolding.php b/framework/Wsat/pages/TWsatScaffolding.php
index afa00273..2fc036ad 100644
--- a/framework/Wsat/pages/TWsatScaffolding.php
+++ b/framework/Wsat/pages/TWsatScaffolding.php
@@ -1,15 +1,20 @@
-<?php
-
-/**
- * Description of Inicio
- *
- * @author daniels
- */
-Prado::using("System.Wsat.TWsatARGenerator");
-
-class TWsatScaffolding extends TPage {
-
-
-}
-
+<?php
+
+/**
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2013 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat.pages
+ */
+
+Prado::using("System.Wsat.TWsatARGenerator");
+
+class TWsatScaffolding extends TPage {
+
+
+}
+
?> \ No newline at end of file
diff --git a/framework/Wsat/themes/PradoSoft/main.css b/framework/Wsat/themes/PradoSoft/main.css
index c35a87d8..9970c88b 100644
--- a/framework/Wsat/themes/PradoSoft/main.css
+++ b/framework/Wsat/themes/PradoSoft/main.css
@@ -58,6 +58,7 @@ html, body{
padding: 1em 1em 1em 1em;
line-height: 135%;
float: left;
+ width: 700px;
}
.topic {
@@ -123,7 +124,7 @@ html, body{
font-size: 11px;
}
-.success_panel{
+.green_panel{
background-color: #C5FBBD;
border: 1px solid #76C376;
padding: 10px;
@@ -132,7 +133,7 @@ html, body{
text-align: center;
}
-.exception_panel{
+.red_panel{
background-color: #ff6666;
border: 1px solid red;
padding: 10px;