Author: jablko
Date: Fri Oct  2 14:44:31 2009
New Revision: 3648

Log:
Move install forms to corresponding actions -- force

Deleted:
   trunk/plugins/sfInstallPlugin/lib/form/
Modified:
   
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureDatabaseAction.class.php
   
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureSiteAction.class.php
   
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/templates/configureDatabaseSuccess.php

Modified: 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureDatabaseAction.class.php
==============================================================================
--- 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureDatabaseAction.class.php
     Fri Oct  2 14:39:36 2009        (r3647)
+++ 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureDatabaseAction.class.php
     Fri Oct  2 14:44:31 2009        (r3648)
@@ -9,11 +9,60 @@
   public function execute($request)
   {
     $this->database = array();
-    $this->form = new sfInstallConfigureDatabaseForm;
+
+    // TODO: Can we avoid hardcoding the database name?
+    $database = $this->context->databaseManager->getDatabase('propel');
+
+    // TODO: This should be handled by sfPdoDatabase::parseDsn()
+    $pattern = '/([^=]*)=([^;]*);?/';
+    $subject = preg_replace('/[^:]*:/', null, $database->getParameter('dsn'));
+    if (false === preg_match_all($pattern, $subject, $matches))
+    {
+      // TODO: Error handling
+    }
+
+    $parameters = array_combine($matches[1], $matches[2]);
+
+    $this->form = new sfForm;
+
+    if (isset($parameters['host']))
+    {
+      $this->form->setDefault('databaseHost', $parameters['host']);
+    }
+
+    $this->form->setValidator('databaseHost', new 
sfValidatorString(array('required' => true)));
+    $this->form->setWidget('databaseHost', new sfWidgetFormInput);
+
+    if (isset($parameters['dbname']))
+    {
+      $this->form->setDefault('databaseName', $parameters['dbname']);
+    }
+
+    $this->form->setValidator('databaseName', new 
sfValidatorString(array('required' => true)));
+    $this->form->setWidget('databaseName', new sfWidgetFormInput);
+
+    $this->form->setDefault('databasePassword', 
$database->getParameter('password'));
+    $this->form->setValidator('databasePassword', new sfValidatorString);
+    $this->form->setWidget('databasePassword', new sfWidgetFormInputPassword);
+
+    if (isset($parameters['port']))
+    {
+      $this->form->setDefault('databasePort', $parameters['port']);
+    }
+
+    $this->form->setValidator('databasePort', new sfValidatorString);
+    $this->form->setWidget('databasePort', new sfWidgetFormInput);
+
+    $this->form->setDefault('databaseUsername', 
$database->getParameter('username'));
+    $this->form->setValidator('databaseUsername', new sfValidatorString);
+    $this->form->setWidget('databaseUsername', new sfWidgetFormInput);
+
+    $this->form->setValidator('tablePrefix', new sfValidatorString);
+    $this->form->setWidget('tablePrefix', new sfWidgetFormInput);
 
     if ($request->isMethod('post'))
     {
-      $this->form->bind($request->getParameter('configure'));
+      $this->form->bind($request->getPostParameters());
 
       if ($this->form->isValid())
       {

Modified: 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureSiteAction.class.php
==============================================================================
--- 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureSiteAction.class.php
 Fri Oct  2 14:39:36 2009        (r3647)
+++ 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/actions/configureSiteAction.class.php
 Fri Oct  2 14:44:31 2009        (r3648)
@@ -21,11 +21,31 @@
 {
   public function execute($request)
   {
-    $this->form = new sfInstallConfigureSiteForm;
+    $this->form = new sfForm;
+
+    $this->form->setValidator('confirmPassword', new 
sfValidatorString(array('required' => true)));
+    $this->form->setWidget('confirmPassword', new sfWidgetFormInputPassword);
+
+    $this->form->setValidator('email', new sfValidatorEmail(array('required' 
=> true)));
+    $this->form->setWidget('email', new sfWidgetFormInput);
+
+    $this->form->setValidator('password', new 
sfValidatorString(array('required' => true)));
+    $this->form->setWidget('password', new sfWidgetFormInputPassword);
+
+    $this->form->setValidator('siteDescription', new sfValidatorString);
+    $this->form->setWidget('siteDescription', new sfWidgetFormInput);
+
+    $this->form->setValidator('siteTitle', new 
sfValidatorString(array('required' => true)));
+    $this->form->setWidget('siteTitle', new sfWidgetFormInput);
+
+    $this->form->setValidator('username', new 
sfValidatorString(array('required' => true)));
+    $this->form->setWidget('username', new sfWidgetFormInput);
+
+    $this->form->getValidatorSchema()->setPostValidator(new 
sfValidatorSchemaCompare('password', '==', 'confirmPassword'));
 
     if ($request->isMethod('post'))
     {
-      $this->form->bind($request->getParameter('configure'));
+      $this->form->bind($request->getPostParameters());
 
       if ($this->form->isValid())
       {

Modified: 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/templates/configureDatabaseSuccess.php
==============================================================================
--- 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/templates/configureDatabaseSuccess.php
        Fri Oct  2 14:39:36 2009        (r3647)
+++ 
trunk/plugins/sfInstallPlugin/modules/sfInstallPlugin/templates/configureDatabaseSuccess.php
        Fri Oct  2 14:44:31 2009        (r3648)
@@ -20,7 +20,7 @@
         To set up your database, enter the following information.
       </p>
     </div>
-    <?php echo $form->databaseName->renderRow() ?>
+    <?php echo $form->databaseName->help('The name of the <em>MySQL</em> 
database your data will be stored in.  It must exist on your server before 
'.$sf_response->getTitle().' can be installed.')->renderRow() ?>
     <?php echo $form->databaseUsername->renderRow() ?>
     <?php echo $form->databasePassword->renderRow() ?>
   </fieldset>
@@ -32,9 +32,9 @@
         These options are only necessary for some sites.  If you're not sure 
what you should enter here, leave the default settings or check with your 
hosting provider.
       </p>
     </div>
-    <?php echo $form->databaseHost->renderRow() ?>
-    <?php echo $form->databasePort->renderRow() ?>
-    <?php echo $form->tablePrefix->renderRow() ?>
+    <?php echo $form->databaseHost->help('If your database is located on a 
different server, change this.')->renderRow() ?>
+    <?php echo $form->databasePort->help('If your database server is listening 
on a non-standard port, enter its number.')->renderRow() ?>
+    <?php echo $form->tablePrefix->help('If more than one application will be 
sharing this database, enter a table prefix such as 
<em>'.strtolower($sf_response->getTitle()).'_</em> for your site 
here.')->renderRow() ?>
   </fieldset>
 
   <input class="form-submit" type="submit" value="Save and continue"/>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to