more_fields-2.2.19/more_fields.theme.inc

more_fields.theme.inc
<?php

use Drupal\Component\Serialization\Json;
use Drupal\Core\Template\Attribute;

function template_preprocess_more_fields_experience_formatter(&$vars) {
  $vars['item'] = [];
  if (!empty($vars['element']['#item'])) {
    $vars['item'] = $vars['element']['#item'];
  }
}

function template_preprocess_more_fields_value_niveau_formatter(&$vars) {
  // dump($vars);
  if (!empty($vars['element']['#item'])) {
    $vars['item'] = $vars['element']['#item'];
  }
}

function template_preprocess_more_fields_experience_formatter3(&$vars) {
  $vars['item'] = [];
  if (!empty($vars['element']['#item'])) {
    $vars['item'] = $vars['element']['#item'];
  }
}

function template_preprocess_more_fields_icon_text(&$vars) {
  $vars['item'] = [];
  if (!empty($vars['element']['#item'])) {
    $vars['item'] = $vars['element']['#item'];
  }
}

function template_preprocess_more_fields_text_bg(&$vars) {
  $vars['item'] = [];
  if (!empty($vars['element']['#item'])) {
    $vars['item'] = $vars['element']['#item'];
  }
}

function template_preprocess_more_fields_accordion_field_formatter(&$vars) {
  if (!empty($vars['element']['#items'])) {
    $vars['items'] = $vars['element']['#items'];
    $vars['attribute'] = $vars['element']['#attribute'];
    $vars['attribute_box'] = $vars['element']['#attribute_box'];
  }
}

function template_preprocess_more_fields_accordion_field_tab_formatter(&$vars) {
  // dd($vars);
  if (!empty($vars['element']['#items'])) {
    $vars['items'] = $vars['element']['#items'];
    $vars['attribute_field'] = $vars['element']['#attribute_field'];
    $vars['field_header_class'] = $vars['element']['#field_header_class'];
    $vars['field_content_class'] = $vars['element']['#field_content_class'];
  }
}

function template_preprocess_more_fields_bef_checkboxes(&$vars) {
  //
}

function template_preprocess_more_fields_bef_radios(&$vars) {
  /**
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
   */
  $moduleHandler = \Drupal::moduleHandler();
  $moduleHandler->loadInclude('better_exposed_filters', "inc", 'includes/better_exposed_filters.theme');
  template_preprocess_bef_radios($vars);
}


function template_preprocess_more_fields_base(&$vars) {
  if (!empty($vars["element"]["#item"])) {
    $vars["item"] = $vars["element"]["#item"];
    $vars['attributes'] = $vars["element"]['#attributes'];
  }
}


function template_preprocess_more_fields_multirender_formatter(&$vars) {
  template_preprocess_more_fields_base($vars);
}

function template_preprocess_more_fields_flexible_text_long_formatter(&$vars) {
  if (!empty($vars["element"]["#item"])) {
    $vars["item"] = $vars["element"]["#item"];
    $vars['attributes'] = $vars["element"]['#attributes'];
    $vars['settings'] = $vars["element"]['#settings'];
  }
}

function template_preprocess_more_fields_restrained_text_formatter(&$vars) {
  if (!empty($vars["element"]["#item"])) {
    $vars["item"] = $vars["element"]["#item"];
    $vars['attributes'] = $vars["element"]['#attributes'];
    $vars['settings'] = $vars["element"]['#settings'];
  }
}

function template_preprocess_more_field_file_image_video($vars) {
  $vars['#attached']['library'][] = 'more_fields/more_field_file_image_video';
  if (!empty($vars["element"]["#item"])) {
    $vars["item"] = $vars["element"]["#item"];
  }
}

function template_preprocess_more_field_mit_gallery_formatter(&$vars) {
  $vars['#attached']['library'][] = 'more_fields/more_field_mit_gallery_formatter';
  if (!empty($vars["element"]["#item"])) {
    $vars["item"] = $vars["element"]["#item"];
  }
}

function template_preprocess_gallery_overlay(&$vars) {
  $image_attributes = [];
  $stop = 0;


  $jsSettings = [
    "section" => [
      "selector" => "#",
      "value" => $vars['image_attributes']['field_attribute']["id"]
    ],
    "galleryContainer" => [
      "selector" => "#",
      "value" => $vars['image_attributes']['gallery_attribute']["id"]
    ],
    "fade_time" => $vars["settings"]["fade_time"],
  ];
  foreach ($vars['image_attributes'] as $key => $value) {
    if (gettype($value) == 'array') {
      $image_attributes[$key] = new Attribute($value);
    } else {
      $image_attributes[$key] = new Attribute(['class' => explode(' ', $value)]);
    }
  }
  $vars['image_attributes'] = $image_attributes;
  $vars['field_attribute'] = $vars['image_attributes']['field_attribute'];
  $vars['gallery_attribute'] = $vars['image_attributes']['gallery_attribute'];
  $vars['field_attribute']->setAttribute('data-gallery-overlay', Json::encode($jsSettings));

  unset($vars['image_attributes']['gallery_attribute']);
  unset($vars['image_attributes']['field_class']);
  $vars['#attached']['library'][] = 'more_fields/more_field_gallery_overlay';
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc