diff options
author | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-04-26 09:11:17 +0000 |
---|---|---|
committer | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-04-26 09:11:17 +0000 |
commit | 404bb16ed51bf67446f94ed2ba7b5f7e7de8834b (patch) | |
tree | 0f70909536a42fe97f28de233ec98707c3c75572 | |
parent | 09b92e820ee961e1768f97ede8880c0191f711ef (diff) | |
download | pmwiki.svn-404bb16ed51bf67446f94ed2ba7b5f7e7de8834b.tar.bz2 |
Refactor $MessagesFmt to allow nested arrays with keys and (:messages key=a,b:).
git-svn-id: svn://pmwiki.org/pmwiki/trunk@4698 524c5546-5005-0410-9a3e-e25e191bd360
-rw-r--r-- | scripts/stdmarkup.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/stdmarkup.php b/scripts/stdmarkup.php index 87cf6540..2afe852d 100644 --- a/scripts/stdmarkup.php +++ b/scripts/stdmarkup.php @@ -213,7 +213,7 @@ Markup('linebreaks', 'directives', ## (:messages:) Markup('messages', 'directives', - '/^\\(:messages:\\)/i', + '/^\\(:messages( .*)?:\\)/i', "MarkupDirectives"); function MarkupDirectives($m) { @@ -222,13 +222,27 @@ function MarkupDirectives($m) { case 'linkwikiwords': return PZZ($GLOBALS['LinkWikiWords']=(@$m[1]!='no')); case 'spacewikiwords': return PZZ($GLOBALS['SpaceWikiWords']=(@$m[1]!='no')); case 'linebreaks': - return PZZ($GLOBALS['HTMLPNewline'] = (@$m[1]!='no') ? '<br />' : ''); + return PZZ($GLOBALS['HTMLPNewline'] = (@$m[1]!='no') ? '<br />' : ''); case 'messages': - return '<:block>'.Keep(FmtPageName( - implode('',(array)$GLOBALS['MessagesFmt']), $pagename)); + global $MessagesFmt; + $args = isset($m[1]) ? ParseArgs($m[1]) : array(); + if (isset($args['key'])) { + $keys = MatchNames(array_keys($MessagesFmt), $args['key']); + $msg = array(); + foreach($keys as $k) $msg[$k] = $MessagesFmt[$k]; + if (! $msg) return ''; + } + else $msg = $MessagesFmt; + return '<:block>'.Keep(FmtPageName(MergeMessages($msg), $pagename)); } } +function MergeMessages($msg) { + $out = ''; + if (is_array($msg)) foreach($msg as $x) $out .= MergeMessages($x); + else $out .= $msg; + return $out; +} ## (:comment:) Markup('comment', 'directives', '/\\(:comment .*?:\\)/i', ''); |