function login_shadowbox_page_build in Shadowbox 8
Implements hook_page_build().
File
- login_shadowbox/
login_shadowbox.module, line 41 - Allows login form to be displayed in a JavaScript modal media viewer application.
Code
function login_shadowbox_page_build(&$page) {
$shadowbox_config = \Drupal::config('shadowbox.settings');
$login_shadowbox_config = \Drupal::config('login_shadowbox.settings');
$enable = $login_shadowbox_config
->get('login_shadowbox_enabled') && $shadowbox_config
->get('shadowbox_enabled');
$path = drupal_get_path('module', 'login_shadowbox');
if ($enable && arg(0) != 'admin') {
$page['#attached']['js'][] = $path . '/scripts/login_shadowbox_check.js';
}
if (!\Drupal::currentUser()
->id() && $enable) {
$alias_manager = \Drupal::service('path.alias_manager.cached');
$login_path = $alias_manager
->getPathByAlias('user/login');
$register_path = $alias_manager
->getPathByAlias('user/register');
$password_path = $alias_manager
->getPathByAlias('user/password');
$login_content = url($alias_manager
->getPathByAlias('user/login/shadowbox'));
$register_content = url($alias_manager
->getPathByAlias('user/register/shadowbox'));
$password_content = url($alias_manager
->getPathByAlias('user/password/shadowbox'));
// Shadowbox login settings
$shadowbox_login_settings = array(
'login_path' => $login_path,
'register_path' => $register_path,
'password_path' => $password_path,
'login_content' => $login_content,
'register_content' => $register_content,
'password_content' => $password_content,
'login_width' => $login_shadowbox_config
->get('login_shadowbox_width'),
'register_width' => $login_shadowbox_config
->get('login_shadowbox_register_width'),
'password_width' => $login_shadowbox_config
->get('login_shadowbox_password_width'),
'login_height' => $login_shadowbox_config
->get('login_shadowbox_height'),
'register_height' => $login_shadowbox_config
->get('login_shadowbox_register_height'),
'password_height' => $login_shadowbox_config
->get('login_shadowbox_password_height'),
'modal' => $login_shadowbox_config
->get('login_shadowbox_modal'),
);
// Adding the neccessary javascript and css files needed by shadowbox login.
$page['#attached']['js'][] = $path . '/scripts/login_shadowbox.js';
$page['#attached']['js'][] = array(
'data' => array(
'shadowboxLogin' => $shadowbox_login_settings,
),
'type' => 'setting',
);
$css_path = $login_shadowbox_config
->get('login_shadowbox_css');
$page['#attached']['css'][] = array(
'data' => $css_path,
'group' => 'CSS_DEFAULT',
);
}
}