private function build_form() { $security_config = SecurityConfig::load(); $this->form = new HTMLForm('adminForm', '', false); $fieldset = new FormFieldsetHTML('adminAccount', $this->lang['admin.account']); $this->form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldTextEditor('display_name', LangLoader::get_message('display_name', 'user-common'), '', array('maxlength' => 100, 'required' => true, 'events' => array('blur' => ' if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") { HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\')); HTMLForms.getField("login").enableValidationMessage(); HTMLForms.getField("login").liveValidate(); }')), array(new FormFieldConstraintLengthRange(3, 100, $this->lang['admin.login.length'])))); $fieldset->add_field(new FormFieldMailEditor('email', $this->lang['admin.email'], '', array('required' => true))); $fieldset->add_field(new FormFieldCheckbox('custom_login', LangLoader::get_message('login.custom', 'user-common'), false, array('description' => LangLoader::get_message('login.custom.explain', 'user-common'), 'events' => array('click' => ' if (HTMLForms.getField("custom_login").getValue()) { HTMLForms.getField("login").enable(); } else { HTMLForms.getField("login").disable(); }')))); $fieldset->add_field(new FormFieldTextEditor('login', LangLoader::get_message('login', 'user-common'), '', array('required' => true, 'hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists()))); $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['admin.password'], '', array('description' => StringVars::replace_vars($this->lang['admin.password.explanation'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length(), StringVars::replace_vars($this->lang['admin.password.length'], array('number' => $security_config->get_internal_password_min_length()))), new FormFieldConstraintPasswordStrength()))); $fieldset->add_field($repeatPassword = new FormFieldPasswordEditor('repeatPassword', $this->lang['admin.password.repeat'], '', array('required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $this->form->add_constraint(new FormConstraintFieldsEquality($password, $repeatPassword)); $fieldset->add_field(new FormFieldCheckbox('createSession', $this->lang['admin.connectAfterInstall'], true)); $fieldset->add_field(new FormFieldCheckbox('autoconnect', $this->lang['admin.autoconnect'], true)); $action_fieldset = new FormFieldsetSubmit('actions'); $back = new FormButtonLinkCssImg($this->lang['step.previous'], InstallUrlBuilder::website(), 'fa fa-arrow-left'); $action_fieldset->add_element($back); $this->submit_button = new FormButtonSubmitCssImg($this->lang['step.next'], 'fa fa-arrow-right', 'admin'); $action_fieldset->add_element($this->submit_button); $this->form->add_fieldset($action_fieldset); }
private function build_form(HTTPRequestCustom $request) { $security_config = SecurityConfig::load(); $form = new HTMLForm(__CLASS__); $fieldset = new FormFieldsetHTML('add_member', LangLoader::get_message('members.add-member', 'admin-user-common')); $form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], '', array('maxlength' => 100, 'required' => true, 'events' => array('blur' => ' if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") { HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\')); HTMLForms.getField("login").enableValidationMessage(); HTMLForms.getField("login").liveValidate(); }')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists()))); $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], '', array('required' => true), array(new FormFieldConstraintMailExist()))); $fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], false, array('events' => array('click' => ' if (HTMLForms.getField("custom_login").getValue()) { HTMLForms.getField("login").enable(); } else { HTMLForms.getField("login").disable(); }')))); $fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], '', array('required' => true, 'hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists()))); $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis)); if ($security_config->are_login_and_email_forbidden_in_password()) { $form->add_constraint(new FormConstraintFieldsInequality($email, $password)); $form->add_constraint(new FormConstraintFieldsInequality($login, $password)); } $fieldset->add_field(new FormFieldRanksSelect('rank', $this->lang['rank'], FormFieldRanksSelect::MEMBER)); $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer())); $this->submit_button = new FormButtonDefaultSubmit(); $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis)); $form->add_button($this->submit_button); $form->add_button(new FormButtonReset()); $this->form = $form; }
private function init() { $this->lang = LangLoader::get('admin-user-common'); $this->user_account_config = UserAccountsConfig::load(); $this->security_config = SecurityConfig::load(); $this->authentication_config = AuthenticationConfig::load(); $this->server_configuration = new ServerConfiguration(); }
private function build_form() { $security_config = SecurityConfig::load(); $form = new HTMLForm(__CLASS__); $this->member_extended_fields_service = new MemberExtendedFieldsService($form); $fieldset = new FormFieldsetHTML('registration', $this->lang['registration']); $form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldHTML('validation_method', $this->get_accounts_validation_method_explain())); $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], '', array('maxlength' => 100, 'required' => true, 'description' => $this->lang['display_name.explain'], 'events' => array('blur' => ' if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") { HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\')); HTMLForms.getField("login").enableValidationMessage(); HTMLForms.getField("login").liveValidate(); }')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists()))); $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], '', array('required' => true), array(new FormFieldConstraintMailExist()))); $fieldset->add_field(new FormFieldCheckbox('user_hide_mail', $this->lang['email.hide'], FormFieldCheckbox::CHECKED)); $fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], false, array('description' => $this->lang['login.custom.explain'], 'events' => array('click' => ' if (HTMLForms.getField("custom_login").getValue()) { HTMLForms.getField("login").enable(); } else { HTMLForms.getField("login").disable(); }')))); $fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], '', array('hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists()))); $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis)); if ($security_config->are_login_and_email_forbidden_in_password()) { $form->add_constraint(new FormConstraintFieldsInequality($email, $password)); $form->add_constraint(new FormConstraintFieldsInequality($login, $password)); } $options_fieldset = new FormFieldsetHTML('options', LangLoader::get_message('options', 'main')); $form->add_fieldset($options_fieldset); $options_fieldset->add_field(new FormFieldTimezone('timezone', $this->lang['timezone.choice'], GeneralConfig::load()->get_site_timezone(), array('description' => $this->lang['timezone.choice.explain']))); if (count(ThemesManager::get_activated_and_authorized_themes_map()) > 1) { $options_fieldset->add_field(new FormFieldThemesSelect('theme', $this->lang['theme'], $this->user_accounts_config->get_default_theme(), array('check_authorizations' => true, 'events' => array('change' => $this->build_javascript_picture_themes())))); $options_fieldset->add_field(new FormFieldFree('preview_theme', $this->lang['theme.preview'], '<img id="img_theme" src="' . $this->get_picture_theme() . '" title="' . $this->lang['theme.preview'] . '" alt="' . $this->lang['theme.preview'] . '" class="preview-img" />')); } $options_fieldset->add_field(new FormFieldEditors('text-editor', $this->lang['text-editor'], ContentFormattingConfig::load()->get_default_editor())); $options_fieldset->add_field(new FormFieldLangsSelect('lang', $this->lang['lang'], $this->user_accounts_config->get_default_lang(), array('check_authorizations' => true))); $this->member_extended_fields_service->display_form_fields(); $agreement_text = FormatingHelper::second_parse($this->user_accounts_config->get_registration_agreement()); if (!empty($agreement_text)) { $agreement_fieldset = new FormFieldsetHTML('agreement_fieldset', $this->lang['agreement']); $form->add_fieldset($agreement_fieldset); $agreement = new FormFieldHTML('agreement.required', $this->lang['agreement.agree.required'] . '<br /><br />'); $agreement_fieldset->add_field($agreement); $agreement = new FormFieldHTML('agreement', '<div id="id-message-helper" class="notice user-agreement">' . $agreement_text . '</div>'); $agreement_fieldset->add_field($agreement); $agreement_fieldset->add_field(new FormFieldCheckbox('agree', $this->lang['agreement.agree'], FormFieldCheckbox::UNCHECKED, array('required' => $this->lang['agreement.agree.required']))); } $this->submit_button = new FormButtonDefaultSubmit(); $form->add_button($this->submit_button); $form->add_button(new FormButtonReset()); $this->form = $form; }
private function build_form() { $security_config = SecurityConfig::load(); $form = new HTMLForm(__CLASS__); $fieldset = new FormFieldsetHTML('fieldset', $this->lang['change-password']); $form->add_fieldset($fieldset); $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password.new'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $this->submit_button = new FormButtonDefaultSubmit(); $form->add_button($this->submit_button); $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis)); $this->form = $form; }
public function __construct($error_message = '') { switch (SecurityConfig::load()->get_internal_password_strength()) { case SecurityConfig::PASSWORD_STRENGTH_STRONG: $regex = self::$strong_strength_regex; $error_message = empty($error_message) ? LangLoader::get_message('form.doesnt_match_strong_password_regex', 'status-messages-common') : $error_message; break; case SecurityConfig::PASSWORD_STRENGTH_MEDIUM: $regex = self::$medium_strength_regex; $error_message = empty($error_message) ? LangLoader::get_message('form.doesnt_match_medium_password_regex', 'status-messages-common') : $error_message; break; default: $regex = self::$weak_strength_regex; break; } $this->set_validation_error_message($error_message); parent::__construct($regex, $regex, $error_message); }
private function init() { $this->security_config = SecurityConfig::load(); $this->authentication_config = AuthenticationConfig::load(); $this->server_configuration = new ServerConfiguration(); }
public static function get_advises(HTMLForm $html_form) { $lang = LangLoader::get('admin-server-common'); $server_configuration = new ServerConfiguration(); $maintenance_config = MaintenanceConfig::load(); $general_config = GeneralConfig::load(); $server_environment_config = ServerEnvironmentConfig::load(); $security_config = SecurityConfig::load(); $url_rewriting_available = false; try { $url_rewriting_available = $server_configuration->has_url_rewriting(); } catch (UnsupportedOperationException $ex) { } $fieldset = new FormFieldsetHTML('advises', $lang['advises']); $fieldset->add_field(new FormFieldFree('modules_management', '', MessageHelper::display($lang['advises.modules_management'], MessageHelper::SUCCESS)->render())); if ($maintenance_config->is_under_maintenance()) { $fieldset->add_field(new FormFieldFree('check_modules_authorizations', '', MessageHelper::display($lang['advises.check_modules_authorizations'], MessageHelper::SUCCESS)->render())); } if (!strstr($general_config->get_site_url(), 'localhost') && !strstr($general_config->get_site_url(), '127.0.0.1') && !$maintenance_config->is_under_maintenance() && Debug::is_debug_mode_enabled()) { $fieldset->add_field(new FormFieldFree('disable_debug_mode', '', MessageHelper::display($lang['advises.disable_debug_mode'], MessageHelper::WARNING)->render())); } if ($url_rewriting_available && !$server_environment_config->is_url_rewriting_enabled()) { $fieldset->add_field(new FormFieldFree('enable_url_rewriting', '', MessageHelper::display($lang['advises.enable_url_rewriting'], MessageHelper::NOTICE)->render())); } if (function_exists('ob_gzhandler') && @extension_loaded('zlib') && !$server_environment_config->is_output_gziping_enabled()) { $fieldset->add_field(new FormFieldFree('enable_output_gz', '', MessageHelper::display($lang['advises.enable_output_gz'], MessageHelper::NOTICE)->render())); } if (DataStoreFactory::is_apc_available() && !DataStoreFactory::is_apc_enabled()) { $fieldset->add_field(new FormFieldFree('enable_apcu_cache', '', MessageHelper::display($lang['advises.enable_apcu_cache'], MessageHelper::NOTICE)->render())); } $fieldset->add_field(new FormFieldFree('save_database', '', MessageHelper::display($lang['advises.save_database'], MessageHelper::SUCCESS)->render())); if (!DatabaseConfig::load()->is_database_tables_optimization_enabled()) { $fieldset->add_field(new FormFieldFree('optimize_database_tables', '', MessageHelper::display($lang['advises.optimize_database_tables'], MessageHelper::SUCCESS)->render())); } if ($security_config->get_internal_password_min_length() == 6 && $security_config->get_internal_password_strength() == SecurityConfig::PASSWORD_STRENGTH_WEAK && !$security_config->are_login_and_email_forbidden_in_password()) { $fieldset->add_field(new FormFieldFree('password_security', '', MessageHelper::display($lang['advises.password_security'], MessageHelper::NOTICE)->render())); } if (ServerConfiguration::get_phpversion() < '5.6') { $fieldset->add_field(new FormFieldFree('upgrade_php_version', '', MessageHelper::display($lang['advises.upgrade_php_version'], MessageHelper::NOTICE)->render())); } if (count($fieldset->get_fields())) { $html_form->add_fieldset($fieldset); } }
private function build_form() { $security_config = SecurityConfig::load(); $form = new HTMLForm('sandboxForm'); // FIELDSET $fieldset = new FormFieldsetHTML('fieldset_1', 'Fieldset'); $form->add_fieldset($fieldset); $fieldset->set_description('Ceci est ma description'); // SINGLE LINE TEXT $fieldset->add_field(new FormFieldTextEditor('text', 'Champ texte', 'toto', array('maxlength' => 25, 'description' => 'Contraintes lettres, chiffres et tiret bas'), array(new FormFieldConstraintRegex('`^[a-z0-9_ ]+$`i')))); $fieldset->add_field(new FormFieldTextEditor('textdisabled', 'Champ désactivé', '', array('maxlength' => 25, 'description' => 'désactivé', 'disabled' => true))); $fieldset->add_field(new FormFieldUrlEditor('siteweb', 'Site web', 'http://www.phpboost.com/index.php', array('description' => 'Url valide'))); $fieldset->add_field(new FormFieldMailEditor('mail', 'Mail', '*****@*****.**', array('description' => 'Mail valide'))); $fieldset->add_field(new FormFieldMailEditor('mail_multiple', 'Mail multiple', 'team.hein@phpboost.com, test@phpboost.com', array('description' => 'Mails valides, séparés par une virgule', 'multiple' => true))); $fieldset->add_field(new FormFieldTelEditor('tel', 'Numéro de téléphone', '0123456789', array('description' => 'Numéro de téléphone valide'))); $fieldset->add_field(new FormFieldTextEditor('text2', 'Champ texte2', 'toto2', array('maxlength' => 25, 'description' => 'Champs requis rempli', 'required' => true))); $fieldset->add_field(new FormFieldTextEditor('text3', 'Champ requis', '', array('maxlength' => 25, 'description' => 'Champs requis vide', 'required' => true))); $fieldset->add_field(new FormFieldNumberEditor('number', 'Nombre requis', 20, array('min' => 0, 'max' => 1000, 'description' => 'Intervalle 0 à 1000', 'required' => true), array(new FormFieldConstraintIntegerRange(0, 1000)))); $fieldset->add_field(new FormFieldNumberEditor('age', 'Age', 20, array('min' => 10, 'max' => 100, 'description' => 'Intervalle 10 à 100'), array(new FormFieldConstraintIntegerRange(10, 100)))); $fieldset->add_field(new FormFieldDecimalNumberEditor('decimal', 'Nombre décimal', 5.5, array('min' => 0, 'step' => 0.1))); // RANGE $fieldset->add_field($password = new FormFieldRangeEditor('range', 'Longueur', 4, array('min' => 1, 'max' => 10, 'description' => 'Slider horizontal'))); // PASSWORD $fieldset->add_field($password = new FormFieldPasswordEditor('password', 'Mot de passe', 'aaaaaa', array('description' => 'Minimum ' . $security_config->get_internal_password_min_length() . ' caractères'), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length())))); $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', 'Confirmation du mot de passe', 'aaaaaa', array('description' => 'Minimum ' . $security_config->get_internal_password_min_length() . ' caractères'), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length())))); // SHORT MULTI LINE TEXT $fieldset->add_field(new FormFieldShortMultiLineTextEditor('short_multi_line_text', 'Champ texte multi lignes moyen', 'titi', array('rows' => 7, 'required' => true))); // MULTI LINE TEXT $fieldset->add_field(new FormFieldMultiLineTextEditor('multi_line_text', 'Champ texte multi lignes', 'toto', array('rows' => 6, 'cols' => 47, 'description' => 'Description', 'required' => true))); // RICH TEXT $fieldset->add_field(new FormFieldRichTextEditor('rich_text', 'Champ texte riche dans éditeur', 'toto <strong>tata</strong>', array('required' => true))); //Checkbox $fieldset->add_field(new FormFieldMultipleCheckbox('multiple_check_box', 'Plusieurs checkbox', array(), array(new FormFieldMultipleCheckboxOption('meet', 'la viande'), new FormFieldMultipleCheckboxOption('fish', 'le poisson')), array('required' => true))); // RADIO $default_option = new FormFieldRadioChoiceOption('Choix 1', '1'); $fieldset->add_field(new FormFieldRadioChoice('radio', 'Choix énumération', '', array($default_option, new FormFieldRadioChoiceOption('Choix 2', '2')), array('required' => true))); // CHECKBOX $fieldset->add_field(new FormFieldCheckbox('checkbox', 'Case à cocher', FormFieldCheckbox::CHECKED)); // SELECT $fieldset->add_field(new FormFieldSimpleSelectChoice('select', 'Liste déroulante', '', array(new FormFieldSelectChoiceOption('', ''), new FormFieldSelectChoiceOption('Choix 1', '1'), new FormFieldSelectChoiceOption('Choix 2', '2'), new FormFieldSelectChoiceOption('Choix 3', '3'), new FormFieldSelectChoiceGroupOption('Groupe 1', array(new FormFieldSelectChoiceOption('Choix 4', '4'), new FormFieldSelectChoiceOption('Choix 5', '5'))), new FormFieldSelectChoiceGroupOption('Groupe 2', array(new FormFieldSelectChoiceOption('Choix 6', '6'), new FormFieldSelectChoiceOption('Choix 7', '7')))), array('required' => true))); // SELECT MULTIPLE $fieldset->add_field(new FormFieldMultipleSelectChoice('multiple_select', 'Liste déroulante multiple', array('1', '2'), array(new FormFieldSelectChoiceOption('Choix 1', '1'), new FormFieldSelectChoiceOption('Choix 2', '2'), new FormFieldSelectChoiceOption('Choix 3', '3')), array('required' => true))); $fieldset->add_field(new FormFieldTimezone('timezone', 'TimeZone', 'UTC+0')); $fieldset->add_field(new FormFieldAjaxSearchUserAutoComplete('user_completition', 'Auto complétion utilisateurs', '')); $fieldset->add_element(new FormButtonButton('Envoyer')); $fieldset2 = new FormFieldsetHTML('fieldset2', 'Fieldset 2'); $form->add_fieldset($fieldset2); // CAPTCHA $fieldset2->add_field(new FormFieldCaptcha('captcha')); // HIDDEN $fieldset2->add_field(new FormFieldHidden('hidden', 'hidden')); // FREE FIELD $fieldset2->add_field(new FormFieldFree('free', 'Champ libre', 'Valeur champ libre', array())); // DATE $fieldset2->add_field(new FormFieldDate('date', 'Date', null, array('required' => true))); // DATE TIME $fieldset2->add_field(new FormFieldDateTime('date_time', 'Heure', null, array('required' => true))); // COLOR PICKER $fieldset2->add_field(new FormFieldColorPicker('color', 'Couleur', '#CC99FF')); // SEARCH $fieldset2->add_field(new FormFieldSearch('search', 'Recherche', '')); // FILE PICKER $fieldset2->add_field(new FormFieldFilePicker('file', 'Fichier')); // MULTIPLE FILE PICKER $fieldset2->add_field(new FormFieldMultipleFilePicker('multiple_files', 'Plusieurs Fichiers')); // UPLOAD FILE $fieldset2->add_field(new FormFieldUploadFile('upload_file', 'Lien vers un fichier', '', array('required' => true))); // UPLOAD PICTURE FILE $fieldset2->add_field(new FormFieldUploadPictureFile('upload_picture_file', 'Lien vers une image', '', array('required' => true))); // AUTH $fieldset3 = new FormFieldsetHTML('fieldset3', 'Autorisations'); $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization('Action 1', 1, 'Autorisations pour l\'action 1'), new ActionAuthorization('Action 2', 2))); $auth_settings->build_from_auth_array(array('r1' => 3, 'r0' => 2, 'm1' => 1, '1' => 2)); $auth_setter = new FormFieldAuthorizationsSetter('auth', $auth_settings); $fieldset3->add_field($auth_setter); $form->add_fieldset($fieldset3); // VERTICAL FIELDSET $vertical_fieldset = new FormFieldsetVertical('fieldset4'); $vertical_fieldset->set_description('Ceci est ma description'); $form->add_fieldset($vertical_fieldset); $vertical_fieldset->add_field(new FormFieldTextEditor('alone', 'Texte', 'fieldset séparé')); $vertical_fieldset->add_field(new FormFieldCheckbox('cbhor', 'A cocher', FormFieldCheckbox::UNCHECKED)); // HORIZONTAL FIELDSET $horizontal_fieldset = new FormFieldsetHorizontal('fieldset5'); $horizontal_fieldset->set_description('Ceci est ma description'); $form->add_fieldset($horizontal_fieldset); $horizontal_fieldset->add_field(new FormFieldTextEditor('texthor', 'Texte', 'fieldset séparé', array('required' => true))); $horizontal_fieldset->add_field(new FormFieldCheckbox('cbvert', 'A cocher', FormFieldCheckbox::CHECKED)); // BUTTONS $buttons_fieldset = new FormFieldsetSubmit('buttons'); $buttons_fieldset->add_element(new FormButtonReset()); $this->preview_button = new FormButtonSubmit('Prévisualiser', 'preview', 'alert("Voulez-vous vraiment prévisualiser ?")'); $buttons_fieldset->add_element($this->preview_button); $this->submit_button = new FormButtonDefaultSubmit(); $buttons_fieldset->add_element($this->submit_button); $buttons_fieldset->add_element(new FormButtonButton('Bouton', 'alert("coucou");')); $form->add_fieldset($buttons_fieldset); // FORM CONSTRAINTS $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis)); return $form; }
private function build_form() { $security_config = SecurityConfig::load(); $activated_auth_types = AuthenticationService::get_activated_types_authentication(); $form = new HTMLForm(__CLASS__); $this->member_extended_fields_service = new MemberExtendedFieldsService($form); $fieldset = new FormFieldsetHTML('edit_profile', $this->lang['profile.edit']); $form->add_fieldset($fieldset); $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], $this->user->get_display_name(), array('maxlength' => 100, 'required' => true, 'description' => $this->lang['display_name.explain'], 'events' => array('blur' => ' if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") { HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\')); HTMLForms.getField("login").enableValidationMessage(); HTMLForms.getField("login").liveValidate(); }')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists($this->user->get_id())))); $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], $this->user->get_email(), array('required' => true), array(new FormFieldConstraintMailExist($this->user->get_id())))); $fieldset->add_field(new FormFieldCheckbox('user_hide_mail', $this->lang['email.hide'], !$this->user->get_show_email())); $fieldset->add_field(new FormFieldCheckbox('delete_account', $this->lang['delete-account'], FormFieldCheckbox::UNCHECKED)); if (AppContext::get_current_user()->is_admin()) { $manage_fieldset = new FormFieldsetHTML('member_management', $this->lang['member-management']); $form->add_fieldset($manage_fieldset); $manage_fieldset->add_field(new FormFieldCheckbox('approbation', $this->lang['approbation'], $this->internal_auth_infos['approved'])); $manage_fieldset->add_field(new FormFieldRanksSelect('rank', $this->lang['rank'], $this->user->get_level())); $manage_fieldset->add_field(new FormFieldGroups('groups', $this->lang['groups'], $this->user->get_groups())); } $connect_fieldset = new FormFieldsetHTML('connect', $this->lang['connection']); $form->add_fieldset($connect_fieldset); $more_than_one_authentication_type = count($activated_auth_types) > 1; $has_custom_login = $this->user->get_email() !== $this->internal_auth_infos['login']; if ($more_than_one_authentication_type) { if (in_array(PHPBoostAuthenticationMethod::AUTHENTICATION_METHOD, $this->user_auth_types)) { $connect_fieldset->add_field(new FormFieldFree('internal_auth', $this->lang['internal_connection'] . ' <i class="fa fa-success"></i>', '<a onclick="javascript:HTMLForms.getField(\'custom_login\').enable();' . ($has_custom_login ? 'HTMLForms.getField(\'login\').enable();' : '') . 'HTMLForms.getField(\'password\').enable();HTMLForms.getField(\'password_bis\').enable();HTMLForms.getField(\'old_password\').enable();">' . LangLoader::get_message('edit', 'common') . '</a>')); } else { $connect_fieldset->add_field(new FormFieldFree('internal_auth', $this->lang['internal_connection'] . ' <i class="fa fa-error"></i>', '<a onclick="javascript:HTMLForms.getField(\'custom_login\').enable();HTMLForms.getField(\'password\').enable();HTMLForms.getField(\'password_bis\').enable();">Créer une authentification interne</a>')); } } $connect_fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], $has_custom_login, array('description' => $this->lang['login.custom.explain'], 'hidden' => $more_than_one_authentication_type, 'events' => array('click' => ' if (HTMLForms.getField("custom_login").getValue()) { HTMLForms.getField("login").enable(); } else { HTMLForms.getField("login").disable(); }')))); $connect_fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], $has_custom_login ? $this->internal_auth_infos['login'] : preg_replace('/\\s+/', '', $this->user->get_display_name()), array('required' => true, 'hidden' => $more_than_one_authentication_type || !$has_custom_login, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists($this->user->get_id())))); $connect_fieldset->add_field(new FormFieldPasswordEditor('old_password', $this->lang['password.old'], '', array('description' => $this->lang['password.old.explain'], 'hidden' => $more_than_one_authentication_type))); $connect_fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'hidden' => $more_than_one_authentication_type), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $connect_fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('hidden' => $more_than_one_authentication_type), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength()))); $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis)); if ($security_config->are_login_and_email_forbidden_in_password()) { $form->add_constraint(new FormConstraintFieldsInequality($email, $password)); $form->add_constraint(new FormConstraintFieldsInequality($login, $password)); } if (in_array('facebook', $activated_auth_types)) { if (in_array(FacebookAuthenticationMethod::AUTHENTICATION_METHOD, $this->user_auth_types)) { $connect_fieldset->add_field(new FormFieldFree('fb_auth', $this->lang['fb_connection'] . ' <i class="fa fa-success"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'dissociate', 'fb')->absolute() . '">' . $this->lang['dissociate_account'] . '</a>')); } else { $connect_fieldset->add_field(new FormFieldFree('fb_auth', $this->lang['fb_connection'] . ' <i class="fa fa-error"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'associate', 'fb')->absolute() . '">' . $this->lang['associate_account'] . '</a>')); } } if (in_array('google', $activated_auth_types)) { if (in_array(GoogleAuthenticationMethod::AUTHENTICATION_METHOD, $this->user_auth_types)) { $connect_fieldset->add_field(new FormFieldFree('google_auth', $this->lang['google_connection'] . ' <i class="fa fa-success"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'dissociate', 'google')->absolute() . '">' . $this->lang['dissociate_account'] . '</a>')); } else { $connect_fieldset->add_field(new FormFieldFree('google_auth', $this->lang['google_connection'] . ' <i class="fa fa-error"></i>', '<a href="' . UserUrlBuilder::edit_profile($this->user->get_id(), 'associate', 'google')->absolute() . '">' . $this->lang['associate_account'] . '</a>')); } } $options_fieldset = new FormFieldsetHTML('options', LangLoader::get_message('options', 'main')); $form->add_fieldset($options_fieldset); $options_fieldset->add_field(new FormFieldTimezone('timezone', $this->lang['timezone.choice'], $this->user->get_timezone(), array('description' => $this->lang['timezone.choice.explain']))); if (count(ThemesManager::get_activated_and_authorized_themes_map()) > 1) { $options_fieldset->add_field(new FormFieldThemesSelect('theme', $this->lang['theme'], $this->user->get_theme(), array('check_authorizations' => true, 'events' => array('change' => $this->build_javascript_picture_themes())))); $options_fieldset->add_field(new FormFieldFree('preview_theme', $this->lang['theme.preview'], '<img id="img_theme" src="' . $this->get_picture_theme($this->user->get_theme()) . '" alt="' . $this->lang['theme.preview'] . '" title="' . $this->lang['theme.preview'] . '" class="preview-img" />')); } $options_fieldset->add_field(new FormFieldEditors('text-editor', $this->lang['text-editor'], $this->user->get_editor())); $options_fieldset->add_field(new FormFieldLangsSelect('lang', $this->lang['lang'], $this->user->get_locale(), array('check_authorizations' => true))); if (AppContext::get_current_user()->is_admin()) { $fieldset_punishment = new FormFieldsetHTML('punishment_management', $this->lang['punishment-management']); $form->add_fieldset($fieldset_punishment); $fieldset_punishment->add_field(new FormFieldMemberCaution('user_warning', $this->lang['caution'], $this->user->get_warning_percentage())); $fieldset_punishment->add_field(new FormFieldMemberSanction('user_readonly', $this->lang['readonly'], $this->user->get_delay_readonly())); $fieldset_punishment->add_field(new FormFieldMemberSanction('user_ban', $this->lang['banned'], $this->user->get_delay_banned())); } $this->member_extended_fields_service->display_form_fields($this->user->get_id()); $this->submit_button = new FormButtonDefaultSubmit(); $form->add_button($this->submit_button); $form->add_button(new FormButtonReset()); $this->form = $form; }