Projet

Général

Profil

Paste
Télécharger (1,49 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / modules / ctools / includes / utility.inc @ a5572547

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains general utility functions for CTools that do not need to be
6
 * in the module file.
7
 *
8
 * In particular, things that are only needed during hook_menu() and
9
 * hook_theme() are placed here.
10
 */
11

    
12
/**
13
 * Provide a hook passthrough to included files.
14
 *
15
 * To organize things neatly, each CTools tool gets its own toolname.$type.inc
16
 * file. If it exists, it's loaded and ctools_$tool_$type() is executed.
17
 * To save time we pass the $items array in so we don't need to do array
18
 * addition. It modifies the array by reference and doesn't need to return it.
19
 */
20
function ctools_passthrough($module, $type, &$items) {
21
  $files = file_scan_directory(drupal_get_path('module', $module) . '/includes', '/\.' . $type . '\.inc$/', array('key' => 'name'));
22
  foreach ($files as $file) {
23
    require_once DRUPAL_ROOT . '/' . $file->uri;
24
    list($tool) = explode('.', $file->name, 2);
25

    
26
    $function = $module . '_' . str_replace ('-', '_', $tool) . '_' . str_replace('-', '_', $type);
27
    if (function_exists($function)) {
28
      $function($items);
29
    }
30
  }
31
}
32

    
33
/**
34
 * Implementation of hook_theme_registry_alter()
35
 */
36
function ctools_theme_registry_alter(&$registry) {
37
  // Move this one last last last so it can catch changes made by modules and themes.
38
  $key = array_search('ctools_preprocess_page', $registry['page']['preprocess functions']);
39
  if ($key) {
40
    unset($registry['page']['preprocess functions'][$key]);
41
  }
42
  $registry['page']['preprocess functions'][] = 'ctools_preprocess_page';
43
}
44