Index: trunk/extensions/TemplateAdventures/TemplateAdventures.i18n.magic.php |
— | — | @@ -6,8 +6,8 @@ |
7 | 7 | # citation magic words |
8 | 8 | 'citation' => array( 1, 'citation' ), |
9 | 9 | 'ta_cc_author' => array( 0, 'author' ), |
10 | | - 'ta_cc_authorsurname' => array( 0, 'surname' ), |
11 | | - 'ta_cc_authorgiven' => array( 0, 'given' ), |
| 10 | + 'ta_cc_authorsurname' => array( 0, 'surname', 'last' ), |
| 11 | + 'ta_cc_authorgiven' => array( 0, 'given', 'first' ), |
12 | 12 | 'ta_cc_authorlink' => array( 0, 'authorlink' ), |
13 | 13 | 'ta_cc_coauthors' => array( 0, 'coauthors' ), |
14 | 14 | 'ta_cc_editor' => array( 0, 'editor' ), |
— | — | @@ -21,4 +21,7 @@ |
22 | 22 | 'ta_cc_periodical' => array( 0, 'periodical' ), |
23 | 23 | 'ta_cc_transitalic' => array( 0, 'transitalic' ), |
24 | 24 | 'ta_cc_transtitle' => array( 0, 'transtitle' ), |
| 25 | + 'ta_cc_year' => array( 0, 'year' ), |
| 26 | + 'ta_cc_publisher' => array( 0, 'publisher' ), |
| 27 | + 'ta_cc_place' => array( 0, 'place' ), |
25 | 28 | ); |
Index: trunk/extensions/TemplateAdventures/TemplateAdventures.i18n.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | 'ta-citepubmed-url' => 'http://www.pubmedcentral.nih.gov/articlerender.fcgi?tool=pmcentrez&artid=$1', |
28 | 28 | 'ta-citetranstitle-render' => '[$1]', |
29 | 29 | 'ta-citewrittenat' => 'written at $1', |
| 30 | + 'ta-citeplacepublisher' => '$1: $2', # $1 = place, $2 = publisher |
30 | 31 | 'ta-citeother' => '$1', |
31 | 32 | 'ta-citeinlanguage' => '$1 (in $2)', # $1 = title/link |
32 | 33 | 'ta-citeformatrender' => '$1 ($2)', # $1 = title/link |
Index: trunk/extensions/TemplateAdventures/Templates/Citation.php |
— | — | @@ -98,18 +98,26 @@ |
99 | 99 | * Render the data after the data have been read. |
100 | 100 | */ |
101 | 101 | public function render() { |
| 102 | + # boolean variables to keep track of output |
| 103 | + $urlDisplayed = false; # whether the url has been displayed |
| 104 | + $authorDisplayed = false; # whether authors or editors have been |
| 105 | + # displayed |
| 106 | + $publisherDisplayed = false; # whether publisher have been displayed |
| 107 | + # output |
102 | 108 | $this->mOutput = ''; |
103 | 109 | # authors |
104 | 110 | if ( count( $this->dAuthors ) > 1 ) { |
105 | 111 | $authorArea = $this->createWriterSection ( $this->dAuthors, $this->dAuthorLinks, $this->dAuthorTruncate ); |
106 | 112 | if ( $this->notNull ( $this->dCoAuthors ) ) |
107 | 113 | $authorArea = wfMsg ( 'ta-citecoauthors', $authorArea, $this->getSeparator( 'author' ), $this->dCoAuthors ); |
108 | | - if ( $this->notNull ( $this->dDate ) ) { |
109 | | - $authorArea = wfMsg ( 'ta-citeauthordate', $authorArea, $this->dDate); |
| 114 | + if ( $this->notNull ( $this->dDate ) |
| 115 | + || $this->notNull ( $this->dYear ) ) { |
| 116 | + $authorArea = wfMsg ( 'ta-citeauthordate', $authorArea, $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
110 | 117 | if ( $this->notNull ( $this->dYearNote ) ) |
111 | 118 | $authorArea = wfMsg ( 'ta-citeauthoryearnote', $authorArea, $this->dYearNote ); |
112 | 119 | } |
113 | 120 | $this->mOutput .= $authorArea . $this->getSeparator ( 'section' ); |
| 121 | + $authorDisplayed = true; |
114 | 122 | # editors |
115 | 123 | } elseif ( count ( $this->dEditors ) > 1 ) { |
116 | 124 | $editorArea = $this->createWriterSection ( $this->dEditors, $this->dEditorLinks, $this->dEditorTruncate ); |
— | — | @@ -118,12 +126,14 @@ |
119 | 127 | else |
120 | 128 | $editorArea = wfMsg ( 'ta-citeeditorssingular', $editorArea ); |
121 | 129 | $editorArea .= $this->getSeparator ( 'section' ); |
122 | | - if ( $this->notNull ( $this->dDate ) ) { |
123 | | - $editorArea = wfMsg ( 'ta-citeauthordate', $editorArea, $this->dDate); |
| 130 | + if ( $this->notNull ( $this->dDate ) |
| 131 | + || $this->notNull ( $this->dYear ) ) { |
| 132 | + $editorArea = wfMsg ( 'ta-citeauthordate', $editorArea, $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
124 | 133 | if ( $this->notNull ( $this->dYearNote ) ) |
125 | 134 | $editorArea .= wfMsg ( 'ta-citeauthoryearnote', $editorArea, $this->dYearNote ); |
126 | 135 | } |
127 | 136 | $this->mOutput .= $editorArea . $this->getSeparator ( 'section' ); |
| 137 | + $authorDisplayed = true; |
128 | 138 | } |
129 | 139 | # included work title |
130 | 140 | if ( $this->notNull( $this->dWorkTitle['includedwork'] ) |
— | — | @@ -160,18 +170,31 @@ |
161 | 171 | } |
162 | 172 | $title = $tmp; |
163 | 173 | } |
164 | | - $this->mOutput .= $this->makeLink ( $url, $title ); |
| 174 | + $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
| 175 | + $urlDisplayed = true; |
| 176 | + } else if ( $this->notNull ( $this->dWorkTitle['title'] ) ) { |
| 177 | + # if only the title is set, assume url is the URL of the title |
| 178 | + $url = $this->dWorkLink['url']; |
| 179 | + $title = $this->dWorkTitle['title']; |
| 180 | + $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
| 181 | + $urlDisplayed = true; |
165 | 182 | } |
166 | 183 | # place, but only if different from publication place. |
167 | 184 | if ( $this->notNull( $this->dPlace ) |
168 | | - && $this->dPlace != $this->dPublication['place'] |
169 | | - && ( |
170 | | - $this->notNull ( $authorArea ) |
171 | | - || $this->notNull ( $editorArea ) |
| 185 | + && ( |
| 186 | + !$this->notNull ( $this->dPublication['place'] ) |
| 187 | + || $this->dPlace != $this->dPublication['place'] |
| 188 | + ) && ( |
| 189 | + $authorDisplayed |
172 | 190 | || $this->notNull ( $this->dWorkTitle['includedwork'] ) |
173 | 191 | ) |
174 | 192 | ) { |
175 | | - $this->mOutput .= wfMsg ( 'ta-citewrittenat', $this->dPlace ) . $this->getSeparator ( 'section' ); |
| 193 | + if ( $this->notNull ( $this->dPublisher ) ) { |
| 194 | + $this->mOutput .= wfMsg ( 'ta-citeplacepublisher', $this->dPlace,$this->dPublisher ) . $this->getSeparator ( 'section' ); |
| 195 | + $publisherDisplayed = true; |
| 196 | + } else { |
| 197 | + $this->mOutput .= wfMsg ( 'ta-citewrittenat', $this->dPlace ) . $this->getSeparator ( 'section' ); |
| 198 | + } |
176 | 199 | } |
177 | 200 | # editor of complication... eerrr... |
178 | 201 | # TODO: we'll do this later... |
— | — | @@ -330,9 +353,10 @@ |
331 | 354 | $this->mOutput .= $newPerArea . $this->getSeparator ( 'section' ); |
332 | 355 | } |
333 | 356 | # date if no author/editor |
334 | | - if ( $authorArea == '' && $editorArea == '' ) { |
335 | | - if ( $this->notNull ( $this->dDate ) ) { |
336 | | - $this->mOutput .= wfMsg ( 'ta-citeauthordate', $this->dDate ); |
| 357 | + if ( !$authorDisplayed ) { |
| 358 | + if ( $this->notNull ( $this->dDate ) |
| 359 | + || $this->notNull ( $this->dYear ) ) { |
| 360 | + $this->mOutput .= wfMsg ( 'ta-citeauthordate', $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
337 | 361 | if ( $this->notNull ( $this->dYearNote ) ) { |
338 | 362 | $this->mOutput .= wfMsg ( 'ta-citeauthoryearnote', $this->dYearNote ); |
339 | 363 | } |
— | — | @@ -415,18 +439,20 @@ |
416 | 440 | # URL and accessdate |
417 | 441 | if ( $this->notNull ( $this->dWorkLink['url'] ) |
418 | 442 | || $this->notNull ( $this->dWorkLink['includedwork'] ) ) { |
419 | | - if ( $this->notNull ( $this->dWorkTitle['title'] ) |
420 | | - || $this->notNull ( $this->dWorkTitle['includedwork'] ) |
421 | | - || $this->notNull ( $this->dWorkTitle['transtitle'] ) ) { |
422 | | - $this->mOutput .= $this->printOnly ( |
| 443 | + if ( !$urlDisplayed ) { |
| 444 | + if ( $this->notNull ( $this->dWorkTitle['title'] ) |
| 445 | + || $this->notNull ( $this->dWorkTitle['includedwork'] ) |
| 446 | + || $this->notNull ( $this->dWorkTitle['transtitle'] ) ) { |
| 447 | + $this->mOutput .= $this->printOnly ( |
| 448 | + ( $this->notNull ( $this->dWorkLink['includedwork'] ) |
| 449 | + ? $this->dWorkLink['includedwork'] |
| 450 | + : $this->dWorkLink['url'] ) ); |
| 451 | + } else { |
| 452 | + $this->mOutput .= |
423 | 453 | ( $this->notNull ( $this->dWorkLink['includedwork'] ) |
424 | 454 | ? $this->dWorkLink['includedwork'] |
425 | | - : $this->dWorkLink['url'] ) ); |
426 | | - } else { |
427 | | - $this->mOutput .= |
428 | | - ( $this->notNull ( $this->dWorkLink['includedwork'] ) |
429 | | - ? $this->dWorkLink['includedwork'] |
430 | | - : $this->dWorkLink['url'] ); |
| 455 | + : $this->dWorkLink['url'] ); |
| 456 | + } |
431 | 457 | } |
432 | 458 | if ( $this->notNull ( $this->dAccessDate ) ) { |
433 | 459 | if ( $this->getSeparator ( 'section' ) == '.' ) |
— | — | @@ -452,6 +478,8 @@ |
453 | 479 | } elseif ( $this->mOutput[strlen($this->mOutput)-1] != $this->getSeparator ( 'end', false ) ) { |
454 | 480 | $this->mOutput .= $this->getSeparator ( 'end', false ); |
455 | 481 | } |
| 482 | + # if the end 'separator' is blank |
| 483 | + $this->mOutput = trim($this->mOutput); |
456 | 484 | } |
457 | 485 | |
458 | 486 | /** |
— | — | @@ -620,19 +648,20 @@ |
621 | 649 | |
622 | 650 | private function appendWriterData( &$array, $num, $name ) { |
623 | 651 | $split = is_array( $name ); |
624 | | - if ( $num != null ) { |
625 | | - if ( isset($array[$num]) && $array[$num][0] ) { |
626 | | - if ( $name[0] != null ) |
627 | | - $array[$num][1][0] = $name[0]; |
628 | | - else |
629 | | - $array[$num][1][1] = $name[1]; |
630 | | - } else { |
631 | | - $array[$num] = array ( |
632 | | - $split, |
633 | | - $name |
634 | | - ); |
635 | | - } |
636 | | - } # let's not permit them to add authors/editors/etc. without a number |
| 652 | + if ( $num == null ) |
| 653 | + # if no number, assume it is the first. |
| 654 | + $num = 1; |
| 655 | + if ( isset($array[$num]) && $array[$num][0] ) { |
| 656 | + if ( $name[0] != null ) |
| 657 | + $array[$num][1][0] = $name[0]; |
| 658 | + else |
| 659 | + $array[$num][1][1] = $name[1]; |
| 660 | + } else { |
| 661 | + $array[$num] = array ( |
| 662 | + $split, |
| 663 | + $name |
| 664 | + ); |
| 665 | + } |
637 | 666 | } |
638 | 667 | |
639 | 668 | private function addOtherStringValue ( $name, $value ) { |
— | — | @@ -649,6 +678,15 @@ |
650 | 679 | case 'periodical': |
651 | 680 | $this->dPeriodical['name'] = $value; |
652 | 681 | break; |
| 682 | + case 'year': |
| 683 | + $this->dYear = $value; |
| 684 | + break; |
| 685 | + case 'place': |
| 686 | + $this->dPlace = $value; |
| 687 | + break; |
| 688 | + case 'publisher': |
| 689 | + $this->dPublisher = $value; |
| 690 | + break; |
653 | 691 | } |
654 | 692 | } |
655 | 693 | |
— | — | @@ -696,6 +734,9 @@ |
697 | 735 | case 'periodical': |
698 | 736 | case 'transitalic': |
699 | 737 | case 'transtitle': |
| 738 | + case 'year': |
| 739 | + case 'place': |
| 740 | + case 'publisher': |
700 | 741 | $this->addOtherStringValue( $name, $value ); |
701 | 742 | break; |
702 | 743 | default: |
— | — | @@ -727,6 +768,8 @@ |
728 | 769 | 'ta_cc_url', 'ta_cc_title', 'ta_cc_pmc', |
729 | 770 | 'ta_cc_includedworktitle', 'ta_cc_periodical', |
730 | 771 | 'ta_cc_transitalic', 'ta_cc_transtitle', |
| 772 | + 'ta_cc_year', 'ta_cc_publisher', |
| 773 | + 'ta_cc_place', |
731 | 774 | ) ); |
732 | 775 | } |
733 | 776 | |