public static function build($config) { $textInputs = $config['textInputs']; $createPath = isset($config['createPath']) ? $config['createPath'] : null; $forgotLinks = isset($config['forgotLinks']) ? $config['forgotLinks'] : null; $showPasswordOnClick = isset($config['showPasswordOnClick']) ? $config['showPasswordOnClick'] : null; $string = '<fieldset>'; $string .= '<legend class="usa-drop_text">Sign in</legend>'; if (!is_null($createPath)) { $string .= '<span>or <a href="' . $createPath . '">create an account</a></span>'; } $string .= TextInput::buildMany($textInputs); if (!is_null($showPasswordOnClick)) { $string .= '<p class="usa-form-note">'; $string .= '<a title="Show password" href="#" class="usa-show_password" aria-controls="password" onclick="' . $showPasswordOnClick . '(); return false">Show password</a>'; $string .= '</p>'; } $string .= Button::build(['title' => 'Sign in']); if (isset($forgotLinks) && count($forgotLinks) > 0) { foreach ($forgotLinks as $path => $title) { $string .= '<p><a href="' . $path . '" title="' . $title . '"> ' . $title . '?</a></p>'; } } $string .= '</fieldset>'; return $string; }
public static function build($config) { $title = $config['title']; $message = $config['message']; $type = isset($config['type']) ? $config['type'] : null; $readMore = isset($config['readMore']) ? $config['readMore'] : null; $string = ''; if (is_null($type) || $type == 'info') { $string .= '<div class="usa-alert usa-alert-info">'; } else { if ($type == 'success') { $string .= '<div class="usa-alert usa-alert-success">'; } elseif ($type == 'warning') { $string .= '<div class="usa-alert usa-alert-warning">'; } elseif ($type == 'error') { $string .= '<div class="usa-alert usa-alert-error" role="alert">'; } } $string .= '<div class="usa-alert-body">'; $string .= '<h3 class="usa-alert-heading">' . $title . '</h3>'; $string .= '<p class="usa-alert-text">' . $message; $string .= !is_null($readMore) ? '<br><a href="' . $readMore . '">Continue reading...</a>' : ''; $string .= '</p>'; $string .= '</div>'; $string .= '</div>'; // We would like to be able to dismiss the alert, // if user is authenticated and the dismissal can be tracked. if (isset($config['dismissPath'])) { $separator = '<div class="usa-alert-body">'; $stringParts = explode($separator, $string); $stringParts[0] .= '<form method="POST" action="' . $config['dismissPath'] . '">'; $stringParts[0] .= !is_null($config['csrfField']) ? $config['csrfField'] : ''; $stringParts[0] .= Button::build(['title' => 'dismiss', 'type' => 'dismiss']); $stringParts[0] .= '</form>'; $string = implode($separator, $stringParts); } return $string; }
/** * To allow the greatest flexibility in the definition of this element, * a keyed array is passed. * * Required keys * * **title:** The text to display within the button. * * Optional keys * * **type:** alt|secondary|gray|outline|outline-inverse|big|disabled (default is the standard USWDS primary button). * * **cancel:** Anchor href target for the cancel link. Usually not necessary. * * @param [type] $config Array of key-value pairs. * @return [type] [description] */ public static function button($config) { return Button::build($config); }