Index: trunk/extensions/inputbox/inputbox.php |
— | — | @@ -73,15 +73,22 @@ |
74 | 74 | } |
75 | 75 | |
76 | 76 | |
77 | | -function getBoxOption(&$value,&$input,$name,$isNumber=false) { |
78 | | - |
79 | | - if(preg_match("/^\s*$name\s*=\s*(.*)/mi",$input,$matches)) { |
80 | | - if($isNumber) { |
81 | | - $value=intval($matches[1]); |
82 | | - } else { |
83 | | - $value=htmlspecialchars($matches[1]); |
84 | | - } |
| 77 | +function getBoxOption( &$value, $input, $name, $isNumber = false ) { |
| 78 | + static $values = false; |
| 79 | + wfProfileIn( __METHOD__ ); |
| 80 | + if( $values === false ) { |
| 81 | + $values = array(); |
| 82 | + $lines = explode( "\n", $input ); |
| 83 | + foreach( $lines as $line ) { |
| 84 | + if( strpos( $line, '=' ) === false ) |
| 85 | + continue; |
| 86 | + list( $lname, $lval ) = explode( '=', $line, 2 ); |
| 87 | + $values[ strtolower( trim( $lname ) ) ] = trim( $lval ); |
| 88 | + } |
85 | 89 | } |
| 90 | + if( isset( $values[$name] ) ) |
| 91 | + $value = $isNumber ? intval( $values[$name] ) : htmlspecialchars( $values[$name] ); |
| 92 | + wfProfileOut( __METHOD__ ); |
86 | 93 | } |
87 | 94 | |
88 | 95 | class Inputbox { |