Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#28003] Multidb install #122

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Add Multidb custom options
  • Loading branch information
elkuku committed Jan 13, 2012
commit 504efe9a82a81e3c2fe7d32452277902e346d28f
28 changes: 27 additions & 1 deletion installation/controllers/setup.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ public function database()

// Get the posted values from the request and validate them.
$data = JRequest::getVar('jform', array(), 'post', 'array');
$return = $model->validate($data, 'database');

$dbType = (isset($data['db_type'])) ? JFilterInput::getInstance()->clean($data['db_type'], 'cmd') : 'mysqli';
$dbType = ('mysqli' == $dbType) ? 'mysql' : $dbType;

$return = $model->validate($data, 'database_'.$dbType);

$r = new JObject();
// Check for validation errors.
Expand Down Expand Up @@ -156,6 +160,28 @@ public function database()
}
}

public function updateDbSettings()
{
// Check for a valid token. If invalid, send a 403 with the error message.
JRequest::checkToken('request') or $this->sendResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));

$model = $this->getModel('Setup', 'JInstallationModel', array('dbo' => null));

$view = $this->getView('Database', 'json');
$view->setModel($model, true);

ob_start();

$view->display();

// Create a response body.
$r = new JObject();
$r->form = ob_get_clean();

// Send the response.
$this->sendResponse($r);
}

/**
* @return void
* @since 1.7
Expand Down
1 change: 0 additions & 1 deletion installation/models/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

jimport('joomla.application.component.model');
jimport('joomla.filesystem.file');
require_once JPATH_INSTALLATION.'/helpers/database.php';

/**
* Database configuration model for the Joomla Core Installer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,45 @@

<field name="db_host" type="text" id="db_host" class="inputbox"
label="INSTL_DATABASE_HOST_LABEL"
description="INSTL_DATABASE_HOST_DESC"
default="localhost"
required="true"
/>
<field name="db_user" type="text" id="db_user" class="inputbox"
label="INSTL_DATABASE_USER_LABEL"
description="INSTL_DATABASE_USER_DESC"
required="true"
/>
<field name="db_pass" type="password" id="db_pass" class="inputbox"
label="INSTL_DATABASE_PASSWORD_LABEL"
description="INSTL_DATABASE_PASSWORD_DESC"
filter="raw"
/>
<field name="db_name" type="text" id="db_name" class="inputbox"
label="INSTL_DATABASE_NAME_LABEL"
description="INSTL_DATABASE_NAME_DESC"
required="true"
/>
</fieldset>

<!-- Advanced Settings -->
<fieldset name="advanced">
<field name="db_prefix" type="prefix" id="db_prefix" class="inputbox"
label="INSTL_DATABASE_PREFIX_LABEL"
required="true"
validate="prefix"
description="INSTL_DATABASE_PREFIX_DESC"
message="INSTL_DATABASE_PREFIX_MSG"
/>
<field name="db_old" type="radio" id="db_old" class="inputbox"
label="INSTL_DATABASE_OLD_PROCESS_LABEL"
default="backup"
description="INSTL_DATABASE_OLD_PROCESS_DESC"
required="true"
>
<option value="backup">INSTL_DATABASE_FIELD_VALUE_BACKUP</option>
<option value="remove">INSTL_DATABASE_FIELD_VALUE_REMOVE</option>
</field>
<field name="db_prefix" type="prefix" id="db_prefix" class="inputbox"
label="INSTL_DATABASE_PREFIX_LABEL"
required="true"
validate="prefix"
message="INSTL_DATABASE_PREFIX_MSG"
/>
</fieldset>
</fieldset>
</form>
53 changes: 43 additions & 10 deletions installation/template/js/installation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ var Installation = new Class({

this.pageInit();
},

pageInit: function() {
this.addToggler();
// Attach the validator
$$('form.form-validate').each(function(form){ this.attachToForm(form); }, document.formvalidator);

if (this.view == 'site' && this.sampleDataLoaded) {
var select = document.id('jform_sample_file');
var button = document.id('theDefault').children[0];
Expand All @@ -31,10 +31,10 @@ var Installation = new Class({
button.setAttribute('value', Locale.get('installation.sampleDataLoaded'));
}
},

submitform: function() {
var form = document.id('adminForm');

if (this.busy) {
return false;
}
Expand Down Expand Up @@ -73,7 +73,7 @@ var Installation = new Class({

return false;
},

goToPage: function(page, fromSubmit) {
var url = this.baseUrl+'?tmpl=body&view='+page;
var req = new Request.HTML({
Expand All @@ -100,7 +100,7 @@ var Installation = new Class({
active.removeClass('active');
var nextStep = document.id(page);
nextStep.addClass('active');
}.bind(this),
}.bind(this)
}).send();

return false;
Expand Down Expand Up @@ -229,7 +229,7 @@ var Installation = new Class({

/**
* Method to remove the installation Folder after a successful installation.
*/
*/
removeFolder: function(el) {
el = document.id(el);
var req = new Request.JSON({
Expand Down Expand Up @@ -270,8 +270,41 @@ var Installation = new Class({
}).send();
},

addToggler: function() {
new Accordion($$('h4.moofx-toggler'), $$('div.moofx-slider'), {
updateDbSettings: function(el) {
el = document.id(el);
var req = new Request.JSON({
method: 'get',
url: 'index.php?'+document.id(el.form).toQueryString(),
data: {'task':'setup.updateDbSettings', 'format':'json'},
onRequest: function() {
},
onComplete: function(r) {
if (r) {
Joomla.replaceTokens(r.token);
if (r.error == false) {
$(document.body).getElement('div.section-smenu').set('html', r.data.form);
} else {
document.id('theDefaultError').setStyle('display','block');
document.id('theDefaultErrorMessage').set('html', r.message);
}
} else {
document.id('theDefaultError').setStyle('display','block');
document.id('theDefaultErrorMessage').set('html', r.message );
}
},
onFailure: function(xhr) {
var r = JSON.decode(xhr.responseText);
if (r) {
Joomla.replaceTokens(r.token);
document.id('theDefaultError').setStyle('display','block');
document.id('theDefaultErrorMessage').set('html', r.message);
}
}
}).send();
},

addToggler: function() {
new Accordion($$('h4.moofx-toggler'), $$('div.moofx-slider'), {
onActive: function(toggler, i) {
toggler.addClass('moofx-toggler-down');
},
Expand All @@ -283,5 +316,5 @@ var Installation = new Class({
alwaysHide:true,
show: 1
});
},
}
});
108 changes: 16 additions & 92 deletions installation/views/database/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,105 +25,29 @@
<div class="m">
<h3><?php echo JText::_('INSTL_DATABASE_TITLE'); ?></h3>
<div class="install-text">
<?php echo JText::_('INSTL_DATABASE_DESC'); ?>
<?php echo JText::_('INSTL_DATABASE_DESC'); ?>
</div>
<div class="install-body">
<div class="m">
<h4 class="title-smenu" title="<?php echo JText::_('Basic'); ?>">
<?php echo JText::_('INSTL_BASIC_SETTINGS'); ?>
</h4>
<div class="section-smenu">
<table class="content2 db-table">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2">
<?php echo $this->form->getLabel('db_type'); ?>
<br />
<?php echo $this->form->getInput('db_type'); ?>
</td>
<td>
<em>
<table class="content2 db-table">
<tr>
<td>
<?php echo $this->form->getLabel('db_type'); ?>
<br />
<?php echo $this->form->getInput('db_type'); ?>
</td>
<td>
<em>
<?php echo JText::_('INSTL_DATABASE_TYPE_DESC'); ?>
</em>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $this->form->getLabel('db_host'); ?>
<br />
<?php echo $this->form->getInput('db_host'); ?>
</td>
<td>
<em>
<?php echo JText::_('INSTL_DATABASE_HOST_DESC'); ?>
</em>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $this->form->getLabel('db_user'); ?>
<br />
<?php echo $this->form->getInput('db_user'); ?>
</td>
<td>
<em>
<?php echo JText::_('INSTL_DATABASE_USER_DESC'); ?>
</em>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $this->form->getLabel('db_pass'); ?>
<br />
<?php echo $this->form->getInput('db_pass'); ?>
</td>
<td>
<em>
<?php echo JText::_('INSTL_DATABASE_PASSWORD_DESC'); ?>
</em>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $this->form->getLabel('db_name'); ?>
<br />
<?php echo $this->form->getInput('db_name'); ?>
</td>
<td>
<em>
<?php echo JText::_('INSTL_DATABASE_NAME_DESC'); ?>
</em>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $this->form->getLabel('db_prefix'); ?>
<br />
<?php echo $this->form->getInput('db_prefix'); ?>
</td>
<td>
<em>
<?php echo JText::_('INSTL_DATABASE_PREFIX_DESC'); ?>
</em>
</td>
</tr>
<tr>
<td colspan="2">
<?php echo $this->form->getLabel('db_old'); ?>
<br />
<?php echo $this->form->getInput('db_old'); ?>
</td>
<td>
<em>
<?php echo JText::_('INSTL_DATABASE_OLD_PROCESS_DESC'); ?>
</em>
</td>
</tr>
</table>
</em>
</td>
</tr>
</table>
<div class="section-smenu">
<?php echo $this->loadTemplate('form'); ?>
</div>
</div>
</div>
Expand Down
30 changes: 30 additions & 0 deletions installation/views/database/tmpl/default_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @package Joomla.Installation
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

$fields = $this->form->getFieldset();

unset($fields['jform_db_type']);

?>
<table class="content2 db-table">
<?php foreach ($fields as $field) : ?>
<tr>
<td>
<?php echo $field->label; ?>
<br/>
<?php echo $field->input; ?>
</td>
<td>
<em>
<?php echo JText::_($field->description); ?>
</em>
</td>
</tr>
<?php endforeach; ?>
</table>
12 changes: 12 additions & 0 deletions installation/views/database/tmpl/json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
/**
* @package Joomla.Installation
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

$this->setLayout('default');

echo $this->loadTemplate('form');
Loading