| 1 |
<?php
|
| 2 |
// $Id: module_paths.module,v 1.4 2008/05/17 16:49:12 soxofaan Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_menu().
|
| 6 |
*/
|
| 7 |
function module_paths_menu() {
|
| 8 |
$items = array();
|
| 9 |
$items['module_paths'] = array(
|
| 10 |
'title' => 'Module paths',
|
| 11 |
'description' => 'View the paths of the enabled modules.',
|
| 12 |
'page callback' => 'module_paths_page',
|
| 13 |
'access arguments' => array('view module paths information'),
|
| 14 |
'type' => MENU_CALLBACK,
|
| 15 |
);
|
| 16 |
return $items;
|
| 17 |
}
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Implementation of hook_perm().
|
| 21 |
*/
|
| 22 |
function module_paths_perm() {
|
| 23 |
return array('view module paths information');
|
| 24 |
}
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Implementation of hook_block()
|
| 28 |
*/
|
| 29 |
function module_paths_block($op = 'list', $delta = 0, $edit = array()) {
|
| 30 |
switch ($op) {
|
| 31 |
case 'list':
|
| 32 |
$blocks['module_paths'] = array('info' => t('Module paths'),);
|
| 33 |
return $blocks;
|
| 34 |
case 'view':
|
| 35 |
switch ($delta) {
|
| 36 |
case 'module_paths':
|
| 37 |
$block['subject'] = t('Module paths');
|
| 38 |
# build content
|
| 39 |
$items = array();
|
| 40 |
foreach (module_list() as $module) {
|
| 41 |
$parts = explode('/', drupal_get_path('module', $module));
|
| 42 |
if ($parts[0] != 'modules') {
|
| 43 |
$items[] = check_plain(array_pop($parts));
|
| 44 |
}
|
| 45 |
}
|
| 46 |
sort($items);
|
| 47 |
if (user_access('view module paths information')) {
|
| 48 |
$items[] = l(t('more ...'), 'module_paths');
|
| 49 |
}
|
| 50 |
$block['content'] = implode(', ', $items);;
|
| 51 |
break;
|
| 52 |
}
|
| 53 |
return $block;
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
/**
|
| 58 |
* Page with list of enabled modules and their paths
|
| 59 |
*/
|
| 60 |
function module_paths_page() {
|
| 61 |
$header = array(t('Module'), t('Path'));
|
| 62 |
$rows = array();
|
| 63 |
foreach (module_list() as $module) {
|
| 64 |
$rows[] = array(check_plain($module), check_plain(drupal_get_path('module', $module)));
|
| 65 |
}
|
| 66 |
return theme_table($header, $rows);
|
| 67 |
}
|