]>
git.proxmox.com Git - pve2-api-doc.git/blob - data/pve-man-include.php
3 # see http://www.mediawiki.org/wiki/Manual:Parser_functions
5 $wgExtensionCredits['parserhook'][] = array(
6 'name' => "PVE Manual Pages",
7 'description' => "Display PVE manual pages",
8 'author' => "Dietmar Maurer",
11 # Define a setup function
12 $wgHooks['ParserFirstCallInit'][] = 'efPvemanParserFunction_Setup';
13 # Add a hook to initialise the magic word
14 $wgHooks['LanguageGetMagic'][] = 'efPvemanParserFunction_Magic';
16 function efPvemanParserFunction_Setup( &$parser ) {
17 # Set a function hook associating the "pveman" magic word with our function
18 $parser->setFunctionHook( 'pveman', 'efPvemanParserFunction_Render' );
22 function efPvemanParserFunction_Magic( &$magicWords, $langCode ) {
24 # The first array element is whether to be case sensitive, in this case (0) it is not case sensitive, 1 would be sensitive
25 # All remaining elements are synonyms for our parser function
26 $magicWords['pveman'] = array( 0, 'pveman' );
27 # unless we return true, other parser functions extensions won't get loaded.
31 function efPvemanParserFunction_Render( $parser, $param1 = '', $param2 = '' ) {
32 # The parser function itself
33 # The input parameters are wikitext with templates expanded
34 # The output should be wikitext too
36 $parser->disableCache();
42 'datacenter.cfg.5.html' => 1,
43 'vm.conf.5.html' => 1,
44 'ha-manager.1.html' => 1,
46 'pct.conf.5.html' => 1,
47 'pve-firewall.8.html' => 1,
48 'pveceph.1.html' => 1,
50 'pvesubscription.1.html' => 1,
52 'qmrestore.1.html' => 1,
56 if (!$allowed[$param1]) {
57 die ("no such manual page");
60 $output = file_get_contents("/usr/share/pve2-api-doc/man/$param1");
62 $output = preg_replace('|^.*(<h1><a name="name">NAME</a></h1>)|s', '\1', $output);
63 $output = preg_replace('|</body>.*$|s', '', $output);
64 $output = preg_replace('|<p>\s*\n\s*</p>\n?|m', '', $output);
65 $output = preg_replace('|<hr\s*/>\n?|', '', $output);
66 $output = preg_replace('|^\n|m', '', $output);
68 return array( $output, 'noparse' => true, 'isHTML' => true );