1 layout.admin.inc | layout_block_list() |
Menu callback; Lists all blocks and their modules.
File
- core/
modules/ layout/ layout.admin.inc, line 3529 - Admin page callbacks for the Layout module.
Code
function layout_block_list() {
$rows = array();
$module_blocks = layout_get_block_info();
$usage = layout_get_block_usage();
// Get all blocks.
foreach ($module_blocks as $module => $blocks) {
if (!empty($blocks)) {
foreach ($blocks as $delta => $block) {
$contexts = !empty($block['required contexts']) ? implode(",", $block['required contexts']) : '';
$usages = array();
if (isset($usage[$module][$delta])) {
foreach ($usage[$module][$delta] as $layout => $layout_use) {
$instances = array();
foreach ($layout_use as $position => $block_use) {
foreach ($block_use as $instance) {
$instances[$position][] = $instance;
}
}
$positions = implode(', ', array_map('ucfirst', array_keys($instances)));
$usages[] = l($instance->layout_title . ' (' . $positions . ')', 'admin/structure/layouts/manage/' . $layout);
}
}
$usage_list = $usages ? theme('item_list', array('items' => $usages)) : t('Not in use');
$block_name = theme('label_machine_name__layout_block', array(
'label' => $block['info'],
'machine_name' => $delta,
));
$rows[] = array(
'name' => $block_name,
'usage' => $usage_list,
'module' => $module,
'contexts' => $contexts,
);
}
}
}
$header = array(
array(
'data' => 'Name',
'field' => 'name',
'sort' => 'ASC',
),
array(
'data' => 'Usage',
'field' => 'usage',
'sort' => 'ASC',
),
array(
'data' => 'Module',
'field' => 'module',
'sort' => 'ASC',
'class' => array(RESPONSIVE_PRIORITY_LOW),
),
array(
'data' => 'Required contexts',
'field' => 'contexts',
'class' => array(RESPONSIVE_PRIORITY_LOW),
),
);
$order = tablesort_get_order($header);
$sort = tablesort_get_sort($header);
backdrop_sort($rows, array($order['sql'] => SORT_STRING));
$rows = ($sort == 'asc') ? $rows : array_reverse($rows);
$page['description_container'] = array(
'#type' => 'container',
);
$page['description_container']['description'] = array(
'#type' => 'help',
'#markup' => t("Provides a summary of all available blocks. The 'Usage' column shows which layout and region to which blocks are currently assigned in the format 'Layout name (region)'."),
);
$page['table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('There are no blocks.'),
);
return $page;
}