You are here

function commerce_line_item_ui_types_overview in Commerce Core 7

Menu callback: display an overview of available types.

1 string reference to 'commerce_line_item_ui_types_overview'
commerce_line_item_ui_menu in modules/line_item/commerce_line_item_ui.module
Implements hook_menu().

File

modules/line_item/includes/commerce_line_item_ui.types.inc, line 6

Code

function commerce_line_item_ui_types_overview() {
  drupal_add_css(drupal_get_path('module', 'commerce_line_item') . '/theme/commerce_line_item.admin.css');
  $header = array(
    t('Name'),
    t('Operations'),
  );
  $rows = array();

  // Loop through all defined line item types.
  foreach (commerce_line_item_types() as $type => $line_item_type) {

    // Build the operation links for the current line item type.
    $type_arg = strtr($type, '_', '-');
    $links = menu_contextual_links('commerce-line-item-type', 'admin/commerce/config/line-items', array(
      $type_arg,
    ));

    // Add the line item type's row to the table's rows array.
    $rows[] = array(
      theme('line_item_type_admin_overview', array(
        'line_item_type' => $line_item_type,
      )),
      theme('links', array(
        'links' => $links,
        'attributes' => array(
          'class' => 'links inline operations',
        ),
      )),
    );
  }

  // If no line item types are defined...
  if (empty($rows)) {

    // Add a standard empty row with a link to add a new line item type.
    $rows[] = array(
      array(
        'data' => t('There are no line item types defined by enabled modules.'),
        'colspan' => 2,
      ),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}