]> git.proxmox.com Git - pve-docs.git/blame - debian/tree/pve-docs-mediawiki/pvedocs-include.php
cluster manager: reword node limit, as there's not a real one
[pve-docs.git] / debian / tree / pve-docs-mediawiki / pvedocs-include.php
CommitLineData
cfabc2e9
DM
1<?php
2
3# see http://www.mediawiki.org/wiki/Manual:Parser_functions
4
5$wgExtensionCredits['parserhook'][] = array(
a45b098f 6 'name' => "PVE Documentation Pages",
208f75bc 7 'description' => "Display PVE Documentation Pages",
cfabc2e9
DM
8 'author' => "Dietmar Maurer",
9);
208f75bc 10
cfabc2e9
DM
11# Define a setup function
12$wgHooks['ParserFirstCallInit'][] = 'efPvedocsParserFunction_Setup';
208f75bc 13$wgHooks['ParserAfterTidy'][] = 'efPvedocsPostProcessFunction';
cfabc2e9
DM
14
15# Add a hook to initialise the magic word
16$wgHooks['LanguageGetMagic'][] = 'efPvedocsParserFunction_Magic';
208f75bc 17
cfabc2e9
DM
18function efPvedocsParserFunction_Setup(&$parser) {
19 # Set a function hook associating the "pvedocs" magic
20 # word with our function
208f75bc 21 $parser->setFunctionHook('pvedocs', 'efPvedocsParserFunction_Render');
599714d6 22
208f75bc 23 $parser->setHook('pvehide', 'renderTagPveHideContent');
599714d6 24
cfabc2e9
DM
25 return true;
26}
599714d6 27
208f75bc
DM
28# similar code as in <htmlet> tag...
29function efPvedocsPostProcessFunction($parser, &$text) {
30 $text = preg_replace_callback(
60598f4c 31 '/<!--- @PVEDOCS_BASE64@ ([0-9a-zA-Z\\+\\/]+=*) @PVEDOCS_BASE64@ -->/sm',
208f75bc
DM
32 function ($m) { return base64_decode("$m[1]"); },
33 $text);
34
35 return true;
36}
37
599714d6
DM
38// Render <pvehide>
39function renderTagPveHideContent($input, array $args, Parser $parser,
40PPFrame $frame ) {
349e8c55 41 // simply return nothing
599714d6
DM
42 return '';
43}
44
208f75bc 45
cfabc2e9
DM
46function efPvedocsParserFunction_Magic(&$magicWords, $langCode) {
47 # Add the magic word
48 # The first array element is whether to be case sensitive,
49 # in this case (0) it is not case sensitive, 1 would be sensitive
50 # All remaining elements are synonyms for our parser function
51 $magicWords['pvedocs'] = array( 0, 'pvedocs' );
52
53 # unless we return true, other parser functions extensions won't get loaded.
54 return true;
55}
56
cfabc2e9
DM
57function efPvedocsParserFunction_Render($parser, $param1 = '', $param2 = '') {
58
59 $parser->disableCache();
60
61 # only allow simply names, so that users can only include
62 # files from within "/usr/share/pve-docs/"
63 if (!preg_match("/[a-z0-9.-]+\.html/i", $param1)) {
64 die("no such manual page");
208f75bc 65 }
cfabc2e9
DM
66
67 $content = file_get_contents("/usr/share/pve-docs/$param1");
68
60598f4c
TL
69 # from https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/HTMLets/+/11e5ef1ea2820319458dc67174ca76d6e00b10cc/HTMLets.php#140
70 $output = '<!--- @PVEDOCS_BASE64@ '.base64_encode($content).' @PVEDOCS_BASE64@ -->';
208f75bc 71 return array($output, 'noparse' => true, 'isHTML' => true);
cfabc2e9
DM
72}
73
74?>