aboutsummaryrefslogtreecommitdiff
path: root/pmwiki.php
diff options
context:
space:
mode:
authorpetko <petko@524c5546-5005-0410-9a3e-e25e191bd360>2024-02-11 08:25:49 +0000
committerpetko <petko@524c5546-5005-0410-9a3e-e25e191bd360>2024-02-11 08:25:49 +0000
commit982e6791d7ccdcb4622680f3fe28d271d2d06542 (patch)
tree820beb3a1b31888ce8e82a87b165a7f99c65537f /pmwiki.php
parentfb67a9cdf10f3b30fd1a70cde81d435af968f718 (diff)
downloadpmwiki.svn-982e6791d7ccdcb4622680f3fe28d271d2d06542.tar.bz2
Refactor PrintFmt, add $EnablePrePrintFmt.
git-svn-id: svn://pmwiki.org/pmwiki/trunk@4628 524c5546-5005-0410-9a3e-e25e191bd360
Diffstat (limited to 'pmwiki.php')
-rw-r--r--pmwiki.php55
1 files changed, 47 insertions, 8 deletions
diff --git a/pmwiki.php b/pmwiki.php
index 93e88441..e16b6148 100644
--- a/pmwiki.php
+++ b/pmwiki.php
@@ -1788,9 +1788,46 @@ function Redirect($pagename, $urlfmt='$PageUrl', $redirecturl=null) {
}
function PrintFmt($pagename,$fmt) {
- global $HTTPHeaders,$FmtV;
+ global $EnablePrePrintFmt;
+ if (IsEnabled($EnablePrePrintFmt, 1)) PrePrintFmt($pagename,$fmt);
+ PostPrintFmt($pagename,$fmt);
+}
+
+## These 3 functions allow for pages/markup included from
+## the skin template like a SideBar, or action pages like
+## $AuthPromptFmt to set $HTMLStylesFmt and $HTMLHeaderFmt.
+function PrePrintFmt($pagename,&$fmt) {
+ global $KeepToken;
if (is_array($fmt)) {
- foreach($fmt as $f) PrintFmt($pagename,$f);
+ foreach($fmt as &$f) PrePrintFmt($pagename,$f);
+ return;
+ }
+ if (!is_string($fmt)) return;
+
+ if (preg_match('/^(markup|wiki|page):/', $fmt)) {
+ $x = FmtPageName($fmt,$pagename);
+ $out = ProcessPrintFmt($pagename,$x);
+
+ # In case $out starts with "file:" or "function:"
+ $fmt = "$KeepToken$KeepToken$out";
+ }
+}
+
+function ProcessPrintFmt($pagename,$x) {
+ global $FmtV;
+ if (substr($x, 0, 7) == 'markup:')
+ return MarkupToHTML($pagename, substr($x, 7));
+ if (substr($x, 0, 5) == 'wiki:')
+ return PrintWikiPage($pagename, substr($x, 5), 'read', true);
+ if (substr($x, 0, 5) == 'page:')
+ return PrintWikiPage($pagename, substr($x, 5), '', true);
+ return $x;
+}
+
+function PostPrintFmt($pagename,$fmt) {
+ global $EnablePrePrintFmt, $KeepToken, $HTTPHeaders, $FmtV;
+ if (is_array($fmt)) {
+ foreach($fmt as $f) PostPrintFmt($pagename,$f);
return;
}
if ($fmt == 'headers:') {
@@ -1798,7 +1835,14 @@ function PrintFmt($pagename,$fmt) {
return;
}
$fmt = strval($fmt);
+
+ $preprint = IsEnabled($EnablePrePrintFmt, 1);
+ if ($preprint && substr($fmt, 0, 4) == "$KeepToken$KeepToken") {
+ echo substr($fmt, 4); return;
+ }
+
$x = FmtPageName($fmt,$pagename);
+
if (strncmp($fmt, 'function:', 9) == 0 &&
preg_match('/^function:(\S+)\s*(.*)$/s', $x, $match) &&
function_exists($match[1]))
@@ -1810,12 +1854,7 @@ function PrintFmt($pagename,$fmt) {
}
return;
}
- if (substr($x, 0, 7) == 'markup:')
- { print MarkupToHTML($pagename, substr($x, 7)); return; }
- if (substr($x, 0, 5) == 'wiki:')
- { PrintWikiPage($pagename, substr($x, 5), 'read'); return; }
- if (substr($x, 0, 5) == 'page:')
- { PrintWikiPage($pagename, substr($x, 5), ''); return; }
+ if (!$preprint) $x = ProcessPrintFmt($pagename,$x);
echo $x;
}