skinr-8.x-2.0-alpha2/modules/system.skinr.inc

modules/system.skinr.inc
<?php

/**
 * @file
 * Implements Skinr hooks for system.module.
 */

/**
 * Implements hook_skinr_config_info().
 */
function system_skinr_config_info() {
  // @todo Break apart into html and region types.
  return ['system' => t('System')];
}

/**
 * Implements hook_skinr_ui_element_options().
 */
function system_skinr_ui_element_options($theme_name = NULL) {
  $options = ['system' => []];

  $options['system']['html'] = t('Page');
  $theme_handler = \Drupal::service('theme_handler');
  $themes = $theme_handler->listInfo();
  foreach ($themes as $theme_name => $theme) {
    if (empty($theme->status)) {
      continue;
    }
    // Create a list options containing visible regions of this theme.
    $regions = [];
    foreach (system_region_list($theme_name, REGIONS_VISIBLE) as $region_name => $region) {
      $regions['region__' . $region_name] = $region;
    }
    // Group the list of options by theme.
    $key = t('@name Regions', ['@name' => $theme->info['name']])->__toString();
    $options['system'][$key] = $regions;
  }

  return $options;
}

/**
 * Implements hook_skinr_ui_element_title().
 */
function system_skinr_ui_element_title($module, $element, $theme_name) {
  if ($module == 'system') {
    $regions = system_region_list($theme_name);

    $title = t('Page');
    if (strpos($element, 'region') === 0) {
      // Strip the region__ part off the region name.
      $region = substr($element, 8);
      $title = t('Region %region', ['%region' => $regions[$region] ?? $region]);
    }
    return $title;
  }
}

/**
 * Implements hook_skinr_theme_hooks().
 */
function system_skinr_theme_hooks($module, $element) {
  $theme_hooks = [];

  if ($module == 'system') {
    if ($element == 'html') {
      $theme_hooks[] = 'html';
    }
    else {
      $theme_hooks[] = $element;
      $theme_hooks[] = 'region';
    }
  }

  return $theme_hooks;
}

/**
 * Implements hook_skinr_elements().
 */
function system_skinr_elements($variables, $hook) {
  $elements = [];
  if ($hook == 'html') {
    $elements['system'] = ['html'];
  }
  elseif ($hook == 'region') {
    $elements['system'] = ['region__' . $variables['region']];
  }
  return $elements;
}

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

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