mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-25 05:22:59 +00:00
Add (untested) redirect page backend
This commit is contained in:
parent
faaa2a21ac
commit
bb21686a84
1 changed files with 27 additions and 1 deletions
|
@ -1,4 +1,30 @@
|
|||
<?php
|
||||
|
||||
register_module([
|
||||
"name" => "Redirect pages",
|
||||
"version" => "0.1",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds support for redirect pages. Uses the same syntax that Mediawiki does.",
|
||||
"id" => "feature-redirect",
|
||||
"code" => function() {
|
||||
register_save_preprocessor(function(&index_entry, &$pagedata) {
|
||||
$matches = [];
|
||||
if(preg_match("/^# ?REDIRECT ?\[\[([^\]]+)\]\]/i", $pagedata) === 1)
|
||||
{
|
||||
// We have found a redirect page!
|
||||
// Update the metadata to reflect this.
|
||||
$index_entry->redirect = true;
|
||||
$index_entry->redirect_target = $matches[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// This page isn't a redirect. Unset the metadata just in case.
|
||||
if(isseet($index_entry->redirect))
|
||||
unset($index_entry->redirect);
|
||||
if(isseet($index_entry->redirect_target))
|
||||
unset($index_entry->redirect_target);
|
||||
}
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue