- md5
- 722d831ed4e86c7d4bbb7b97c93f5971
- sha1
- ec1d610970d59e22478672cceeb9bdc46cdf0d2b
- sha256
- 13ab7b4b8fc507bbb0cfd7bb17a1ca237dbdaa8a93f6ef9f0af2327d08a1e852
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
<?php
/**
* @package Joomla.Installation
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Setup controller for the Joomla Core Installer.
*
* @package Joomla.Installation
* @since 1.6
*/
class JInstallationControllerSetup extends JControllerLegacy
{
/**
* Method to set the setup language for the application.
*
* @return void
* @since 1.6
*/
public function setlanguage()
{
// Get the application object.
$app = JFactory::getApplication();
// Check for potentially unwritable session
$session = JFactory::getSession();
if ($session->isNew()) {
JError::setErrorHandling(E_ERROR, 'message');
JError::raise(E_ERROR, 500, JText::_('INSTL_COOKIES_NOT_ENABLED'));
return false;
}
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the setup model.
$model = $this->getModel('Setup', 'JInstallationModel', array('dbo' => null));
// Get the posted values from the request and validate them.
$data = JRequest::getVar('jform', array(), 'post', 'array');
$return = $model->validate($data, 'language');
// Check for validation errors.
if ($return === false) {
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
} else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Redirect back to the language selection screen.
$this->setRedirect('index.php?view=language');
return false;
}
// Store the options in the session.
$vars = $model->storeOptions($return);
// Redirect to the next page.
$this->setRedirect('index.php?view=preinstall');
}
/**
* @since 1.6
*/
function database()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the application object.
$app = JFactory::getApplication();
// Get the setup model.
$model = $this->getModel('Setup', 'JInstallationModel', array('dbo' => null));
// Get the posted values from the request and validate them.
$data = JRequest::getVar('jform', array(), 'post', 'array');
$return = $model->validate($data, 'database');
// Check for validation errors.
if ($return === false) {
// Store the options in the session.
$vars = $model->storeOptions($data);
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
} else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Redirect back to the database selection screen.
$this->setRedirect('index.php?view=database');
return false;
}
// Store the options in the session.
$vars = $model->storeOptions($return);
// Get the database model.
$database = $this->getModel('Database', 'JInstallationModel', array('dbo' => null));
// Attempt to initialise the database.
$return = $database->initialise($vars);
// Check if the databasa was initialised
if (!$return) {
$this->setMessage($database->getError(), 'notice');
$this->setRedirect('index.php?view=database');
} else {
// Mark sample content as not installed yet
$data = array(
'sample_installed' => '0'
);
$dummy = $model->storeOptions($data);
$this->setRedirect('index.php?view=filesystem');
}
}
/**
* @since 1.6
*/
function filesystem()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the application object.
$app = JFactory::getApplication();
// Get the setup model.
$model = $this->getModel('Setup', 'JInstallationModel', array('dbo' => null));
// Get the posted values from the request and validate them.
$data = JRequest::getVar('jform', array(), 'post', 'array');
$return = $model->validate($data, 'filesystem');
// Check for validation errors.
if ($return === false) {
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
} else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Redirect back to the database selection screen.
$this->setRedirect('index.php?view=filesystem');
return false;
}
// Store the options in the session.
$vars = $model->storeOptions($return);
$this->setRedirect('index.php?view=site');
}
/**
* @since 1.6
*/
function saveconfig()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the application object.
$app = JFactory::getApplication();
// Get the setup model.
$model = $this->getModel('Setup', 'JInstallationModel', array('dbo' => null));
// Get the posted values from the request and validate them.
$data = JRequest::getVar('jform', array(), 'post', 'array');
$return = $model->validate($data, 'site');
// Attempt to save the data before validation
$form = $model->getForm();
$data = $form->filter($data);
unset($data['admin_password2']);
$model->storeOptions($data);
// Check for validation errors.
if ($return === false) {
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
} else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Redirect back to the database selection screen.
$this->setRedirect('index.php?view=site');
return false;
}
// Store the options in the session.
unset($return['admin_password2']);
$vars = $model->storeOptions($return);
// Get the configuration model.
$configuration = $this->getModel('Configuration', 'JInstallationModel', array('dbo' => null));
// Attempt to setup the configuration.
$return = $configuration->setup($vars);
// Ensure a language was set.
if (!$return) {
$this->setMessage($configuration->getError(), 'notice');
$this->setRedirect('index.php?view=site');
} else {
$this->setRedirect('index.php?view=complete');
}
}
}
The same content is in 11 releases, Joomla 2.5.18 to 2.5.28. See them all, or every version of this file.