/** * Method to render the view. * * @return string The rendered view. * * @since 3.1 */ public function render() { $this->options = $this->model->getOptions(); // Get the config string from the session. $this->config = JFactory::getSession()->get('setup.config', null); return parent::render(); }
/** * Method to get the field options. * * @return array The field option objects. * * @since 1.6 */ protected function getOptions() { $app = JFactory::getApplication(); // Detect the native language. $native = JLanguageHelper::detectLanguage(); if (empty($native)) { $native = 'en-GB'; } // Get a forced language if it exists. $forced = $app->getLocalise(); if (!empty($forced['language'])) { $native = $forced['language']; } // If a language is already set in the session, use this instead $model = new InstallationModelSetup(); $options = $model->getOptions(); if (isset($options['language'])) { $native = $options['language']; } // Get the list of available languages. $options = JLanguageHelper::createLanguageList($native); if (!$options || $options instanceof Exception) { $options = array(); } else { usort($options, array($this, '_sortLanguages')); } // Set the default value from the native language. $this->value = $native; // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to render the view. * * @return string The rendered view. * * @since 3.1 */ public function render() { $this->options = $this->model->getOptions(); /* * Prepare the tasks array * Note: The first character of the task *MUST* be capitalised or the application will not find the task */ $this->tasks[] = $this->options['db_old'] == 'remove' ? 'Database_remove' : 'Database_backup'; $this->tasks[] = 'Database'; if ($this->options['sample_file']) { $this->tasks[] = 'Sample'; } $this->tasks[] = 'Config'; if ($this->options['summary_email']) { $this->tasks[] = 'Email'; } return parent::render(); }
/** * 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. $db = new InstallationModelDatabase(); // Attempt to create the database tables. $return = $db->createTables($options); $r = new stdClass(); $r->view = 'install'; // Check if the database was initialised if (!$return) { $r->view = 'database'; } $app->sendJsonResponse($r); }
/** * 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(); $name = $options['admin_user']; $email = $options['admin_email']; $subject = JText::sprintf(JText::_('INSTL_EMAIL_SUBJECT'), $options['site_name']); // Prepare email body $body = array(); $body[] = JText::sprintf(JText::_('INSTL_EMAIL_HEADING'), $options['site_name']); $body[] = ''; $body[] = array(JText::_('INSTL_SITE_NAME_LABEL'), $options['site_name']); $body[] = $this->emailTitle(JText::_('INSTL_COMPLETE_ADMINISTRATION_LOGIN_DETAILS')); $body[] = array(JText::_('JEMAIL'), $options['admin_email']); $body[] = array(JText::_('JUSERNAME'), $options['admin_user']); if ($options['summary_email_passwords']) { $body[] = array(JText::_('INSTL_ADMIN_PASSWORD_LABEL'), $options['admin_password']); } $body[] = $this->emailTitle(JText::_('INSTL_DATABASE')); $body[] = array(JText::_('INSTL_DATABASE_TYPE_LABEL'), $options['db_type']); $body[] = array(JText::_('INSTL_DATABASE_HOST_LABEL'), $options['db_host']); $body[] = array(JText::_('INSTL_DATABASE_USER_LABEL'), $options['db_user']); if ($options['summary_email_passwords']) { $body[] = array(JText::_('INSTL_DATABASE_PASSWORD_LABEL'), $options['db_pass']); } $body[] = array(JText::_('INSTL_DATABASE_NAME_LABEL'), $options['db_name']); $body[] = array(JText::_('INSTL_DATABASE_PREFIX_LABEL'), $options['db_prefix']); if (isset($options['ftp_enable']) && $options['ftp_enable']) { $body[] = $this->emailTitle(JText::_('INSTL_FTP')); $body[] = array(JText::_('INSTL_FTP_USER_LABEL'), $options['ftp_user']); if ($options['summary_email_passwords']) { $body[] = array(JText::_('INSTL_FTP_PASSWORD_LABEL'), $options['ftp_pass']); } $body[] = array(JText::_('INSTL_FTP_HOST_LABEL'), $options['ftp_host']); $body[] = array(JText::_('INSTL_FTP_PORT_LABEL'), $options['ftp_port']); } $max = 0; foreach ($body as $line) { if (is_array($line)) { $max = max(array($max, strlen($line['0']))); } } foreach ($body as $i => $line) { if (is_array($line)) { $label = $line['0']; $label .= ': ' . str_repeat(' ', $max - strlen($label)); $body[$i] = $label . $line['1']; } } $body = implode("\r\n", $body); $mail = JFactory::getMailer(); $mail->addRecipient($email); $mail->addReplyTo($email, $name); $mail->setSender(array($email, $name)); $mail->setSubject($subject); $mail->setBody($body); $r = new stdClass(); $r->view = 'install'; try { $mail->Send(); } catch (Exception $e) { $app->enqueueMessage(JText::_('INSTL_EMAIL_NOT_SENT'), 'notice'); $r->view = 'complete'; } $app->sendJsonResponse($r); }
/** * Execute the controller. * * @return string The rendered view. * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Get the document object. $document = $app->getDocument(); // Set the default view name and format from the request. if (file_exists(JPATH_CONFIGURATION . '/configuration.php') && filesize(JPATH_CONFIGURATION . '/configuration.php') > 10 && file_exists(JPATH_INSTALLATION . '/index.php')) { $default_view = 'remove'; } else { $default_view = 'site'; } $vName = $this->input->getWord('view', $default_view); $vFormat = $document->getType(); $lName = $this->input->getWord('layout', 'default'); if (strcmp($vName, $default_view) == 0) { $this->input->set('view', $default_view); } switch ($vName) { case 'preinstall': $model = new InstallationModelSetup(); $sufficient = $model->getPhpOptionsSufficient(); $checkOptions = false; $options = $model->getOptions(); if ($sufficient) { $app->redirect('index.php'); } break; case 'languages': case 'defaultlanguage': $model = new InstallationModelLanguages(); $checkOptions = false; $options = array(); break; default: $model = new InstallationModelSetup(); $sufficient = $model->getPhpOptionsSufficient(); $checkOptions = true; $options = $model->getOptions(); if (!$sufficient) { $app->redirect('index.php?view=preinstall'); } break; } if ($vName != $default_view && ($checkOptions && empty($options))) { $this->setRedirect('index.php'); } // Include the component HTML helpers. JHtml::addIncludePath(JPATH_COMPONENT . '/helper/html'); // Register the layout paths for the view $paths = new SplPriorityQueue(); $paths->insert(JPATH_INSTALLATION . '/view/' . $vName . '/tmpl', 'normal'); $vClass = 'InstallationView' . ucfirst($vName) . ucfirst($vFormat); if (!class_exists($vClass)) { $vClass = 'InstallationViewDefault'; } /* @var JViewHtml $view */ $view = new $vClass($model, $paths); $view->setLayout($lName); // Render our view and return it to the application. return $view->render(); }