1 block.node_types.inc | DashboardContentTypesBlock::getContent() |
Return the content of a block.
Return value
mixed:
Overrides Block::getContent
File
- core/
modules/ dashboard/ includes/ block.node_types.inc, line 50 - Dashboard block displaying information about content types.
Class
- DashboardContentTypesBlock
- @file Dashboard block displaying information about content types.
Code
function getContent() {
$node_types = node_type_get_types();
$access = user_access('administer content types');
$options = array('destination' => current_path());
$header = array(
array('data' => t('Content type')),
array('data' => t('Operations')),
);
$rows = array();
// Check access, then add a link to create content.
if ($access) {
foreach ($node_types as $machine => $node_type) {
// If no types are specified, show all types.
if (empty($this->settings['types']) || in_array($machine, $this->settings['types'])) {
$type_url_string = str_replace('_', '-', $node_type->type);
$links['configure'] = array(
'title' => t('Configure'),
'href' => 'admin/structure/types/manage/' . $type_url_string,
'query' => $options,
);
$links['manage'] = array(
'title' => t('Manage fields'),
'href' => 'admin/structure/types/manage/' . $type_url_string . '/fields',
'query' => $options,
);
$links['add'] = array(
'title' => t('Manage display'),
'href' => 'admin/structure/types/manage/' . $type_url_string . '/display',
'query' => $options,
);
$operations = array(
'#type' => 'dropbutton',
'#links' => $links,
);
$rows[] = array(
'data' => array(
check_plain(t($node_type->name)),
backdrop_render($operations),
),
);
}
}
}
else {
return array();
}
if (empty($rows)) {
$rows[] = array(
array(
'data' => t('There are no content types to display.'),
'colspan' => 4,
),
);
}
$panel = array(
'#theme' => 'dashboard_panel__node_types',
);
$panel['table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
if ($access) {
$panel['link'] = array(
'#theme' => 'link',
'#path' => 'admin/structure/types',
'#text' => t('Manage content types'),
);
}
return $panel;
}