summaryrefslogtreecommitdiff
path: root/lib/prado/framework/Wsat/pages
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-02-24 23:18:07 +0100
committeremkael <emkael@tlen.pl>2016-02-24 23:18:07 +0100
commit6f7fdef0f500cd4bb540affd3bc1482243f337c1 (patch)
tree4853eecd0769a903e6130c1896e1d070848150dd /lib/prado/framework/Wsat/pages
parent61f2ea48a4e11cb5fb941b3783e19c9e9ef38a45 (diff)
* Prado 3.3.0
Diffstat (limited to 'lib/prado/framework/Wsat/pages')
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatGenerateAR.page56
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatGenerateAR.php57
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatHome.page27
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatHome.php17
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatLogin.page44
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatLogin.php32
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatScaffolding.page23
-rw-r--r--lib/prado/framework/Wsat/pages/TWsatScaffolding.php72
-rw-r--r--lib/prado/framework/Wsat/pages/config.xml9
-rw-r--r--lib/prado/framework/Wsat/pages/layout/TWsatLayout.php36
-rw-r--r--lib/prado/framework/Wsat/pages/layout/TWsatLayout.tpl54
11 files changed, 427 insertions, 0 deletions
diff --git a/lib/prado/framework/Wsat/pages/TWsatGenerateAR.page b/lib/prado/framework/Wsat/pages/TWsatGenerateAR.page
new file mode 100644
index 0000000..53ccc16
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatGenerateAR.page
@@ -0,0 +1,56 @@
+<com:TContent ID="Content">
+ <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 tool 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" />
+ <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="Class Suffix:" ForControl="class_suffix" style="margin-right: 27px"/>
+ <com:TTextBox ID="class_suffix" 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="feedback_panel" Visible="false" style="width: 400px">
+ <com:TLabel ID="generation_msg" />
+ </com:TPanel>
+
+ <br/>
+ <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/lib/prado/framework/Wsat/pages/TWsatGenerateAR.php b/lib/prado/framework/Wsat/pages/TWsatGenerateAR.php
new file mode 100644
index 0000000..1677a8e
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatGenerateAR.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat.pages
+ */
+Prado::using("System.Wsat.TWsatARGenerator");
+
+class TWsatGenerateAR extends TPage
+{
+
+ public function generate($sender)
+ {
+ if ($this->IsValid)
+ {
+ $tableName = $this->table_name->Text;
+ $outputFolderNs = $this->output_folder->Text;
+ $classPrefix = $this->class_prefix->Text;
+ $classSuffix = $this->class_suffix->Text;
+
+ try
+ {
+ $ar_generator = new TWsatARGenerator();
+ $ar_generator->setOpFile($outputFolderNs);
+ $ar_generator->setClasPrefix($classPrefix);
+ $ar_generator->setClassSufix($classSuffix);
+
+ if ($this->build_rel->Checked)
+ $ar_generator->buildRelations();
+
+ if ($tableName != "*")
+ $ar_generator->generate($tableName);
+ else
+ $ar_generator->generateAll();
+
+ $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;
+ }
+ }
+
+ public function preview($sender)
+ {
+ throw new THttpException(500, "Not implemented yet.");
+ }
+
+} \ No newline at end of file
diff --git a/lib/prado/framework/Wsat/pages/TWsatHome.page b/lib/prado/framework/Wsat/pages/TWsatHome.page
new file mode 100644
index 0000000..3083a39
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatHome.page
@@ -0,0 +1,27 @@
+<com:TContent ID="Content">
+ <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>
+ <!---
+ <tr style="background-color: #cccccc">
+ <td style="padding: 5px; width: 100px">
+ <com:THyperLink NavigateUrl="<%= $this->Service->constructUrl('TWsatScaffolding') %>" Text="Scaffolding" />
+ </td>
+ <td style="padding: 5px">
+ Enables you to generate a completed CRUD based in DB tables. It allow to choose bootstrap for the view generation.
+ </td>
+ </tr>
+ --->
+ </table>
+</com:TContent>
diff --git a/lib/prado/framework/Wsat/pages/TWsatHome.php b/lib/prado/framework/Wsat/pages/TWsatHome.php
new file mode 100644
index 0000000..6e1b72d
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatHome.php
@@ -0,0 +1,17 @@
+<?php
+
+/**
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @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/lib/prado/framework/Wsat/pages/TWsatLogin.page b/lib/prado/framework/Wsat/pages/TWsatLogin.page
new file mode 100644
index 0000000..6b9d845
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatLogin.page
@@ -0,0 +1,44 @@
+<%@ MasterClass="" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <com:THead Title="PRADO - WSAT">
+ <com:TMetaTag HttpEquiv="Content-Type" Content="text/html; charset=utf-8" />
+ <com:TMetaTag HttpEquiv="Content-Language" Content="en" />
+ </com:THead>
+
+ <body>
+ <com:TForm>
+
+ <div id="header">
+ <a href="<%= $this->Service->DefaultPageUrl %>">
+ <div class="logo"></div>
+ <div style="float: left; margin-top: 17px">PRADO <br /> Web Site Administration Tool</div>
+ </a>
+ <div class="mantisbg"></div>
+ <div style="clear: both"></div>
+ </div>
+
+ <div class="mainmenu">
+ <div style="float: right"><com:THyperLink NavigateUrl="https://github.com/pradosoft/prado" Text="Prado framework" Target="_blank" />&nbsp;|&nbsp;</div>
+ <div style="float: right"><com:THyperLink NavigateUrl="<%= $this->Service->DefaultPageUrl %>" Text="Web App" Target="_blank" />&nbsp;|&nbsp;</div>
+ <div style="clear: both"></div>
+ </div>
+
+ <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." 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">
+ Copyright &copy; 2005-<%= date('Y') %> <a href="https://github.com/pradosoft">The PRADO Group</a>.
+ <br/><br/>
+ <%= Prado::poweredByPrado() %>
+ </div>
+ </com:TForm>
+ </body>
+</html>
diff --git a/lib/prado/framework/Wsat/pages/TWsatLogin.php b/lib/prado/framework/Wsat/pages/TWsatLogin.php
new file mode 100644
index 0000000..cfd4d56
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatLogin.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat.pages
+ */
+class TWsatLogin extends TPage
+{
+
+ public function login()
+ {
+ if ($this->IsValid)
+ {
+ $this->Session["wsat_password"] = $this->getService()->getPassword();
+ $url = $this->Service->constructUrl('TWsatHome');
+ $this->Response->redirect($url);
+ }
+ }
+
+ public function validatePassword($sender, $param)
+ {
+ $config_pass = $this->Service->Password;
+ $user_pass = $this->password->Text;
+ $param->IsValid = $user_pass === $config_pass;
+ }
+
+} \ No newline at end of file
diff --git a/lib/prado/framework/Wsat/pages/TWsatScaffolding.page b/lib/prado/framework/Wsat/pages/TWsatScaffolding.page
new file mode 100644
index 0000000..f3e53df
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatScaffolding.page
@@ -0,0 +1,23 @@
+<com:TContent ID="Content">
+ <div class="section_title">Scaffolding Generator</div>
+
+ <div>
+ <com:TPanel ID="tableNames" GroupingText="Select tables to generate CRUD for:" Width="400px"/>
+ </div>
+
+ <div class="form_row">
+ <com:TLabel Text="Output Folder:" ForControl="output_folder" style="margin-right: 8px"/>
+ <com:TTextBox ID="output_folder" Text="Application.pages" CssClass="in_text" />
+ <label style="color: red">*</label>
+ <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" />
+ </div>
+</com:TContent>
diff --git a/lib/prado/framework/Wsat/pages/TWsatScaffolding.php b/lib/prado/framework/Wsat/pages/TWsatScaffolding.php
new file mode 100644
index 0000000..b480174
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/TWsatScaffolding.php
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat.pages
+ */
+Prado::using("System.Wsat.TWsatScaffoldingGenerator");
+
+class TWsatScaffolding extends TPage
+{
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $this->startVisual();
+ }
+
+ private function startVisual()
+ {
+ $scf_generator = new TWsatScaffoldingGenerator();
+ foreach ($scf_generator->getAllTableNames() as $tableName)
+ {
+ $dynChb = new TCheckBox();
+ $dynChb->ID = "cb_$tableName";
+ $dynChb->Text = ucfirst($tableName);
+ $dynChb->Checked = true;
+ $this->registerObject("cb_$tableName", $dynChb);
+ $this->tableNames->getControls()->add($dynChb);
+ $this->tableNames->getControls()->add("</br>");
+ }
+ }
+
+ /**
+ * Generate Scaffolding code for selected tables
+ * @param type $sender
+ */
+ public function generate($sender)
+ {
+ if ($this->IsValid)
+ {
+ try
+ {
+ $scf_generator = new TWsatScaffoldingGenerator();
+ $scf_generator->setOpFile($this->output_folder->Text);
+ foreach ($scf_generator->getAllTableNames() as $tableName)
+ {
+ $id = "cb_$tableName";
+ $obj = $this->tableNames->findControl($id);
+ if($obj!==null && $obj->Checked)
+ {
+ $scf_generator->generateCRUD($tableName);
+ }
+ }
+
+ $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
diff --git a/lib/prado/framework/Wsat/pages/config.xml b/lib/prado/framework/Wsat/pages/config.xml
new file mode 100644
index 0000000..727e8ea
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/config.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<configuration>
+ <modules>
+ <module id="session" class="THttpSession" CookieMode="Allow" UseCustomStorage="false"
+ AutoStart="true" GCProbability="1" UseTransparentSessionID="true" TimeOut="3600" />
+ </modules>
+ <pages Theme="PradoSoft" MasterClass="System.Wsat.pages.layout.TWsatLayout" />
+</configuration> \ No newline at end of file
diff --git a/lib/prado/framework/Wsat/pages/layout/TWsatLayout.php b/lib/prado/framework/Wsat/pages/layout/TWsatLayout.php
new file mode 100644
index 0000000..67caa77
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/layout/TWsatLayout.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * Description of MainLayout
+ *
+ * @author daniels
+ */
+class TWsatLayout extends TTemplateControl
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $this->validateSecurity();
+ }
+
+ private function validateSecurity()
+ {
+ if ($this->Session["wsat_password"] !== $this->getService()->getPassword())
+ {
+ if (!$this->getPage() instanceof TWsatLogin)
+ {
+ $url = $this->Service->constructUrl('TWsatLogin');
+ $this->Response->redirect($url);
+ }
+ }
+ }
+
+ public function logout()
+ {
+ $this->Session["wsat_password"] = "";
+ $url = $this->Service->constructUrl('TWsatLogin');
+ $this->Response->redirect($url);
+ }
+
+} \ No newline at end of file
diff --git a/lib/prado/framework/Wsat/pages/layout/TWsatLayout.tpl b/lib/prado/framework/Wsat/pages/layout/TWsatLayout.tpl
new file mode 100644
index 0000000..36ec5ba
--- /dev/null
+++ b/lib/prado/framework/Wsat/pages/layout/TWsatLayout.tpl
@@ -0,0 +1,54 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <com:THead Title="PRADO - WSAT">
+ <com:TMetaTag HttpEquiv="Content-Type" Content="text/html; charset=utf-8" />
+ <com:TMetaTag HttpEquiv="Content-Language" Content="en" />
+ </com:THead>
+
+ <body>
+ <com:TForm>
+
+ <div id="header">
+ <a href="<%= $this->Service->DefaultPageUrl %>">
+ <div class="logo"></div>
+ <div style="float: left; margin-top: 17px">PRADO <br /> Web Site Administration Tool</div>
+ </a>
+ <div class="mantisbg"></div>
+ <div style="clear: both"></div>
+ </div>
+
+ <div class="mainmenu">
+ <div style="float: right"><com:TLinkButton Text="Logout" OnClick="logout" /></div>
+ <div style="float: right"><com:THyperLink NavigateUrl="https://github.com/pradosoft/prado" Text="Prado framework" Target="_blank" />&nbsp;|&nbsp;</div>
+ <div style="float: right"><com:THyperLink NavigateUrl="<%= $this->Service->DefaultPageUrl %>" Text="Web App" Target="_blank" />&nbsp;|&nbsp;</div>
+ <div style="clear: both"></div>
+ </div>
+
+ <div id="central_div">
+ <div id="toc">
+ <div class="topic">
+ <div>Code Generation</div>
+ <ul>
+ <li><com:THyperLink NavigateUrl="<%= $this->Service->constructUrl('TWsatGenerateAR') %>" Text="AR Classes" /></li>
+ <!---
+ <li><com:THyperLink NavigateUrl="<%= $this->Service->constructUrl('TWsatScaffolding') %>" Text="Scaffolding" /></li>
+ --->
+ </ul>
+ </div>
+ </div>
+
+ <div id="content">
+ <com:TContentPlaceHolder ID="Content" />
+ </div>
+
+ <div style="clear: both"></div>
+ </div>
+
+ <div id="footer">
+ Copyright &copy; 2005-<%= date('Y') %> <a href="https://github.com/pradosoft">The PRADO Group</a>.
+ <br/><br/>
+ <%= Prado::poweredByPrado() %>
+ </div>
+ </com:TForm>
+ </body>
+</html> \ No newline at end of file