register_hook('HTML_UPDATEPROFILEFORM_OUTPUT', 'BEFORE', $this, 'handle_profile_update', array()); } /** * To modify the register form and add class * * Deprecated object passed by the event but still in use * https://www.dokuwiki.org/devel:event:html_profiledeleteform_output * * Event using the new object but not found anywhere * https://www.dokuwiki.org/devel:event:form_profiledelete_output */ if (PluginUtility::getConfValue(self::CONF_ENABLE_PROFILE_DELETE_FORM, 1)) { $controller->register_hook('HTML_PROFILEDELETEFORM_OUTPUT', 'BEFORE', $this, 'handle_profile_delete', array()); } } function handle_profile_update(&$event, $param) { /** * The profile page is created via buffer * We print before the forms to avoid a FOUC */ print Identity::getHtmlStyleTag(self::TAG_UPDATE); /** * @var Doku_Form $form */ $form = &$event->data; $class = &$form->params["class"]; Identity::addIdentityClass($class, self::FORM_PROFILE_UPDATE_CLASS); $newFormContent = []; /** * Header (Logo / Title) */ $newFormContent[] = Identity::getHeaderHTML($form, self::FORM_PROFILE_UPDATE_CLASS); /** * Form Attributes * https://getbootstrap.com/docs/5.0/forms/layout/#horizontal-form */ $rowClass = "row"; if (Bootstrap::getBootStrapMajorVersion() == Bootstrap::BootStrapFourMajorVersion) { $rowClass .= " form-group"; } $firstColWeight = 5; $secondColWeight = 12 - $firstColWeight; /** * Replace the field * * The password text localized by lang is shared * between the password and the password check field */ $passwordText = "Password"; foreach ($form->_content as $field) { if (!is_array($field)) { continue; } $fieldName = $field["name"]; if ($fieldName == null) { // this is not an input field switch ($field["type"]) { case "submit": /** * This is important to keep the submit element intact * for forms integration such as captcha * The search the submit button to insert before it */ $classes = "btn btn-primary"; if (isset($field["class"])) { $field["class"] = $field["class"] . " " . $classes; } else { $field["class"] = $classes; } $field["tabindex"] = "6"; $newFormContent[] = $field; break; case "reset": $classes = "btn btn-secondary"; if (isset($field["class"])) { $field["class"] = $field["class"] . " " . $classes; } else { $field["class"] = $classes; } $field["tabindex"] = "7"; $newFormContent[] = $field; break; } continue; } switch ($fieldName) { case "login": $loginText = $field["_text"]; $loginValue = $field["value"]; $loginHTML = <<
EOF; $newFormContent[] = $loginHTML; break; case "fullname": $fullNameText = $field["_text"]; $fullNameValue = $field["value"]; $fullNameHtml = <<
EOF; $newFormContent[] = $fullNameHtml; break; case "email": $emailText = $field["_text"]; $emailValue = $field["value"]; $emailHTML = <<
EOF; $newFormContent[] = $emailHTML; break; case "newpass": $passwordText = $field["_text"]; $passwordHtml = <<
EOF; $newFormContent[] = $passwordHtml; break; case "passchk": $passwordCheckText = $field["_text"]; $passwordCheckHtml = <<
EOF; $newFormContent[] = $passwordCheckHtml; break; case "oldpass": $passwordCheckText = $field["_text"]; $passwordCheckHtml = <<
EOF; $newFormContent[] = $passwordCheckHtml; break; default: $tag = self::TAG_UPDATE; LogUtility::msg("The $tag field name ($fieldName) is unknown", LogUtility::LVL_MSG_ERROR, self::CANONICAL); } } /** * Update */ $form->_content = $newFormContent; return true; } public function handle_profile_delete($event, $param) { /** * The profile page is created via buffer * We print before the forms to avoid a FOUC */ print Identity::getHtmlStyleTag(self::TAG_DELETE); /** * @var Doku_Form $form */ $form = &$event->data; $class = &$form->params["class"]; Identity::addIdentityClass($class, self::FORM_PROFILE_DELETE_CLASS); $newFormContent = []; /** * Header (Logo / Title) */ $newFormContent[] = Identity::getHeaderHTML($form, self::FORM_PROFILE_DELETE_CLASS, false); /** * Field */ foreach ($form->_content as $field) { if (!is_array($field)) { continue; } $fieldName = $field["name"]; if ($fieldName == null) { // this is not an input field if ($field["type"] == "submit") { /** * This is important to keep the submit element intact * for forms integration such as captcha * They search the submit button to insert before it */ $classes = "btn btn-primary btn-block"; if (isset($field["class"])) { $field["class"] = $field["class"] . " " . $classes; } else { $field["class"] = $classes; } $newFormContent[] = $field; } continue; } switch ($fieldName) { case "oldpass": $passwordText = $field["_text"]; $passwordFieldHTML = << EOF; $newFormContent[] = $passwordFieldHTML; break; case "confirm_delete": $confirmText = $field["_text"]; $ConfirmValue = $field["value"]; $rememberMeHtml = << EOF; $newFormContent[] = $rememberMeHtml; break; default: $tag = self::TAG_DELETE; LogUtility::msg("The $tag field name ($fieldName) is unknown", LogUtility::LVL_MSG_ERROR, self::CANONICAL); } } $form->_content = $newFormContent; return true; } }