You are here

function content_types_overview in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 includes/content.admin.inc \content_types_overview()

Menu callback; replacement for node_overview_types().

1 string reference to 'content_types_overview'
content_menu_alter in ./content.module
Implementation of hook_menu_alter().

File

includes/content.admin.inc, line 12
Administrative interface for content type creation.

Code

function content_types_overview() {
  $types = node_get_types();
  $names = node_get_types('names');
  $header = array(
    t('Name'),
    t('Type'),
    t('Description'),
    array(
      'data' => t('Operations'),
      'colspan' => '4',
    ),
  );
  $rows = array();
  foreach ($names as $key => $name) {
    $type = $types[$key];
    if (node_hook($type, 'form')) {
      $type_url_str = str_replace('_', '-', $type->type);
      $row = array(
        check_plain($name),
        check_plain($type->type),
      );

      // Make the description smaller
      $row[] = array(
        'data' => filter_xss_admin($type->description),
        'class' => 'description',
      );

      // Set the edit column.
      $row[] = array(
        'data' => l(t('edit'), 'admin/content/node-type/' . $type_url_str),
      );

      // Set links for managing fields.
      // TODO: a hook to allow other content modules to add more stuff?
      $row[] = array(
        'data' => l(t('manage fields'), 'admin/content/node-type/' . $type_url_str . '/fields'),
      );

      // Set the delete column.
      if ($type->custom) {
        $row[] = array(
          'data' => l(t('delete'), 'admin/content/node-type/' . $type_url_str . '/delete'),
        );
      }
      else {
        $row[] = array(
          'data' => '',
        );
      }
      $rows[] = $row;
    }
  }

  // Allow external modules alter the table headers and rows.
  foreach (module_implements('content_types_overview_alter') as $module) {
    $function = $module . '_content_types_overview_alter';
    $function($header, $rows);
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('No content types available.'),
        'colspan' => '7',
        'class' => 'message',
      ),
    );
  }
  return theme('table', $header, $rows) . theme('content_overview_links');
}