Index: trunk/extensions/QPoll/qp_user.php |
— | — | @@ -103,6 +103,10 @@ |
104 | 104 | NS_QP_INTERPRETATION => 'Interpretation', |
105 | 105 | NS_QP_INTERPRETATION_TALK => 'Interpretation_talk' |
106 | 106 | ); |
| 107 | + # stores interpretation script line numbers separately for |
| 108 | + # every script language (currently only php eval is implemented) |
| 109 | + # key is value of <qpinterpret> xml tag 'lang' attribute, value is source line counter |
| 110 | + static $scriptLinesCount = array(); |
107 | 111 | |
108 | 112 | /** |
109 | 113 | * default configuration settings |
— | — | @@ -478,9 +482,18 @@ |
479 | 483 | static function showScript( $input, $argv, $parser, $frame = false ) { |
480 | 484 | $lines_count = count( preg_split( '`(\r\n|\n|\r)`', $input, -1 ) ); |
481 | 485 | $line_numbers = ''; |
482 | | - for ( $i = 1; $i <= $lines_count; $i++ ) { |
| 486 | + if ( !isset( $argv['lang'] ) ) { |
| 487 | + return '<strong class="error">' . wfMsg( 'qp_error_eval_missed_lang_attr' ) . '</strong>'; |
| 488 | + } |
| 489 | + $lang = $argv['lang']; |
| 490 | + if ( !array_key_exists( $lang, self::$scriptLinesCount ) ) { |
| 491 | + self::$scriptLinesCount[$lang] = 1; |
| 492 | + } |
| 493 | + $slc = &self::$scriptLinesCount[$lang]; |
| 494 | + for ( $i = $slc; $i < $slc + $lines_count; $i++ ) { |
483 | 495 | $line_numbers .= "{$i}\n"; |
484 | 496 | } |
| 497 | + $slc = $i; |
485 | 498 | $out = |
486 | 499 | array( '__tag'=>'div', 'class'=>'qpoll', |
487 | 500 | array( '__tag'=>'div', 'class'=>'line_numbers', $line_numbers ), |