Skip to content

Commit

Permalink
Issue backdrop#3882: [UX] Content type listing page: style it consist…
Browse files Browse the repository at this point in the history
…ently with the Views listing page

backdrop/backdrop-issues#3882
  • Loading branch information
klonos authored Jun 22, 2019
1 parent 6559543 commit 6c69dfe
Showing 1 changed file with 72 additions and 35 deletions.
107 changes: 72 additions & 35 deletions core/modules/node/node.types.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,96 @@
function node_overview_types() {
$types = node_type_get_types();
$names = node_type_get_names();
$field_ui = module_exists('field_ui') && user_access('administer fields');
$header = array(t('Name'), t('Operations'));

$header = array(
array('data' => t('Name'), 'class' => array('content-type-name')),
array('data' => t('Description'), 'class' => array('content-type-description', 'priority-low')),
array('data' => t('Operations'), 'class' => array('content-type-operations')),
);

$rows = array();

// Sort the list of content types by label instead of machine name.
natcasesort($names);

foreach ($names as $key => $name) {
$type = $types[$key];
$type_url_str = str_replace('_', '-', $type->type);
$row = array(theme('node_admin_overview', array('name' => $name, 'type' => $type)));
$links['configure'] = array(
'title' => t('Configure'),
'href' => 'admin/structure/types/manage/' . $type_url_str,
'weight' => 0,

$row = array();
$row[] = array(
'data' => theme('node_type_name', array('type' => $type)),
'class' => array('content-type-name'),
'data-label' => t('Name'),
);
$row[] = array(
'data' => theme('node_type_description', array('type' => $type)),
'class' => array('content-type-description'),
'data-label' => t('Description'),
);
if ($field_ui) {
$links['fields'] = array(
'title' => t('Manage fields'),
'href' => 'admin/structure/types/manage/' . $type_url_str . '/fields',
'weight' => 5,
);
$links['display'] = array(
'title' => t('Manage displays'),
'href' => 'admin/structure/types/manage/' . $type_url_str . '/display',
'weight' => 10,
);
}
if ($type->module === 'node') {
$links['delete'] = array(
'title' => t('Delete'),
'href' => 'admin/structure/types/manage/' . $type_url_str . '/delete',
'weight' => 15,
);
}
$row[] = array(
'data' => array(
'#type' => 'operations',
'#links' => $links,
'#links' => _node_type_get_operations($type),
),
'class' => array('content-type-operations'),
'data-label' => t('Operations'),
);

$rows[] = $row;
$rows[] = array(
'data' => $row,
'class' => array($type->disabled ? 'disabled' : 'enabled'),
);
}

$build['node_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No content types available. <a href="@link">Add content type</a>.', array('@link' => url('admin/structure/types/add'))),
backdrop_add_css(backdrop_get_path('module', 'node') . '/css/node.admin.css');

$table = array(
'header' => $header,
'rows' => $rows,
'empty' => t('No content types available. <a href="@link">Add content type</a>.', array('@link' => url('admin/structure/types/add'))),
'attributes' => array(
'id' => 'content-types-list',
'class' => array('content-types-list'),
),
);

return $build;
return theme('table', $table);
}

/**
* Given a content type, return a list of operations that can be performed on
* it.
*/
function _node_type_get_operations($content_type) {
$links = array();
$type_url_str = str_replace('_', '-', $content_type->type);

$links['configure'] = array(
'title' => t('Configure'),
'href' => 'admin/structure/types/manage/' . $type_url_str,
'weight' => 0,
);
if (module_exists('field_ui') && user_access('administer fields')) {
$links['fields'] = array(
'title' => t('Manage fields'),
'href' => 'admin/structure/types/manage/' . $type_url_str . '/fields',
'weight' => 5,
);
$links['display'] = array(
'title' => t('Manage displays'),
'href' => 'admin/structure/types/manage/' . $type_url_str . '/display',
'weight' => 10,
);
}
if ($content_type->module === 'node') {
$links['delete'] = array(
'title' => t('Delete'),
'href' => 'admin/structure/types/manage/' . $type_url_str . '/delete',
'weight' => 15,
);
}

return $links;
}

/**
Expand Down

0 comments on commit 6c69dfe

Please sign in to comment.