]> git.proxmox.com Git - pve2-api-doc.git/blame - data/pve-man-include.php
add all files to pve-man-include.php
[pve2-api-doc.git] / data / pve-man-include.php
CommitLineData
b18ac5f8
DM
1<?php
2
3# see http://www.mediawiki.org/wiki/Manual:Parser_functions
4
5$wgExtensionCredits['parserhook'][] = array(
6 'name' => "PVE Manual Pages",
7 'description' => "Display PVE manual pages",
8 'author' => "Dietmar Maurer",
9);
10
11# Define a setup function
12$wgHooks['ParserFirstCallInit'][] = 'efPvemanParserFunction_Setup';
13# Add a hook to initialise the magic word
14$wgHooks['LanguageGetMagic'][] = 'efPvemanParserFunction_Magic';
15
16function efPvemanParserFunction_Setup( &$parser ) {
17 # Set a function hook associating the "pveman" magic word with our function
18 $parser->setFunctionHook( 'pveman', 'efPvemanParserFunction_Render' );
19 return true;
20}
21
22function efPvemanParserFunction_Magic( &$magicWords, $langCode ) {
23 # Add the magic word
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.
28 return true;
29}
30
31function 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
35
36 $parser->disableCache();
37
38 $allowed = array(
0f7ebb09
DM
39 'pvecm.1.html' => 1,
40 'qm.1.html' => 1,
41 'datacenter.cfg.5.html' => 1,
42 'vm.conf.5.html' => 1,
43 'ha-manager.1.html' => 1,
44 'pct.1.html' => 1,
45 'pct.conf.5.html' => 1,
46 'pve-firewall.8.html' => 1,
47 'pveceph.1.html' => 1,
48 'pvesm.1.html' => 1,
49 'pvesubscription.1.html' => 1,
50 'pveum.1.html' => 1,
51 'qmrestore.1.html' => 1,
52 'vzdump.1.html' => 1,
53 );
b18ac5f8
DM
54
55 if (!$allowed[$param1]) {
56 die ("no such manual page");
57 }
58
59 $output = file_get_contents("/usr/share/pve2-api-doc/man/$param1");
60
61 $output = preg_replace('|^.*(<h1><a name="name">NAME</a></h1>)|s', '\1', $output);
62 $output = preg_replace('|</body>.*$|s', '', $output);
63 $output = preg_replace('|<p>\s*\n\s*</p>\n?|m', '', $output);
64 $output = preg_replace('|<hr\s*/>\n?|', '', $output);
65 $output = preg_replace('|^\n|m', '', $output);
66
67 return array( $output, 'noparse' => true, 'isHTML' => true );
68}
69
70?>