Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ctools / includes / utility.inc @ 96a203dd

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
}