r109833 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109832‎ | r109833 | r109834 >
Date:17:00, 23 January 2012
Author:gregchiasson
Status:resolved (Comments)
Tags:aft 
Comment:
AFT5 feedback page - adding HTML classes for the designers, and making the username/IP address links work.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -293,6 +293,7 @@
294294 'class' => 'articleFeedbackv5-comment-details-updates'
295295 ) )
296296 . Linker::link(
 297+#TODO: take out that hardcoded thing.
297298 Title::newFromText( 'Greg' ),
298299 wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age ),
299300 array(),
@@ -362,9 +363,19 @@
363364 . Html::closeElement( 'ul' )
364365 . Html::closeElement( 'div' );
365366
 367+ # Only set a wrapper class for bucket 1.
 368+ $class = '';
 369+ if( array_key_exists( 'found', $record ) ) {
 370+ if ( $record['found']->aa_response_boolean ) {
 371+ $class = 'positive';
 372+ } else {
 373+ $class = 'negative';
 374+ }
 375+ }
 376+
366377 return Html::openElement( 'div', array( 'class' => 'articleFeedbackv5-feedback' ) )
367378 . Html::openElement( 'div', array(
368 - 'class' => 'articleFeedbackv5-comment-wrap'
 379+ 'class' => "articleFeedbackv5-comment-wrap $class"
369380 ) )
370381 . $content
371382 . $footer_links
@@ -376,7 +387,9 @@
377388 }
378389
379390 private function renderBucket1( $record ) {
380 - $name = htmlspecialchars( $record[0]->user_name );
 391+ $name = htmlspecialchars( $record[0]->user_name );
 392+ $link = $record[0]->af_user_id ? "User:$name" : "Special:Contributions/$name";
 393+
381394 if ( $record['found']->aa_response_boolean ) {
382395 $msg = 'articlefeedbackv5-form1-header-found';
383396 $class = 'positive';
@@ -385,9 +398,8 @@
386399 $class = 'negative';
387400 }
388401 $found = Html::openElement( 'h3' )
389 - . Html::element( 'a', array(
390 - 'href' => '#',
391 - ), $name )
 402+ . Html::element( 'span', array( 'class' => 'icon' ) )
 403+ . Linker::link( Title::newFromText( $link ), $name )
392404 .Html::element( 'span', array(
393405 'class' => $class,
394406 ), wfMessage( $msg, '')->escaped() )
@@ -406,15 +418,23 @@
407419 // * articlefeedbackv5-form2-header-problem
408420 // * articlefeedbackv5-form2-header-question
409421 // * articlefeedbackv5-form2-header-suggestion
410 - return wfMessage( 'articlefeedbackv5-form2-header-' . $type, $name )->escaped()
 422+ return
 423+ Html::openElement( 'h3' )
 424+ . wfMessage( 'articlefeedbackv5-form2-header-' . $type, $name )->escaped()
 425+ . Html::closeElement( 'h3' )
411426 . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text )
412427 . '</blockquote>';
413428 }
414429
 430+ # TODO: The headers here really need the same treatment as bucket1, with
 431+ # the links and such.
415432 private function renderBucket3( $record ) {
416433 $name = htmlspecialchars( $record[0]->user_name );
417434 $rating = htmlspecialchars( $record['rating']->aa_response_rating );
418 - return wfMessage( 'articlefeedbackv5-form3-header', $name, $rating )->escaped()
 435+ return
 436+ Html::openElement( 'h3' )
 437+ . wfMessage( 'articlefeedbackv5-form3-header', $name, $rating )->escaped()
 438+ . Html::closeElement( 'h3' )
419439 . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text )
420440 . '</blockquote>';
421441 }
@@ -425,7 +445,10 @@
426446
427447 private function renderBucket5( $record ) {
428448 $name = htmlspecialchars( $record[0]->user_name );
429 - $rv = wfMessage( 'articlefeedbackv5-form5-header', $name )->escaped();
 449+ $rv =
 450+ Html::openElement( 'h3' )
 451+ . wfMessage( 'articlefeedbackv5-form5-header', $name )->escaped()
 452+ . Html::closeElement( 'h3' );
430453 $rv .= '<ul>';
431454 foreach ( $record as $key => $answer ) {
432455 if ( $answer->afi_data_type == 'rating' && $key != '0' ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r110407AFT5 - Fix the way links to user pages or contributions (for anonymous) are b...gregchiasson16:54, 31 January 2012

Comments

#Comment by Catrope (talk | contribs)   06:19, 31 January 2012
+		$name = htmlspecialchars( $record[0]->user_name );
+		$link = $record[0]->af_user_id ? "User:$name" : "Special:Contributions/$name";

This will go wrong if $name contains characters that are escaped by htmlspecialchars(). You have to use the unescaped name in the title. Also, you can construct these titles using $title = Title::makeTitleSafe( NS_USER, $name ); and $title = SpecialPage::getTitleFor( 'Contributions', $name ); respectively.

OK otherwise.

Status & tagging log