Index: trunk/extensions/TemplateAdventures/TemplateAdventures.i18n.magic.php |
— | — | @@ -22,6 +22,9 @@ |
23 | 23 | 'ta_cc_transitalic' => array( 0, 'transitalic' ), |
24 | 24 | 'ta_cc_transtitle' => array( 0, 'transtitle' ), |
25 | 25 | 'ta_cc_year' => array( 0, 'year' ), |
26 | | - 'ta_cc_publisher' => array( 0, 'publisher' ), |
27 | | - 'ta_cc_place' => array( 0, 'place' ), |
| 26 | + 'ta_cc_publisher' => array( 0, 'publisher', 'newspaper' ), |
| 27 | + 'ta_cc_place' => array( 0, 'place', 'location' ), |
| 28 | + 'ta_cc_transtitle' => array( 0, 'transtitle', 'trans_title' ), |
| 29 | + 'ta_cc_language' => array( 0, 'language' ), |
| 30 | + 'ta_cc_date' => array( 0, 'date' ), |
28 | 31 | ); |
Index: trunk/extensions/TemplateAdventures/TemplateAdventures.i18n.php |
— | — | @@ -29,7 +29,10 @@ |
30 | 30 | 'ta-citeplacepublisher' => '$1: $2', # $1 = place, $2 = publisher |
31 | 31 | 'ta-citeother' => '$1', |
32 | 32 | 'ta-citeinlanguage' => '$1 (in $2)', # $1 = title/link |
| 33 | + 'ta-citetitletrans' => '"$1 [$2]"', # $1 = title/link, $2 = transtitle |
33 | 34 | 'ta-citeformatrender' => '$1 ($2)', # $1 = title/link |
| 35 | + 'ta-newspublisherplace' => "''$1'' ($2)", |
| 36 | + 'ta-newspublisher' => "''$1''", |
34 | 37 | 'ta-citeperiodical' => "''$1''", |
35 | 38 | 'ta-citeperiodicaltitle' => "''$1''", |
36 | 39 | 'ta-series' => '$1', |
— | — | @@ -49,6 +52,7 @@ |
50 | 53 | 'ta-citeretrievedlower' => 'retrieved $1', |
51 | 54 | |
52 | 55 | # citation span messages |
| 56 | + 'ta-citationspan' => '<span class="citation $2">$1</span>', |
53 | 57 | 'ta-citeprintonlyspan' => '<span class="printonly">$1</span>', |
54 | 58 | 'ta-citeaccessdatespan' => '<span class="reference-accessdate">$1</span>', |
55 | 59 | ); |
Index: trunk/extensions/TemplateAdventures/TemplateAdventures.php |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | # first input is a bit different than the rest, |
133 | 133 | # so we'll treat that differently |
134 | 134 | $primary = trim( $this->mFrame->expand( array_shift( $args ) ) ); |
135 | | - $primary = $this->handleInputItem( $primary ); |
| 135 | + $primary = $this->handlePrimaryItem( $primary ); |
136 | 136 | |
137 | 137 | # check the rest for options |
138 | 138 | foreach( $args as $arg ) { |
— | — | @@ -172,6 +172,17 @@ |
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
| 176 | + * This functions handles the primary item. It is supposed to be |
| 177 | + * overwriteable |
| 178 | + * |
| 179 | + * @param $arg String Argument |
| 180 | + * @return String if understood, else return false |
| 181 | + */ |
| 182 | + protected function handlePrimaryItem( $arg ) { |
| 183 | + return false; |
| 184 | + } |
| 185 | + |
| 186 | + /** |
176 | 187 | * Parse the option. |
177 | 188 | * This should be rewritten in classes inheriting this class. |
178 | 189 | * |
Index: trunk/extensions/TemplateAdventures/Templates/Citation.php |
— | — | @@ -2,6 +2,8 @@ |
3 | 3 | |
4 | 4 | class Citation extends TemplateAdventureBasic { |
5 | 5 | |
| 6 | + private $citeType = null; # type of citation, e.g. 'news' |
| 7 | + # currently only 'news' supported. |
6 | 8 | private $dSeparators = array( # separators between names, items, etc. |
7 | 9 | 'section' => ',', |
8 | 10 | 'end' => '.', |
— | — | @@ -103,6 +105,7 @@ |
104 | 106 | $authorDisplayed = false; # whether authors or editors have been |
105 | 107 | # displayed |
106 | 108 | $publisherDisplayed = false; # whether publisher have been displayed |
| 109 | + $languageDisplayed = false; |
107 | 110 | # output |
108 | 111 | $this->mOutput = ''; |
109 | 112 | # authors |
— | — | @@ -175,8 +178,18 @@ |
176 | 179 | } else if ( $this->notNull ( $this->dWorkTitle['title'] ) ) { |
177 | 180 | # if only the title is set, assume url is the URL of the title |
178 | 181 | $url = $this->dWorkLink['url']; |
179 | | - $title = $this->dWorkTitle['title']; |
180 | | - $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
| 182 | + if ( $this->notNull ( $this->dWorkTitle['transtitle'] ) ) { |
| 183 | + $title = wfMsg ( 'ta-citetitletrans', $this->dWorkTitle['title'], $this->dWorkTitle['transtitle'] ); |
| 184 | + if ( $this->notNull ( $this->dLanguage ) ) { |
| 185 | + $this->mOutput .= wfMsg ( 'ta-citeinlanguage', $this->makeLink ( $url, $title ), $this->dLanguage ) . $this->getSeparator( 'section' ); |
| 186 | + $languageDisplayed = true; |
| 187 | + } else { |
| 188 | + $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
| 189 | + } |
| 190 | + } else { |
| 191 | + $title = $this->dWorkTitle['title']; |
| 192 | + $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
| 193 | + } |
181 | 194 | $urlDisplayed = true; |
182 | 195 | } |
183 | 196 | # place, but only if different from publication place. |
— | — | @@ -187,15 +200,24 @@ |
188 | 201 | ) && ( |
189 | 202 | $authorDisplayed |
190 | 203 | || $this->notNull ( $this->dWorkTitle['includedwork'] ) |
191 | | - ) |
| 204 | + ) && ( $this->citeType != 'news' ) |
192 | 205 | ) { |
193 | | - if ( $this->notNull ( $this->dPublisher ) ) { |
| 206 | + if ( $this->notNull ( $this->dPublisher ) |
| 207 | + && ( $this->citeType != 'news' ) ) { |
194 | 208 | $this->mOutput .= wfMsg ( 'ta-citeplacepublisher', $this->dPlace,$this->dPublisher ) . $this->getSeparator ( 'section' ); |
195 | 209 | $publisherDisplayed = true; |
196 | 210 | } else { |
197 | 211 | $this->mOutput .= wfMsg ( 'ta-citewrittenat', $this->dPlace ) . $this->getSeparator ( 'section' ); |
198 | 212 | } |
199 | 213 | } |
| 214 | + if ( ( $this->citeType == 'news' ) |
| 215 | + && $this->notNull ( $this->dPublisher ) ) { |
| 216 | + if ( $this->notNull ( $this->dPlace ) ) { |
| 217 | + $this->mOutput .= wfMsg ( 'ta-newspublisherplace', $this->dPublisher, $this->dPlace ) . $this->getSeparator ( 'section' ); |
| 218 | + } else { |
| 219 | + $this->mOutput .= wfMsg ( 'ta-newspublisher', $this->dPublisher ) . $this->getSeparator ( 'section' ); |
| 220 | + } |
| 221 | + } |
200 | 222 | # editor of complication... eerrr... |
201 | 223 | # TODO: we'll do this later... |
202 | 224 | |
— | — | @@ -250,8 +272,10 @@ |
251 | 273 | $this->mOutput .= $perArea; |
252 | 274 | } |
253 | 275 | # language |
254 | | - if ( $this->notNull ( $this->dLanguage ) ) { |
| 276 | + if ( $this->notNull ( $this->dLanguage ) |
| 277 | + && !$languageDisplayed ) { |
255 | 278 | $this->mOutput .= wfMsg ( 'ta-citeinlanguage', $this->dLanguage ); |
| 279 | + $languageDisplayed = true; |
256 | 280 | } |
257 | 281 | # format |
258 | 282 | if ( $this->notNull ( $this->dFormat ) ) { |
— | — | @@ -478,8 +502,8 @@ |
479 | 503 | } elseif ( $this->mOutput[strlen($this->mOutput)-1] != $this->getSeparator ( 'end', false ) ) { |
480 | 504 | $this->mOutput .= $this->getSeparator ( 'end', false ); |
481 | 505 | } |
482 | | - # if the end 'separator' is blank |
483 | | - $this->mOutput = trim($this->mOutput); |
| 506 | + # if the end 'separator' is blank, so we trim |
| 507 | + $this->mOutput = wfMsg ( 'ta-citationspan', trim($this->mOutput), $this->citeType ); |
484 | 508 | } |
485 | 509 | |
486 | 510 | /** |
— | — | @@ -539,9 +563,13 @@ |
540 | 564 | if ( $writer[1][0] != null ) |
541 | 565 | $tmp .= $this->getSeparator( 'name' ) . $writer[1][0]; |
542 | 566 | } else { |
543 | | - # maybe we shan't support no surname/given name structure |
544 | | - # in the future, but we'll leave it like this for now. |
545 | | - $tmp .= $writer[1][1]; |
| 567 | + if ( is_array ( $writer[1] ) ) { |
| 568 | + # maybe we shan't support no surname/given name structure |
| 569 | + # in the future, but we'll leave it like this for now. |
| 570 | + $tmp .= $writer[1][1]; |
| 571 | + } else { |
| 572 | + $tmp .= $writer[1]; |
| 573 | + } |
546 | 574 | } |
547 | 575 | if ( isset ( $links[$i] ) ) |
548 | 576 | $tmp = "[{$links[$i]} $tmp]"; |
— | — | @@ -558,9 +586,7 @@ |
559 | 587 | } |
560 | 588 | |
561 | 589 | private function notNull ( $check ) { |
562 | | - if ( $check == null && $check == '' ) |
563 | | - return false; |
564 | | - return true; |
| 590 | + return !( $check == null && $check == '' ); |
565 | 591 | } |
566 | 592 | |
567 | 593 | /** |
— | — | @@ -672,6 +698,12 @@ |
673 | 699 | case 'title': |
674 | 700 | $this->dWorkTitle['title'] = $value; |
675 | 701 | break; |
| 702 | + case 'transtitle': |
| 703 | + $this->dWorkTitle['transtitle'] = $value; |
| 704 | + break; |
| 705 | + case 'language': |
| 706 | + $this->dLanguage = $value; |
| 707 | + break; |
676 | 708 | case 'includedworktitle': |
677 | 709 | $this->dWorkTitle['includedwork'] = $value; |
678 | 710 | break; |
— | — | @@ -681,6 +713,9 @@ |
682 | 714 | case 'year': |
683 | 715 | $this->dYear = $value; |
684 | 716 | break; |
| 717 | + case 'date': |
| 718 | + $this->dDate = $value; |
| 719 | + break; |
685 | 720 | case 'place': |
686 | 721 | $this->dPlace = $value; |
687 | 722 | break; |
— | — | @@ -735,8 +770,10 @@ |
736 | 771 | case 'transitalic': |
737 | 772 | case 'transtitle': |
738 | 773 | case 'year': |
| 774 | + case 'date': |
739 | 775 | case 'place': |
740 | 776 | case 'publisher': |
| 777 | + case 'language': |
741 | 778 | $this->addOtherStringValue( $name, $value ); |
742 | 779 | break; |
743 | 780 | default: |
— | — | @@ -745,6 +782,11 @@ |
746 | 783 | } |
747 | 784 | return true; |
748 | 785 | } |
| 786 | + |
| 787 | + protected function handlePrimaryItem( $item ) { |
| 788 | + if ( in_array ( $item, array ( 'news' ) ) ) |
| 789 | + $this->citeType = $item; |
| 790 | + } |
749 | 791 | |
750 | 792 | /** |
751 | 793 | * This one parses the variable name given to optionParse to figure out |
— | — | @@ -769,7 +811,8 @@ |
770 | 812 | 'ta_cc_includedworktitle', 'ta_cc_periodical', |
771 | 813 | 'ta_cc_transitalic', 'ta_cc_transtitle', |
772 | 814 | 'ta_cc_year', 'ta_cc_publisher', |
773 | | - 'ta_cc_place', |
| 815 | + 'ta_cc_place', 'ta_cc_transtitle', |
| 816 | + 'ta_cc_language', 'ta_cc_date', |
774 | 817 | ) ); |
775 | 818 | } |
776 | 819 | |