r93165 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93164‎ | r93165 | r93166 >
Date:09:54, 26 July 2011
Author:questpc
Status:deferred
Tags:
Comment:
Interpretation script source fragments line numbering fix
Modified paths:
  • /trunk/extensions/QPoll/qp_user.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/qp_user.php
@@ -103,6 +103,10 @@
104104 NS_QP_INTERPRETATION => 'Interpretation',
105105 NS_QP_INTERPRETATION_TALK => 'Interpretation_talk'
106106 );
 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();
107111
108112 /**
109113 * default configuration settings
@@ -478,9 +482,18 @@
479483 static function showScript( $input, $argv, $parser, $frame = false ) {
480484 $lines_count = count( preg_split( '`(\r\n|\n|\r)`', $input, -1 ) );
481485 $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++ ) {
483495 $line_numbers .= "{$i}\n";
484496 }
 497+ $slc = $i;
485498 $out =
486499 array( '__tag'=>'div', 'class'=>'qpoll',
487500 array( '__tag'=>'div', 'class'=>'line_numbers', $line_numbers ),

Status & tagging log