function tableofcontents_filter in Table of Contents 6.3
Same name and namespace in other branches
- 5.2 tableofcontents.module \tableofcontents_filter()
- 5 tableofcontents.module \tableofcontents_filter()
- 6.2 tableofcontents.module \tableofcontents_filter()
Implementation of hook_filter().
File
- ./
tableofcontents.module, line 89 - This is a filter module to generate a collapsible jquery enabled mediawiki style table of contents based on <h[1-6]> tags. Transforms header tags into named anchors.
Code
function tableofcontents_filter($op, $delta = 0, $format = -1, $text = '') {
global $_tableofcontents_block_processing;
if ($op == 'list') {
return array(
0 => t('Table of contents'),
1 => t('Assign an ID to each header'),
);
}
switch ($op) {
case 'description':
switch ($delta) {
default:
return t('Inserts a table of contents in place of [toc ...] tags.');
case 1:
return t('Add an ID to all the anchors on the page. May be necessary in case the table of contents block is used.');
}
/*NOTREACHED*/
break;
case 'no cache':
// allow caching
return FALSE;
case 'settings':
module_load_include('admin.inc', 'tableofcontents');
return _tableofcontents_settings($format);
case 'prepare':
if ($delta != 1) {
module_load_include('pages.inc', 'tableofcontents');
return _tableofcontents_prepare($delta, $format, $text);
}
return $text;
case 'process':
// NOTE: we cannot test for a [toc:...] and skip if none
// because the user could have the auto-toc turned on.
if (!$_tableofcontents_block_processing) {
module_load_include('pages.inc', 'tableofcontents');
return _tableofcontents_process($delta, $format, $text);
}
return $text;
}
}