Index: tableofcontents.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tableofcontents/tableofcontents.module,v retrieving revision 1.2.4.2.2.2.2.13 diff -u -r1.2.4.2.2.2.2.13 tableofcontents.module --- tableofcontents.module 14 Dec 2008 03:08:02 -0000 1.2.4.2.2.2.2.13 +++ tableofcontents.module 1 Jan 2009 17:21:09 -0000 @@ -52,7 +52,7 @@ if ($long) { if ($override) { - return t('Every instance of "<!--tableofcontents-->" in the input text will be replaced with a collapsible mediawiki-style table of contents. Accepts options for title, list style, minimum heading level, and maximum heading level, and attachments as follows: <!--tableofcontents list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;-->. All arguments are optional.'); + return t('Every instance of "<!--tableofcontents-->" in the input text will be replaced with a collapsible mediawiki-style table of contents. Accepts options for title, show / hide toggle, list style, minimum heading level, and maximum heading level, and attachments as follows: <!--tableofcontents list: ol; toggle: 1; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;-->. All arguments are optional.'); } else { return t('Every instance of "<!--tableofcontents-->" in the input text will be replaced with a collapsible mediawiki-style table of contents.'); @@ -60,7 +60,7 @@ } else { if ($override) { - return t('Insert <!--tableofcontents [list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;]--> to insert a mediawiki style collapsible table of contents. Arguments within [] are optional.'); + return t('Insert <!--tableofcontents [toggle: 1; list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;]--> to insert a mediawiki style collapsible table of contents. Arguments within [] are optional.'); } else { return t('Insert <!--tableofcontents--> to insert a mediawiki style collapsible table of contents.'); @@ -102,6 +102,7 @@ // We save a translate call and only translate this when we process the options. $toc_options["title"] = variable_get('tableofcontents_title_' . $format, 'Table of Contents'); + $toc_options['toggle'] = variable_get('tableofcontents_display_toggle_' . $format, TRUE); $toc_options["list"] = variable_get('tableofcontents_list_type_' . $format, 'ol'); $toc_options["minlevel"] = variable_get('tableofcontents_minlevel_' . $format, 2); $toc_options["maxlevel"] = variable_get('tableofcontents_maxlevel_' . $format, 3); @@ -125,6 +126,10 @@ // validate option values, use defaults for invalid values, build & display error message $error_status = false; + if (!($toc_options["toggle"] === TRUE || $toc_options["toggle"] === "1" || $toc_options["toggle"] === FALSE || $toc_options["toggle"] === "0")) { + $error_message[] = t("!toggle is an invalid toogle option. The toggle option must be set to '1' to display or '0' to hide.", array('!toggle' => $toc_options["toggle"])); + $error_status = true; + } if (($toc_options["list"] != "ol") && ($toc_options["list"] != "ul")) { $error_message[] = $toc_options["list"]." is an invalid list type. The only valid values for list are 'ol' or 'ul'. Using default value of ol.\n"; $error_status = true; @@ -264,6 +269,13 @@ '#description' => t('Enter a default title for each Table of Contents. This will be translated for each individual page.'), ); + $form['tableofcontents']['tableofcontents_display_toggle_' . $format] = array( + '#title' => t('Display show / hide toggle link'), + '#type' => 'checkbox', + '#default_value' => variable_get('tableofcontents_display_toggle_' . $format, TRUE), + '#description' => t('If enabled, a JavaScript link will be inserted into the Table of Contents allowing it to be shown or hidden.'), + ); + $form['tableofcontents']['tableofcontents_list_type_' . $format] = array( '#title' => t('List Type'), '#type' => 'radios', @@ -389,9 +401,13 @@ * Rendered HTML to be displayed. */ function theme_tableofcontents_toc($toc, $options, $files = array()) { - $output = "
\n
" . - $options["title"] . " [" . t('hide') . "]
\n
\n<" . - $options["list"] . ">\n"; + $output = "
\n
" . $options["title"]; + + if ($options['toggle']) { + $output .= " [" . t('hide') . "]"; + } + + $output .= "
\n
\n<" . $options["list"] . ">\n"; $depth = $options["minlevel"]; foreach ($toc as $index=>$title) {