From 1cfcc403294460d3f04dc3da812d50e1015fde69 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sat, 9 Aug 2008 06:08:54 +0000 Subject: [PATCH] Add 3 new functions to the PPTemplateFrames to allow extensions to efficiently extract the whole list of parameters (or only numbered or named) passed to the template they are nested inside of. --- CREDITS | 1 + includes/parser/Preprocessor_DOM.php | 26 ++++++++++++++++++++++++++ includes/parser/Preprocessor_Hash.php | 26 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/CREDITS b/CREDITS index 5527e9fd80..2ecc30f98b 100644 --- a/CREDITS +++ b/CREDITS @@ -8,6 +8,7 @@ following names for their contribution to the product. * Brion Vibber * Bryan Tong Minh * Chad Horohoe +* Daniel Friesen * Greg Sabino Mullane * Hojjat * Mohamed Magdy diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 34d589676f..a4a2674064 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -1218,6 +1218,32 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { return !count( $this->numberedArgs ) && !count( $this->namedArgs ); } + function getArguments() { + $arguments = array(); + foreach ( array_merge( + array_keys($this->numberedArgs), + array_keys($this->namedArgs)) as $key ) { + $arguments[$key] = $this->getArgument($key); + } + return $arguments; + } + + function getNumberedArguments() { + $arguments = array(); + foreach ( array_keys($this->numberedArgs) as $key ) { + $arguments[$key] = $this->getArgument($key); + } + return $arguments; + } + + function getNamedArguments() { + $arguments = array(); + foreach ( array_keys($this->namedArgs) as $key ) { + $arguments[$key] = $this->getArgument($key); + } + return $arguments; + } + function getNumberedArgument( $index ) { if ( !isset( $this->numberedArgs[$index] ) ) { return false; diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index b57752437d..867878dccd 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -1173,6 +1173,32 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { return !count( $this->numberedArgs ) && !count( $this->namedArgs ); } + function getArguments() { + $arguments = array(); + foreach ( array_merge( + array_keys($this->numberedArgs), + array_keys($this->namedArgs)) as $key ) { + $arguments[$key] = $this->getArgument($key); + } + return $arguments; + } + + function getNumberedArguments() { + $arguments = array(); + foreach ( array_keys($this->numberedArgs) as $key ) { + $arguments[$key] = $this->getArgument($key); + } + return $arguments; + } + + function getNamedArguments() { + $arguments = array(); + foreach ( array_keys($this->namedArgs) as $key ) { + $arguments[$key] = $this->getArgument($key); + } + return $arguments; + } + function getNumberedArgument( $index ) { if ( !isset( $this->numberedArgs[$index] ) ) { return false; -- 2.20.1