You are here

function fancy_login_page_bottom in Fancy Login 8.2

Same name and namespace in other branches
  1. 3.0.x fancy_login.module \fancy_login_page_bottom()

Implements hook_page_bottom().

Adds login form and page dimmer to the footer of the page.

File

./fancy_login.module, line 82
Holds hooks for the Fancy Login module.

Code

function fancy_login_page_bottom(array &$page_bottom) {
  if (\Drupal::currentUser()
    ->isAnonymous() || !empty($GLOBALS['menu_admin'])) {
    $form = \Drupal::formBuilder()
      ->getForm('Drupal\\fancy_login\\Form\\FancyLoginLoginForm');
    $login_path = \Drupal::service('path.alias_manager')
      ->getAliasByPath('/user/login');
    $fl_config = \Drupal::config('fancy_login.settings');
    $fl_settings = [
      'screenFadeColor' => $fl_config
        ->get('screen_fade_color'),
      'screenFadeZIndex' => $fl_config
        ->get('screen_fade_z_index'),
      'loginBoxBackgroundColor' => $fl_config
        ->get('login_box_background_color'),
      'loginBoxTextColor' => $fl_config
        ->get('login_box_text_color'),
      'loginBoxBorderColor' => $fl_config
        ->get('login_box_border_color'),
      'loginBoxBorderWidth' => $fl_config
        ->get('login_box_border_width'),
      'loginBoxBorderStyle' => $fl_config
        ->get('login_box_border_style'),
      'loginPath' => $login_path,
      'dimFadeSpeed' => $fl_config
        ->get('dim_fade_speed'),
      'boxFadeSpeed' => $fl_config
        ->get('box_fade_speed'),
      'hideObjects' => $fl_config
        ->get('hide_objects'),
    ];
    $page_bottom['fancy_login'] = [
      '#prefix' => '<div class="region region-page-bottom"><div id="fancy_login_dim_screen"></div><div id="fancy_login_login_box">',
      '#suffix' => '</div></div>',
      'form_wrapper' => [
        '#prefix' => '<div id="fancy_login_form_contents"><a href="#" id="fancy_login_close_button">X</a>',
        '#suffix' => '</div>',
        'form' => $form,
      ],
    ];
    $page_bottom['fancy_login']['#attached']['library'][] = 'fancy_login/popup';
    $page_bottom['fancy_login']['#attached']['drupalSettings']['fancyLogin'] = $fl_settings;
  }
}