Index: trunk/extensions/SemanticResultFormats/BibTeX/SRF_BibTeX.php |
— | — | @@ -129,11 +129,10 @@ |
130 | 130 | $volume = ''; |
131 | 131 | $year = ''; |
132 | 132 | |
133 | | - $var = false; |
134 | | - |
135 | 133 | foreach ( $row as /* SMWResultArray */ $field ) { |
136 | 134 | $req = $field->getPrintRequest(); |
137 | 135 | $label = strtolower( $req->getLabel() ); |
| 136 | + $var = false; |
138 | 137 | |
139 | 138 | switch ( $label ) { |
140 | 139 | case 'type': $var =& $type; break; |
— | — | @@ -169,6 +168,8 @@ |
170 | 169 | if ( $dataValue !== false ) { |
171 | 170 | $var = $dataValue->getShortWikiText(); |
172 | 171 | } |
| 172 | + |
| 173 | + unset( $var ); |
173 | 174 | } |
174 | 175 | else { |
175 | 176 | switch ( $label ) { |
— | — | @@ -177,8 +178,14 @@ |
178 | 179 | while ( ( /* SMWDataValue */ $dataValue = efSRFGetNextDV( $field ) ) !== false ) { |
179 | 180 | $wikiTexts[] = $dataValue->getShortWikiText(); |
180 | 181 | } |
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 | + } |
183 | 190 | break; |
184 | 191 | case 'date': |
185 | 192 | $dataValue = efSRFGetNextDV( $field ); |
— | — | @@ -252,17 +259,23 @@ |
253 | 260 | // generating the URI: author last name + year + first letters of title |
254 | 261 | $URI = ''; |
255 | 262 | 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] ); |
258 | 267 | } |
259 | | - if ( $year ) $URI .= $year; |
| 268 | + |
| 269 | + if ( $year ) { |
| 270 | + $URI .= $year; |
| 271 | + } |
| 272 | + |
260 | 273 | 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 | + } |
266 | 278 | } |
| 279 | + |
267 | 280 | $this->URI = strtolower( $URI ); |
268 | 281 | } |
269 | 282 | |
— | — | @@ -272,9 +285,11 @@ |
273 | 286 | */ |
274 | 287 | public function text() { |
275 | 288 | $text = '@' . $this->bibTeXtype . '{' . $this->URI . ",\r\n"; |
| 289 | + |
276 | 290 | foreach ( $this->fields as $key => $value ) { |
277 | 291 | $text .= ' ' . $key . ' = "' . $value . '", ' . "\r\n"; |
278 | 292 | } |
| 293 | + |
279 | 294 | $text .= "}\r\n\r\n"; |
280 | 295 | |
281 | 296 | return $text; |