r109967 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109966‎ | r109967 | r109968 >
Date:23:26, 24 January 2012
Author:gregchiasson
Status:resolved (Comments)
Tags:aft 
Comment:
AFT5 feedback tool - move comment rendering into it's own function as preperation for truncating at 500 characters down the road. Committing now because of the HTML change - wrapper around the abuse/helpfulness links - that the design staff needed.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -325,7 +325,10 @@
326326 . Html::closeElement( 'div' );
327327 ;
328328
329 - $footer_links = Html::openElement( 'p', array( 'class' => 'articleFeedbackv5-comment-foot' ) );
 329+ $footer_links = Html::openElement( 'div', array(
 330+ 'class' => 'articleFeedbackv5-vote-wrapper'
 331+ ) )
 332+ . Html::openElement( 'p', array( 'class' => 'articleFeedbackv5-comment-foot' ) );
330333
331334 if( $can_vote ) {
332335 $footer_links .= Html::element( 'span', array(
@@ -350,7 +353,8 @@
351354 'id' => "articleFeedbackv5-abuse-link-$id",
352355 'class' => 'articleFeedbackv5-abuse-link'
353356 ), wfMessage( 'articlefeedbackv5-form-abuse', $record[0]->af_abuse_count )->text() ) ) : '' )
354 - . Html::closeElement( 'p' );
 357+ . Html::closeElement( 'p' )
 358+ . Html::closeElement( 'div' );
355359
356360 // Don't render the toolbox if they can't do anything with it.
357361 $tools = null;
@@ -436,11 +440,8 @@
437441 $class = 'negative';
438442 }
439443
440 - $found = $this->feedbackHead( $msg, $class, $record[0] );
441 -
442 - return "$found
443 - <blockquote>" . htmlspecialchars( $record['comment']->aa_response_text )
444 - . '</blockquote>';
 444+ return $this->feedbackHead( $msg, $class, $record[0] )
 445+ . $this->renderComment( $record['comment']->aa_response_text );
445446 }
446447
447448
@@ -453,8 +454,7 @@
454455 // * articlefeedbackv5-form2-header-question
455456 // * articlefeedbackv5-form2-header-suggestion
456457 return $this->feedbackHead( "articlefeedbackv5-form2-header-$type", $class, $record[0], $type )
457 - . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text )
458 - . '</blockquote>';
 458+ . $this->renderComment( $record['comment']->aa_response_text );
459459 }
460460
461461 private function renderBucket3( $record ) {
@@ -463,8 +463,7 @@
464464 $class = $record['rating']->aa_response_rating >= 3 ? 'positive' : 'negative';
465465
466466 return $this->feedbackHead( 'articlefeedbackv5-form3-header', $class, $record[0], $record['rating']->aa_response_rating )
467 - . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text )
468 - . '</blockquote>';
 467+ . $this->renderComment( $record['comment']->aa_response_text );
469468 }
470469
471470 private function renderBucket4( $record ) {
@@ -525,6 +524,18 @@
526525 );
527526 }
528527
 528+ private function renderComment( $text ) {
 529+ if( strlen( $text ) <= 500 ) {
 530+ $rv = "<blockquote>"
 531+ . htmlspecialchars( $record['comment']->aa_response_text )
 532+ . '</blockquote>';
 533+ } else {
 534+ $rv = "<blockquote>"
 535+ . htmlspecialchars( $record['comment']->aa_response_text )
 536+ . '</blockquote>';
 537+ }
 538+ }
 539+
529540 private function feedbackHead( $message, $class, $record, $extra = '' ) {
530541 $gender = ''; #?
531542 $name = htmlspecialchars( $record->user_name );

Follow-up revisions

RevisionCommit summaryAuthorDate
r110012AFT5 feedback page - add truncation to comments over 500 characters, with exp...gregchiasson18:43, 25 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   07:44, 25 January 2012

strlen counts bytes, not characters.

#Comment by Nikerabbit (talk | contribs)   07:45, 25 January 2012

Btw Language class has language aware multibyte-safe truncate function.

#Comment by Santhosh.thottingal (talk | contribs)   14:37, 25 January 2012

The if and else blocks of renderComment looks same to me

Status & tagging log