You are here

function _tableofcontents_parse_option in Table of Contents 6.3

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

Parse one option and save its value.

The function returns NULL since we don't need to replace anything in the source.

@param[in] $opt An array with the option name and value.

1 string reference to '_tableofcontents_parse_option'
_tableofcontents_get_options in ./tableofcontents.pages.inc
Parse options and save them in your $toc variable.

File

./tableofcontents.pages.inc, line 334
Applies the filter functions.

Code

function _tableofcontents_parse_option($opt) {
  global $_tableofcontents_toc;
  $opt[1] = trim($opt[1]);
  $opt[2] = trim($opt[2]);
  switch (drupal_strtolower($opt[1])) {
    case 'id':
    case 'title':

      // check_plain() on $opt[2] is applied later as required by the administrator
      $_tableofcontents_toc->{$opt}[1] = $opt[2];
      break;

    // We may want to, at some point, look into supporting such things
    // for the headers... then this would be valid again.
    case 'list':

      // ignore since some users may have been using it...
      break;

    //  switch (drupal_strtolower($opt[2])) {
    //  case 'ol':
    //  case 'ordered':
    //    $_tableofcontents_toc->numbering = 4;
    //    break;
    //  case 'ul':
    //  case 'unordered':
    //    // in this case, just make sure we don't have 'ol'
    //    if ($_tableofcontents_toc->numbering == 4) {
    //      $_tableofcontents_toc->numbering = 0;
    //    }
    //    break;
    //  case 'none':
    //    $_tableofcontents_toc->numbering = 0;
    //    break;
    //  case 'numbering':
    //    $_tableofcontents_toc->numbering = 1;
    //    break;
    //  case 'sub-numbering':
    //    $_tableofcontents_toc->numbering = 2;
    //    break;
    //  case 'sub-numbering-with-zero':
    //    $_tableofcontents_toc->numbering = 3;
    //    break;
    //  default:
    //    drupal_set_message(t("Table of contents error: !opt is not a valid list type. Expected 'ul', 'unordered', 'ol', or 'ordered'",
    //      array('!opt' => $opt[2])), 'error');
    //    break;
    //  }
    //  break;
    case 'minlevel':
    case 'maxlevel':
    case 'back_to_top_minlevel':
    case 'back_to_top_maxlevel':
      if (!is_numeric($opt[2]) || $opt[2] < 1 || $opt[2] > 6) {
        drupal_set_message(t("Table of contents error: @opt is not a valid level. Expected a number from 1 to 6", array(
          '@opt' => $opt[2],
        )), 'error');
      }
      else {
        $_tableofcontents_toc->{$opt}[1] = $opt[2];
      }
      break;
    case 'hidden':
    case 'hide':

    // support bug from previous versions...
    case 'attachments':
    case 'hideshow':
    case 'collapsed':
      switch (drupal_strtolower($opt[2])) {
        case '0':
        case 'false':
          $_tableofcontents_toc->{$opt}[1] = FALSE;
          break;
        case '1':
        case 'true':
          $_tableofcontents_toc->{$opt}[1] = TRUE;
          break;
        default:
          drupal_set_message(t("Table of contents error: @val is not a valid boolean value for @opt. Expected 0, false, 1, or true.", array(
            '@opt' => $opt[1],
            '@val' => $opt[2],
          )), 'error');
          break;
      }
      break;
    default:
      drupal_set_message(t("Table of contents error: @opt is not a valid option.", array(
        '@opt' => $opt[1],
      )), 'error');
      break;
  }
}