summaryrefslogtreecommitdiff
path: root/framework/Wsat/TWsatService.php
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2014-08-23 13:08:33 +0200
committerFabio Bas <ctrlaltca@gmail.com>2014-08-23 13:08:33 +0200
commit0269aefc30d65ddb5d197bac7819feed5bf78de8 (patch)
tree785c3e8d7438e78fcca7bf2867620910515109b4 /framework/Wsat/TWsatService.php
parent8e4409a70876175ba8dc54e1a084c37a7861bfbf (diff)
Manually backported Wsat
Diffstat (limited to 'framework/Wsat/TWsatService.php')
-rw-r--r--framework/Wsat/TWsatService.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/framework/Wsat/TWsatService.php b/framework/Wsat/TWsatService.php
new file mode 100644
index 00000000..63bfebc7
--- /dev/null
+++ b/framework/Wsat/TWsatService.php
@@ -0,0 +1,81 @@
+<?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
+ */
+
+/**
+ * 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>
+ * <services>
+ * ...
+ * <service id="wsat" class="System.Wsat.TWsatService" Password="my_secret_password" />
+ * </services>
+ * </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
+{
+
+ 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/themes";
+
+ $themeManager->init(null);
+ $this->setThemeManager($themeManager);
+ }
+
+ public function getPassword()
+ {
+ return $this->_pass;
+ }
+
+ public function setPassword($_pass)
+ {
+ $this->_pass = $_pass;
+ }
+
+} \ No newline at end of file