function block_inject_exceptions_list in Block Inject 7
Callback for the Block Inject Exceptions page.
1 string reference to 'block_inject_exceptions_list'
- block_inject_menu in ./
block_inject.module - Implements hook_menu().
File
- ./
block_inject.admin.inc, line 50 - The admin functions for the module.
Code
function block_inject_exceptions_list() {
$result = block_inject_get_exceptions();
$header = array(
array(
'data' => t('Excepted Nodes'),
),
array(
'data' => t('Node type'),
),
array(
'data' => t('Type of exception'),
),
array(
'data' => t('Offset'),
),
array(
'data' => t('Offset from default condition'),
),
array(
'data' => t('Edit'),
),
);
$rows = array();
if (isset($result)) {
foreach ($result as $row) {
$node = node_load($row->nid);
$node_type = node_type_load($node->type);
// Check the exception value for the node.
$get_exception = block_inject_green_light($row->nid);
if ($get_exception['except_injection'] == 1) {
$exception = 'Not injected';
}
else {
$exception = 'Injected';
}
// Check the offset for the node.
$get_offset = block_inject_get_offset($row->nid);
if ($get_offset != 0) {
$offset = $get_offset['offset'] . ' paragraphs';
}
else {
$offset = 'None';
}
// Check for existing condition on this node.
$region_id = block_inject_find_bi_id($node->type);
$region = block_inject_get_region_by_id($region_id->id);
if ($region->bi_condition) {
$condition = unserialize($region->bi_condition);
// Get the body field.
$body_field = field_get_items('node', $node, 'body');
$body = $body_field[0]['safe_value'];
$condition_offset = block_inject_process_condition($node->type, $body);
}
$tablerow = array(
array(
'data' => l(check_plain($node->title), 'node/' . $node->nid),
),
array(
'data' => check_plain($node_type->name),
),
array(
'data' => $exception,
),
array(
'data' => $offset,
),
array(
'data' => isset($condition_offset) ? $condition_offset . ' paragraphs' : 'No',
),
array(
'data' => l(t('Edit'), 'node/' . $node->nid . '/edit'),
),
);
$rows[] = $tablerow;
}
}
if (!$rows) {
$rows[] = array(
array(
'data' => t('No exceptions available.'),
'colspan' => 6,
),
);
}
$build = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array(
'id' => 'block_inject_exceptions',
),
);
return $build;
}