|
|
|
@ -17,7 +17,8 @@ use Drupal\user\UserInterface; |
|
|
|
* |
|
|
|
* |
|
|
|
* Adds body classes if certain regions have content. |
|
|
|
* Adds body classes if certain regions have content. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_html(&$variables) { |
|
|
|
function oliveskspaces_preprocess_html(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
if (theme_get_setting('mobile_menu_all_widths') === 1) { |
|
|
|
if (theme_get_setting('mobile_menu_all_widths') === 1) { |
|
|
|
$variables['attributes']['class'][] = 'is-always-mobile-nav'; |
|
|
|
$variables['attributes']['class'][] = 'is-always-mobile-nav'; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -37,7 +38,7 @@ function oliveskspaces_preprocess_html(&$variables) { |
|
|
|
// stylesheet for primary menu. |
|
|
|
// stylesheet for primary menu. |
|
|
|
$variables['noscript_styles'] = [ |
|
|
|
$variables['noscript_styles'] = [ |
|
|
|
'#type' => 'html_tag', |
|
|
|
'#type' => 'html_tag', |
|
|
|
'#noscript' => TRUE, |
|
|
|
'#noscript' => true, |
|
|
|
'#tag' => 'link', |
|
|
|
'#tag' => 'link', |
|
|
|
'#attributes' => [ |
|
|
|
'#attributes' => [ |
|
|
|
'rel' => 'stylesheet', |
|
|
|
'rel' => 'stylesheet', |
|
|
|
@ -50,7 +51,8 @@ function oliveskspaces_preprocess_html(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for page title templates. |
|
|
|
* Implements hook_preprocess_HOOK() for page title templates. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_page_title(&$variables) { |
|
|
|
function oliveskspaces_preprocess_page_title(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// Since the title and the shortcut link are both block level elements, |
|
|
|
// 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. |
|
|
|
// positioning them next to each other is much simpler with a wrapper div. |
|
|
|
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) { |
|
|
|
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) { |
|
|
|
@ -71,7 +73,7 @@ function oliveskspaces_preprocess_page_title(&$variables) { |
|
|
|
|
|
|
|
|
|
|
|
// Unset shortcut link on front page. |
|
|
|
// Unset shortcut link on front page. |
|
|
|
$variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage(); |
|
|
|
$variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage(); |
|
|
|
if ($variables['is_front'] === TRUE) { |
|
|
|
if ($variables['is_front'] === true) { |
|
|
|
unset($variables['title_suffix']['add_or_remove_shortcut']); |
|
|
|
unset($variables['title_suffix']['add_or_remove_shortcut']); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -79,7 +81,8 @@ function oliveskspaces_preprocess_page_title(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for maintenance-page.html.twig. |
|
|
|
* Implements hook_preprocess_HOOK() for maintenance-page.html.twig. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_maintenance_page(&$variables) { |
|
|
|
function oliveskspaces_preprocess_maintenance_page(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// By default, site_name is set to Drupal if no db connection is available |
|
|
|
// 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 |
|
|
|
// or during site installation. Setting site_name to an empty string makes |
|
|
|
// the site and update pages look cleaner. |
|
|
|
// the site and update pages look cleaner. |
|
|
|
@ -95,7 +98,8 @@ function oliveskspaces_preprocess_maintenance_page(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for node.html.twig. |
|
|
|
* Implements hook_preprocess_HOOK() for node.html.twig. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_node(&$variables) { |
|
|
|
function oliveskspaces_preprocess_node(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// Remove the "Add new comment" link on teasers or when the comment form is |
|
|
|
// Remove the "Add new comment" link on teasers or when the comment form is |
|
|
|
// displayed on the page. |
|
|
|
// displayed on the page. |
|
|
|
if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) { |
|
|
|
if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) { |
|
|
|
@ -103,7 +107,7 @@ function oliveskspaces_preprocess_node(&$variables) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Apply custom date formatter to "date" field. |
|
|
|
// Apply custom date formatter to "date" field. |
|
|
|
if (!empty($variables['date']) && !empty($variables['display_submitted']) && $variables['display_submitted'] === TRUE) { |
|
|
|
if (!empty($variables['date']) && !empty($variables['display_submitted']) && $variables['display_submitted'] === true) { |
|
|
|
$variables['date'] = \Drupal::service('date.formatter')->format($variables['node']->getCreatedTime(), 'oliveskspaces_medium'); |
|
|
|
$variables['date'] = \Drupal::service('date.formatter')->format($variables['node']->getCreatedTime(), 'oliveskspaces_medium'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -118,7 +122,8 @@ function oliveskspaces_preprocess_node(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for block.html.twig. |
|
|
|
* Implements hook_preprocess_HOOK() for block.html.twig. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_block(&$variables) { |
|
|
|
function oliveskspaces_preprocess_block(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
if (!empty($variables['elements']['#id'])) { |
|
|
|
if (!empty($variables['elements']['#id'])) { |
|
|
|
/** @var \Drupal\block\BlockInterface $block */ |
|
|
|
/** @var \Drupal\block\BlockInterface $block */ |
|
|
|
$block = \Drupal::entityTypeManager() |
|
|
|
$block = \Drupal::entityTypeManager() |
|
|
|
@ -138,8 +143,7 @@ function oliveskspaces_preprocess_block(&$variables) { |
|
|
|
if ($region === 'primary_menu') { |
|
|
|
if ($region === 'primary_menu') { |
|
|
|
$variables['#attached']['library'][] = 'oliveskspaces/search-narrow'; |
|
|
|
$variables['#attached']['library'][] = 'oliveskspaces/search-narrow'; |
|
|
|
$variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search']; |
|
|
|
$variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search']; |
|
|
|
} |
|
|
|
} elseif ($region === 'secondary_menu') { |
|
|
|
elseif ($region === 'secondary_menu') { |
|
|
|
|
|
|
|
$variables['#attached']['library'][] = 'oliveskspaces/search-wide'; |
|
|
|
$variables['#attached']['library'][] = 'oliveskspaces/search-wide'; |
|
|
|
$variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search']; |
|
|
|
$variables['content']['actions']['submit']['#theme_wrappers'] = ['input__submit__header_search']; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -167,7 +171,8 @@ function oliveskspaces_preprocess_block(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter() for menu. |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter() for menu. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_theme_suggestions_menu_alter(&$suggestions, array $variables) { |
|
|
|
function oliveskspaces_theme_suggestions_menu_alter(&$suggestions, array $variables) |
|
|
|
|
|
|
|
{ |
|
|
|
if (isset($variables['attributes']['region'])) { |
|
|
|
if (isset($variables['attributes']['region'])) { |
|
|
|
$suggestions[] = 'menu__' . $variables['attributes']['region']; |
|
|
|
$suggestions[] = 'menu__' . $variables['attributes']['region']; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -176,7 +181,8 @@ function oliveskspaces_theme_suggestions_menu_alter(&$suggestions, array $variab |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_menu(&$variables) { |
|
|
|
function oliveskspaces_preprocess_menu(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
if (isset($variables['attributes']['region'])) { |
|
|
|
if (isset($variables['attributes']['region'])) { |
|
|
|
if ($variables['attributes']['region'] === 'sidebar') { |
|
|
|
if ($variables['attributes']['region'] === 'sidebar') { |
|
|
|
$variables['attributes']['class'][] = 'menu--sidebar'; |
|
|
|
$variables['attributes']['class'][] = 'menu--sidebar'; |
|
|
|
@ -188,7 +194,8 @@ function oliveskspaces_preprocess_menu(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter() for form templates. |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter() for form templates. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_theme_suggestions_form_alter(array &$suggestions, array $variables) { |
|
|
|
function oliveskspaces_theme_suggestions_form_alter(array &$suggestions, array $variables) |
|
|
|
|
|
|
|
{ |
|
|
|
if ($variables['element']['#form_id'] === 'search_block_form') { |
|
|
|
if ($variables['element']['#form_id'] === 'search_block_form') { |
|
|
|
$suggestions[] = 'form__search_block_form'; |
|
|
|
$suggestions[] = 'form__search_block_form'; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -197,7 +204,8 @@ function oliveskspaces_theme_suggestions_form_alter(array &$suggestions, array $ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_form_alter() for adding classes and placeholder text to the search forms. |
|
|
|
* Implements hook_form_alter() for adding classes and placeholder text to the search forms. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_form_alter(&$form, FormStateInterface $form_state, $form_id) { |
|
|
|
function oliveskspaces_form_alter(&$form, FormStateInterface $form_state, $form_id) |
|
|
|
|
|
|
|
{ |
|
|
|
if (isset($form['actions']['submit']) && (count($form['actions'])) <= 2) { |
|
|
|
if (isset($form['actions']['submit']) && (count($form['actions'])) <= 2) { |
|
|
|
$form['actions']['submit']['#attributes']['class'][] = 'button--primary'; |
|
|
|
$form['actions']['submit']['#attributes']['class'][] = 'button--primary'; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -222,7 +230,8 @@ function oliveskspaces_form_alter(&$form, FormStateInterface $form_state, $form_ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter() for block(). |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter() for block(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_theme_suggestions_block_alter(&$suggestions, array $variables) { |
|
|
|
function oliveskspaces_theme_suggestions_block_alter(&$suggestions, array $variables) |
|
|
|
|
|
|
|
{ |
|
|
|
if (!empty($variables['elements']['#id'])) { |
|
|
|
if (!empty($variables['elements']['#id'])) { |
|
|
|
|
|
|
|
|
|
|
|
/** @var \Drupal\block\BlockInterface $block */ |
|
|
|
/** @var \Drupal\block\BlockInterface $block */ |
|
|
|
@ -245,7 +254,8 @@ function oliveskspaces_theme_suggestions_block_alter(&$suggestions, array $varia |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for menu-local-tasks templates. |
|
|
|
* Implements hook_preprocess_HOOK() for menu-local-tasks templates. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_menu_local_tasks(&$variables) { |
|
|
|
function oliveskspaces_preprocess_menu_local_tasks(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
foreach (Element::children($variables['primary']) as $key) { |
|
|
|
foreach (Element::children($variables['primary']) as $key) { |
|
|
|
$variables['primary'][$key]['#level'] = 'primary'; |
|
|
|
$variables['primary'][$key]['#level'] = 'primary'; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -257,8 +267,9 @@ function oliveskspaces_preprocess_menu_local_tasks(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_form_element(). |
|
|
|
* Implements hook_preprocess_form_element(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_form_element(&$variables) { |
|
|
|
function oliveskspaces_preprocess_form_element(&$variables) |
|
|
|
if (in_array($variables['element']['#type'] ?? FALSE, ['checkbox', 'radio'], TRUE)) { |
|
|
|
{ |
|
|
|
|
|
|
|
if (in_array($variables['element']['#type'] ?? false, ['checkbox', 'radio'], true)) { |
|
|
|
$variables['attributes']['class'][] = 'form-type-boolean'; |
|
|
|
$variables['attributes']['class'][] = 'form-type-boolean'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -274,18 +285,20 @@ function oliveskspaces_preprocess_form_element(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_form_element_label(&$variables) { |
|
|
|
function oliveskspaces_preprocess_form_element_label(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$variables['attributes']['class'][] = 'form-item__label'; |
|
|
|
$variables['attributes']['class'][] = 'form-item__label'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_input(&$variables) { |
|
|
|
function oliveskspaces_preprocess_input(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
!empty($variables['element']['#title_display']) && |
|
|
|
!empty($variables['element']['#title_display']) |
|
|
|
$variables['element']['#title_display'] === 'attribute' && |
|
|
|
&& $variables['element']['#title_display'] === 'attribute' |
|
|
|
!empty((string) $variables['element']['#title']) |
|
|
|
&& !empty((string) $variables['element']['#title']) |
|
|
|
) { |
|
|
|
) { |
|
|
|
$variables['attributes']['title'] = (string) $variables['element']['#title']; |
|
|
|
$variables['attributes']['title'] = (string) $variables['element']['#title']; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -309,7 +322,7 @@ function oliveskspaces_preprocess_input(&$variables) { |
|
|
|
'week', |
|
|
|
'week', |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
if (in_array($type_html, $text_types_html, TRUE)) { |
|
|
|
if (in_array($type_html, $text_types_html, true)) { |
|
|
|
$variables['attributes']['class'][] = 'form-element'; |
|
|
|
$variables['attributes']['class'][] = 'form-element'; |
|
|
|
$variables['attributes']['class'][] = Html::getClass('form-element--type-' . $type_html); |
|
|
|
$variables['attributes']['class'][] = Html::getClass('form-element--type-' . $type_html); |
|
|
|
$variables['attributes']['class'][] = Html::getClass('form-element--api-' . $type_api); |
|
|
|
$variables['attributes']['class'][] = Html::getClass('form-element--api-' . $type_api); |
|
|
|
@ -321,7 +334,7 @@ function oliveskspaces_preprocess_input(&$variables) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (in_array($type_html, ['checkbox', 'radio'], TRUE)) { |
|
|
|
if (in_array($type_html, ['checkbox', 'radio'], true)) { |
|
|
|
$variables['attributes']['class'][] = 'form-boolean'; |
|
|
|
$variables['attributes']['class'][] = 'form-boolean'; |
|
|
|
$variables['attributes']['class'][] = Html::getClass('form-boolean--type-' . $type_html); |
|
|
|
$variables['attributes']['class'][] = Html::getClass('form-boolean--type-' . $type_html); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -330,7 +343,8 @@ function oliveskspaces_preprocess_input(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_textarea(&$variables) { |
|
|
|
function oliveskspaces_preprocess_textarea(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$variables['attributes']['class'][] = 'form-element'; |
|
|
|
$variables['attributes']['class'][] = 'form-element'; |
|
|
|
$variables['attributes']['class'][] = 'form-element--type-textarea'; |
|
|
|
$variables['attributes']['class'][] = 'form-element--type-textarea'; |
|
|
|
$variables['attributes']['class'][] = 'form-element--api-textarea'; |
|
|
|
$variables['attributes']['class'][] = 'form-element--api-textarea'; |
|
|
|
@ -339,34 +353,38 @@ function oliveskspaces_preprocess_textarea(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_select(&$variables) { |
|
|
|
function oliveskspaces_preprocess_select(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$variables['attributes']['class'][] = 'form-element'; |
|
|
|
$variables['attributes']['class'][] = 'form-element'; |
|
|
|
$variables['attributes']['class'][] = $variables['element']['#multiple'] ? |
|
|
|
$variables['attributes']['class'][] = $variables['element']['#multiple'] |
|
|
|
'form-element--type-select-multiple' : |
|
|
|
? 'form-element--type-select-multiple' |
|
|
|
'form-element--type-select'; |
|
|
|
: 'form-element--type-select'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_checkboxes(&$variables) { |
|
|
|
function oliveskspaces_preprocess_checkboxes(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$variables['attributes']['class'][] = 'form-boolean-group'; |
|
|
|
$variables['attributes']['class'][] = 'form-boolean-group'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_radios(&$variables) { |
|
|
|
function oliveskspaces_preprocess_radios(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$variables['attributes']['class'][] = 'form-boolean-group'; |
|
|
|
$variables['attributes']['class'][] = 'form-boolean-group'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_field(&$variables) { |
|
|
|
function oliveskspaces_preprocess_field(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$rich_field_types = ['text_with_summary', 'text', 'text_long']; |
|
|
|
$rich_field_types = ['text_with_summary', 'text', 'text_long']; |
|
|
|
|
|
|
|
|
|
|
|
if (in_array($variables['field_type'], $rich_field_types, TRUE)) { |
|
|
|
if (in_array($variables['field_type'], $rich_field_types, true)) { |
|
|
|
$variables['attributes']['class'][] = 'text-content'; |
|
|
|
$variables['attributes']['class'][] = 'text-content'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -378,7 +396,8 @@ function oliveskspaces_preprocess_field(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_field_multiple_value_form(&$variables) { |
|
|
|
function oliveskspaces_preprocess_field_multiple_value_form(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// Make disabled available for the template. |
|
|
|
// Make disabled available for the template. |
|
|
|
$variables['disabled'] = !empty($variables['element']['#disabled']); |
|
|
|
$variables['disabled'] = !empty($variables['element']['#disabled']); |
|
|
|
|
|
|
|
|
|
|
|
@ -417,8 +436,7 @@ function oliveskspaces_preprocess_field_multiple_value_form(&$variables) { |
|
|
|
if (is_array($cell) && isset($cell['data'])) { |
|
|
|
if (is_array($cell) && isset($cell['data'])) { |
|
|
|
$cell = $cell + ['class' => []]; |
|
|
|
$cell = $cell + ['class' => []]; |
|
|
|
$cell['class'][] = 'is-disabled'; |
|
|
|
$cell['class'][] = 'is-disabled'; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
// We have to modify the structure of this header cell. |
|
|
|
// We have to modify the structure of this header cell. |
|
|
|
$cell = [ |
|
|
|
$cell = [ |
|
|
|
'data' => $cell, |
|
|
|
'data' => $cell, |
|
|
|
@ -433,14 +451,15 @@ function oliveskspaces_preprocess_field_multiple_value_form(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for menu-local-task templates. |
|
|
|
* Implements hook_preprocess_HOOK() for menu-local-task templates. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_menu_local_task(&$variables) { |
|
|
|
function oliveskspaces_preprocess_menu_local_task(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$variables['link']['#options']['attributes']['class'][] = 'tabs__link'; |
|
|
|
$variables['link']['#options']['attributes']['class'][] = 'tabs__link'; |
|
|
|
$variables['link']['#options']['attributes']['class'][] = 'js-tabs-link'; |
|
|
|
$variables['link']['#options']['attributes']['class'][] = 'js-tabs-link'; |
|
|
|
|
|
|
|
|
|
|
|
// Ensure is-active class is set when the tab is active. The generic active |
|
|
|
// Ensure is-active class is set when the tab is active. The generic active |
|
|
|
// link handler applies stricter comparison rules than what is necessary for |
|
|
|
// link handler applies stricter comparison rules than what is necessary for |
|
|
|
// tabs. |
|
|
|
// tabs. |
|
|
|
if (isset($variables['is_active']) && $variables['is_active'] === TRUE) { |
|
|
|
if (isset($variables['is_active']) && $variables['is_active'] === true) { |
|
|
|
$variables['link']['#options']['attributes']['class'][] = 'is-active'; |
|
|
|
$variables['link']['#options']['attributes']['class'][] = 'is-active'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -452,7 +471,8 @@ function oliveskspaces_preprocess_menu_local_task(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements template_preprocess_HOOK() for fieldset. |
|
|
|
* Implements template_preprocess_HOOK() for fieldset. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_fieldset(&$variables) { |
|
|
|
function oliveskspaces_preprocess_fieldset(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$element = $variables['element']; |
|
|
|
$element = $variables['element']; |
|
|
|
$composite_types = ['checkboxes', 'radios']; |
|
|
|
$composite_types = ['checkboxes', 'radios']; |
|
|
|
|
|
|
|
|
|
|
|
@ -475,9 +495,9 @@ function oliveskspaces_preprocess_fieldset(&$variables) { |
|
|
|
if (!empty($variables['attributes']['class'])) { |
|
|
|
if (!empty($variables['attributes']['class'])) { |
|
|
|
$container_inline_key = array_search('container-inline', $variables['attributes']['class']); |
|
|
|
$container_inline_key = array_search('container-inline', $variables['attributes']['class']); |
|
|
|
|
|
|
|
|
|
|
|
if ($container_inline_key !== FALSE) { |
|
|
|
if ($container_inline_key !== false) { |
|
|
|
unset($variables['attributes']['class'][$container_inline_key]); |
|
|
|
unset($variables['attributes']['class'][$container_inline_key]); |
|
|
|
$variables['inline_items'] = TRUE; |
|
|
|
$variables['inline_items'] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -485,14 +505,16 @@ function oliveskspaces_preprocess_fieldset(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter(). |
|
|
|
* Implements hook_theme_suggestions_HOOK_alter(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_theme_suggestions_user_alter(&$suggestions, $variables) { |
|
|
|
function oliveskspaces_theme_suggestions_user_alter(&$suggestions, $variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$suggestions[] = 'user__' . $variables['elements']['#view_mode']; |
|
|
|
$suggestions[] = 'user__' . $variables['elements']['#view_mode']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
* Implements hook_preprocess_HOOK(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_field__node__created(&$variables) { |
|
|
|
function oliveskspaces_preprocess_field__node__created(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
foreach (Element::children($variables['items']) as $item) { |
|
|
|
foreach (Element::children($variables['items']) as $item) { |
|
|
|
unset($variables['items'][$item]['content']['#prefix']); |
|
|
|
unset($variables['items'][$item]['content']['#prefix']); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -501,14 +523,16 @@ function oliveskspaces_preprocess_field__node__created(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for setting classes. |
|
|
|
* Implements hook_preprocess_HOOK() for setting classes. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_filter_caption(&$variables) { |
|
|
|
function oliveskspaces_preprocess_filter_caption(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$variables['classes'] = isset($variables['classes']) && !empty($variables['classes']) ? $variables['classes'] . ' caption' : 'caption'; |
|
|
|
$variables['classes'] = isset($variables['classes']) && !empty($variables['classes']) ? $variables['classes'] . ' caption' : 'caption'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_form_FORM_ID_alter(). |
|
|
|
* Implements hook_form_FORM_ID_alter(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_form_node_preview_form_select_alter(&$form, FormStateInterface $form_state, $form_id) { |
|
|
|
function oliveskspaces_form_node_preview_form_select_alter(&$form, FormStateInterface $form_state, $form_id) |
|
|
|
|
|
|
|
{ |
|
|
|
$form['backlink']['#options']['attributes']['class'][] = 'button'; |
|
|
|
$form['backlink']['#options']['attributes']['class'][] = 'button'; |
|
|
|
$form['backlink']['#options']['attributes']['class'][] = 'button--small'; |
|
|
|
$form['backlink']['#options']['attributes']['class'][] = 'button--small'; |
|
|
|
$form['backlink']['#options']['attributes']['class'][] = 'button--icon-back'; |
|
|
|
$form['backlink']['#options']['attributes']['class'][] = 'button--icon-back'; |
|
|
|
@ -519,7 +543,8 @@ function oliveskspaces_form_node_preview_form_select_alter(&$form, FormStateInte |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for comment.html.twig. |
|
|
|
* Implements hook_preprocess_HOOK() for comment.html.twig. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_comment(&$variables) { |
|
|
|
function oliveskspaces_preprocess_comment(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// Getting the node creation time stamp from the comment object. |
|
|
|
// Getting the node creation time stamp from the comment object. |
|
|
|
$date = $variables['comment']->getCreatedTime(); |
|
|
|
$date = $variables['comment']->getCreatedTime(); |
|
|
|
// Formatting "created" as "X days ago". |
|
|
|
// Formatting "created" as "X days ago". |
|
|
|
@ -529,7 +554,8 @@ function oliveskspaces_preprocess_comment(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_HOOK() for field--comment.html.twig. |
|
|
|
* Implements hook_preprocess_HOOK() for field--comment.html.twig. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_field__comment(&$variables) { |
|
|
|
function oliveskspaces_preprocess_field__comment(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// Add a comment_count. |
|
|
|
// Add a comment_count. |
|
|
|
$variables['comment_count'] = count(array_filter($variables['comments'], 'is_numeric', ARRAY_FILTER_USE_KEY)); |
|
|
|
$variables['comment_count'] = count(array_filter($variables['comments'], 'is_numeric', ARRAY_FILTER_USE_KEY)); |
|
|
|
|
|
|
|
|
|
|
|
@ -550,7 +576,8 @@ function oliveskspaces_preprocess_field__comment(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_element_info_alter(). |
|
|
|
* Implements hook_element_info_alter(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_element_info_alter(&$info) { |
|
|
|
function oliveskspaces_element_info_alter(&$info) |
|
|
|
|
|
|
|
{ |
|
|
|
if (array_key_exists('text_format', $info)) { |
|
|
|
if (array_key_exists('text_format', $info)) { |
|
|
|
$info['text_format']['#pre_render'][] = [OliveskspacesPreRender::class, 'textFormat']; |
|
|
|
$info['text_format']['#pre_render'][] = [OliveskspacesPreRender::class, 'textFormat']; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -565,7 +592,8 @@ function oliveskspaces_element_info_alter(&$info) { |
|
|
|
* |
|
|
|
* |
|
|
|
* @todo Remove when https://www.drupal.org/node/3016343 is fixed. |
|
|
|
* @todo Remove when https://www.drupal.org/node/3016343 is fixed. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_text_format_wrapper(&$variables) { |
|
|
|
function oliveskspaces_preprocess_text_format_wrapper(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$description_attributes = []; |
|
|
|
$description_attributes = []; |
|
|
|
if (!empty($variables['attributes']['id'])) { |
|
|
|
if (!empty($variables['attributes']['id'])) { |
|
|
|
$description_attributes['id'] = $variables['attributes']['aria-describedby'] = $variables['attributes']['id']; |
|
|
|
$description_attributes['id'] = $variables['attributes']['aria-describedby'] = $variables['attributes']['id']; |
|
|
|
@ -577,7 +605,8 @@ function oliveskspaces_preprocess_text_format_wrapper(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_search_result(). |
|
|
|
* Implements hook_preprocess_search_result(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_search_result(&$variables) { |
|
|
|
function oliveskspaces_preprocess_search_result(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// Apply custom date formatter to "date" field. |
|
|
|
// Apply custom date formatter to "date" field. |
|
|
|
if (!empty($variables['result']['date'])) { |
|
|
|
if (!empty($variables['result']['date'])) { |
|
|
|
$variables['info_date'] = \Drupal::service('date.formatter')->format($variables['result']['node']->getCreatedTime(), 'oliveskspaces_medium'); |
|
|
|
$variables['info_date'] = \Drupal::service('date.formatter')->format($variables['result']['node']->getCreatedTime(), 'oliveskspaces_medium'); |
|
|
|
@ -587,7 +616,8 @@ function oliveskspaces_preprocess_search_result(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_links__comment(). |
|
|
|
* Implements hook_preprocess_links__comment(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_links__comment(&$variables) { |
|
|
|
function oliveskspaces_preprocess_links__comment(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
foreach ($variables['links'] as &$link) { |
|
|
|
foreach ($variables['links'] as &$link) { |
|
|
|
$link['link']['#options']['attributes']['class'][] = 'comment__links-link'; |
|
|
|
$link['link']['#options']['attributes']['class'][] = 'comment__links-link'; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -596,16 +626,17 @@ function oliveskspaces_preprocess_links__comment(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_preprocess_table(). |
|
|
|
* Implements hook_preprocess_table(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_preprocess_table(&$variables) { |
|
|
|
function oliveskspaces_preprocess_table(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
// Mark the whole table and the first cells if rows are draggable. |
|
|
|
// Mark the whole table and the first cells if rows are draggable. |
|
|
|
if (!empty($variables['rows'])) { |
|
|
|
if (!empty($variables['rows'])) { |
|
|
|
$draggable_row_found = FALSE; |
|
|
|
$draggable_row_found = false; |
|
|
|
foreach ($variables['rows'] as &$row) { |
|
|
|
foreach ($variables['rows'] as &$row) { |
|
|
|
/** @var \Drupal\Core\Template\Attribute $row['attributes'] */ |
|
|
|
/** @var \Drupal\Core\Template\Attribute $row['attributes'] */ |
|
|
|
if (!empty($row['attributes']) && $row['attributes']->hasClass('draggable')) { |
|
|
|
if (!empty($row['attributes']) && $row['attributes']->hasClass('draggable')) { |
|
|
|
if (!$draggable_row_found) { |
|
|
|
if (!$draggable_row_found) { |
|
|
|
$variables['attributes']['class'][] = 'draggable-table'; |
|
|
|
$variables['attributes']['class'][] = 'draggable-table'; |
|
|
|
$draggable_row_found = TRUE; |
|
|
|
$draggable_row_found = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -615,7 +646,8 @@ function oliveskspaces_preprocess_table(&$variables) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Implements hook_form_views_exposed_form_alter(). |
|
|
|
* Implements hook_form_views_exposed_form_alter(). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function oliveskspaces_form_views_exposed_form_alter(&$form) { |
|
|
|
function oliveskspaces_form_views_exposed_form_alter(&$form) |
|
|
|
|
|
|
|
{ |
|
|
|
$form['#attributes']['class'][] = 'form--inline'; |
|
|
|
$form['#attributes']['class'][] = 'form--inline'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -638,7 +670,8 @@ function oliveskspaces_form_views_exposed_form_alter(&$form) { |
|
|
|
* |
|
|
|
* |
|
|
|
* @internal |
|
|
|
* @internal |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function _oliveskspaces_hex_to_hsl(string $hex_string) { |
|
|
|
function _oliveskspaces_hex_to_hsl(string $hex_string) |
|
|
|
|
|
|
|
{ |
|
|
|
// Convert hexcode pairs to rgb values (0-255). |
|
|
|
// Convert hexcode pairs to rgb values (0-255). |
|
|
|
$hex_val = trim($hex_string, '#'); |
|
|
|
$hex_val = trim($hex_string, '#'); |
|
|
|
$r0 = hexdec($hex_val[0] . $hex_val[1]); |
|
|
|
$r0 = hexdec($hex_val[0] . $hex_val[1]); |
|
|
|
@ -657,8 +690,7 @@ function _oliveskspaces_hex_to_hsl(string $hex_string) { |
|
|
|
|
|
|
|
|
|
|
|
if ($delta == 0) { |
|
|
|
if ($delta == 0) { |
|
|
|
$h = 0; |
|
|
|
$h = 0; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
switch ($c_max) { |
|
|
|
switch ($c_max) { |
|
|
|
case $r: |
|
|
|
case $r: |
|
|
|
$h = fmod((($g - $b) / $delta), 6); |
|
|
|
$h = fmod((($g - $b) / $delta), 6); |
|
|
|
@ -698,7 +730,8 @@ function _oliveskspaces_hex_to_hsl(string $hex_string) { |
|
|
|
return [$h, $s, $l]; |
|
|
|
return [$h, $s, $l]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function oliveskspaces_preprocess_mirador(&$variables) { |
|
|
|
function oliveskspaces_preprocess_mirador(&$variables) |
|
|
|
|
|
|
|
{ |
|
|
|
$key = "#{$variables['mirador_view_id']}"; |
|
|
|
$key = "#{$variables['mirador_view_id']}"; |
|
|
|
if (!isset($variables['#attached']['drupalSettings']['mirador']['viewers'][$key])) { |
|
|
|
if (!isset($variables['#attached']['drupalSettings']['mirador']['viewers'][$key])) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
@ -706,4 +739,11 @@ function oliveskspaces_preprocess_mirador(&$variables) { |
|
|
|
$viewer = &$variables['#attached']['drupalSettings']['mirador']['viewers'][$key]; |
|
|
|
$viewer = &$variables['#attached']['drupalSettings']['mirador']['viewers'][$key]; |
|
|
|
|
|
|
|
|
|
|
|
// ---- Paste configuration overrides below ---- |
|
|
|
// ---- Paste configuration overrides below ---- |
|
|
|
|
|
|
|
$viewer['window']['panels']['info'] = false; |
|
|
|
|
|
|
|
$viewer['window']['panels']['attribution'] = false; |
|
|
|
|
|
|
|
$viewer['window']['panels']['canvas'] = false; |
|
|
|
|
|
|
|
$viewer['window']['panels']['annotations'] = false; |
|
|
|
|
|
|
|
$viewer['window']['panels']['layers'] = false; |
|
|
|
|
|
|
|
$viewer['window']['panels']['search'] = true; |
|
|
|
|
|
|
|
$viewer['window']['defaultSideBarPanel'] = 'search'; |
|
|
|
} |
|
|
|
} |
|
|
|
|