function fancy_login_form in Fancy Login 6
Function that is displayed in the popup to allow the user to log in
1 call to fancy_login_form()
- fancy_login_get_form in ./
fancy_login.module - Function that is called to create the popup that allows the user to log in
File
- ./
fancy_login.module, line 88
Code
function fancy_login_form() {
global $base_url;
$form_id = 'user_login';
$form = array();
$icon_position = FALSE;
if (variable_get('fancy_login_https', 0) && ($icon_position = variable_get('fancy_login_icon_position', 0))) {
$icon = theme('ssl_icon', $base_url);
}
if ($icon_position == 1) {
$form['ssl_logo'] = array(
'#value' => $icon,
);
}
$form['name'] = array(
'#title' => t('Username'),
'#type' => 'textfield',
'#maxlength' => USERNAME_MAX_LENGTH,
'#size' => 15,
'#required' => TRUE,
'#attributes' => array(
'tabindex' => '1',
),
);
$form['pass'] = array(
'#title' => t('Password'),
'#type' => 'password',
'#required' => TRUE,
'#size' => 15,
'#attributes' => array(
'tabindex' => '2',
),
);
if ($icon_position == 2) {
$form['ssl_logo'] = array(
'#value' => $icon,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Log in'),
'#weight' => 2,
'#attributes' => array(
'tabindex' => '3',
),
);
$form['#validate'] = user_login_default_validators();
$form['#build_id'] = sprintf('form-%s', md5(uniqid(mt_rand(), TRUE)));
$form_state = array();
drupal_prepare_form($form_id, $form, $form_state);
drupal_process_form($form_id, $form, $form_state);
$out = new stdClass();
if (variable_get('fancy_login_https', 0)) {
$post_url = preg_replace('/^http:\\/\\//', 'https://', url('user/login', array(
'absolute' => TRUE,
)));
}
else {
$post_url = url('user/login');
}
$out->form_start = sprintf('<form id="user-login" method="post" accept-charset="UTF-8" action="%s"><div>', $post_url);
if ($icon_position == 1) {
$out->form_start = str_replace('<form ', '<form class="ssl_icon_above" ', $out->form_start);
}
elseif ($icon_position == 2) {
$out->form_start = str_replace('<form ', '<form class="ssl_icon_below" ', $out->form_start);
}
$out->form_end = "</div></form>";
foreach (element_children($form) as $key) {
if (!in_array($key, array(
'submit',
'form_build_id',
'form_id',
))) {
$out->{$key} = drupal_render($form[$key]);
}
}
$items = array();
if (variable_get('user_register', 1)) {
$items[] = l(t('Create new account'), 'user/register', array(
'attributes' => array(
'title' => t('Create a new user account.'),
),
));
}
if (!module_exists('noreqnewpass') || !variable_get('noreqnewpass_disabled', FALSE)) {
$items[] = l(t('Request new password'), 'user/password', array(
'attributes' => array(
'title' => t('Request new password via e-mail.'),
),
));
}
$form['links'] = array(
'#value' => theme('item_list', $items),
);
$out->links = drupal_render($form['links']);
$out->submit = drupal_render($form['form_id']) . drupal_render($form['form_build_id']) . drupal_render($form['submit']);
return $out;
}