r89530 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89529‎ | r89530 | r89531 >
Date:20:28, 5 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
some fixes
Modified paths:
  • /trunk/extensions/SemanticResultFormats/BibTeX/SRF_BibTeX.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/BibTeX/SRF_BibTeX.php
@@ -129,11 +129,10 @@
130130 $volume = '';
131131 $year = '';
132132
133 - $var = false;
134 -
135133 foreach ( $row as /* SMWResultArray */ $field ) {
136134 $req = $field->getPrintRequest();
137135 $label = strtolower( $req->getLabel() );
 136+ $var = false;
138137
139138 switch ( $label ) {
140139 case 'type': $var =& $type; break;
@@ -169,6 +168,8 @@
170169 if ( $dataValue !== false ) {
171170 $var = $dataValue->getShortWikiText();
172171 }
 172+
 173+ unset( $var );
173174 }
174175 else {
175176 switch ( $label ) {
@@ -177,8 +178,14 @@
178179 while ( ( /* SMWDataValue */ $dataValue = efSRFGetNextDV( $field ) ) !== false ) {
179180 $wikiTexts[] = $dataValue->getShortWikiText();
180181 }
181 - $var =& $label == 'author' || $label == 'authors' ? $author : $editor;
182 - $var = $GLOBALS['wgLang']->listToText( $wikiTexts );
 182+ $wikiText = $GLOBALS['wgLang']->listToText( $wikiTexts );
 183+
 184+ if ( $label == 'author' || $label == 'authors' ) {
 185+ $author = $wikiText;
 186+ }
 187+ else {
 188+ $author = $editor;
 189+ }
183190 break;
184191 case 'date':
185192 $dataValue = efSRFGetNextDV( $field );
@@ -252,17 +259,23 @@
253260 // generating the URI: author last name + year + first letters of title
254261 $URI = '';
255262 if ( $author ) {
256 - $arrayAuthor = explode( ' ', $author );
257 - if ( array_key_exists( 1, $arrayAuthor ) ) $URI .= $arrayAuthor[1];
 263+ $authors = explode( ',', $author );
 264+ $authors = explode( wfMsg( 'and' ), $authors[0] );
 265+ $arrayAuthor = explode( ' ', $authors[0], 2 );
 266+ $URI .= str_replace( ' ', '', $arrayAuthor[array_key_exists( 1, $arrayAuthor ) ? 1 : 0] );
258267 }
259 - if ( $year ) $URI .= $year;
 268+
 269+ if ( $year ) {
 270+ $URI .= $year;
 271+ }
 272+
260273 if ( $title ) {
261 - $arrayTitle = explode( ' ', $title );
262 - foreach ( $arrayTitle as $titleWord ) {
263 - $charsTitleWord = preg_split( '//', $titleWord, - 1, PREG_SPLIT_NO_EMPTY );
264 - $URI .= $charsTitleWord[0];
265 - }
 274+ foreach ( explode( ' ', $title ) as $titleWord ) {
 275+ $charsTitleWord = preg_split( '//', $titleWord, - 1, PREG_SPLIT_NO_EMPTY );
 276+ $URI .= $charsTitleWord[0];
 277+ }
266278 }
 279+
267280 $this->URI = strtolower( $URI );
268281 }
269282
@@ -272,9 +285,11 @@
273286 */
274287 public function text() {
275288 $text = '@' . $this->bibTeXtype . '{' . $this->URI . ",\r\n";
 289+
276290 foreach ( $this->fields as $key => $value ) {
277291 $text .= ' ' . $key . ' = "' . $value . '", ' . "\r\n";
278292 }
 293+
279294 $text .= "}\r\n\r\n";
280295
281296 return $text;