original_string: protected function process_toc() {
          if (empty($this->toc)) {
              return;
          }
  
          $toc = "";
          $currentsection = array(0, 0, 0);
          $i = 1;
          foreach ($this->toc as & $header) {
              switch ($header[0]) {
              case 1:
                  $currentsection = array($currentsection[0] + 1, 0, 0);
                  break;
              case 2:
                  $currentsection[1]++;
                  $currentsection[2] = 0;
                  if ($currentsection[0] == 0) {
                      $currentsection[0]++;
                  }
                  break;
              case 3:
                  $currentsection[2]++;
                  if ($currentsection[1] == 0) {
                      $currentsection[1]++;
                  }
                  if ($currentsection[0] == 0) {
                      $currentsection[0]++;
                  }
                  break;
              default:
                  continue 2;
              }
              $number = "$currentsection[0]";
              if (!empty($currentsection[1])) {
                  $number .= ".$currentsection[1]";
                  if (!empty($currentsection[2])) {
                      $number .= ".$currentsection[2]";
                  }
              }
              $toc .= parser_utils::h('p', $number . ". " .
                 parser_utils::h('a', str_replace(array('[[', ']]'), '', $header[1]), array('href' => "#toc-$i")),
                 array('class' => 'wiki-toc-section-' . $header[0] . " wiki-toc-section"));
              $i++;
          }
  
          $this->returnvalues['toc'] = "<div class=\"wiki-toc\"><p class=\"wiki-toc-title\">" . get_string('tableofcontents', 'wiki') . "</p>$toc</div>";
      }
code: protected function process_toc() {
          if (empty($this->toc)) {
              return;
          }
  
          $toc = "";
          $currentsection = array(0, 0, 0);
          $i = 1;
          foreach ($this->toc as & $header) {
              switch ($header[0]) {
              case 1:
                  $currentsection = array($currentsection[0] + 1, 0, 0);
                  break;
              case 2:
                  $currentsection[1]++;
                  $currentsection[2] = 0;
                  if ($currentsection[0] == 0) {
                      $currentsection[0]++;
                  }
                  break;
              case 3:
                  $currentsection[2]++;
                  if ($currentsection[1] == 0) {
                      $currentsection[1]++;
                  }
                  if ($currentsection[0] == 0) {
                      $currentsection[0]++;
                  }
                  break;
              default:
                  continue 2;
              }
              $number = "$currentsection[0]";
              if (!empty($currentsection[1])) {
                  $number .= ".$currentsection[1]";
                  if (!empty($currentsection[2])) {
                      $number .= ".$currentsection[2]";
                  }
              }
              $toc .= parser_utils::h('p', $number . ". " .
                 parser_utils::h('a', str_replace(array('[[', ']]'), '', $header[1]), array('href' => "#toc-$i")),
                 array('class' => 'wiki-toc-section-' . $header[0] . " wiki-toc-section"));
              $i++;
          }
  
          $this->returnvalues['toc'] = "<div class=\"wiki-toc\"><p class=\"wiki-toc-title\">" . get_string('tableofcontents', 'wiki') . "</p>$toc</div>";
      }
code_tokens: protected function process_toc ( ) { if ( empty ( $ this -> toc ) ) { return ; } $ toc = "" ; $ currentsection = array ( 0 , 0 , 0 ) ; $ i = 1 ; foreach ( $ this -> toc as & $ header ) { switch ( $ header [ 0 ] ) { case 1 : $ currentsection = array ( $ currentsection [ 0 ] + 1 , 0 , 0 ) ; break ; case 2 : $ currentsection [ 1 ] ++ ; $ currentsection [ 2 ] = 0 ; if ( $ currentsection [ 0 ] == 0 ) { $ currentsection [ 0 ] ++ ; } break ; case 3 : $ currentsection [ 2 ] ++ ; if ( $ currentsection [ 1 ] == 0 ) { $ currentsection [ 1 ] ++ ; } if ( $ currentsection [ 0 ] == 0 ) { $ currentsection [ 0 ] ++ ; } break ; default : continue 2 ; } $ number = "$currentsection[0]" ; if ( ! empty ( $ currentsection [ 1 ] ) ) { $ number .= ".$currentsection[1]" ; if ( ! empty ( $ currentsection [ 2 ] ) ) { $ number .= ".$currentsection[2]" ; } } $ toc .= parser_utils :: h ( 'p' , $ number . ". " . parser_utils :: h ( 'a' , str_replace ( array ( '[[' , ']]' ) , '' , $ header [ 1 ] ) , array ( 'href' => "#toc-$i" ) ) , array ( 'class' => 'wiki-toc-section-' . $ header [ 0 ] . " wiki-toc-section" ) ) ; $ i ++ ; } $ this -> returnvalues [ 'toc' ] = "<div class=\"wiki-toc\"><p class=\"wiki-toc-title\">" . get_string ( 'tableofcontents' , 'wiki' ) . "</p>$toc</div>" ; }
docstring: Table of contents processing after parsing
docstring_tokens: Table of contents processing after parsing