You are here

function _menu_block_format_title in Menu Block 5.2

Same name and namespace in other branches
  1. 5 menu_block.admin.inc \_menu_block_format_title()
  2. 6.2 menu_block.admin.inc \_menu_block_format_title()
  3. 7.3 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

$delta: int The delta of the menu block

Return value

string The title of the block

2 calls to _menu_block_format_title()
_menu_block_block_list in ./menu_block.admin.inc
Returns the 'list' $op info for hook_block().
_menu_block_delete in ./menu_block.admin.inc
Menu callback: confirm deletion of menu blocks.

File

./menu_block.admin.inc, line 119
Provides infrequently used functions for menu_block.

Code

function _menu_block_format_title($delta) {
  $menu_name = variable_get("menu_block_{$delta}_menu_name", NULL);
  if (is_null($menu_name)) {
    $title = t('Unconfigured menu block');
  }
  else {
    $level = variable_get("menu_block_{$delta}_level", 1);
    $depth = variable_get("menu_block_{$delta}_depth", 0);
    $expanded = variable_get("menu_block_{$delta}_expanded", 0);
    $menus = menu_get_root_menus();

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