function commerce_shipping_ui_overview in Commerce Shipping 7.2
Displays all shipping methods or services defined for a method in a table.
1 string reference to 'commerce_shipping_ui_overview'
- commerce_shipping_ui_menu in ./
commerce_shipping_ui.module - Implements hook_menu().
File
- includes/
commerce_shipping_ui.admin.inc, line 11 - Administrative page callbacks for the Shipping UI module.
Code
function commerce_shipping_ui_overview($type, $method = NULL) {
drupal_add_css(drupal_get_path('module', 'commerce_shipping_ui') . '/theme/commerce_shipping.admin.css');
// Load the items that will be represented in the overview table.
if ($type == 'methods') {
$items = commerce_shipping_methods();
}
else {
$items = commerce_shipping_services($method);
uasort($items, 'drupal_sort_weight');
}
$header = array(
t('Title'),
t('Operations'),
);
$rows = array();
// Loop through all of the items to include in the overview.
foreach ($items as $name => $item) {
if ($item['admin_list']) {
// Build the operation links for the current item.
$arg = $type == 'methods' ? strtr($name, '_', '-') : strtr($method . '-' . $name, '_', '-');
$links = menu_contextual_links('commerce-shipping-' . $type, 'admin/commerce/config/shipping/' . $type, array(
$arg,
));
// Add the item's row to the table's rows array.
$rows[] = array(
$type == 'methods' ? theme('shipping_method_admin_overview', array(
'shipping_method' => $item,
)) : theme('shipping_service_admin_overview', array(
'shipping_service' => $item,
)),
theme('links', array(
'links' => $links,
'attributes' => array(
'class' => 'links inline operations',
),
)),
);
}
}
// If no items are defined...
if (empty($rows)) {
// Add a standard empty row with a link to add a new item.
if ($type == 'methods' || $method == NULL) {
$empty_text = t('There are no shipping methods enabled.');
}
else {
$empty_text = t('There are no services defined for the %title shipping method.', array(
'%title' => commerce_shipping_method_get_title($method),
));
}
$rows[] = array(
array(
'data' => $empty_text,
'colspan' => 2,
),
);
}
return theme('table', array(
'header' => $header,
'rows' => $rows,
));
}