You are here

function _menu_block_format_title in Menu Block 7.3

Same name and namespace in other branches
  1. 5.2 menu_block.admin.inc \_menu_block_format_title()
  2. 5 menu_block.admin.inc \_menu_block_format_title()
  3. 6.2 menu_block.admin.inc \_menu_block_format_title()
  4. 7.2 menu_block.admin.inc \_menu_block_format_title()

Return the title of the block.

Parameters

$config: array The configuration of the menu block.

Return value

string The title of the block.

3 calls to _menu_block_format_title()
menu_block_delete_form in ./menu_block.admin.inc
Menu callback: confirm deletion of menu blocks.
menu_block_menu_tree_content_type_admin_title in plugins/content_types/menu_tree/menu_tree.inc
Return the tree's title with an admin-sensitive prefix.
_menu_block_block_info in ./menu_block.admin.inc
Implements hook_block_info().

File

./menu_block.admin.inc, line 155
Provides infrequently used functions and hooks for menu_block.

Code

function _menu_block_format_title($config) {

  // If an administrative title is specified, use it.
  if (!empty($config['admin_title'])) {
    return check_plain($config['admin_title']);
  }
  $menus = menu_block_get_all_menus();
  $menus[MENU_TREE__CURRENT_PAGE_MENU] = t('Current menu');
  if (empty($config['menu_name'])) {
    $title = t('Unconfigured menu block');
  }
  elseif (!isset($menus[$config['menu_name']])) {
    $title = t('Deleted/missing menu @menu', array(
      '@menu' => $config['menu_name'],
    ));
  }
  else {

    // Show the configured levels in the block info
    $replacements = array(
      '@menu_name' => $menus[$config['menu_name']],
      '@level1' => $config['level'],
      '@level2' => $config['level'] + $config['depth'] - 1,
    );
    if ($config['parent_mlid']) {
      $parent_item = menu_link_load($config['parent_mlid']);
      $replacements['@menu_name'] = $parent_item['title'];
    }
    if ($config['follow']) {
      $title = t('@menu_name (active menu item)', $replacements);
    }
    elseif ($config['depth'] == 1) {
      $title = t('@menu_name (level @level1)', $replacements);
    }
    elseif ($config['depth']) {
      if ($config['expanded']) {
        $title = t('@menu_name (expanded levels @level1-@level2)', $replacements);
      }
      else {
        $title = t('@menu_name (levels @level1-@level2)', $replacements);
      }
    }
    else {
      if ($config['expanded']) {
        $title = t('@menu_name (expanded levels @level1+)', $replacements);
      }
      else {
        $title = t('@menu_name (levels @level1+)', $replacements);
      }
    }
  }
  return $title;
}