taxonomy_manager-2.0.3/taxonomy_manager.module

taxonomy_manager.module
<?php

/**
 * @file
 * Taxonomy Manager.
 *
 * Administration interface for managing taxonomy vocabularies.
 */

/**
 * Implements hook_admin_menu_map().
 */
function taxonomy_manager_admin_menu_map() {
  if (!\Drupal::currentUser()->hasPermission('administer taxonomy')) {
    return;
  }
  $map['admin/structure/taxonomy_manager/voc/%taxonomy_vocabulary_machine_name'] = [
    'parent' => 'admin/structure/taxonomy_manager/voc',
    'arguments' => [
      ['%taxonomy_vocabulary_machine_name' => array_keys(\Drupal::entityQuery('taxonomy_vocabulary')->execute())],
    ],
  ];
  return $map;
}

/**
 * Implements hook_help().
 */
function taxonomy_manager_help($path, $arg) {
  switch ($path) {
    case 'admin/help#taxonomy_manager':
      $output = t("The Taxonomy Manager provides an additional interface for managing vocabularies of the taxonomy module. It's especially very useful for long sets of terms.
                   The vocabulary is represented in a dynamic tree view.
                   It supports operation like mass adding and deleting of terms, fast weight editing, moving of terms in hierarchies, merging of terms and fast term data editing.
                   For more information on how to use please read the readme file included in the taxonomy_manager directory.");
      return $output;
  }
}

/**
 * Implements hook_entity_type_alter().
 */
function taxonomy_manager_entity_type_alter(array &$entity_types) {
  // Provide a custom form class for editing terms via taxonomy manager.
  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
  foreach ($entity_types as $type => $entity_type) {
    if ($type == 'taxonomy_term' && !$entity_type->getFormClass('taxonomy_manager')) {
      $entity_type->setFormClass('taxonomy_manager', '\Drupal\taxonomy_manager\Form\TaxonomyManagerTermForm');
    }
  }
}

/**
 * Checks whether the given vocabulary supports translations.
 */
function taxonomy_manager_vocabulary_translatable($vid): bool {
  if (\Drupal::hasService('content_translation.manager')) {
    $translatable = \Drupal::config('taxonomy_manager.settings')->get('taxonomy_manager_translations') &&
      \Drupal::service('content_translation.manager')->isEnabled('taxonomy_term', $vid);
  }
  return $translatable ?? FALSE;
}

/**
 * Implements hook_library_info_alter().
 */
function taxonomy_manager_library_info_alter(&$libraries, $extension) {
  if ($extension === 'taxonomy_manager' && isset($libraries['jquery.fancytree'])) {
    if (!file_exists(DRUPAL_ROOT . array_key_first($libraries['jquery.fancytree']['js']))) {
      $libraries['jquery.fancytree'] = $libraries['jquery.fancytree.cdn'];
    }
  }
}

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

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