Extension:Wiki2LaTeX/Documentation/Extending Wiki2LaTeX

From MediaWiki.org
Jump to: navigation, search

[edit] Example: Adding an Option to the Export-Form

This example is taken from contrib/microtype.php

// Adding some functions to some hooks
$wgHooks['w2lFormOptions'][]     = 'w2lMicrotypeForm';
$wgHooks['w2lFinish'][]          = 'w2lMicrotypeHook';
$wgHooks['w2lRegisterOptions'][] = 'w2lMicrotype';
 
function w2lMicrotype(&$core) {
        // This line adds our parameter to the parser...
        $core->addParserParameter('use_microtype');
        return true;
}
 
function w2lMicrotypeHook( &$parser, &$text ) {
 
        if ( $parser->getVal('use_microtype') ) {
                // Add a packagedependancy so that the auto-template
                // can load this package.
                $parser->addPackageDependency('microtype');
        }
        return true;
}
 
function w2lMicrotypeForm( &$core, &$output ) {
        // Adding a checkbox to the export-form.
        $output .= '<label><input type="checkbox" name="use_microtype" value="true" /> ';
        $output .= 'Use Microtype</label><br />'."\n";
        return true;
}
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox