bootstrap_modal_messages.module in Bootstrap Modal Messages 8
Main functions for bootstrap_modal_messages module.
File
bootstrap_modal_messages.module
View source
<?php
define('BOOTSTRAP_MODAL_MESSAGES_HEADER', '<h4 class="modal-title">' . t('Messages') . '</h4>');
define('BOOTSTRAP_MODAL_MESSAGES_FOOTER', '<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>');
function bootstrap_modal_messages_help($path, $arg) {
switch ($path) {
case 'admin/help#bootstrap_modal_messages':
return '';
case 'admin/config/user-interface/bootstrap_modal_messages':
return '<p>' . t('This page provides configuration options for bootstrap_modal_messages.module. You can configure how multiple messages are grouped.') . '</p>';
}
}
function bootstrap_modal_messages_page_attachments_alter(array &$page) {
$ignore_admin = \Drupal::config('bootstrap_modal_messages.settings')
->get('bootstrap_modal_messages_ignore_admin');
if ($ignore_admin && \Drupal::service('router.admin_context')
->isAdminRoute()) {
return;
}
$config = \Drupal::config('bootstrap_modal_messages.settings');
$title_text = BOOTSTRAP_MODAL_MESSAGES_HEADER;
$title = $config
->get('bootstrap_modal_messages_title');
if (isset($title['value']) && isset($title['format']) && $title['value'] != '') {
$title_text = check_markup($title['value'], $title['format']);
}
$footer_text = BOOTSTRAP_MODAL_MESSAGES_FOOTER;
$footer = $config
->get('bootstrap_modal_messages_footer_html');
if (isset($footer['value']) && isset($footer['format']) && $footer['value'] != '') {
$footer_text = check_markup($footer['value'], $footer['format']);
}
$controls_text = '';
$controls = $config
->get('bootstrap_modal_messages_controls_html');
if (isset($controls['value']) && isset($controls['format'])) {
$controls_text = check_markup($controls['value'], $controls['format']);
}
$js_settings = array(
'selector' => $config
->get('bootstrap_modal_messages_selector'),
'show_header' => $config
->get('bootstrap_modal_messages_show_header'),
'title' => $title_text,
'header_close' => $config
->get('bootstrap_modal_messages_header_close'),
'show_footer' => $config
->get('bootstrap_modal_messages_show_footer'),
'footer_html' => $footer_text,
'multiple' => $config
->get('bootstrap_modal_messages_multiple'),
'show_onload' => $config
->get('bootstrap_modal_messages_show_onload'),
'onload_expiration' => $config
->get('bootstrap_modal_messages_onload_expiration'),
'show_controls' => $config
->get('bootstrap_modal_messages_show_controls'),
'controls_html' => $controls_text,
);
if (!\Drupal::currentUser()
->hasPermission('view bootstrap modal messages controls')) {
$js_settings['show_controls'] = 0;
}
$page['#attached']['library'][] = 'bootstrap_modal_messages/bootstrap-modal-messages';
$page['#attached']['drupalSettings']['bootstrap_modal_messages'] = $js_settings;
}