private function build_form() { $admin_user_lang = LangLoader::get('admin-user-common'); $this->form = new HTMLForm('websiteForm', '', false); $fieldset = new FormFieldsetHTML('yourSite', $this->lang['website.yours']); $this->form->add_fieldset($fieldset); $host = new FormFieldUrlEditor('host', $this->lang['website.host'], $this->current_server_host(), array('description' => $this->lang['website.host.explanation'], 'required' => $this->lang['website.host.required'])); $host->add_event('change', $this->warning_if_not_equals($host, $this->lang['website.host.warning'])); $fieldset->add_field($host); $path = new FormFieldTextEditor('path', $this->lang['website.path'], $this->current_server_path(), array('description' => $this->lang['website.path.explanation'])); $path->add_event('change', $this->warning_if_not_equals($path, $this->lang['website.path.warning'])); $fieldset->add_field($path); $fieldset->add_field(new FormFieldTextEditor('name', $this->lang['website.name'], '', array('required' => $this->lang['website.name.required']))); $fieldset->add_field(new FormFieldTextEditor('slogan', $this->lang['website.slogan'], '')); $fieldset->add_field(new FormFieldMultiLineTextEditor('description', $this->lang['website.description'], '', array('description' => $this->lang['website.description.explanation']))); $fieldset->add_field(new FormFieldTimezone('timezone', $this->lang['website.timezone'], 'Europe/Paris', array('description' => $this->lang['website.timezone.explanation']))); $fieldset = new FormFieldsetHTML('security_config', $admin_user_lang['members.config-security']); $this->form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldNumberEditor('internal_password_min_length', $admin_user_lang['security.config.internal-password-min-length'], $this->security_config->get_internal_password_min_length(), array('min' => 6, 'max' => 30), array(new FormFieldConstraintRegex('`^[0-9]+$`i'), new FormFieldConstraintIntegerRange(6, 30)))); $fieldset->add_field(new FormFieldSimpleSelectChoice('internal_password_strength', $admin_user_lang['security.config.internal-password-strength'], $this->security_config->get_internal_password_strength(), array(new FormFieldSelectChoiceOption($admin_user_lang['security.config.internal-password-strength.weak'], SecurityConfig::PASSWORD_STRENGTH_WEAK), new FormFieldSelectChoiceOption($admin_user_lang['security.config.internal-password-strength.medium'], SecurityConfig::PASSWORD_STRENGTH_MEDIUM), new FormFieldSelectChoiceOption($admin_user_lang['security.config.internal-password-strength.strong'], SecurityConfig::PASSWORD_STRENGTH_STRONG)))); $fieldset->add_field(new FormFieldCheckbox('login_and_email_forbidden_in_password', $admin_user_lang['security.config.login-and-email-forbidden-in-password'], $this->security_config->are_login_and_email_forbidden_in_password())); if ($this->server_configuration->has_curl_library()) { $fieldset = new FormFieldsetHTML('authentication_config', $admin_user_lang['members.config-authentication']); $this->form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldCheckbox('fb_auth_enabled', $admin_user_lang['authentication.config.fb-auth-enabled'], $this->authentication_config->is_fb_auth_enabled(), array('description' => $admin_user_lang['authentication.config.fb-auth-enabled-explain'], 'events' => array('click' => ' if (HTMLForms.getField("fb_auth_enabled").getValue()) { HTMLForms.getField("fb_app_id").enable(); HTMLForms.getField("fb_app_key").enable(); } else { HTMLForms.getField("fb_app_id").disable(); HTMLForms.getField("fb_app_key").disable(); }')))); $fieldset->add_field(new FormFieldTextEditor('fb_app_id', $admin_user_lang['authentication.config.fb-app-id'], $this->authentication_config->get_fb_app_id(), array('required' => true, 'hidden' => !$this->authentication_config->is_fb_auth_enabled()))); $fieldset->add_field(new FormFieldPasswordEditor('fb_app_key', $admin_user_lang['authentication.config.fb-app-key'], $this->authentication_config->get_fb_app_key(), array('required' => true, 'hidden' => !$this->authentication_config->is_fb_auth_enabled()))); $fieldset->add_field(new FormFieldCheckbox('google_auth_enabled', $admin_user_lang['authentication.config.google-auth-enabled'], $this->authentication_config->is_google_auth_enabled(), array('description' => $admin_user_lang['authentication.config.google-auth-enabled-explain'], 'events' => array('click' => ' if (HTMLForms.getField("google_auth_enabled").getValue()) { HTMLForms.getField("google_client_id").enable(); HTMLForms.getField("google_client_secret").enable(); } else { HTMLForms.getField("google_client_id").disable(); HTMLForms.getField("google_client_secret").disable(); }')))); $fieldset->add_field(new FormFieldTextEditor('google_client_id', $admin_user_lang['authentication.config.google-client-id'], $this->authentication_config->get_google_client_id(), array('required' => true, 'hidden' => !$this->authentication_config->is_google_auth_enabled()))); $fieldset->add_field(new FormFieldPasswordEditor('google_client_secret', $admin_user_lang['authentication.config.google-client-secret'], $this->authentication_config->get_google_client_secret(), array('required' => true, 'hidden' => !$this->authentication_config->is_google_auth_enabled()))); } $action_fieldset = new FormFieldsetSubmit('actions'); $back = new FormButtonLinkCssImg($this->lang['step.previous'], InstallUrlBuilder::database(), 'fa fa-arrow-left'); $action_fieldset->add_element($back); $this->submit_button = new FormButtonSubmitCssImg($this->lang['step.next'], 'fa fa-arrow-right', 'website'); $action_fieldset->add_element($this->submit_button); $this->form->add_fieldset($action_fieldset); }
/** * @desc Constructs a FormFieldUrlEditor. * @param string $id Field identifier * @param string $label Field label * @param string $value Default value * @param string[] $field_options Map containing the options * @param FormFieldConstraint[] $constraints The constraints checked during the validation */ public function __construct($id, $label, $value, $field_options = array(), array $constraints = array()) { $constraints[] = new FormFieldConstraintUrl(); $constraints[] = new FormFieldConstraintUrlExists(); parent::__construct($id, $label, $value, $field_options, $constraints); $this->set_css_form_field_class('form-field-url'); }
protected function compute_options(array &$field_options) { foreach ($field_options as $attribute => $value) { $attribute = strtolower($attribute); switch ($attribute) { case 'multiple': $this->multiple = (bool) $value; unset($field_options['multiple']); break; } } parent::compute_options($field_options); }
private function build_form() { $this->form = new HTMLForm('databaseForm', '', false); $fieldset_server = new FormFieldsetHTML('serverConfig', $this->lang['dbms.parameters']); $this->form->add_fieldset($fieldset_server); $host = new FormFieldTextEditor('host', $this->lang['dbms.host'], 'localhost', array('description' => $this->lang['dbms.host.explanation'], 'required' => $this->lang['db.required.host'])); $fieldset_server->add_field($host); $port = new FormFieldTextEditor('port', $this->lang['dbms.port'], '3306', array('description' => $this->lang['dbms.port.explanation'], 'required' => $this->lang['db.required.port'])); $port->add_constraint(new FormFieldConstraintIntegerRange(1, 65536)); $fieldset_server->add_field($port); $login = new FormFieldTextEditor('login', $this->lang['dbms.login'], 'root', array('description' => $this->lang['dbms.login.explanation'], 'required' => $this->lang['db.required.login'])); $fieldset_server->add_field($login); $password = new FormFieldPasswordEditor('password', $this->lang['dbms.password'], '', array('description' => $this->lang['dbms.password.explanation'])); $fieldset_server->add_field($password); $fieldset_schema = new FormFieldsetHTML('schemaConfig', $this->lang['schema.properties']); $this->form->add_fieldset($fieldset_schema); $schema = new FormFieldTextEditor('schema', $this->lang['schema'], '', array('description' => $this->lang['schema.explanation'], 'required' => $this->lang['db.required.schema']), array(new FormFieldConstraintRegex('`^[a-z0-9_-]+$`i'))); $schema->add_event('change', '$FFS(\'overwriteFieldset\').disable()'); $fieldset_schema->add_field($schema); $tables_prefix = new FormFieldTextEditor('tablesPrefix', $this->lang['schema.tablePrefix'], 'phpboost_', array('description' => $this->lang['schema.tablePrefix.explanation'], 'required' => true), array(new FormFieldConstraintRegex('`^[a-z0-9_]+$`i'))); $fieldset_schema->add_field($tables_prefix); $this->overwrite_fieldset = new FormFieldsetHTML('overwriteFieldset', $this->lang['phpboost.alreadyInstalled']); $this->form->add_fieldset($this->overwrite_fieldset); $overwrite_message = new FormFieldHTML('', $this->lang['phpboost.alreadyInstalled.explanation']); $this->overwrite_fieldset->add_field($overwrite_message); $this->overwrite_field = new FormFieldCheckbox('overwrite', $this->lang['phpboost.alreadyInstalled.overwrite'], false, array('required' => $this->lang['phpboost.alreadyInstalled.overwrite.confirm'])); $this->overwrite_fieldset->add_field($this->overwrite_field); $this->overwrite_fieldset->disable(); $action_fieldset = new FormFieldsetSubmit('actions'); $back = new FormButtonLinkCssImg($this->lang['step.previous'], InstallUrlBuilder::server_configuration(), 'fa fa-arrow-left'); $action_fieldset->add_element($back); $check = new FormButtonSubmitCssImg($this->lang['db.config.check'], 'fa fa-refresh', 'database'); $action_fieldset->add_element($check); $this->submit_button = new FormButtonSubmitCssImg($this->lang['step.next'], 'fa fa-arrow-right', 'database'); $action_fieldset->add_element($this->submit_button); $this->form->add_fieldset($action_fieldset); }
/** * @desc Constructs a FormFieldSearch. * @param string $id Field identifier * @param string $label Field label * @param string $value Default value * @param string[] $field_options Map containing the options * @param FormFieldConstraint[] $constraints The constraints checked during the validation */ public function __construct($id, $label, $value, $field_options = array(), array $constraints = array()) { $this->placeholder = LangLoader::get_message('search', 'main') . '...'; parent::__construct($id, $label, $value, $field_options, $constraints); }
protected function compute_options(array &$field_options) { foreach ($field_options as $attribute => $value) { $attribute = strtolower($attribute); switch ($attribute) { case 'method': $this->method = $value; unset($field_options['method']); break; case 'file': $this->file = $value; unset($field_options['file']); break; case 'name_parameter': $this->name_parameter = $value; unset($field_options['name_parameter']); break; } } parent::compute_options($field_options); }