You are here

function total_control_menus_content_type_render in Total Control Admin Dashboard 7.2

Same name and namespace in other branches
  1. 6.2 plugins/content_types/menus.inc \total_control_menus_content_type_render()

Run-time rendering of the body of the block.

File

plugins/content_types/menus.inc, line 41

Code

function total_control_menus_content_type_render($subtype, $conf, $args, &$context) {
  if (!module_exists('menu')) {
    return;
  }
  $items = array();
  $menus = menu_get_menus();
  $options = array(
    'query' => array(
      'destination' => 'admin/dashboard',
    ),
  );
  $header = array(
    array(
      'data' => t('Menu'),
    ),
    array(
      'data' => t('Operations'),
      'colspan' => 3,
    ),
  );
  $rows = array();
  foreach ($menus as $menu_name => $menu) {
    if (array_key_exists($menu_name, $conf['menus'])) {
      if ($conf['menus'][$menu_name] === $menu_name) {
        $rows[] = array(
          'data' => array(
            t($menu),
            l(t('Configure'), 'admin/structure/menu/manage/' . $menu_name . '/edit', $options),
            l(t('Manage links'), 'admin/structure/menu/manage/' . $menu_name, $options),
            l(t('Add new link'), 'admin/structure/menu/manage/' . $menu_name . '/add', $options),
          ),
        );
      }
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('There are no menus to display.'),
        'colspan' => 4,
      ),
    );
  }

  // Build a link to the menu admin UI.
  $link = '';
  if (user_access('administer menu')) {
    $link = l(t('Menu administration'), 'admin/structure/menu');
  }
  $block = new stdClass();
  $block->title = t('Manage Menus');
  $block->module = t('total_control');
  $block->content = theme('total_control_admin_table', array(
    'header' => $header,
    'rows' => $rows,
    'link' => $link,
  ));
  return $block;
}