Ejemplo n.º 1
0
 public function Step2()
 {
     Theme::Set('form_action', 'install.php');
     // Choice of new or existing database
     // Tabs
     $tabs = array();
     $tabs[] = FormManager::AddTab('new', __('Create a new database'));
     $tabs[] = FormManager::AddTab('existing', __('Use an existing database'));
     Theme::Set('form_tabs', $tabs);
     $formFields = array();
     // Set some defaults
     $this->db_create = $this->db_create == '' ? 1 : $this->db_create;
     $this->new_db_host = $this->new_db_host == '' ? 'localhost' : $this->new_db_host;
     $this->db_admin_user = $this->db_admin_user == '' ? 'root' : $this->db_admin_user;
     // New DB tab
     $formFields['new'][] = FormManager::AddHidden('step', 3);
     $formFields['new'][] = FormManager::AddMessage(sprintf(__("%s needs to set-up a connection to your MySQL database."), Theme::GetConfig('app_name')));
     $formFields['new'][] = FormManager::AddMessage(__('If you have not yet created an empty database and database user for Xibo to use, and know the user name / password of a MySQL administrator stay on this tab, otherwise click "Use Existing".'));
     $formFields['new'][] = FormManager::AddRadio('db_create', 'db_create1', __('Create a new database'), $this->db_create, 1, __('Select to create a new database'), 'c');
     $formFields['new'][] = FormManager::AddText('host', __('Host'), $this->new_db_host, __('Please enter the hostname for the MySQL server. This is usually localhost.'), 'h');
     $formFields['new'][] = FormManager::AddText('admin_username', __('Admin Username'), $this->db_admin_user, __('Please enter the user name of an account that has administrator privileges on the MySQL server.'), 'h');
     $formFields['new'][] = FormManager::AddPassword('admin_password', __('Admin Password'), $this->db_admin_pass, __('Please enter password for the Admin account.'), 'h');
     $formFields['new'][] = FormManager::AddText('db_name', __('Database Name'), $this->new_db_name, __('Please enter the name of the database that should be created.'), 'h');
     $formFields['new'][] = FormManager::AddText('db_username', __('Database Username'), $this->new_db_user, __('Please enter the name of the database user that should be created.'), 'h');
     $formFields['new'][] = FormManager::AddPassword('db_password', __('Database Password'), $this->new_db_pass, __('Please enter a password for this user.'), 'h');
     // Existing DB tab
     $formFields['existing'][] = FormManager::AddRadio('db_create', 'db_create2', __('Use an existing database'), $this->db_create, 2, __('Select to use an existing database. Please note that when you use an existing database it must be empty of all other contents.'), 'e');
     $formFields['existing'][] = FormManager::AddText('existing_host', __('Host'), $this->existing_db_host, __('Please enter the hostname for the MySQL server. This is usually localhost.'), 'h');
     $formFields['existing'][] = FormManager::AddText('existing_db_name', __('Database Name'), $this->existing_db_name, __('Please enter the name of the database that should be created.'), 'h');
     $formFields['existing'][] = FormManager::AddText('existing_db_username', __('Database Username'), $this->existing_db_user, __('Please enter the name of the database user that should be created.'), 'h');
     $formFields['existing'][] = FormManager::AddPassword('existing_db_password', __('Database Password'), $this->existing_db_pass, __('Please enter a password for this user.'), 'h');
     // Put up an error message if one has been set (and then unset it)
     if ($this->errorMessage != '') {
         Theme::Set('message', $this->errorMessage);
         Theme::Set('prepend', Theme::RenderReturn('message_box'));
         $this->errorMessage == '';
     }
     // Return a rendered form
     Theme::Set('form_fields_new', $formFields['new']);
     Theme::Set('form_fields_existing', $formFields['existing']);
     Theme::Set('form_buttons', array(FormManager::AddButton(__('Next'))));
     return Theme::RenderReturn('form_render');
 }