Index: trunk/extensions/Cite/Cite_body.php |
— | — | @@ -167,7 +167,7 @@ |
168 | 168 | $this->mParser = $parser; |
169 | 169 | |
170 | 170 | # The key here is the "name" attribute. |
171 | | - list( $key, $group ) = $this->refArg( $argv ); |
| 171 | + list( $key, $group, $follow ) = $this->refArg( $argv ); |
172 | 172 | |
173 | 173 | # Split these into groups. |
174 | 174 | if ( $group === null ) { |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | return $this->error( 'cite_error_ref_no_key' ); |
240 | 240 | } |
241 | 241 | |
242 | | - if ( preg_match( '/^[0-9]+$/', $key ) ) { |
| 242 | + if ( preg_match( '/^[0-9]+$/', $key ) || preg_match( '/^[0-9]+$/', $follow ) ) { |
243 | 243 | # Numeric names mess up the resulting id's, potentially produ- |
244 | 244 | # cing duplicate id's in the XHTML. The Right Thing To Do |
245 | 245 | # would be to mangle them, but it's not really high-priority |
— | — | @@ -274,7 +274,7 @@ |
275 | 275 | # we'll figure that out later. Likewise it's definitely valid |
276 | 276 | # if there's any content, regardless of key. |
277 | 277 | |
278 | | - return $this->stack( $str, $key, $group, $argv ); |
| 278 | + return $this->stack( $str, $key, $group, $follow, $argv ); |
279 | 279 | } |
280 | 280 | |
281 | 281 | # Not clear how we could get here, but something is probably |
— | — | @@ -284,6 +284,10 @@ |
285 | 285 | |
286 | 286 | /** |
287 | 287 | * Parse the arguments to the <ref> tag |
| 288 | + * |
| 289 | + * "name" : Key of the reference. |
| 290 | + * "group" : Group to which it belongs. Needs to be passed to <references /> too. |
| 291 | + * "follow" : If the current reference is the continuation of another, key of that reference. |
288 | 292 | * |
289 | 293 | * @static |
290 | 294 | * |
— | — | @@ -296,18 +300,28 @@ |
297 | 301 | $cnt = count( $argv ); |
298 | 302 | $group = null; |
299 | 303 | $key = null; |
| 304 | + $follow = null; |
300 | 305 | |
301 | 306 | if ( $cnt > 2 ) |
302 | | - // There should only be one key and one group |
| 307 | + // There should only be one key or follow parameter, and one group parameter |
303 | 308 | // FIXME : this looks inconsistent, it should probably return a tuple |
304 | 309 | return false; |
305 | 310 | else if ( $cnt >= 1 ) { |
| 311 | + if ( isset( $argv['name'] ) && isset( $argv['follow'] ) ) { |
| 312 | + return array( false, false, false ); |
| 313 | + } |
306 | 314 | if ( isset( $argv['name'] ) ) { |
307 | 315 | // Key given. |
308 | 316 | $key = Sanitizer::escapeId( $argv['name'], 'noninitial' ); |
309 | 317 | unset( $argv['name'] ); |
310 | 318 | --$cnt; |
311 | 319 | } |
| 320 | + if ( isset( $argv['follow'] ) ) { |
| 321 | + // Follow given. |
| 322 | + $follow = Sanitizer::escapeId( $argv['follow'], 'noninitial' ); |
| 323 | + unset( $argv['follow'] ); |
| 324 | + --$cnt; |
| 325 | + } |
312 | 326 | if ( isset( $argv['group'] ) ) { |
313 | 327 | if ( ! $wgAllowCiteGroups ) return array( false ); // remove when groups are fully tested. |
314 | 328 | // Group given. |
— | — | @@ -317,14 +331,14 @@ |
318 | 332 | } |
319 | 333 | |
320 | 334 | if ( $cnt == 0 ) |
321 | | - return array ( $key, $group ); |
| 335 | + return array ( $key, $group, $follow ); |
322 | 336 | else |
323 | 337 | // Invalid key |
324 | | - return array( false, false ); |
| 338 | + return array( false, false, false ); |
325 | 339 | } |
326 | 340 | else |
327 | 341 | // No key |
328 | | - return array( null, $group ); |
| 342 | + return array( null, $group, false ); |
329 | 343 | } |
330 | 344 | |
331 | 345 | /** |
— | — | @@ -334,12 +348,33 @@ |
335 | 349 | * @param mixed $key Argument to the <ref> tag as returned by $this->refArg() |
336 | 350 | * @return string |
337 | 351 | */ |
338 | | - function stack( $str, $key = null, $group, $call ) { |
| 352 | + function stack( $str, $key = null, $group, $follow, $call ) { |
339 | 353 | if ( ! isset( $this->mRefs[$group] ) ) |
340 | 354 | $this->mRefs[$group] = array(); |
341 | 355 | if ( ! isset( $this->mGroupCnt[$group] ) ) |
342 | 356 | $this->mGroupCnt[$group] = 0; |
343 | 357 | |
| 358 | + if ( $follow != null ) { |
| 359 | + if ( isset( $this->mRefs[$group][$follow] ) && is_array( $this->mRefs[$group][$follow] ) ) { |
| 360 | + // add text to the note that is being followed |
| 361 | + $this->mRefs[$group][$follow]['text'] = $this->mRefs[$group][$follow]['text'] . ' '. $str; |
| 362 | + } else { |
| 363 | + // insert part of note at the beginning of the group |
| 364 | + for( $k=0 ; $k< count( $this->mRefs[$group] ) ; $k++) { |
| 365 | + if( $this->mRefs[$group][$k]['follow'] == null ) break; |
| 366 | + } |
| 367 | + array_splice( $this->mRefs[$group], $k, 0, |
| 368 | + array( array( 'count' => - 1, |
| 369 | + 'text' => $str, |
| 370 | + 'key' => ++$this->mOutCnt , |
| 371 | + 'follow' => $follow) ) ); |
| 372 | + array_splice( $this->mRefCallStack, $k, 0, |
| 373 | + array( array( 'new', $call, $str, $key, $group, $this->mOutCnt ) ) ); |
| 374 | + $this->mInCnt++; |
| 375 | + } |
| 376 | + // return an empty string : this is not a reference |
| 377 | + return ''; |
| 378 | + } |
344 | 379 | if ( $key === null ) { |
345 | 380 | // No key |
346 | 381 | // $this->mRefs[$group][] = $str; |
— | — | @@ -608,6 +643,13 @@ |
609 | 644 | $this->refKey( $key ), |
610 | 645 | $val |
611 | 646 | ); |
| 647 | + else if ( $val['follow'] ) |
| 648 | + return |
| 649 | + wfMsgForContentNoTrans( |
| 650 | + 'cite_references_no_link', |
| 651 | + $this->referencesKey( $val['follow'] ), |
| 652 | + $val['text'] |
| 653 | + ); |
612 | 654 | else if ( $val['text'] == '' ) return |
613 | 655 | wfMsgForContentNoTrans( |
614 | 656 | 'cite_references_link_one', |
Index: trunk/extensions/Cite/Cite.i18n.php |
— | — | @@ -65,6 +65,7 @@ |
66 | 66 | 'cite_references_link_suffix' => '', |
67 | 67 | |
68 | 68 | 'cite_reference_link' => '<sup id="$1" class="reference">[[#$2|<nowiki>[</nowiki>$3<nowiki>]</nowiki>]]</sup>', |
| 69 | + 'cite_references_no_link' => '<p id="$1">$2</p>', |
69 | 70 | 'cite_references_link_one' => '<li id="$1">[[#$2|↑]] $3</li>', |
70 | 71 | 'cite_references_link_many' => '<li id="$1">↑ $2 $3</li>', |
71 | 72 | 'cite_references_link_many_format' => '<sup>[[#$1|$2]]</sup>', |
— | — | @@ -150,6 +151,7 @@ |
151 | 152 | 'cite_references_link_prefix' => '{{optional}}', |
152 | 153 | 'cite_references_link_suffix' => '{{optional}}', |
153 | 154 | 'cite_reference_link' => '{{optional}}', |
| 155 | + 'cite_references_no_link' => '{{optional}}', |
154 | 156 | 'cite_references_link_one' => '{{optional}}', |
155 | 157 | 'cite_references_link_many' => '{{optional}}', |
156 | 158 | 'cite_references_link_many_format' => '{{optional}}', |