Index: trunk/phase3/includes/SiteConfiguration.php |
— | — | @@ -36,11 +36,25 @@ |
37 | 37 | |
38 | 38 | if ( !is_null( $retval ) && count( $params ) ) { |
39 | 39 | foreach ( $params as $key => $value ) { |
40 | | - $retval = str_replace( '$' . $key, $value, $retval ); |
| 40 | + $retval = $this->doReplace( '$' . $key, $value, $retval ); |
41 | 41 | } |
42 | 42 | } |
43 | 43 | return $retval; |
44 | 44 | } |
| 45 | + |
| 46 | + /** Type-safe string replace; won't do replacements on non-strings */ |
| 47 | + function doReplace( $from, $to, $in ) { |
| 48 | + if( is_string( $in ) ) { |
| 49 | + return str_replace( $from, $to, $in ); |
| 50 | + } elseif( is_array( $in ) ) { |
| 51 | + foreach( $in as $key => $val ) { |
| 52 | + $in[$key] = $this->doReplace( $from, $to, $in ); |
| 53 | + } |
| 54 | + return $in; |
| 55 | + } else { |
| 56 | + return $in; |
| 57 | + } |
| 58 | + } |
45 | 59 | |
46 | 60 | /** */ |
47 | 61 | function getAll( $wiki, $suffix, $params ) { |