Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php |
— | — | @@ -50,12 +50,12 @@ |
51 | 51 | * |
52 | 52 | * 'arraymap' is called as: |
53 | 53 | * |
54 | | - * {{#arraymap:value|delimiter|var|new_value|new_delimiter}} |
| 54 | + * {{#arraymap:value|delimiter|var|formula|new_delimiter}} |
55 | 55 | * |
56 | 56 | * This function applies the same transformation to every section of a |
57 | 57 | * delimited string; each such section, as dictated by the 'delimiter' |
58 | 58 | * value, is given the same transformation that the 'var' string is |
59 | | - * given in 'new_value'. Finally, the transformed strings are joined |
| 59 | + * given in 'formula'. Finally, the transformed strings are joined |
60 | 60 | * together using the 'new_delimiter' string. Both 'delimiter' and |
61 | 61 | * 'new_delimiter' default to commas. |
62 | 62 | * |
— | — | @@ -86,6 +86,7 @@ |
87 | 87 | * @author Yaron Koren |
88 | 88 | * @author Sergey Chernyshev |
89 | 89 | * @author Daniel Friesen |
| 90 | + * @author Barry Welch |
90 | 91 | */ |
91 | 92 | |
92 | 93 | |
— | — | @@ -178,9 +179,9 @@ |
179 | 180 | } |
180 | 181 | |
181 | 182 | /** |
182 | | - * {{#arraymap:value|delimiter|var|new_value|new_delimiter}} |
| 183 | + * {{#arraymap:value|delimiter|var|formula|new_delimiter}} |
183 | 184 | */ |
184 | | -function sfRenderArrayMap( &$parser, $value = '', $delimiter = ',', $var = 'x', $new_value = 'x', $new_delimiter = ', ' ) { |
| 185 | +function sfRenderArrayMap( &$parser, $value = '', $delimiter = ',', $var = 'x', $formula = 'x', $new_delimiter = ', ' ) { |
185 | 186 | $values_array = explode($parser->mStripState->unstripNoWiki($delimiter), $value); |
186 | 187 | $results = array(); |
187 | 188 | foreach ($values_array as $cur_value) { |
— | — | @@ -188,7 +189,7 @@ |
189 | 190 | // ignore a value if it's null |
190 | 191 | if ('' != $cur_value) { |
191 | 192 | // remove whitespaces |
192 | | - $results[] = str_replace($var, $cur_value, $new_value); |
| 193 | + $results[] = str_replace($var, $cur_value, $formula); |
193 | 194 | } |
194 | 195 | } |
195 | 196 | return implode($new_delimiter, $results); |
— | — | @@ -196,20 +197,15 @@ |
197 | 198 | |
198 | 199 | /** |
199 | 200 | * SFH_OBJ_ARGS |
200 | | - * {{#arraymap:value|delimiter|var|new_value|new_delimiter}} |
| 201 | + * {{#arraymap:value|delimiter|var|formula|new_delimiter}} |
201 | 202 | */ |
202 | 203 | function sfRenderArrayMapObj( &$parser, $frame, $args ) { |
203 | 204 | # Set variables |
204 | | - $value = isset($args[0]) ? $args[0] : ''; |
205 | | - $delimiter = isset($args[1]) ? $args[1] : ','; |
206 | | - $var = isset($args[2]) ? $args[2] : 'x'; |
207 | | - $new_value = isset($args[3]) ? $args[3] : 'x'; |
208 | | - $new_delimiter = isset($args[4]) ? $args[4] : ', '; |
209 | | - # Expand some |
210 | | - $value = trim($frame->expand($value)); |
211 | | - $delimiter = trim($frame->expand($delimiter)); |
212 | | - $var = trim($frame->expand($var, PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES)); |
213 | | - $new_delimiter = trim($frame->expand($new_delimiter)); |
| 205 | + $value = isset($args[0]) ? trim($frame->expand($args[0])) : ''; |
| 206 | + $delimiter = isset($args[1]) ? trim($frame->expand($args[1])) : ','; |
| 207 | + $var = isset($args[2]) ? trim($frame->expand($args[2])) : 'x'; |
| 208 | + $formula = isset($args[3]) ? trim($frame->expand($args[3])) : 'x'; |
| 209 | + $new_delimiter = isset($args[4]) ? trim($frame->expand($args[4])) : ', '; |
214 | 210 | # Unstrip some |
215 | 211 | $delimiter = $parser->mStripState->unstripNoWiki($delimiter); |
216 | 212 | |
— | — | @@ -218,7 +214,7 @@ |
219 | 215 | foreach( $values_array as $old_value ) { |
220 | 216 | $old_value = trim($old_value); |
221 | 217 | if( $old_value == '' ) continue; |
222 | | - $result_value = $frame->expand($new_value, PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES); |
| 218 | + $result_value = $frame->expand($formula, PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES); |
223 | 219 | $result_value = str_replace($var, $old_value, $result_value); |
224 | 220 | $result_value = $parser->preprocessToDom($result_value, $frame->isTemplate() ? Parser::PTD_FOR_INCLUSION : 0); |
225 | 221 | $results_array[] = trim($frame->expand($result_value)); |