@ -2,10 +2,10 @@
/**
* @file
* Functions to support theming in the Olivessdu theme.
* Functions to support theming in the Olivesbdh theme.
*/
use Drupal\olivessdu\Olivessdu PreRender;
use Drupal\olivesbdh\Olivesbdh PreRender;
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Template\Attribute;
@ -17,19 +17,19 @@ use Drupal\user\UserInterface;
*
* Adds body classes if certain regions have content.
*/
function olivessdu _preprocess_html(&$variables) {
function olivesbdh _preprocess_html(&$variables) {
if (theme_get_setting('mobile_menu_all_widths') === 1) {
$variables['attributes']['class'][] = 'is-always-mobile-nav';
}
// Convert custom hex to hsl so we can use the hue value
$brand_color_hex = theme_get_setting('base_primary_color') ?? '#1b9ae4';
[$h, $s, $l] = _olivessdu _hex_to_hsl($brand_color_hex);
[$h, $s, $l] = _olivesbdh _hex_to_hsl($brand_color_hex);
$variables['html_attributes']->setAttribute('style', "--color--primary-hue:$h;--color--primary-saturation:$s%;--color--primary-lightness:$l");
// So fonts can be preloaded from base theme in the event Olivessdu is used as a subtheme.
$variables['olivessdu _path'] = \Drupal::request()->getBasePath() . '/' . \Drupal::service('extension.list.theme')->getPath('olivessdu ');
// So fonts can be preloaded from base theme in the event Olivesbdh is used as a subtheme.
$variables['olivesbdh _path'] = \Drupal::request()->getBasePath() . '/' . \Drupal::service('extension.list.theme')->getPath('olivesbdh ');
$query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0';
@ -41,7 +41,7 @@ function olivessdu_preprocess_html(&$variables) {
'#tag' => 'link',
'#attributes' => [
'rel' => 'stylesheet',
'href' => $variables['olivessdu _path'] . '/css/components/navigation/nav-primary-no-js.css?' . $query_string,
'href' => $variables['olivesbdh _path'] . '/css/components/navigation/nav-primary-no-js.css?' . $query_string,
],
];
}
@ -50,7 +50,7 @@ function olivessdu_preprocess_html(&$variables) {
/**
* Implements hook_preprocess_HOOK() for page title templates.
*/
function olivessdu _preprocess_page_title(&$variables) {
function olivesbdh _preprocess_page_title(&$variables) {
// Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
@ -79,7 +79,7 @@ function olivessdu_preprocess_page_title(&$variables) {
/**
* Implements hook_preprocess_HOOK() for maintenance-page.html.twig.
*/
function olivessdu _preprocess_maintenance_page(&$variables) {
function olivesbdh _preprocess_maintenance_page(&$variables) {
// By default, site_name is set to Drupal if no db connection is available
// or during site installation. Setting site_name to an empty string makes
// the site and update pages look cleaner.
@ -88,14 +88,14 @@ function olivessdu_preprocess_maintenance_page(&$variables) {
$variables['site_name'] = '';
}
// Olivessdu has custom styling for the maintenance page.
$variables['#attached']['library'][] = 'olivessdu /maintenance-page';
// Olivesbdh has custom styling for the maintenance page.
$variables['#attached']['library'][] = 'olivesbdh /maintenance-page';
}
/**
* Implements hook_preprocess_HOOK() for node.html.twig.
*/
function olivessdu _preprocess_node(&$variables) {
function olivesbdh _preprocess_node(&$variables) {
// Remove the "Add new comment" link on teasers or when the comment form is
// displayed on the page.
if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) {
@ -104,7 +104,7 @@ function olivessdu_preprocess_node(&$variables) {
// Apply custom date formatter to "date" field.
if (!empty($variables['date']) && !empty($variables['display_submitted']) && $variables['display_submitted'] === TRUE) {
$variables['date'] = \Drupal::service('date.formatter')->format($variables['node']->getCreatedTime(), 'olivessdu _medium');
$variables['date'] = \Drupal::service('date.formatter')->format($variables['node']->getCreatedTime(), 'olivesbdh _medium');
}
// Pass layout variable to template if content type is article in full view
@ -118,7 +118,7 @@ function olivessdu_preprocess_node(&$variables) {
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
function olivessdu _preprocess_block(&$variables) {
function olivesbdh _preprocess_block(&$variables) {
if (!empty($variables['elements']['#id'])) {
/** @var \Drupal\block\BlockInterface $block */
$block = \Drupal::entityTypeManager()
@ -130,17 +130,17 @@ function olivessdu_preprocess_block(&$variables) {
if ($variables['base_plugin_id'] === 'system_menu_block') {
$variables['content']['#attributes']['region'] = $region;
if ($region === 'sidebar') {
$variables['#attached']['library'][] = 'olivessdu /menu-sidebar';
$variables['#attached']['library'][] = 'olivesbdh /menu-sidebar';
}
}
if ($variables['base_plugin_id'] === 'search_form_block') {
if ($region === 'primary_menu') {
$variables['#attached']['library'][] = 'olivessdu /search-narrow';
$variables['#attached']['library'][] = 'olivesbdh /search-narrow';
$variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search'];
}
elseif ($region === 'secondary_menu') {
$variables['#attached']['library'][] = 'olivessdu /search-wide';
$variables['#attached']['library'][] = 'olivesbdh /search-wide';
$variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search'];
}
}
@ -167,7 +167,7 @@ function olivessdu_preprocess_block(&$variables) {
/**
* Implements hook_theme_suggestions_HOOK_alter() for menu.
*/
function olivessdu _theme_suggestions_menu_alter(&$suggestions, array $variables) {
function olivesbdh _theme_suggestions_menu_alter(&$suggestions, array $variables) {
if (isset($variables['attributes']['region'])) {
$suggestions[] = 'menu__' . $variables['attributes']['region'];
}
@ -176,7 +176,7 @@ function olivessdu_theme_suggestions_menu_alter(&$suggestions, array $variables)
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_menu(&$variables) {
function olivesbdh _preprocess_menu(&$variables) {
if (isset($variables['attributes']['region'])) {
if ($variables['attributes']['region'] === 'sidebar') {
$variables['attributes']['class'][] = 'menu--sidebar';
@ -188,7 +188,7 @@ function olivessdu_preprocess_menu(&$variables) {
/**
* Implements hook_theme_suggestions_HOOK_alter() for form templates.
*/
function olivessdu _theme_suggestions_form_alter(array &$suggestions, array $variables) {
function olivesbdh _theme_suggestions_form_alter(array &$suggestions, array $variables) {
if ($variables['element']['#form_id'] === 'search_block_form') {
$suggestions[] = 'form__search_block_form';
}
@ -197,7 +197,7 @@ function olivessdu_theme_suggestions_form_alter(array &$suggestions, array $vari
/**
* Implements hook_form_alter() for adding classes and placeholder text to the search forms.
*/
function olivessdu _form_alter(&$form, FormStateInterface $form_state, $form_id) {
function olivesbdh _form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (isset($form['actions']['submit']) && (count($form['actions'])) <= 2) {
$form['actions']['submit']['#attributes']['class'][] = 'button--primary';
}
@ -222,7 +222,7 @@ function olivessdu_form_alter(&$form, FormStateInterface $form_state, $form_id)
/**
* Implements hook_theme_suggestions_HOOK_alter() for block().
*/
function olivessdu _theme_suggestions_block_alter(&$suggestions, array $variables) {
function olivesbdh _theme_suggestions_block_alter(&$suggestions, array $variables) {
if (!empty($variables['elements']['#id'])) {
/** @var \Drupal\block\BlockInterface $block */
@ -245,7 +245,7 @@ function olivessdu_theme_suggestions_block_alter(&$suggestions, array $variables
/**
* Implements hook_preprocess_HOOK() for menu-local-tasks templates.
*/
function olivessdu _preprocess_menu_local_tasks(&$variables) {
function olivesbdh _preprocess_menu_local_tasks(&$variables) {
foreach (Element::children($variables['primary']) as $key) {
$variables['primary'][$key]['#level'] = 'primary';
}
@ -257,7 +257,7 @@ function olivessdu_preprocess_menu_local_tasks(&$variables) {
/**
* Implements hook_preprocess_form_element().
*/
function olivessdu _preprocess_form_element(&$variables) {
function olivesbdh _preprocess_form_element(&$variables) {
if (in_array($variables['element']['#type'] ?? FALSE, ['checkbox', 'radio'], TRUE)) {
$variables['attributes']['class'][] = 'form-type-boolean';
}
@ -274,14 +274,14 @@ function olivessdu_preprocess_form_element(&$variables) {
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_form_element_label(&$variables) {
function olivesbdh _preprocess_form_element_label(&$variables) {
$variables['attributes']['class'][] = 'form-item__label';
}
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_input(&$variables) {
function olivesbdh _preprocess_input(&$variables) {
if (
!empty($variables['element']['#title_display']) &&
$variables['element']['#title_display'] === 'attribute' &&
@ -330,7 +330,7 @@ function olivessdu_preprocess_input(&$variables) {
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_textarea(&$variables) {
function olivesbdh _preprocess_textarea(&$variables) {
$variables['attributes']['class'][] = 'form-element';
$variables['attributes']['class'][] = 'form-element--type-textarea';
$variables['attributes']['class'][] = 'form-element--api-textarea';
@ -339,7 +339,7 @@ function olivessdu_preprocess_textarea(&$variables) {
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_select(&$variables) {
function olivesbdh _preprocess_select(&$variables) {
$variables['attributes']['class'][] = 'form-element';
$variables['attributes']['class'][] = $variables['element']['#multiple'] ?
'form-element--type-select-multiple' :
@ -349,21 +349,21 @@ function olivessdu_preprocess_select(&$variables) {
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_checkboxes(&$variables) {
function olivesbdh _preprocess_checkboxes(&$variables) {
$variables['attributes']['class'][] = 'form-boolean-group';
}
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_radios(&$variables) {
function olivesbdh _preprocess_radios(&$variables) {
$variables['attributes']['class'][] = 'form-boolean-group';
}
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_field(&$variables) {
function olivesbdh _preprocess_field(&$variables) {
$rich_field_types = ['text_with_summary', 'text', 'text_long'];
if (in_array($variables['field_type'], $rich_field_types, TRUE)) {
@ -378,7 +378,7 @@ function olivessdu_preprocess_field(&$variables) {
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_field_multiple_value_form(&$variables) {
function olivesbdh _preprocess_field_multiple_value_form(&$variables) {
// Make disabled available for the template.
$variables['disabled'] = !empty($variables['element']['#disabled']);
@ -433,7 +433,7 @@ function olivessdu_preprocess_field_multiple_value_form(&$variables) {
/**
* Implements hook_preprocess_HOOK() for menu-local-task templates.
*/
function olivessdu _preprocess_menu_local_task(&$variables) {
function olivesbdh _preprocess_menu_local_task(&$variables) {
$variables['link']['#options']['attributes']['class'][] = 'tabs__link';
$variables['link']['#options']['attributes']['class'][] = 'js-tabs-link';
@ -452,7 +452,7 @@ function olivessdu_preprocess_menu_local_task(&$variables) {
/**
* Implements template_preprocess_HOOK() for fieldset.
*/
function olivessdu _preprocess_fieldset(&$variables) {
function olivesbdh _preprocess_fieldset(&$variables) {
$element = $variables['element'];
$composite_types = ['checkboxes', 'radios'];
@ -485,14 +485,14 @@ function olivessdu_preprocess_fieldset(&$variables) {
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function olivessdu _theme_suggestions_user_alter(&$suggestions, $variables) {
function olivesbdh _theme_suggestions_user_alter(&$suggestions, $variables) {
$suggestions[] = 'user__' . $variables['elements']['#view_mode'];
}
/**
* Implements hook_preprocess_HOOK().
*/
function olivessdu _preprocess_field__node__created(&$variables) {
function olivesbdh _preprocess_field__node__created(&$variables) {
foreach (Element::children($variables['items']) as $item) {
unset($variables['items'][$item]['content']['#prefix']);
}
@ -501,14 +501,14 @@ function olivessdu_preprocess_field__node__created(&$variables) {
/**
* Implements hook_preprocess_HOOK() for setting classes.
*/
function olivessdu _preprocess_filter_caption(&$variables) {
function olivesbdh _preprocess_filter_caption(&$variables) {
$variables['classes'] = isset($variables['classes']) && !empty($variables['classes']) ? $variables['classes'] . ' caption' : 'caption';
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function olivessdu _form_node_preview_form_select_alter(&$form, FormStateInterface $form_state, $form_id) {
function olivesbdh _form_node_preview_form_select_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['backlink']['#options']['attributes']['class'][] = 'button';
$form['backlink']['#options']['attributes']['class'][] = 'button--small';
$form['backlink']['#options']['attributes']['class'][] = 'button--icon-back';
@ -519,7 +519,7 @@ function olivessdu_form_node_preview_form_select_alter(&$form, FormStateInterfac
/**
* Implements hook_preprocess_HOOK() for comment.html.twig.
*/
function olivessdu _preprocess_comment(&$variables) {
function olivesbdh _preprocess_comment(&$variables) {
// Getting the node creation time stamp from the comment object.
$date = $variables['comment']->getCreatedTime();
// Formatting "created" as "X days ago".
@ -529,7 +529,7 @@ function olivessdu_preprocess_comment(&$variables) {
/**
* Implements hook_preprocess_HOOK() for field--comment.html.twig.
*/
function olivessdu _preprocess_field__comment(&$variables) {
function olivesbdh _preprocess_field__comment(&$variables) {
// Add a comment_count.
$variables['comment_count'] = count(array_filter($variables['comments'], 'is_numeric', ARRAY_FILTER_USE_KEY));
@ -550,13 +550,13 @@ function olivessdu_preprocess_field__comment(&$variables) {
/**
* Implements hook_element_info_alter().
*/
function olivessdu _element_info_alter(&$info) {
function olivesbdh _element_info_alter(&$info) {
if (array_key_exists('text_format', $info)) {
$info['text_format']['#pre_render'][] = [Olivessdu PreRender::class, 'textFormat'];
$info['text_format']['#pre_render'][] = [Olivesbdh PreRender::class, 'textFormat'];
}
if (isset($info['status_messages'])) {
$info['status_messages']['#pre_render'][] = [Olivessdu PreRender::class, 'messagePlaceholder'];
$info['status_messages']['#pre_render'][] = [Olivesbdh PreRender::class, 'messagePlaceholder'];
}
}
@ -565,7 +565,7 @@ function olivessdu_element_info_alter(&$info) {
*
* @todo Remove when https://www.drupal.org/node/3016343 is fixed.
*/
function olivessdu _preprocess_text_format_wrapper(&$variables) {
function olivesbdh _preprocess_text_format_wrapper(&$variables) {
$description_attributes = [];
if (!empty($variables['attributes']['id'])) {
$description_attributes['id'] = $variables['attributes']['aria-describedby'] = $variables['attributes']['id'];
@ -577,17 +577,17 @@ function olivessdu_preprocess_text_format_wrapper(&$variables) {
/**
* Implements hook_preprocess_search_result().
*/
function olivessdu _preprocess_search_result(&$variables) {
function olivesbdh _preprocess_search_result(&$variables) {
// Apply custom date formatter to "date" field.
if (!empty($variables['result']['date'])) {
$variables['info_date'] = \Drupal::service('date.formatter')->format($variables['result']['node']->getCreatedTime(), 'olivessdu _medium');
$variables['info_date'] = \Drupal::service('date.formatter')->format($variables['result']['node']->getCreatedTime(), 'olivesbdh _medium');
}
}
/**
* Implements hook_preprocess_links__comment().
*/
function olivessdu _preprocess_links__comment(&$variables) {
function olivesbdh _preprocess_links__comment(&$variables) {
foreach ($variables['links'] as &$link) {
$link['link']['#options']['attributes']['class'][] = 'comment__links-link';
}
@ -596,7 +596,7 @@ function olivessdu_preprocess_links__comment(&$variables) {
/**
* Implements hook_preprocess_table().
*/
function olivessdu _preprocess_table(&$variables) {
function olivesbdh _preprocess_table(&$variables) {
// Mark the whole table and the first cells if rows are draggable.
if (!empty($variables['rows'])) {
$draggable_row_found = FALSE;
@ -615,7 +615,7 @@ function olivessdu_preprocess_table(&$variables) {
/**
* Implements hook_form_views_exposed_form_alter().
*/
function olivessdu _form_views_exposed_form_alter(&$form) {
function olivesbdh _form_views_exposed_form_alter(&$form) {
$form['#attributes']['class'][] = 'form--inline';
}
@ -638,7 +638,7 @@ function olivessdu_form_views_exposed_form_alter(&$form) {
*
* @internal
*/
function _olivessdu _hex_to_hsl(string $hex_string) {
function _olivesbdh _hex_to_hsl(string $hex_string) {
// Convert hexcode pairs to rgb values (0-255).
$hex_val = trim($hex_string, '#');
$r0 = hexdec($hex_val[0] . $hex_val[1]);
@ -699,7 +699,7 @@ function _olivessdu_hex_to_hsl(string $hex_string) {
}
/*
function olivessdu _preprocess_mirador(&$variables) {
function olivesbdh _preprocess_mirador(&$variables) {
$block = \Drupal::service('plugin.manager.block')->createInstance($viewer . 'mirador_block', [
'iiif_manifest_url' => "/node/$manifest_nid/manifest-single",
'thumbnail_navigation_position' => 'hidden',