111 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			111 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
/**
 | 
						|
 * @file
 | 
						|
 * Functions to support theming in the Seven theme.
 | 
						|
 */
 | 
						|
 | 
						|
use Drupal\Core\Form\FormStateInterface;
 | 
						|
use \Drupal\Core\Url;
 | 
						|
use Drupal\Core\Render\Markup;
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_preprocess_HOOK() for HTML document templates.
 | 
						|
 */
 | 
						|
// function ouatminimal_preprocess_html(&$variables) {
 | 
						|
//   // If on a node add or edit page, add a node-layout class.
 | 
						|
//   $path_args = explode('/', \Drupal::request()->getPathInfo());
 | 
						|
//   if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) {
 | 
						|
//     foreach ($suggestions as $suggestion) {
 | 
						|
//       // dsm($suggestion);
 | 
						|
//       preg_match('/taxonomy-manage-[^-]+-add$/', $suggestion, $matches);
 | 
						|
//       // ksm($matches);
 | 
						|
//       if ($suggestion === 'page--taxonomy-term-edit' || isset($matches)) {
 | 
						|
//         $variables['attributes']['class'][] = 'node-form-layout';
 | 
						|
//       }
 | 
						|
//     }
 | 
						|
//   }
 | 
						|
// }
 | 
						|
 | 
						|
// function ouatminimal_form_alter(&$form, FormStateInterface $form_state, $form_id){
 | 
						|
//   // dsm($form_id);
 | 
						|
//   // create a colomuned term form (not working yet)
 | 
						|
//   if(in_array($form_id, ['taxonomy_term_company_form', 'taxonomy_term_showroom_form'])){
 | 
						|
//     // ksm($form);
 | 
						|
//     $form['#theme'] = ['term_edit_form'];
 | 
						|
//     $form['#attached']['library'][] = 'seven/node-form';
 | 
						|
// 
 | 
						|
//     $form['advanced']['#type'] = 'container';
 | 
						|
//     $form['meta']['#type'] = 'container';
 | 
						|
//     $form['meta']['#access'] = TRUE;
 | 
						|
//     $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
 | 
						|
//     $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
 | 
						|
// 
 | 
						|
//     $form['revision_information']['#type'] = 'container';
 | 
						|
//     $form['revision_information']['#group'] = 'meta';
 | 
						|
//   }
 | 
						|
// }
 | 
						|
 | 
						|
/**
 | 
						|
 * Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm.
 | 
						|
 *
 | 
						|
 * Changes vertical tabs to container.
 | 
						|
 */
 | 
						|
function ouatminimal_form_node_form_alter(&$form, FormStateInterface $form_state) {
 | 
						|
  $form['#theme'] = ['node_edit_form'];
 | 
						|
  $form['#attached']['library'][] = 'seven/node-form';
 | 
						|
 | 
						|
  $form['advanced']['#type'] = 'container';
 | 
						|
  $form['meta']['#type'] = 'container';
 | 
						|
  $form['meta']['#access'] = TRUE;
 | 
						|
  $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
 | 
						|
  $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
 | 
						|
 | 
						|
  $form['revision_information']['#type'] = 'container';
 | 
						|
  $form['revision_information']['#group'] = 'meta';
 | 
						|
}
 | 
						|
 | 
						|
// https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_theme_suggestions_HOOK_alter/10
 | 
						|
function ouatminimal_theme_suggestions_node_edit_form_alter(array &$suggestions, array $variables) {
 | 
						|
  if ($node = \Drupal::routeMatch()->getParameter('node')){
 | 
						|
    $nid = $node->id();
 | 
						|
    $type = $node->getType();
 | 
						|
    $suggestions[] = 'node_edit_form__node_' . $type;
 | 
						|
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
// https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_theme_suggestions_HOOK_alter/10
 | 
						|
function ouatminimal_theme_suggestions_field_multiple_value_form_alter(array &$suggestions, array $variables) {
 | 
						|
  if ($node = \Drupal::routeMatch()->getParameter('node')){
 | 
						|
    $nid = $node->id();
 | 
						|
    $type = $node->getType();
 | 
						|
    $suggestions[] = 'field_multiple_value_form__' . $variables['element']['#field_name'];
 | 
						|
    $suggestions[] = 'field_multiple_value_form__node_' . $type;
 | 
						|
    $suggestions[] = 'field_multiple_value_form__' . $variables['element']['#field_name'] . '__node_' . $type;
 | 
						|
 | 
						|
  }
 | 
						|
}
 | 
						|
// field-multiple-value-form--field-entite--node-concernement
 | 
						|
function ouatminimal_preprocess_field_multiple_value_form__field_entite__node_concernement(&$variables) {
 | 
						|
  // $element = $variables['element'];
 | 
						|
  $attributes = $variables['attributes'];
 | 
						|
  $variables['#attached']['library'][] = 'ouatminimal/boussole';
 | 
						|
}
 | 
						|
// template_preprocess_field_multiple_value_form
 | 
						|
// function ouatminimal_preprocess_field_multiple_value_form(&$variables) {
 | 
						|
//   $element = $variables['element'];
 | 
						|
//   $attributes = $variables['attributes'];
 | 
						|
//   if($attributes['data-drupal-selector'] === 'edit-field-entite' ){
 | 
						|
//     $t="t";
 | 
						|
//   }
 | 
						|
// }
 | 
						|
 | 
						|
function ouatminimal_preprocess_toolbar(&$variables) {
 | 
						|
  unset($variables['tabs']['home']['link']['#options']['attributes']['data-toolbar-escape-admin']);
 | 
						|
  unset($variables['tabs']['home']['link']['#attributes']['data-toolbar-escape-admin']);
 | 
						|
  unset($variables['tabs']['home']['link']['#markup']);
 | 
						|
  unset($variables['tabs']['home']['link']['#children']);
 | 
						|
  $uri = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
 | 
						|
  $variables['tabs']['home']['link']['#url'] = Url::fromUri($uri);
 | 
						|
} |