You are here

function theme_tableofcontents_number in Table of Contents 7

Same name and namespace in other branches
  1. 6.3 tableofcontents.pages.inc \theme_tableofcontents_number()
  2. 7.2 tableofcontents.themes.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.

2 theme calls to theme_tableofcontents_number()
_tableofcontents_comments in ./tableofcontents.pages.inc
This function adds comments to the toc.
_tableofcontents_replace_headers in ./tableofcontents.pages.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.pages.inc, line 1130
Applies the filter functions.

Code

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

    // no numbering
    case 4:

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

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

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

  // we add a space at the end (before the title)
  $output = $toc->number_start_letter . $result . $toc->number_end_letter . ' ';
  return theme('tableofcontents_number_text', $output);
}