mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-12-22 13:45:02 +00:00
Add parser variable to list subpages
This commit is contained in:
parent
b044651dc3
commit
999c1abafd
4 changed files with 53 additions and 15 deletions
|
@ -1,7 +1,7 @@
|
|||
# Changelog
|
||||
# v0.11-dev
|
||||
# Added
|
||||
- Unlocked the uploading of any file type. Note that only the file types specified in the settings are allowed to be uploaded.7
|
||||
- Unlocked the uploading of any file type. Note that only the file types specified in the settings are allowed to be uploaded.
|
||||
- Uploaded video and audio files can now be viewed on their respective pages
|
||||
- The file preview tool is now aware that not everything will be an image.
|
||||
- Enhanced the recent changes page.
|
||||
|
@ -10,7 +10,9 @@
|
|||
- Uploads show with an arrow next to them along with the size of the uploaded file
|
||||
- Added mathematical expression parsing between dollar signs.
|
||||
- Generated previews now have etags. This should speed up load times of subsequent requests significantly.
|
||||
- Added an extra debug variable that displays the top level page name (i.e. the page that has been requested). It can be used like this: `{{{~}}}`
|
||||
- Added some extra built-in variables to the parser.
|
||||
- `{{{~}}}`: Displays the top level page name (i.e. the page that has been requested).
|
||||
- `{{{*}}}`: Displays a comma-separated list of subpages of the requested page.
|
||||
- Links to non-existent pages are now coloured red by default.
|
||||
|
||||
# Changed
|
||||
|
|
|
@ -4234,9 +4234,16 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$this->InlineTypes["{"][] = "Template";
|
||||
}
|
||||
|
||||
/*
|
||||
* ████████ ███████ ███ ███ ██████ ██ █████ ████████ ██ ███ ██ ██████
|
||||
* ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██
|
||||
* ██ █████ ██ ████ ██ ██████ ██ ███████ ██ ██ ██ ██ ██ ██ ███
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██ ███████ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ████ ██████
|
||||
*/
|
||||
protected function inlineTemplate($fragment)
|
||||
{
|
||||
global $env;
|
||||
global $env, $pageindex;
|
||||
|
||||
// Variable parsing
|
||||
if(preg_match("/\{\{\{([^}]+)\}\}\}/", $fragment["text"], $matches))
|
||||
|
@ -4253,7 +4260,7 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$variableValue = false;
|
||||
switch ($variableKey)
|
||||
{
|
||||
case "@":
|
||||
case "@": // Lists all subpages
|
||||
if(!empty($params))
|
||||
{
|
||||
$variableValue = "<table>
|
||||
|
@ -4265,7 +4272,7 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$variableValue .= "</table>";
|
||||
}
|
||||
break;
|
||||
case "#":
|
||||
case "#": // Shows a stack trace
|
||||
$variableValue = "<ol start=\"0\">\n";
|
||||
$variableValue .= "\t<li>$env->page</li>\n";
|
||||
foreach($this->paramStack as $curStackEntry)
|
||||
|
@ -4274,10 +4281,21 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
}
|
||||
$variableValue .= "</ol>\n";
|
||||
break;
|
||||
case "~":
|
||||
case "~": // Show requested page's name
|
||||
if(!empty($this->paramStack))
|
||||
$variableValue = $this->escapeText($env->page);
|
||||
// TODO: Add a option that displays a list of subpages here
|
||||
break;
|
||||
case "*": // Lists subpages
|
||||
$subpages = get_subpages($pageindex, $env->page);
|
||||
$variableValue = [];
|
||||
foreach($subpages as $pagename => $depth)
|
||||
{
|
||||
$variableValue[] = $pagename;
|
||||
}
|
||||
$variableValue = implode(", ", $variableValue);
|
||||
if(strlen($variableValue) === 0)
|
||||
$variableValue = "<em>(none yet!)</em>";
|
||||
break;
|
||||
}
|
||||
if(isset($params[$variableKey]))
|
||||
{
|
||||
|
@ -4285,7 +4303,7 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$variableValue = $this->escapeText($variableValue);
|
||||
}
|
||||
|
||||
if($variableValue)
|
||||
if($variableValue !== false)
|
||||
{
|
||||
return [
|
||||
"extent" => strlen($matches[0]),
|
||||
|
|
|
@ -194,7 +194,7 @@
|
|||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
||||
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds a some weight to your installation, and also *requires* write access to the disk on first load.",
|
||||
"id": "parser-parsedown",
|
||||
"lastupdate": 1460145045,
|
||||
"lastupdate": 1460184547,
|
||||
"optional": false
|
||||
}
|
||||
]
|
|
@ -87,9 +87,16 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$this->InlineTypes["{"][] = "Template";
|
||||
}
|
||||
|
||||
/*
|
||||
* ████████ ███████ ███ ███ ██████ ██ █████ ████████ ██ ███ ██ ██████
|
||||
* ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██
|
||||
* ██ █████ ██ ████ ██ ██████ ██ ███████ ██ ██ ██ ██ ██ ██ ███
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██ ███████ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ████ ██████
|
||||
*/
|
||||
protected function inlineTemplate($fragment)
|
||||
{
|
||||
global $env;
|
||||
global $env, $pageindex;
|
||||
|
||||
// Variable parsing
|
||||
if(preg_match("/\{\{\{([^}]+)\}\}\}/", $fragment["text"], $matches))
|
||||
|
@ -106,7 +113,7 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$variableValue = false;
|
||||
switch ($variableKey)
|
||||
{
|
||||
case "@":
|
||||
case "@": // Lists all subpages
|
||||
if(!empty($params))
|
||||
{
|
||||
$variableValue = "<table>
|
||||
|
@ -118,7 +125,7 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$variableValue .= "</table>";
|
||||
}
|
||||
break;
|
||||
case "#":
|
||||
case "#": // Shows a stack trace
|
||||
$variableValue = "<ol start=\"0\">\n";
|
||||
$variableValue .= "\t<li>$env->page</li>\n";
|
||||
foreach($this->paramStack as $curStackEntry)
|
||||
|
@ -127,10 +134,21 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
}
|
||||
$variableValue .= "</ol>\n";
|
||||
break;
|
||||
case "~":
|
||||
case "~": // Show requested page's name
|
||||
if(!empty($this->paramStack))
|
||||
$variableValue = $this->escapeText($env->page);
|
||||
// TODO: Add a option that displays a list of subpages here
|
||||
break;
|
||||
case "*": // Lists subpages
|
||||
$subpages = get_subpages($pageindex, $env->page);
|
||||
$variableValue = [];
|
||||
foreach($subpages as $pagename => $depth)
|
||||
{
|
||||
$variableValue[] = $pagename;
|
||||
}
|
||||
$variableValue = implode(", ", $variableValue);
|
||||
if(strlen($variableValue) === 0)
|
||||
$variableValue = "<em>(none yet!)</em>";
|
||||
break;
|
||||
}
|
||||
if(isset($params[$variableKey]))
|
||||
{
|
||||
|
@ -138,7 +156,7 @@ class PeppermintParsedown extends ParsedownExtra
|
|||
$variableValue = $this->escapeText($variableValue);
|
||||
}
|
||||
|
||||
if($variableValue)
|
||||
if($variableValue !== false)
|
||||
{
|
||||
return [
|
||||
"extent" => strlen($matches[0]),
|
||||
|
|
Loading…
Reference in a new issue