Esempio n. 1
0
 /**
  * Execute the controller.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function execute()
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = $this->getApplication();
     // Check for request forgeries.
     JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
     // Get the setup model.
     $model = new InstallationModelSetup();
     // Get the options from the session
     $options = $model->getOptions();
     // Get the database model.
     $configuration = new InstallationModelConfiguration();
     // Attempt to setup the configuration.
     $return = $configuration->setup($options);
     $r = new stdClass();
     $r->view = 'complete';
     // Check if the database was initialised
     if (!$return) {
         $r->view = 'database';
     }
     $app->sendJsonResponse($r);
 }
 /**
  * Entry point for the script
  *
  * @return	void
  *
  * @since	 2.5
  */
 public function doExecute()
 {
     JFactory::getApplication('CliInstaller');
     // Parse options
     $options = $this->parseOptions();
     if (array_key_exists('help', $options)) {
         $this->displayUsage();
         $this->close(0);
     }
     $errors = $this->validateOptions($options);
     if (!empty($errors)) {
         foreach ($errors as $error) {
             $this->enqueueMessage($error, 'fatal');
         }
         $this->displayUsage();
         $this->close(1);
     }
     // Attempt to initialise the database.
     $db = new InstallationModelDatabase();
     if (!$db->createDatabase($options)) {
         $this->fatal("Error executing createDatabase");
     }
     // FIXME install model relies on session manipulation which doesn't work in cli
     $options['db_created'] = 1;
     $options['db_select'] = 1;
     if ($options['db_old'] == 'backup') {
         if (!$db->handleOldDatabase($options)) {
             $this->fatal("Error executing handleOldDatabase");
         }
     }
     if (!$db->createTables($options)) {
         $this->fatal("Error executing createTables");
     }
     // Attempt to setup the configuration.
     $configuration = new InstallationModelConfiguration();
     if (!$configuration->setup($options)) {
         $this->fatal("Error executing setup");
     }
     // Attempt to create the database tables.
     if ($options['sample_file']) {
         if (!$db->installSampleData($options)) {
             $this->fatal("Error executing installSampleData");
         }
     }
     $this->out('Done');
 }