From 5632770c86d30361fe0c3eefc7d327786b478702 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 26 Nov 2013 11:34:52 +0100 Subject: Removed Wsat, will live in its own branch --- framework/Wsat/TWsatARGenerator.php | 232 --------------------- framework/Wsat/TWsatService.php | 62 ------ framework/Wsat/TWsatUserManager.php | 18 -- framework/Wsat/pages/TWsatGenerateAR.page | 33 --- framework/Wsat/pages/TWsatGenerateAR.php | 49 ----- framework/Wsat/pages/TWsatHome.page | 5 - framework/Wsat/pages/TWsatHome.php | 15 -- framework/Wsat/pages/TWsatLogin.page | 45 ---- framework/Wsat/pages/TWsatLogin.php | 30 --- framework/Wsat/pages/TWsatScaffolding.page | 3 - framework/Wsat/pages/TWsatScaffolding.php | 15 -- framework/Wsat/pages/config.xml | 5 - framework/Wsat/pages/layout/TWsatLayout.php | 32 --- framework/Wsat/pages/layout/TWsatLayout.tpl | 53 ----- framework/Wsat/themes/.htaccess | 1 - framework/Wsat/themes/PradoSoft/imgs/arrowdown.gif | Bin 836 -> 0 bytes framework/Wsat/themes/PradoSoft/imgs/mantisbg.jpg | Bin 4043 -> 0 bytes framework/Wsat/themes/PradoSoft/imgs/pradologo.gif | Bin 3039 -> 0 bytes framework/Wsat/themes/PradoSoft/main.css | 133 ------------ 19 files changed, 731 deletions(-) delete mode 100644 framework/Wsat/TWsatARGenerator.php delete mode 100644 framework/Wsat/TWsatService.php delete mode 100644 framework/Wsat/TWsatUserManager.php delete mode 100644 framework/Wsat/pages/TWsatGenerateAR.page delete mode 100644 framework/Wsat/pages/TWsatGenerateAR.php delete mode 100644 framework/Wsat/pages/TWsatHome.page delete mode 100644 framework/Wsat/pages/TWsatHome.php delete mode 100644 framework/Wsat/pages/TWsatLogin.page delete mode 100644 framework/Wsat/pages/TWsatLogin.php delete mode 100644 framework/Wsat/pages/TWsatScaffolding.page delete mode 100644 framework/Wsat/pages/TWsatScaffolding.php delete mode 100644 framework/Wsat/pages/config.xml delete mode 100644 framework/Wsat/pages/layout/TWsatLayout.php delete mode 100644 framework/Wsat/pages/layout/TWsatLayout.tpl delete mode 100644 framework/Wsat/themes/.htaccess delete mode 100644 framework/Wsat/themes/PradoSoft/imgs/arrowdown.gif delete mode 100644 framework/Wsat/themes/PradoSoft/imgs/mantisbg.jpg delete mode 100644 framework/Wsat/themes/PradoSoft/imgs/pradologo.gif delete mode 100644 framework/Wsat/themes/PradoSoft/main.css diff --git a/framework/Wsat/TWsatARGenerator.php b/framework/Wsat/TWsatARGenerator.php deleted file mode 100644 index 433e1640..00000000 --- a/framework/Wsat/TWsatARGenerator.php +++ /dev/null @@ -1,232 +0,0 @@ -_conn = $ar_manager->getDbConnection(); - $this->_conn->Active = true; - $this->_gateway = $ar_manager->getRecordGateway(); - } - - /** - * Destructor. - * Disconnect the db connection. - */ - public function __destruct() { - if ($this->_conn !== null) - $this->_conn->Active = false; - } - - 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->_op_file = $op_file; - } - - public function setClasPrefix($_clas_prefix) { - $this->_clas_prefix = $_clas_prefix; - } - -//----------------------------------------------------------------------------- - // - public function generate($tableName) { - $tableInfo = $this->_gateway->getTableInfo($this->_conn, $tableName); - if (count($tableInfo->getColumns()) === 0) { - throw new Exception("Unable to find table or view $tableName in " . $this->_conn->getConnectionString() . "."); - } else { - $properties = array(); - foreach ($tableInfo->getColumns() as $field => $column) - $properties[] = $this->generateProperty($field, $column); - $toString = $this->_buildSmartToString($tableInfo); - } - - $clasName = $this->_getProperClassName($tableName); - $class = $this->generateClass($properties, $tableName, $clasName, $toString); - $output = $this->_op_file . DIRECTORY_SEPARATOR . $clasName . ".php"; - file_put_contents($output, $class); - } - - public function generateAll() { - foreach ($this->_getAllTableNames() as $tableName) { - if ($tableName == "pradocache") { - continue; - } - $this->generate($tableName); - } - } - - public function buildRelations() { - $this->_relations = array(); - foreach ($this->_getAllTableNames() as $table_name) { - $tableInfo = $this->_gateway->getTableInfo($this->_conn, $table_name); - foreach ($tableInfo->getForeignKeys() as $fk_data) { - $owner_table = $fk_data["table"]; - $slave_table = $table_name; - $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 - ); - - $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 - ); - } - } - } - -// -//----------------------------------------------------------------------------- - // - - private function _getAllTableNames() { - $command = $this->_conn->createCommand("Show Tables"); - $dataReader = $command->query(); - $dataReader->bindColumn(1, $table); - $tables = array(); - while ($dataReader->read()) { - $tables[] = $table; - } - return $tables; - } - - 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; - } - - public function renderAllTablesInformation() { - foreach ($this->_getAllTableNames() as $table_name) { - echo $table_name . "
"; - - $tableInfo = $this->_gateway->getTableInfo($this->_conn, $table_name); - echo "Table info:" . "
"; - echo "
";
-            var_dump($tableInfo);
-            echo "
"; - } - } - -//----------------------------------------------------------------------------- - - protected function generateProperty($field, $column) { - $prop = ''; - $name = '$' . $field; - - /* TODO use in version 2.0 */ - // $type = $column->getPHPType(); - - $prop .= "\tpublic $name;"; - return $prop; - } - - private function _renderRelations($tablename) { - if (!isset($this->_relations[$tablename])) { - return ""; - } - $code = "\tpublic static \$RELATIONS = array ("; - foreach ($this->_relations[$tablename] as $rel_data) { - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; - } - $code = substr($code, 0, -1); - $code .= "\n\t);"; - return $code; - } - - private function _buildSmartToString($tableInfo) { - $code = "\tpublic function __toString() {"; - $property = "throw new THttpException(500, 'Not implemented yet.');"; - 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); - break; - } - } - } catch (Exception $ex) { - - } - $code .= "\n\t\treturn \$this->$property;"; - $code .= "\n\t}"; - return $code; - } - - protected function generateClass($properties, $tablename, $classname, $toString) { - $props = implode("\n", $properties); - $relations = $this->_renderRelations($tablename); - $date = date('Y-m-d h:i:s'); - return << -EOD; - } - -//
-} - -?> diff --git a/framework/Wsat/TWsatService.php b/framework/Wsat/TWsatService.php deleted file mode 100644 index 3af34d49..00000000 --- a/framework/Wsat/TWsatService.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * ... - * - * - * - * ...and then you need to go to http://localhost/yoursite/index.php?wsat=TWsatLogin - * and generate code and configure your site. - */ -class TWsatService extends TPageService { - - private $_pass = ''; - -//----------------------------------------------------------------------------- - public function init($config) { - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) { - throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); - } - if (empty($this->_pass)) { - throw new TConfigurationException("You need to specify the Password attribute."); - } - $this->setDefaultPage("TWsatHome"); - $this->_startThemeManager(); - parent::init($config); - } - - public function getBasePath() { - $basePath = Prado::getPathOfNamespace("System.Wsat.pages"); - return realpath($basePath); - } - - private function _startThemeManager() { - $themeManager = new TThemeManager; - $themeManager->BasePath = "System.Wsat.themes"; - $url = Prado::getApplication()->getAssetManager()->publishFilePath(Prado::getPathOfNamespace('System.Wsat')); - $themeManager->BaseUrl = $url . DIRECTORY_SEPARATOR . "themes"; - - $themeManager->init(null); - $this->setThemeManager($themeManager); - } - - public function getPassword() { - return $this->_pass; - } - - public function setPassword($_pass) { - $this->_pass = $_pass; - } - -} - -?> diff --git a/framework/Wsat/TWsatUserManager.php b/framework/Wsat/TWsatUserManager.php deleted file mode 100644 index 1dfd2288..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 deleted file mode 100644 index acd456fd..00000000 --- a/framework/Wsat/pages/TWsatGenerateAR.page +++ /dev/null @@ -1,33 +0,0 @@ - -
-
- - - -
-
- - -
-
- - -
- -
- - -
- - - - - -
-
- - -
-
- -
diff --git a/framework/Wsat/pages/TWsatGenerateAR.php b/framework/Wsat/pages/TWsatGenerateAR.php deleted file mode 100644 index 3d4291e2..00000000 --- a/framework/Wsat/pages/TWsatGenerateAR.php +++ /dev/null @@ -1,49 +0,0 @@ -IsValid) { - $table_name = $this->table_name->Text; - $class_prefix = $this->class_prefix->Text; - $output_folder_ns = $this->output_folder->Text; - - try { - $ar_generator = new TWsatARGenerator(); - $ar_generator->setOpFile($output_folder_ns); - $ar_generator->setClasPrefix($class_prefix); - - if ($this->build_rel->Checked) { - $ar_generator->buildRelations(); - } - if ($table_name != "*") { - $ar_generator->generate($table_name); - } else { - $ar_generator->generateAll(); - } - $this->success_panel->CssClass = "success_panel"; - $this->generation_msg->Text = "The code has been generated successfully."; - } catch (Exception $ex) { - $this->success_panel->CssClass = "exception_panel"; - $this->generation_msg->Text = $ex->getMessage(); - } - $this->success_panel->Visible = true; - } - } - - public function preview($sender) { -// $ar_generator = new TWsatARGenerator(); -// $ar_generator->renderAllTablesInformation(); - throw new THttpException(500, "Not implemented yet."); - } - -} - -?> \ No newline at end of file diff --git a/framework/Wsat/pages/TWsatHome.page b/framework/Wsat/pages/TWsatHome.page deleted file mode 100644 index 16aa3669..00000000 --- a/framework/Wsat/pages/TWsatHome.page +++ /dev/null @@ -1,5 +0,0 @@ - - - -
Application Dir: <%= Prado::getPathOfNamespace('Application') %>
-
diff --git a/framework/Wsat/pages/TWsatHome.php b/framework/Wsat/pages/TWsatHome.php deleted file mode 100644 index a7430911..00000000 --- a/framework/Wsat/pages/TWsatHome.php +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/framework/Wsat/pages/TWsatLogin.page b/framework/Wsat/pages/TWsatLogin.page deleted file mode 100644 index d0a94f2a..00000000 --- a/framework/Wsat/pages/TWsatLogin.page +++ /dev/null @@ -1,45 +0,0 @@ -<%@ MasterClass="" %> - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/Wsat/pages/TWsatLogin.php b/framework/Wsat/pages/TWsatLogin.php deleted file mode 100644 index 69f8cc39..00000000 --- a/framework/Wsat/pages/TWsatLogin.php +++ /dev/null @@ -1,30 +0,0 @@ -getService()->getPassword(); - $user_pass = $this->password->Text; - - if ($user_pass === $config_pass) { - $this->Session["wsat_password"] = $config_pass; - - $authManager = $this->Application->getModule('auth'); - $url = $authManager->ReturnUrl; - if (empty($url)) { - $url = $this->Service->constructUrl('TWsatHome'); - } - $this->Response->redirect($url); - } else { - echo "user or pass wrong"; - } - } - -} - -?> \ No newline at end of file diff --git a/framework/Wsat/pages/TWsatScaffolding.page b/framework/Wsat/pages/TWsatScaffolding.page deleted file mode 100644 index 42f78d09..00000000 --- a/framework/Wsat/pages/TWsatScaffolding.page +++ /dev/null @@ -1,3 +0,0 @@ - - Scaffolding will be avaliable in Prado 3.4 - diff --git a/framework/Wsat/pages/TWsatScaffolding.php b/framework/Wsat/pages/TWsatScaffolding.php deleted file mode 100644 index ce5860d3..00000000 --- a/framework/Wsat/pages/TWsatScaffolding.php +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/framework/Wsat/pages/config.xml b/framework/Wsat/pages/config.xml deleted file mode 100644 index 3ed8ea41..00000000 --- a/framework/Wsat/pages/config.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/framework/Wsat/pages/layout/TWsatLayout.php b/framework/Wsat/pages/layout/TWsatLayout.php deleted file mode 100644 index ce337265..00000000 --- a/framework/Wsat/pages/layout/TWsatLayout.php +++ /dev/null @@ -1,32 +0,0 @@ -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/framework/Wsat/pages/layout/TWsatLayout.tpl b/framework/Wsat/pages/layout/TWsatLayout.tpl deleted file mode 100644 index d91ff333..00000000 --- a/framework/Wsat/pages/layout/TWsatLayout.tpl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - -
-
-
-
Code Generation
-
    -
  • -
  • -
-
-
- -
- -
- -
-
- - -
- - \ No newline at end of file diff --git a/framework/Wsat/themes/.htaccess b/framework/Wsat/themes/.htaccess deleted file mode 100644 index f7661d04..00000000 --- a/framework/Wsat/themes/.htaccess +++ /dev/null @@ -1 +0,0 @@ -allow from all diff --git a/framework/Wsat/themes/PradoSoft/imgs/arrowdown.gif b/framework/Wsat/themes/PradoSoft/imgs/arrowdown.gif deleted file mode 100644 index 1b508cd6..00000000 Binary files a/framework/Wsat/themes/PradoSoft/imgs/arrowdown.gif and /dev/null differ diff --git a/framework/Wsat/themes/PradoSoft/imgs/mantisbg.jpg b/framework/Wsat/themes/PradoSoft/imgs/mantisbg.jpg deleted file mode 100644 index ee06998d..00000000 Binary files a/framework/Wsat/themes/PradoSoft/imgs/mantisbg.jpg and /dev/null differ diff --git a/framework/Wsat/themes/PradoSoft/imgs/pradologo.gif b/framework/Wsat/themes/PradoSoft/imgs/pradologo.gif deleted file mode 100644 index 3b073b80..00000000 Binary files a/framework/Wsat/themes/PradoSoft/imgs/pradologo.gif and /dev/null differ diff --git a/framework/Wsat/themes/PradoSoft/main.css b/framework/Wsat/themes/PradoSoft/main.css deleted file mode 100644 index ed36c238..00000000 --- a/framework/Wsat/themes/PradoSoft/main.css +++ /dev/null @@ -1,133 +0,0 @@ -html, body{ - margin: 0px; - padding: 0px; - font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif; - font-weight: normal; -} - -#header { - font-size:25px; - font-weight:bold; - color: #666; -} - -.logo{ - width: 204px; - height:100px; - background-image: url('imgs/pradologo.gif'); - background-repeat: no-repeat; - float: left; -} - -.mantisbg{ - width: 221px; - height: 100px; - background-image: url('imgs/mantisbg.jpg'); - background-repeat: no-repeat; - float: right; -} - -.mainmenu { - padding:10px; - padding-right:10px; - background:#EDEDED; - border-bottom: 1px solid #A6A6A6; - border-top: 1px solid #DCDCDC; - color:white; - text-align:right; - font-size: 10pt; -} - -.mainmenu a { - color:#737373; - text-decoration:none; -} - -.mainmenu a:hover { - color: #FF0000; -} - -#toc { - background-color: #F3F3F3; - width:220px; - padding:0px 10px 0px 10px; - float: left; -} - -#content { - padding: 1em 1em 1em 1em; - line-height: 135%; - float: left; -} - -.topic { - font-size: 9pt; - padding: 0px 0px 0px 0px; -} - -.topic div { - background-image: url('imgs/arrowdown.gif'); - background-repeat: no-repeat; - background-position: left center; - margin: 0px; - font-size: 8pt; - font-weight:bold; - color:#2A480A; - padding: 5px; - padding-left: 15px; - border-top: 1px solid #fff; - border-bottom: 1px solid #E2E2E2; -} - -.topic ul -{ - margin: 0px; - padding: 0px; -} - -.topic ul li -{ - list-style: none; - margin: 0px; - padding: 5px; - padding-left: 15px; - border-bottom: 1px dotted #D8D8D8; -} - -.topic a { - color:#4F811A; - font-size: 8pt; - text-decoration: none; -} - -.topic a:hover { - color:#2A480A; -} - -/* form styles */ -.form_row{ - margin: 10px; -} - -.in_text{ - width: 250px; -} - -.login_form{ - text-align: center; - margin: 30px auto; - border: 1px solid red; - border-radius: 5px; - padding: 10px; - width: 250px; - font-size: 11px; -} - -#footer { - clear:both; - color: gray; - font-size:8pt; - text-align:center; - margin-top:25px; - padding:10px; -} \ No newline at end of file -- cgit v1.2.3