r105542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105541‎ | r105542 | r105543 >
Date:12:19, 8 December 2011
Author:hashar
Status:ok (Comments)
Tags:
Comment:
use Html::element instead of sprintf / htmlspecialchars

follow up r95427
Modified paths:
  • /trunk/extensions/CodeReview/backend/DiffHighlighter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/DiffHighlighter.php
@@ -157,17 +157,13 @@
158158 }
159159
160160 function formatLine( $content, $class = null ) {
161 - $formatLN =
162 - "<td class=\"linenumbers\">%s</td>"
163 - . "<td class=\"linenumbers\">%s</td>"
164 - ;
165161
166 - $idAttr = $this->getLineIdAttr();
167162 if( is_null($class) ) {
168 - return sprintf( "<tr class=\"commentable\" {$idAttr}>{$formatLN}<td>%s</td></tr>\n",
169 - $this->left,
170 - $this->right,
171 - $content
 163+ return Html::rawElement( 'tr',
 164+ array_merge( $this->getLineIdAttr(), array( 'class' => 'commentable' ) ),
 165+ Html::Element( 'td', array( 'class'=>'linenumbers' ), $this->left )
 166+ . Html::Element( 'td', array( 'class'=>'linenumbers' ), $this->right )
 167+ . Html::Element( 'td', array() , $content )
172168 );
173169 }
174170
@@ -193,11 +189,12 @@
194190 # Rely on $left, $right initialization above
195191 }
196192
197 - $content = htmlspecialchars( $content );
198 - $classAttr = is_null($class) ? '' : " class=\"$class\"";
199 - return sprintf( "<tr class=\"commentable\" {$idAttr}>{$formatLN}<td%s>%s</td></tr>\n",
200 - $left, $right,
201 - $classAttr, $content
 193+ $classAttr = is_null($class) ? array() : array( 'class' => $class );
 194+ return Html::rawElement( 'tr',
 195+ array_merge( $this->getLineIdAttr(), array( 'class' => 'commentable' ) ),
 196+ Html::rawElement( 'td', array( 'class'=>'linenumbers' ), $left )
 197+ . Html::rawElement( 'td', array( 'class'=>'linenumbers' ), $right )
 198+ . Html::Element( 'td', $classAttr, $content )
202199 );
203200 }
204201
@@ -233,13 +230,15 @@
234231
235232 function handleLineFile( $line ) {
236233 $this->chunk = 0;
237 - $idAttr = $this->getLineIdAttr();
238 - return "<tr $idAttr class=\"patchedfile\"><td colspan=\"3\">$line</td></tr>";
 234+ return Html::rawElement( 'tr',
 235+ array_merge( $this->getLineIdAttr(), array( 'class' => 'patchedfile' ) ),
 236+ Html::Element( 'td', array('colspan'=>3), $line )
 237+ );
239238 }
240239 #### END OF LINES HANDLERS #########################################
241240
242241 function getLineIdAttr() {
243 - return "id=\"line-{$this->lineNumber}\"";
 242+ return array( 'id' => $this->lineNumber );
244243 }
245244
246245 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95043line numbers and better style...hashar21:00, 19 August 2011
r95427add an id to each line of the CR diffhashar19:52, 24 August 2011

Comments

#Comment by Hashar (talk | contribs)   12:38, 8 December 2011

also follow up r95043

Status & tagging log