Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / diff / diff.module
1 <?php
2
3 /**
4  * @file
5  * This is the diff module to compare revisions.
6  */
7
8 use Drupal\Core\Routing\RouteMatchInterface;
9
10 /**
11  * Implements hook_help().
12  */
13 function diff_help($route_name, RouteMatchInterface $route_match) {
14   switch ($route_name) {
15     case 'help.page.diff':
16       $output = '';
17       $output .= '<h3>' . t('About') . '</h3>';
18       $output .= '<p>' . t('The Diff module replaces the normal <em>Revisions </em> node tab and enhances the listing of revisions with an option to view the differences between any two content revisions.') . '</p>';
19       $output .= '<h3>' . t('Uses') . '</h3>';
20       $output .= '<dl>';
21       $output .= '<dt>' . t('Compare content entity revisions') . '</dt>';
22       $output .= '<dd>' . t('Diff provides the possibility of comparing two node revisions but it also provides support for comparing any two content entities. With minimum effort it can be extended to display differences between any two content entities.') . '</dd>';
23       $output .= '<dt>' . t('Control field visibility settings') . '</dt>';
24       $output .= '<dd>' . t('Fields visibility can be controlled from view modes for configurable fields and from Diff settings page for entity base fields. Diff field types specific settings can also be configured from Diff settings page') . '</dd>';
25       $output .= '<dt>' . t('Configure diff field type settings') . '</dt>';
26       $output .= '<dd>' . t('Every field type has specific diff settings (display or not the field title, markdown format or other settings). These settings can be configured from Diff settings page') . '</dd>';
27       $output .= '</dl>';
28       return $output;
29
30     case 'diff.general_settings':
31       return '<p>' . t('Configurations for the revision comparison functionality and diff layout plugins.') . '</p>';
32
33     case 'diff.revision_overview':
34       return '<p>' . t('Revisions allow you to track differences between multiple versions of your content, and revert to older versions.') . '</p>';
35
36     case 'diff.fields_list':
37       return '<p>' . t('This table provides a summary of the field support found on the system. For every field, a diff plugin can be selected and configured. These settings are applied to Unified and Split fields layouts.') . '</p>';
38   }
39 }
40
41 /**
42  * Returns the label of a certain field.
43  *
44  * Therefore it looks up in all bundles to find the most used field.
45  *
46  * @param string $entity_type
47  *   The entity type id.
48  * @param string $field_name
49  *   The field name.
50  *
51  * @return array
52  *   Array of labels used for the field sorted by the most used.
53  */
54 function _diff_field_label($entity_type, $field_name) {
55   $labels = [];
56   // Count the amount of instances of each label per field storage.
57   $bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type);
58   $field_manager = \Drupal::service('entity_field.manager');
59   foreach (array_keys($bundles) as $bundle) {
60     $bundle_instances = $field_manager->getFieldDefinitions($entity_type, $bundle);
61     if (isset($bundle_instances[$field_name])) {
62       $instance = $bundle_instances[$field_name];
63       $label = (string) $instance->getLabel();
64       $labels[$label] = isset($labels[$label]) ? ++$labels[$label] : 1;
65     }
66   }
67
68   if (empty($labels)) {
69     // Return the original field name if there is no other label found.
70     return [$field_name];
71   }
72
73   // Return the labels sorted by the most used.
74   arsort($labels);
75   return array_keys($labels);
76 }