Index: trunk/extensions/Cite/Cite.i18n.php |
— | — | @@ -67,6 +67,7 @@ |
68 | 68 | # Although I could just use # instead of <li> above and nothing here that |
69 | 69 | # will break on input that contains linebreaks |
70 | 70 | 'cite_references_prefix' => '<ol class="references">', |
| 71 | + 'cite_references_prefix_a' => '<ol type="a" class="references">', |
71 | 72 | 'cite_references_suffix' => '</ol>', |
72 | 73 | ); |
73 | 74 | |
Index: trunk/extensions/Cite/Cite.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | * </code> |
69 | 69 | * |
70 | 70 | * This works because: |
71 | | - * * PHP's datastructures are guarenteed to be returned in the |
| 71 | + * * PHP's datastructures are guaranteed to be returned in the |
72 | 72 | * order that things are inserted into them (unless you mess |
73 | 73 | * with that) |
74 | 74 | * * User supplied keys can't be integers, therefore avoiding |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | * |
84 | 84 | * @var int |
85 | 85 | */ |
86 | | - var $mOutCnt = 0; |
| 86 | + static $mOutCnt = 0; |
87 | 87 | var $mGroupCnt = array(); |
88 | 88 | |
89 | 89 | /** |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | * |
94 | 94 | * @var int |
95 | 95 | */ |
96 | | - var $mInCnt = 0; |
| 96 | + static $mInCnt = 0; |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * The backlinks, in order, to pass as $3 to |
— | — | @@ -282,9 +282,9 @@ |
283 | 283 | if ( $key === null ) { |
284 | 284 | // No key |
285 | 285 | //$this->mRefs[$group][] = $str; |
286 | | - $this->mRefs[$group][] = array('count'=>-1, 'text'=>$str, 'key'=>++$this->mOutCnt); |
| 286 | + $this->mRefs[$group][] = array('count'=>-1, 'text'=>$str, 'key'=>++self::$mOutCnt); |
287 | 287 | |
288 | | - return $this->linkRef( $group, $this->mInCnt++ ); |
| 288 | + return $this->linkRef( $group, self::$mInCnt++ ); |
289 | 289 | } else if ( is_string( $key ) ) { |
290 | 290 | // Valid key |
291 | 291 | if ( ! isset( $this->mRefs[$group][$key] ) || ! is_array( $this->mRefs[$group][$key] ) ) { |
— | — | @@ -292,10 +292,10 @@ |
293 | 293 | $this->mRefs[$group][$key] = array( |
294 | 294 | 'text' => $str, |
295 | 295 | 'count' => 0, |
296 | | - 'key' => ++$this->mOutCnt, |
| 296 | + 'key' => ++self::$mOutCnt, |
297 | 297 | 'number' => ++$this->mGroupCnt[$group] |
298 | 298 | ); |
299 | | - $this->mInCnt++; |
| 299 | + self::$mInCnt++; |
300 | 300 | return |
301 | 301 | $this->linkRef( |
302 | 302 | $group, |
— | — | @@ -373,7 +373,7 @@ |
374 | 374 | * |
375 | 375 | * @return string XHTML ready for output |
376 | 376 | */ |
377 | | - function referencesFormat($group) { |
| 377 | + function referencesFormat($group, $prefix='cite_references_prefix') { |
378 | 378 | if (( count( $this->mRefs ) == 0 ) or (empty( $this->mRefs[$group] ) )) |
379 | 379 | return ''; |
380 | 380 | |
— | — | @@ -383,7 +383,7 @@ |
384 | 384 | foreach ( $this->mRefs[$group] as $k => $v ) |
385 | 385 | $ent[] = $this->referencesFormatEntry( $k, $v ); |
386 | 386 | |
387 | | - $prefix = wfMsgForContentNoTrans( 'cite_references_prefix' ); |
| 387 | + $prefix = wfMsgForContentNoTrans( $prefix ); |
388 | 388 | $suffix = wfMsgForContentNoTrans( 'cite_references_suffix' ); |
389 | 389 | $content = implode( "\n", $ent ); |
390 | 390 | |
— | — | @@ -516,6 +516,12 @@ |
517 | 517 | } |
518 | 518 | } |
519 | 519 | |
| 520 | + function refCounterString($counter) { |
| 521 | + global $wgContLang; |
| 522 | + return $wgContLang->formatNum($counter); |
| 523 | + } |
| 524 | + |
| 525 | + |
520 | 526 | /** |
521 | 527 | * Return an id for use in wikitext output based on a key and |
522 | 528 | * optionally the number of it, used in <references>, not <ref> |
— | — | @@ -564,19 +570,18 @@ |
565 | 571 | * @param int $count The index of the key, used for distinguishing |
566 | 572 | * multiple occurances of the same key |
567 | 573 | * @param int $label The label to use for the link, I want to |
568 | | - * use the same label for all occourances of |
| 574 | + * use the same label for all occurances of |
569 | 575 | * the same named reference. |
570 | 576 | * @return string |
571 | 577 | */ |
572 | 578 | function linkRef( $group, $key, $count = null, $label = null, $subkey = '' ) { |
573 | | - global $wgContLang; |
574 | 579 | return |
575 | 580 | $this->parse( |
576 | 581 | wfMsgForContentNoTrans( |
577 | 582 | 'cite_reference_link', |
578 | 583 | $this->refKey( $key, $count ), |
579 | 584 | $this->referencesKey( $key . $subkey ), |
580 | | - (($group == CITE_DEFAULT_GROUP)?'':"$group ").$wgContLang->formatNum( is_null( $label ) ? ++$this->mGroupCnt[$group] : $label ) |
| 585 | + (($group == CITE_DEFAULT_GROUP)?'':"$group ").$this->refCounterString( is_null( $label ) ? ++$this->mGroupCnt[$group] : $label ) |
581 | 586 | ) |
582 | 587 | ); |
583 | 588 | } |
— | — | @@ -680,8 +685,8 @@ |
681 | 686 | */ |
682 | 687 | function clearState() { |
683 | 688 | $this->mGroupCnt = array(); |
684 | | - $this->mOutCnt = -1; |
685 | | - $this->mInCnt = 0; |
| 689 | + self::$mOutCnt = -1; |
| 690 | + self::$mInCnt = 0; |
686 | 691 | $this->mRefs = array(); |
687 | 692 | |
688 | 693 | return true; |
— | — | @@ -732,7 +737,51 @@ |
733 | 738 | /**#@-*/ |
734 | 739 | } |
735 | 740 | |
| 741 | + |
| 742 | + |
| 743 | + class Note extends Cite |
| 744 | + { |
| 745 | + |
| 746 | + /** |
| 747 | + * Constructor |
| 748 | + */ |
| 749 | + function Note() { |
| 750 | + $this->setHooks(); |
| 751 | + } |
| 752 | + |
| 753 | + /** |
| 754 | + * Initialize the parser hooks |
| 755 | + */ |
| 756 | + function setHooks() { |
| 757 | + global $wgParser, $wgHooks; |
| 758 | + |
| 759 | + $wgParser->setHook( 'note' , array( &$this, 'ref' ) ); |
| 760 | + $wgParser->setHook( 'footnotes' , array( &$this, 'references' ) ); |
| 761 | + |
| 762 | + $wgHooks['ParserClearState'][] = array( &$this, 'clearState' ); |
| 763 | + } |
| 764 | + |
| 765 | + function refCounterString($counter) { |
| 766 | + return $this->referencesFormatEntryAlternateBacklinkLabel( $counter-1 ); |
| 767 | + } |
| 768 | + |
| 769 | + |
| 770 | + /** |
| 771 | + * Make output to be returned from the references() function |
| 772 | + * |
| 773 | + * @return string XHTML ready for output |
| 774 | + */ |
| 775 | + function referencesFormat($group, $prefix='cite_references_prefix_a') { |
| 776 | + return parent::referencesFormat($group, $prefix); |
| 777 | +} |
| 778 | + |
| 779 | + } |
| 780 | + |
| 781 | + |
| 782 | + |
| 783 | + |
736 | 784 | new Cite; |
| 785 | + new Note; |
737 | 786 | } |
738 | 787 | |
739 | 788 | /**#@-*/ |