Projet

Général

Profil

Paste
Télécharger (3,71 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ds / modules / ds_extras / includes / ds_extras.registry.inc @ 3dfa8105

1
<?php
2

    
3
/**
4
 * @file
5
 * Display Suite Extras registry file.
6
 */
7

    
8
/**
9
 * Implements hook_menu_alter().
10
 */
11
function _ds_extras_menu_alter(&$items) {
12

    
13
  // Switch view mode.
14
  if (variable_get('ds_extras_switch_view_mode', FALSE)) {
15

    
16
    // Check if page manager is overriding.
17
    $skip_node_override = FALSE;
18
    if (module_exists('page_manager')) {
19
      if ($task = page_manager_get_task('node_view')) {
20
        if (isset($task['disabled']) && !$task['disabled']) {
21
          $skip_node_override = TRUE;
22
        }
23
      }
24
    }
25

    
26
    if (!$skip_node_override) {
27
      $items['node/%node']['page callback'] = 'ds_extras_node_page_view';
28
      $items['node/%node']['file'] = 'includes/ds_extras.pages.inc';
29
      $items['node/%node']['file path'] = drupal_get_path('module', 'ds_extras');
30
    }
31
  }
32
}
33

    
34
/**
35
 * Implements hook_entity_info().
36
 */
37
function _ds_extras_entity_info() {
38

    
39
  if (!variable_get('ds_extras_vd', FALSE)) {
40
    return;
41
  }
42

    
43
  $bundles = array();
44
  ctools_include('export');
45
  $vd_settings = ctools_export_crud_load_all('ds_vd');
46
  foreach ($vd_settings as $key => $vd) {
47
    $bundles[$vd->vd] = array(
48
      'label' => check_plain($vd->label),
49
      'admin' => array('path' => 'admin/structure/ds/vd/manage/' . $vd->vd),
50
    );
51
  }
52

    
53
  // Register a views entity on behalf of Views.
54
  $return = array(
55
    'ds_views' => array(
56
      'label' => t('Display Suite Views'),
57
      'bundles' => $bundles,
58
      'ds_display' => TRUE,
59
      'base table' => 'views_view',
60
      'entity keys' => array(
61
        'id' => 'vid',
62
        'label' => 'name',
63
      ),
64
    ),
65
  );
66

    
67
  return $return;
68
}
69

    
70
/**
71
 * Implements hook_theme_registry_alter().
72
 */
73
function _ds_extras_theme_registry_alter(&$theme_registry) {
74

    
75
  // Add views preprocess layout.
76
  if (variable_get('ds_extras_vd', FALSE)) {
77
    $theme_registry['views_view']['preprocess functions'][] = 'ds_extras_preprocess_view_layout';
78
  }
79

    
80
  // Add process page function.
81
  if (variable_get('ds_extras_hide_page_title', FALSE)) {
82
    $theme_registry['page']['process functions'][] = 'ds_extras_process_page_title';
83
  }
84

    
85
  // Remove ds_preprocess_field in case field templates is not enabled.
86
  if (!variable_get('ds_extras_field_template', FALSE) && isset($theme_registry['field']['preprocess functions'])) {
87
    $key = array_search('ds_extras_preprocess_field', $theme_registry['field']['preprocess functions']);
88
    if (!empty($key)) {
89
      unset($theme_registry['field']['preprocess functions'][$key]);
90
    }
91
  }
92
}
93

    
94
/**
95
 * Implements hook_module_implements_alter().
96
 */
97
function _ds_extras_module_implements_alter(&$implementations, $hook) {
98

    
99
  // Because it's possible to turn on/off features for DS extras,
100
  // we'll unset hooks here if necessary which otherwhise do nothing at all.
101

    
102
  // Field template
103
  $ft_hooks = array(
104
    'ds_field_settings_alter',
105
    'form_ds_classes_form_alter',
106
    'form_field_ui_field_edit_form_alter',
107
    'theme',
108
  );
109
  if (!variable_get('ds_extras_field_template', FALSE) && in_array($hook, $ft_hooks)) {
110
    unset($implementations['ds_extras']);
111
  }
112

    
113
  // Region to block
114
  $region_hooks = array(
115
    'ds_layout_region_alter',
116
    'field_attach_view_alter',
117
    'block_info',
118
    'block_view'
119
  );
120
  if (!variable_get('ds_extras_region_to_block', FALSE) && in_array($hook, $region_hooks)) {
121
    unset($implementations['ds_extras']);
122
  }
123

    
124
  // Switch view mode
125
  $switch_hooks = array(
126
    'form_node_form_alter',
127
  );
128
  if (!variable_get('ds_extras_switch_view_mode', FALSE) && in_array($hook, $switch_hooks)) {
129
    unset($implementations['ds_extras']);
130
  }
131

    
132
  // Views displays
133
  $vd_hooks = array(
134
    'entity_info',
135
    'ctools_plugin_api',
136
    'ds_fields_ui_alter',
137
  );
138
  if (!variable_get('ds_extras_vd', FALSE) && in_array($hook, $vd_hooks)) {
139
    unset($implementations['ds_extras']);
140
  }
141
}