r63307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63306‎ | r63307 | r63308 >
Date:00:38, 6 March 2010
Author:bawolff
Status:ok
Tags:
Comment:
follow-up r63291 - per suggestion change to using wgContLang->commaList() for comma list
Modified paths:
  • /trunk/extensions/intersection/DynamicPageList.i18n.php (modified) (history)
  • /trunk/extensions/intersection/DynamicPageList.php (modified) (history)

Diff [purge]

Index: trunk/extensions/intersection/DynamicPageList.i18n.php
@@ -13,7 +13,6 @@
1414 'intersection_toomanycats' => 'Error: Too many categories!',
1515 'intersection_noresults' => 'Error: No results!',
1616 'intersection_noincludecats' => 'Error: You need to include at least one category, or specify a namespace!',
17 - 'intersection_inline_delimiter' => ', ' //probably don't need to translate
1817 );
1918
2019 /** Message documentation (Message documentation)
@@ -21,7 +20,6 @@
2221 */
2322 $messages['qqq'] = array(
2423 'intersection-desc' => 'Short description of the Intersection extension, shown in [[Special:Version]]. Do not translate or change links.',
25 - 'intersection_inline_delimiter' => 'Seperator when used in inline mode. Probably should not translate.',
2624 );
2725
2826 /** Afrikaans (Afrikaans)
Index: trunk/extensions/intersection/DynamicPageList.php
@@ -73,7 +73,7 @@
7474 $sEndList = '</ul>';
7575 $sStartItem = '<li>';
7676 $sEndItem = '</li>';
77 - $bDoNotEndLastItem = false; // control putting $sEndItem after last item
 77+ $bInlineMode = false;
7878
7979 $bUseGallery = false;
8080 $bGalleryFileSize = false;
@@ -178,22 +178,21 @@
179179 $sEndList = '';
180180 $sStartItem = '';
181181 $sEndItem = '<br />';
182 - $bDoNotEndLastItem = false;
 182+ $bInlineMode = false;
183183 break;
184184 case 'ordered':
185185 $sStartList = '<ol>';
186186 $sEndList = '</ol>';
187187 $sStartItem = '<li>';
188188 $sEndItem = '</li>';
189 - $bDoNotEndLastItem = false;
 189+ $bInlineMode = false;
190190 break;
191191 case 'inline':
192192 //aka comma seperated list
193193 $sStartList = '';
194194 $sEndList = '';
195195 $sStartItem = '';
196 - $sEndItem = wfMsgHtml('intersection_inline_delimiter');
197 - $bDoNotEndLastItem = true;
 196+ $bInlineMode = true;
198197 break;
199198 case 'unordered':
200199 default:
@@ -201,7 +200,7 @@
202201 $sEndList = '</ul>';
203202 $sStartItem = '<li>';
204203 $sEndItem = '</li>';
205 - $bDoNotEndLastItem = false;
 204+ $bInlineMode = false;
206205 break;
207206 }
208207 break;
@@ -543,11 +542,9 @@
544543
545544 //process results of query, outputing equivalent of <li>[[Article]]</li> for each result,
546545 //or something similar if the list uses other startlist/endlist
547 - $rowCount = $dbr->numRows( $res );
 546+ $articleList = Array();
548547 while ($row = $dbr->fetchObject( $res ) ) {
549 - $rowCount--;
550548 $title = Title::makeTitle( $row->page_namespace, $row->page_title);
551 - $output .= $sStartItem;
552549 if ( true == $bAddFirstCategoryDate ) {
553550 if ( $sDateFormat != '' ) {
554551 # this is a tad ugly
@@ -588,11 +585,8 @@
589586 # would come from the dateformatter <span>.
590587 $gallery->add( $title, $categoryDate );
591588 } else {
592 - $output .= $categoryDate;
593 - $output .= $sk->link( $title, htmlspecialchars( $titleText ), $aLinkOptions, $query, array( 'forcearticlepath', 'known' ) );
594 - if (!($bDoNotEndLastItem && $rowCount === 0)) {
595 - $output .= $sEndItem . "\n";
596 - }
 589+ $articleList[] = $categoryDate
 590+ . $sk->link( $title, htmlspecialchars( $titleText ), $aLinkOptions, $query, array( 'forcearticlepath', 'known' ) );
597591 }
598592 }
599593
@@ -611,6 +605,13 @@
612606 $gallery->setCaption( $sGalleryCaption ); # gallery class escapes string
613607 $output = $gallery->toHtml();
614608 } else {
 609+ $output .= $sStartItem;
 610+ if ( $bInlineMode ) {
 611+ $output .= $wgContLang->commaList( $articleList );
 612+ } else {
 613+ $output .= implode( "$sEndItem \n $sStartItem", $articleList );
 614+ }
 615+ $output .= $sEndItem;
615616 $output .= $sEndList . "\n";
616617 }
617618 return $output;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r63291Bug 8886 - add an inline list mode to intersectionbawolff21:15, 5 March 2010

Status & tagging log