summaryrefslogtreecommitdiff
path: root/framework/Wsat/TWsatScaffoldingGenerator.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Wsat/TWsatScaffoldingGenerator.php')
-rw-r--r--framework/Wsat/TWsatScaffoldingGenerator.php83
1 files changed, 77 insertions, 6 deletions
diff --git a/framework/Wsat/TWsatScaffoldingGenerator.php b/framework/Wsat/TWsatScaffoldingGenerator.php
index 7986793d..b1c54bc3 100644
--- a/framework/Wsat/TWsatScaffoldingGenerator.php
+++ b/framework/Wsat/TWsatScaffoldingGenerator.php
@@ -6,13 +6,25 @@
* @copyright Copyright © 2005-2014 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
- * @since 3.3
+ * @since 4.0
* @package Wsat
*/
Prado::using("System.Wsat.TWsatBaseGenerator");
class TWsatScaffoldingGenerator extends TWsatBaseGenerator
{
+ /**
+ * Const View Types for generation
+ */
+
+ const LIST_TYPE = 0;
+ const ADD_TYPE = 1;
+ const SHOW_TYPE = 2;
+
+ /**
+ * Bootstrap option
+ */
+ private $_bootstrap;
function __construct()
{
@@ -27,20 +39,79 @@ class TWsatScaffoldingGenerator extends TWsatBaseGenerator
file_put_contents($outputClass, $class);
$outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page";
- $page = $this->generatePage($unitName);
+ $page = $this->generatePage("student", self::ADD_TYPE);
file_put_contents($outputPage, $page);
}
- // <editor-fold defaultstate="collapsed" desc="Generate Sigle Page">
- private function generatePage($fileName, $tContentId = "Content")
+ // <editor-fold defaultstate="collapsed" desc="Page Generation">
+ private function generatePage($tableName, $type, $tContentId = "Content")
{
+ $pageContent = $this->getPageContent($tableName, $type);
return <<<EOD
-<com:TContent ID="Content">
-
+<com:TContent ID="$tContentId">
+
+ $pageContent
+
</com:TContent>
EOD;
}
+ private function getPageContent($tableName, $type)
+ {
+ $code = "";
+ $tableInfo = $this->_dbMetaData->getTableInfo($tableName);
+ switch ($type)
+ {
+ case self::LIST_TYPE:
+ break;
+ case self::ADD_TYPE:
+ foreach ($tableInfo->getColumns() as $colField => $colMetadata)
+ {
+ if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey)
+ {
+ $code .= $this->generateControl($colMetadata);
+ $code .= $this->generateValidators($colMetadata);
+ $code .= "\n";
+ }
+ }
+ foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata)
+ {
+ $colField = '"' . $colMetadata["table"] . '"';
+ $code .= "\t<com:TTextBox ID=$colField />\n";
+ $code .= "\n";
+ // TWsatBaseGenerator::pr($tableInfo);
+ }
+
+ case self::SHOW_TYPE:
+ break;
+ }
+ return $code;
+ }
+
+ private function generateControl($colMetadata)
+ {
+ $controlType = "TTextBox";
+ switch ($colMetadata->DbType){
+
+ }
+ $controlId = $colMetadata->ColumnId;
+ return "\t<com:$controlType ID=\"$controlId\" />\n";
+ }
+
+ private function generateValidators($colMetadata)
+ {
+ $controlId = $colMetadata->ColumnId;
+ $code = "";
+ if (!$colMetadata->AllowNull)
+ {
+ $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n";
+ }
+ return $code;
+ }
+
+// </editor-fold>
+ //---------------------------------------------------------------------
+ // <editor-fold defaultstate="collapsed" desc="Code Behind Generation">
private function generateClass($classname)
{
$date = date('Y-m-d h:i:s');