summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <darthdaniel85@gmail.com>2014-10-22 18:03:30 -0500
committerDaniel <darthdaniel85@gmail.com>2014-10-22 18:03:30 -0500
commitbd341e6469cbd49a35711b732386dc56a3c59ed0 (patch)
tree470dd452d5539e70c7d118587fd4b7701881097c
parent0cc7b59c95cb3bf5103450cf858f71fdb150458b (diff)
Scaffolding 5%
-rw-r--r--framework/Web/Javascripts/packages.php19
-rw-r--r--framework/Wsat/TWsatARGenerator.php85
-rw-r--r--framework/Wsat/TWsatBaseGenerator.php71
-rw-r--r--framework/Wsat/TWsatScaffoldingGenerator.php13
-rw-r--r--framework/Wsat/pages/TWsatGenerateAR.page2
-rw-r--r--framework/Wsat/pages/TWsatGenerateAR.php2
-rw-r--r--framework/Wsat/pages/TWsatScaffolding.page11
-rw-r--r--framework/Wsat/pages/TWsatScaffolding.php34
-rw-r--r--framework/Wsat/themes/PradoSoft/main.css6
9 files changed, 163 insertions, 80 deletions
diff --git a/framework/Web/Javascripts/packages.php b/framework/Web/Javascripts/packages.php
index ef1c14b6..61735847 100644
--- a/framework/Web/Javascripts/packages.php
+++ b/framework/Web/Javascripts/packages.php
@@ -5,7 +5,7 @@
// To make future upgrades easier
if (!defined('PROTOTYPE_DIR')) define ('PROTOTYPE_DIR', 'prototype-1.7');
if (!defined('JQUERY_DIR')) define ('JQUERY_DIR', 'jquery');
-if (!defined('BOOTSTRAP_DIR')) define ('BOOTSTRAP_DIR', 'bootstrap3/js');
+if (!defined('BOOTSTRAP_DIR')) define ('BOOTSTRAP_DIR', 'bootstrap3');
if (!defined('SCRIPTACULOUS_DIR')) define ('SCRIPTACULOUS_DIR', 'scriptaculous-1.9.0');
//package names and its contents (files relative to the current directory)
@@ -95,7 +95,7 @@ $packages = array(
//bootstrap
'bootstrap' => array(
- BOOTSTRAP_DIR.'/bootstrap.js'
+ BOOTSTRAP_DIR.'/js/bootstrap.js',
),
'dragdrop'=>array(
@@ -118,27 +118,28 @@ $packages = array(
$dependencies = array(
'jquery' => array('jquery'),
'prado' => array('jquery', 'prado'),
+ 'bootstrap' => array('jquery', 'bootstrap'),
'validator' => array('jquery', 'prado', 'validator'),
'tabpanel' => array('jquery', 'prado', 'tabpanel'),
'ajax' => array('jquery', 'prado', 'ajax'),
'logger' => array('jquery', 'prado', 'logger'),
- 'activefileupload' => array('jquery', 'prado', 'ajax', 'activefileupload'),
+ 'activefileupload' => array('jquery', 'prado', 'ajax', 'activefileupload'),
'effects' => array('jquery', 'jqueryui'),
- 'datepicker' => array('jquery', 'prado', 'datepicker'),
- 'activedatepicker' => array('jquery', 'prado', 'datepicker', 'ajax', 'activedatepicker'),
- 'colorpicker' => array('jquery', 'prado', 'colorpicker'),
+ 'datepicker' => array('jquery', 'prado', 'datepicker'),
+ 'activedatepicker' => array('jquery', 'prado', 'datepicker', 'ajax', 'activedatepicker'),
+ 'colorpicker' => array('jquery', 'prado', 'colorpicker'),
'htmlarea' => array('jquery', 'prado', 'htmlarea'),
'htmlarea4' => array('jquery', 'prado', 'htmlarea4'),
'keyboard' => array('jquery', 'prado', 'keyboard'),
'slider' => array('jquery', 'prado', 'slider'),
- 'inlineeditor' => array('jquery', 'prado', 'ajax', 'inlineeditor'),
+ 'inlineeditor' => array('jquery', 'prado', 'ajax', 'inlineeditor'),
'accordion' => array('jquery', 'prado', 'accordion'),
'ratings' => array('jquery', 'prado', 'ajax', 'ratings'),
'jqueryui' => array('jquery', 'jqueryui'),
'prototype' => array('prototype'),
'dragdrop' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop'),
- 'dragdropextra' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop','dragdropextra'),
- 'autocomplete' => array('prototype', 'jquery', 'prado', 'ajax', 'autocomplete'),
+ 'dragdropextra' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop','dragdropextra'),
+ 'autocomplete' => array('prototype', 'jquery', 'prado', 'ajax', 'autocomplete'),
);
return array($packages, $dependencies);
diff --git a/framework/Wsat/TWsatARGenerator.php b/framework/Wsat/TWsatARGenerator.php
index c6cef1d5..b05a6d96 100644
--- a/framework/Wsat/TWsatARGenerator.php
+++ b/framework/Wsat/TWsatARGenerator.php
@@ -9,24 +9,12 @@
* @since 3.3
* @package Wsat
*/
+Prado::using("System.Wsat.TWsatBaseGenerator");
-Prado::using('System.Data.Common.TDbMetaData');
-
-class TWsatARGenerator
+class TWsatARGenerator extends TWsatBaseGenerator
{
/**
- * @return TDbMetaData for retrieving metadata information, such as
- * table and columns information, from a database connection.
- */
- private $_dbMetaData;
-
- /**
- * Output folder where AR classes will be saved.
- */
- private $_opFile;
-
- /**
* Class name prefix
*/
private $_clasPrefix;
@@ -49,22 +37,7 @@ class TWsatARGenerator
function __construct()
{
- if(!class_exists("TActiveRecordManager", false))
- throw new Exception("You need to enable the ActiveRecord module in your application configuration file.");
- $ar_manager = TActiveRecordManager::getInstance();
- $_conn = $ar_manager->getDbConnection();
- $_conn->Active = true;
- $this->_dbMetaData = TDbMetaData::getInstance($_conn);
- }
-
- public function setOpFile($op_file_namespace)
- {
- $op_file = Prado::getPathOfNamespace($op_file_namespace);
- if (empty($op_file))
- throw new Exception("You need to fix your output folder namespace.");
- if (!is_dir($op_file))
- mkdir($op_file, 0777, true);
- $this->_opFile = $op_file;
+ parent::__construct();
}
public function setClasPrefix($_clas_prefix)
@@ -87,10 +60,8 @@ class TWsatARGenerator
public function generateAll()
{
- foreach ($this->_dbMetaData->findTableNames() as $tableName)
+ foreach ($this->getAllTableNames() as $tableName)
{
- if ($tableName == "pradocache")
- continue;
$tableInfo = $this->_dbMetaData->getTableInfo($tableName);
if (!empty($this->_relations))
{
@@ -105,7 +76,7 @@ class TWsatARGenerator
public function buildRelations()
{
$this->_relations = array();
- foreach ($this->_dbMetaData->findTableNames() as $table_name)
+ foreach ($this->getAllTableNames() as $table_name)
{
$tableInfo = $this->_dbMetaData->getTableInfo($table_name);
$pks = $tableInfo->getPrimaryKeys();
@@ -117,17 +88,17 @@ class TWsatARGenerator
$table_name_mm2 = $fks[1]["table"];
$this->_relations[$table_name_mm][] = array(
- "prop_name" => strtolower($table_name_mm2),
- "rel_type" => "self::MANY_TO_MANY",
- "ref_class_name" => $this->_getProperClassName($table_name_mm2),
- "prop_ref" => $table_name
+ "prop_name" => strtolower($table_name_mm2),
+ "rel_type" => "self::MANY_TO_MANY",
+ "ref_class_name" => $this->_getProperClassName($table_name_mm2),
+ "prop_ref" => $table_name
);
$this->_relations[$table_name_mm2][] = array(
- "prop_name" => strtolower($table_name_mm),
- "rel_type" => "self::MANY_TO_MANY",
- "ref_class_name" => $this->_getProperClassName($table_name_mm),
- "prop_ref" => $table_name
+ "prop_name" => strtolower($table_name_mm),
+ "rel_type" => "self::MANY_TO_MANY",
+ "ref_class_name" => $this->_getProperClassName($table_name_mm),
+ "prop_ref" => $table_name
);
continue;
}
@@ -138,17 +109,17 @@ class TWsatARGenerator
$fk_prop = key($fk_data["keys"]);
$this->_relations[$owner_table][] = array(
- "prop_name" => strtolower($slave_table),
- "rel_type" => "self::HAS_MANY",
- "ref_class_name" => $this->_getProperClassName($slave_table),
- "prop_ref" => $fk_prop
+ "prop_name" => strtolower($slave_table),
+ "rel_type" => "self::HAS_MANY",
+ "ref_class_name" => $this->_getProperClassName($slave_table),
+ "prop_ref" => $fk_prop
);
$this->_relations[$slave_table][] = array(
- "prop_name" => strtolower($owner_table),
- "rel_type" => "self::BELONGS_TO",
- "ref_class_name" => $this->_getProperClassName($owner_table),
- "prop_ref" => $fk_prop
+ "prop_name" => strtolower($owner_table),
+ "rel_type" => "self::BELONGS_TO",
+ "ref_class_name" => $this->_getProperClassName($owner_table),
+ "prop_ref" => $fk_prop
);
}
}
@@ -183,20 +154,6 @@ class TWsatARGenerator
return $this->_clasPrefix . $final_conversion . $this->_classSufix;
}
- public function renderAllTablesInformation()
- {
- foreach ($this->_dbMetaData->findTableNames() as $table_name)
- {
- echo $table_name . "<br>";
-
- $tableInfo = $this->_dbMetaData->getTableInfo($table_name);
- echo "Table info:" . "<br>";
- echo "<pre>";
- var_dump($tableInfo);
- echo "</pre>";
- }
- }
-
//-----------------------------------------------------------------------------
protected function generateProperty($field, $column)
diff --git a/framework/Wsat/TWsatBaseGenerator.php b/framework/Wsat/TWsatBaseGenerator.php
new file mode 100644
index 00000000..7f81f503
--- /dev/null
+++ b/framework/Wsat/TWsatBaseGenerator.php
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2014 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat
+ */
+Prado::using('System.Data.Common.TDbMetaData');
+
+class TWsatBaseGenerator
+{
+
+ /**
+ * @return TDbMetaData for retrieving metadata information, such as
+ * table and columns information, from a database connection.
+ */
+ protected $_dbMetaData;
+
+ /**
+ * Output folder where AR classes will be saved.
+ */
+ protected $_opFile;
+
+ function __construct()
+ {
+ if (!class_exists("TActiveRecordManager", false))
+ throw new Exception("You need to enable the ActiveRecord module in your application configuration file.");
+ $ar_manager = TActiveRecordManager::getInstance();
+ $_conn = $ar_manager->getDbConnection();
+ $_conn->Active = true;
+ $this->_dbMetaData = TDbMetaData::getInstance($_conn);
+ }
+
+ public function setOpFile($op_file_namespace)
+ {
+ $op_file = Prado::getPathOfNamespace($op_file_namespace);
+ if (empty($op_file))
+ throw new Exception("You need to fix your output folder namespace.");
+ if (!is_dir($op_file))
+ mkdir($op_file, 0777, true);
+ $this->_opFile = $op_file;
+ }
+
+ public function renderAllTablesInformation()
+ {
+ foreach ($this->getAllTableNames() as $table_name)
+ {
+ echo $table_name . "<br>";
+ $tableInfo = $this->_dbMetaData->getTableInfo($table_name);
+ echo "Table info:" . "<br>";
+ echo "<pre>";
+ print_r($tableInfo);
+ echo "</pre>";
+ }
+ }
+
+ public function getAllTableNames()
+ {
+ $tableNames = $this->_dbMetaData->findTableNames();
+ $index = array_search('pradocache', $tableNames);
+ array_splice($tableNames, $index, 1);
+ return $tableNames;
+ }
+
+}
+
+?>
diff --git a/framework/Wsat/TWsatScaffoldingGenerator.php b/framework/Wsat/TWsatScaffoldingGenerator.php
index 2c49d735..37b8ae00 100644
--- a/framework/Wsat/TWsatScaffoldingGenerator.php
+++ b/framework/Wsat/TWsatScaffoldingGenerator.php
@@ -9,10 +9,17 @@
* @since 3.3
* @package Wsat
*/
-
-class TWsatScaffoldingGenerator
+
+Prado::using("System.Wsat.TWsatBaseGenerator");
+
+class TWsatScaffoldingGenerator extends TWsatBaseGenerator
{
- //put your code here
+
+ function __construct()
+ {
+ parent::__construct();
+ }
+
}
?>
diff --git a/framework/Wsat/pages/TWsatGenerateAR.page b/framework/Wsat/pages/TWsatGenerateAR.page
index 926d6b0f..c41d03a5 100644
--- a/framework/Wsat/pages/TWsatGenerateAR.page
+++ b/framework/Wsat/pages/TWsatGenerateAR.page
@@ -1,5 +1,5 @@
<com:TContent ID="Content">
- <div style="margin: 10px; font-size: 16px; font-weight: bold">Active Record Classes Generator</div>
+ <div class="section_title">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>
diff --git a/framework/Wsat/pages/TWsatGenerateAR.php b/framework/Wsat/pages/TWsatGenerateAR.php
index 4a3714de..2e7bab06 100644
--- a/framework/Wsat/pages/TWsatGenerateAR.php
+++ b/framework/Wsat/pages/TWsatGenerateAR.php
@@ -51,7 +51,7 @@ class TWsatGenerateAR extends TPage
public function preview($sender)
{
-// throw new THttpException(500, "Not implemented yet.");
+ throw new THttpException(500, "Not implemented yet.");
}
} \ No newline at end of file
diff --git a/framework/Wsat/pages/TWsatScaffolding.page b/framework/Wsat/pages/TWsatScaffolding.page
index 42f78d09..bcf4d276 100644
--- a/framework/Wsat/pages/TWsatScaffolding.page
+++ b/framework/Wsat/pages/TWsatScaffolding.page
@@ -1,3 +1,12 @@
<com:TContent ID="Content">
- Scaffolding will be avaliable in Prado 3.4
+ <div class="section_title">Scaffolding Generator</div>
+
+ <div>
+ <com:TPanel ID="tableNames"/>
+ </div>
+
+ <div style="text-align: center; width: 400px">
+ <com:TButton Text="Preview" OnClick="preview" Visible="false" />
+ <com:TButton Text="Generate" OnClick="generate" />
+ </div>
</com:TContent>
diff --git a/framework/Wsat/pages/TWsatScaffolding.php b/framework/Wsat/pages/TWsatScaffolding.php
index fe691dd9..7352b2ae 100644
--- a/framework/Wsat/pages/TWsatScaffolding.php
+++ b/framework/Wsat/pages/TWsatScaffolding.php
@@ -9,9 +9,41 @@
* @since 3.3
* @package Wsat.pages
*/
-Prado::using("System.Wsat.TWsatARGenerator");
+Prado::using("System.Wsat.TWsatScaffoldingGenerator");
class TWsatScaffolding extends TPage
{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ if (!$this->IsPostBack)
+ {
+ $this->startVisual();
+ }
+ }
+
+ private function startVisual()
+ {
+ $scf_generator = new TWsatScaffoldingGenerator();
+ foreach ($scf_generator->getAllTableNames() as $tableName)
+ {
+ $dynChb = new TCheckBox();
+ $dynChb->ID = $tableName;
+ $dynChb->Text = ucfirst($tableName);
+ $dynChb->Checked = true;
+ $this->tableNames->getControls()->add($dynChb);
+
+ }
+ }
+
+ public function generate($sender)
+ {
+ if ($this->IsValid)
+ {
+ $scf_generator = new TWsatScaffoldingGenerator();
+ $scf_generator->renderAllTablesInformation();
+ }
+ }
+
} \ No newline at end of file
diff --git a/framework/Wsat/themes/PradoSoft/main.css b/framework/Wsat/themes/PradoSoft/main.css
index 9970c88b..d525f96a 100644
--- a/framework/Wsat/themes/PradoSoft/main.css
+++ b/framework/Wsat/themes/PradoSoft/main.css
@@ -149,4 +149,10 @@ html, body{
text-align:center;
margin-top:25px;
padding:10px;
+}
+
+.section_title {
+ margin: 10px;
+ font-size: 16px;
+ font-weight: bold
} \ No newline at end of file