You are here

function theme_tableofcontents_number in Table of Contents 7.2

Same name and namespace in other branches
  1. 6.3 tableofcontents.pages.inc \theme_tableofcontents_number()
  2. 7 tableofcontents.pages.inc \theme_tableofcontents_number()

Theme the output of a multi-level number.

Parameters

$toc A TOC object with the options and levels.:

Return value

Rendered HTML to be displayed.

1 theme call to theme_tableofcontents_number()
_tableofcontents_replace_headers in ./tableofcontents.inc
This function changes a header attributes. It adds an identifier in case there are none. It registers the identifier if there is already one.

File

./tableofcontents.themes.inc, line 246
Table of Contents - Versatile system for generating Tables of Contents for fields - themes.

Code

function theme_tableofcontents_number($variables) {
  $toc = $variables['toc'];
  $result = '';
  switch ($toc['numbering']['method']) {
    case 0:

    // no numbering
    case 4:

      // numbering by browser
      return '';
    case 1:

      // "regular" (like <ol>)
      $result = _tableofcontents_convert_number($toc['numbering']['mode'], $toc['header']['counters'][$toc['header']['level_to']]);
      break;
    case 2:
    case 3:

      // 1., 1.1, 1.2, 2., 2.1, 2.2, ...
      $mode = $toc['numbering']['mode'];
      $result = _tableofcontents_convert_number($mode, $toc['header']['counters'][$toc['header']['level_from']]);
      for ($idx = $toc['header']['level_from'] + 1; $idx <= $toc['header']['level_to']; ++$idx) {
        $result .= $toc['numbering']['separator'] . _tableofcontents_convert_number($mode, $toc['header']['counters'][$idx]);
      }
      if ($toc['numbering']['method'] == 3 && $toc['header']['level_from'] == $toc['header']['level_to']) {
        $result .= $toc['numbering']['separator'] . _tableofcontents_convert_number($mode, 0);
      }
      break;
  }

  // we add a space at the end (before the title)
  $output = $toc['numbering']['prefix'] . $result . $toc['numbering']['suffix'] . ' ';
  return theme('tableofcontents_number_text', $output);
}