- md5
- cae958bdc77483eee0f3f4af738be2e4
- sha1
- 472be11e1acb68dd7be17c774c4025351eafd02d
- sha256
- f021e17347d496baeb58b8097374ce0b1a616ec0c5ecb4554b1bcca0e0c910ab
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
<?php
/**
* @package Joomla.Installation
* @subpackage Controller
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Installation\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Utilities\ArrayHelper;
/**
* Default controller class for the Joomla Installer.
*
* @since 3.1
*/
class InstallationController extends JSONController
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The JApplication for the dispatcher
* @param \JInput $input Input
*
* @since 3.0
*/
public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);
$this->registerTask('remove', 'backup');
}
/**
* Database check task.
*
* @return void
*
* @since 4.0.0
*/
public function dbcheck()
{
$this->checkValidToken();
// Redirect to the page.
$r = new \stdClass;
$r->view = 'setup';
// Check the form
/** @var \Joomla\CMS\Installation\Model\SetupModel $model */
$model = $this->getModel('Setup');
if ($model->checkForm('setup') === false || $model->validateDbConnection() === false)
{
$r->messages = Text::_('INSTL_DATABASE_VALIDATION_ERROR');
$r->view = 'setup';
}
$this->sendJsonResponse($r);
}
/**
* Config task.
*
* @return void
*
* @since 4.0.0
*/
public function config()
{
$this->checkValidToken();
// Get the options from the session
$options = $this->getModel('Setup')->getOptions();
$r = new \stdClass;
$r->view = 'remove';
// Attempt to setup the configuration.
if (!$this->getModel('Configuration')->setup($options))
{
$r->view = 'setup';
}
$this->sendJsonResponse($r);
}
/**
* Database task.
*
* @return void
*
* @since 4.0.0
*/
public function database()
{
$this->checkValidToken();
/** @var \Joomla\CMS\Installation\Model\SetupModel $model */
$model = $this->getModel('Setup');
$model->checkForm('setup');
$r = new \stdClass;
// Attempt to create the database tables
/** @var \Joomla\CMS\Installation\Model\DatabaseModel $dbModel */
$dbModel = $this->getModel('Database');
if (!$dbModel->initialise() || !$dbModel->installCmsData())
{
$r->view = 'database';
}
$this->sendJsonResponse($r);
}
/**
* Backup task.
*
* @return void
*
* @since 4.0.0
*/
public function backup()
{
$this->checkValidToken();
$r = new \stdClass;
$r->view = 'install';
/** @var \Joomla\CMS\Installation\Model\DatabaseModel $model */
$model = $this->getModel('Database');
// Attempt to handle the old database.
if (!$model->handleOldDatabase())
{
$r->view = 'database';
}
$this->sendJsonResponse($r);
}
/**
* Languages task.
*
* @return void
*
* @since 4.0.0
*/
public function languages()
{
$this->checkValidToken();
// Get array of selected languages
$lids = $this->input->get('cid', [], 'array');
$lids = ArrayHelper::toInteger($lids, []);
if (!$lids)
{
// No languages have been selected
$this->app->enqueueMessage(\JText::_('INSTL_LANGUAGES_NO_LANGUAGE_SELECTED'), 'warning');
}
else
{
// Get the languages model.
/** @var \Joomla\CMS\Installation\Model\LanguagesModel $model */
$model = $this->getModel('Languages');
// Install selected languages
$model->install($lids);
// Publish the Content Languages.
$model->publishContentLanguages();
$this->app->enqueueMessage(\JText::_('INSTL_LANGUAGES_MORE_LANGUAGES'), 'notice');
}
// Redirect to the page.
$r = new \stdClass;
$r->view = 'remove';
$this->sendJsonResponse($r);
}
/**
* Languages task.
*
* @return void
*
* @since 4.0.0
*/
public function sample()
{
$this->checkValidToken();
$r = new \stdClass;
$r->view = 'remove';
/** @var \Joomla\CMS\Installation\Model\DatabaseModel $model */
$model = $this->getModel('Database');
// Check if the database was initialised
if (!$model->installSampleData())
{
$r->view = 'remove';
}
$this->sendJsonResponse($r);
}
/**
* Delete installation folder task.
*
* @return void
*
* @since 4.0.0
*/
public function delete()
{
$this->checkValidToken();
/** @var \Joomla\CMS\Installation\Model\CleanupModel $model */
$model = $this->getModel('Cleanup');
$success = $model->deleteInstallationFolder();
// If an error was encountered return an error.
if (!$success)
{
$this->app->enqueueMessage(\JText::sprintf('INSTL_COMPLETE_ERROR_FOLDER_DELETE', 'installation'), 'warning');
}
$r = new \stdClass;
$r->view = 'remove';
$this->sendJsonResponse($r);
}
}
No other release has this exact content. See every version of this file.