Index: trunk/extensions/TemplateAdventures/TemplateAdventures.i18n.php |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | # citation messages |
20 | 20 | 'ta-citeetal' => "$1 ''et al''.", # $1 = list of authors |
21 | 21 | 'ta-citecoauthors' => '$1$2 $3', # $1 = authors, $2 = separator |
| 22 | + 'ta-citealonedate' => '$1', # $1 = date |
22 | 23 | 'ta-citeauthordate' => '$1 ($2)', # $1 = authors or separator |
23 | 24 | 'ta-citeauthoryearnote' => '$1 [$2]', # $1 = date |
24 | 25 | 'ta-citeeditorsplural' => '$1, eds', # $1 = editors |
— | — | @@ -31,10 +32,15 @@ |
32 | 33 | 'ta-citeinlanguage' => '$1 (in $2)', # $1 = title/link |
33 | 34 | 'ta-citetitletrans' => '"$1 [$2]"', # $1 = title/link, $2 = transtitle |
34 | 35 | 'ta-citeformatrender' => '$1 ($2)', # $1 = title/link |
35 | | - 'ta-newspublisherplace' => "''$1'' ($2)", |
36 | | - 'ta-newspublisher' => "''$1''", |
| 36 | + 'ta-citenewspublisherplace' => "''$1'' ($2)", |
| 37 | + 'ta-citenewspublisher' => "''$1''", |
37 | 38 | 'ta-citeperiodical' => "''$1''", |
38 | 39 | 'ta-citeperiodicaltitle' => "''$1''", |
| 40 | + 'ta-citebooktitle' => "''$1''", |
| 41 | + 'ta-citebookpubplace' => '$1: $2', # $1 = location, $2 = publisher |
| 42 | + 'ta-citebookpublisher' => '$1', |
| 43 | + 'ta-citebookpage' => 'p. $1', |
| 44 | + 'ta-citebookisbn' => '[[Special:BookSources/$1|ISBN $2]]', |
39 | 45 | 'ta-series' => '$1', |
40 | 46 | 'ta-citepublicationplaceandpublisher' => '($1: $2)', |
41 | 47 | 'ta-citepublicationplace' => '($1)', |
— | — | @@ -50,6 +56,8 @@ |
51 | 57 | 'ta-citepublicationdate' => '$1', |
52 | 58 | 'ta-citeretrievedupper' => 'Retrieved $1', |
53 | 59 | 'ta-citeretrievedlower' => 'retrieved $1', |
| 60 | + 'ta-citejournal' => "''$1''", |
| 61 | + 'ta-citejournalpage' => "''$1'': $2", |
54 | 62 | |
55 | 63 | # citation span messages |
56 | 64 | 'ta-citationspan' => '<span class="citation $2">$1</span>', |
Index: trunk/extensions/TemplateAdventures/Templates/Citation.php |
— | — | @@ -64,6 +64,11 @@ |
65 | 65 | 'issn' => null, |
66 | 66 | ); |
67 | 67 | private $dLibrary = null; # library id |
| 68 | + private $dBook = array( # a book |
| 69 | + 'title' => null, |
| 70 | + 'isbn' => null, |
| 71 | + 'page' => null |
| 72 | + ); |
68 | 73 | private $dISBN = null; # isbn number |
69 | 74 | private $dLay = array( # an article of the same publication, but |
70 | 75 | # written in more layman friendly fashion. |
— | — | @@ -78,6 +83,10 @@ |
79 | 84 | 'broken' => null, # date broken |
80 | 85 | ); |
81 | 86 | private $dBibcode = null; # bibcode id |
| 87 | + private $dJournal = array( # journal and its page |
| 88 | + 'title' => null, |
| 89 | + 'page' => null, |
| 90 | + ); |
82 | 91 | private $dOther = null; # other stuff |
83 | 92 | |
84 | 93 | /** |
— | — | @@ -112,20 +121,35 @@ |
113 | 122 | $this->mOutput = ''; |
114 | 123 | # authors |
115 | 124 | if ( count( $this->dAuthors ) > 1 ) { |
116 | | - $authorArea = $this->createWriterSection ( $this->dAuthors, $this->dAuthorLinks, $this->dAuthorTruncate ); |
| 125 | + # remember element 0 is always set |
| 126 | + $authorArea = $this->createWriterSection ( |
| 127 | + $this->dAuthors, |
| 128 | + $this->dAuthorLinks, |
| 129 | + $this->dAuthorTruncate ); |
117 | 130 | if ( $this->notNull ( $this->dCoAuthors ) ) |
118 | | - $authorArea = wfMsg ( 'ta-citecoauthors', $authorArea, $this->getSeparator( 'author' ), $this->dCoAuthors ); |
| 131 | + $authorArea = wfMsg ( 'ta-citecoauthors', |
| 132 | + $authorArea, |
| 133 | + $this->getSeparator( 'author' ), |
| 134 | + $this->dCoAuthors ); |
119 | 135 | if ( $this->notNull ( $this->dDate ) |
120 | 136 | || $this->notNull ( $this->dYear ) ) { |
121 | | - $authorArea = wfMsg ( 'ta-citeauthordate', $authorArea, $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
| 137 | + $authorArea = wfMsg ( 'ta-citeauthordate', |
| 138 | + $authorArea, |
| 139 | + $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
122 | 140 | if ( $this->notNull ( $this->dYearNote ) ) |
123 | | - $authorArea = wfMsg ( 'ta-citeauthoryearnote', $authorArea, $this->dYearNote ); |
| 141 | + $authorArea = wfMsg ( 'ta-citeauthoryearnote', |
| 142 | + $authorArea, |
| 143 | + $this->dYearNote ); |
124 | 144 | } |
125 | 145 | $this->mOutput .= $authorArea . $this->getSeparator ( 'section' ); |
126 | 146 | $authorDisplayed = true; |
127 | 147 | # editors |
128 | 148 | } elseif ( count ( $this->dEditors ) > 1 ) { |
129 | | - $editorArea = $this->createWriterSection ( $this->dEditors, $this->dEditorLinks, $this->dEditorTruncate ); |
| 149 | + # remember element 0 is always set |
| 150 | + $editorArea = $this->createWriterSection ( |
| 151 | + $this->dEditors, |
| 152 | + $this->dEditorLinks, |
| 153 | + $this->dEditorTruncate ); |
130 | 154 | if ( count ( $this->dEditors ) > 2 ) |
131 | 155 | $editorArea = wfMsg ( 'ta-citeeditorsplural', $editorArea ); |
132 | 156 | else |
— | — | @@ -133,9 +157,12 @@ |
134 | 158 | $editorArea .= $this->getSeparator ( 'section' ); |
135 | 159 | if ( $this->notNull ( $this->dDate ) |
136 | 160 | || $this->notNull ( $this->dYear ) ) { |
137 | | - $editorArea = wfMsg ( 'ta-citeauthordate', $editorArea, $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
| 161 | + $editorArea = wfMsg ( 'ta-citeauthordate', |
| 162 | + $editorArea, |
| 163 | + $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
138 | 164 | if ( $this->notNull ( $this->dYearNote ) ) |
139 | | - $editorArea .= wfMsg ( 'ta-citeauthoryearnote', $editorArea, $this->dYearNote ); |
| 165 | + $editorArea .= wfMsg ( 'ta-citeauthoryearnote', |
| 166 | + $editorArea, $this->dYearNote ); |
140 | 167 | } |
141 | 168 | $this->mOutput .= $editorArea . $this->getSeparator ( 'section' ); |
142 | 169 | $authorDisplayed = true; |
— | — | @@ -181,7 +208,9 @@ |
182 | 209 | # if only the title is set, assume url is the URL of the title |
183 | 210 | $url = $this->dWorkLink['url']; |
184 | 211 | if ( $this->notNull ( $this->dWorkTitle['transtitle'] ) ) { |
185 | | - $title = wfMsg ( 'ta-citetitletrans', $this->dWorkTitle['title'], $this->dWorkTitle['transtitle'] ); |
| 212 | + $title = wfMsg ( 'ta-citetitletrans', |
| 213 | + $this->dWorkTitle['title'], |
| 214 | + $this->dWorkTitle['transtitle'] ); |
186 | 215 | if ( $this->notNull ( $this->dLanguage ) ) { |
187 | 216 | $this->mOutput .= wfMsg ( 'ta-citeinlanguage', $this->makeLink ( $url, $title ), $this->dLanguage ) . $this->getSeparator( 'section' ); |
188 | 217 | $languageDisplayed = true; |
— | — | @@ -190,9 +219,12 @@ |
191 | 220 | } |
192 | 221 | } else { |
193 | 222 | $title = $this->dWorkTitle['title']; |
194 | | - $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
| 223 | + $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
195 | 224 | } |
196 | 225 | $urlDisplayed = true; |
| 226 | + } else if ( $this->citeType == 'book' |
| 227 | + && $this->notNull ( $this->dBook['title'] ) ) { |
| 228 | + $this->mOutput .= wfMsg ( 'ta-citebooktitle', $this->dBook['title'] ) .$this->getSeparator ( 'section' ); |
197 | 229 | } |
198 | 230 | # place, but only if different from publication place. |
199 | 231 | if ( $this->notNull( $this->dPlace ) |
— | — | @@ -202,7 +234,7 @@ |
203 | 235 | ) && ( |
204 | 236 | $authorDisplayed |
205 | 237 | || $this->notNull ( $this->dWorkTitle['includedwork'] ) |
206 | | - ) && ( $this->citeType != 'news' ) |
| 238 | + ) && ( !in_array ( $this->citeType, array ( 'news', 'book' ) ) ) |
207 | 239 | ) { |
208 | 240 | if ( $this->notNull ( $this->dPublisher ) |
209 | 241 | && ( $this->citeType != 'news' ) ) { |
— | — | @@ -215,11 +247,33 @@ |
216 | 248 | if ( ( $this->citeType == 'news' ) |
217 | 249 | && $this->notNull ( $this->dPublisher ) ) { |
218 | 250 | if ( $this->notNull ( $this->dPlace ) ) { |
219 | | - $this->mOutput .= wfMsg ( 'ta-newspublisherplace', $this->dPublisher, $this->dPlace ) . $this->getSeparator ( 'section' ); |
| 251 | + $this->mOutput .= wfMsg ( 'ta-citenewspublisherplace', $this->dPublisher, $this->dPlace ) . $this->getSeparator ( 'section' ); |
220 | 252 | } else { |
221 | | - $this->mOutput .= wfMsg ( 'ta-newspublisher', $this->dPublisher ) . $this->getSeparator ( 'section' ); |
| 253 | + $this->mOutput .= wfMsg ( 'ta-citenewspublisher', $this->dPublisher ) . $this->getSeparator ( 'section' ); |
222 | 254 | } |
223 | 255 | } |
| 256 | + if ( ( $this->citeType == 'journal' ) |
| 257 | + && $this->notNull ( $this->dJournal['title'] ) ) { |
| 258 | + if ( $this->notNull ( $this->dJournal['page'] ) ) { |
| 259 | + $this->mOutput .= wfMsg ( 'ta-citejournalpage', |
| 260 | + $this->dJournal['title'], |
| 261 | + $this->dJournal['page'] ) . $this->getSeparator ( 'section' ); |
| 262 | + } else { |
| 263 | + $this->mOutput .= wfMsg ( 'ta-citejournal', |
| 264 | + $this->dJournal['title'] ) . $this->getSeparator ( 'section' ); |
| 265 | + } |
| 266 | + } |
| 267 | + if ( ( $this->citeType == 'book' ) |
| 268 | + && $this->notNull ( $this->dPublisher ) ) { |
| 269 | + if ( $this->notNull ( $this->dPlace ) ) { |
| 270 | + $this->mOutput .= wfMsg ( 'ta-citebookpubplace', $this->dPlace, $this->dPublisher ) . $this->getSeparator ( 'section' ); |
| 271 | + } else { |
| 272 | + $this->mOutput .= wfMsg ( 'ta-citebookpublisher', $this->dPublisher ) . $this->getSeparator ( 'section' ); |
| 273 | + } |
| 274 | + if ( $this->notNull ( $this->dBook['page'] ) ) { |
| 275 | + $this->mOutput .= wfMsg ( 'ta-citebookpage', $this->dBook['page'] ) . $this->getSeparator ( 'section' ); |
| 276 | + } |
| 277 | + } |
224 | 278 | # editor of complication... eerrr... |
225 | 279 | # TODO: we'll do this later... |
226 | 280 | |
— | — | @@ -382,11 +436,11 @@ |
383 | 437 | if ( !$authorDisplayed ) { |
384 | 438 | if ( $this->notNull ( $this->dDate ) |
385 | 439 | || $this->notNull ( $this->dYear ) ) { |
386 | | - $this->mOutput .= wfMsg ( 'ta-citeauthordate', $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
| 440 | + $tmp = wfMsg ( 'ta-citealonedate', $this->notNull ( $this->dDate ) ? $this->dDate : $this->dYear ); |
387 | 441 | if ( $this->notNull ( $this->dYearNote ) ) { |
388 | | - $this->mOutput .= wfMsg ( 'ta-citeauthoryearnote', $this->dYearNote ); |
| 442 | + $tmp = wfMsg ( 'ta-citeauthoryearnote', $tmp, $this->dYearNote ); |
389 | 443 | } |
390 | | - $this->mOutput .= $this->getSeparator ( 'section' ); |
| 444 | + $this->mOutput .= $tmp . $this->getSeparator ( 'section' ); |
391 | 445 | } |
392 | 446 | } |
393 | 447 | # publication date |
— | — | @@ -424,15 +478,18 @@ |
425 | 479 | # |{{{Sep|,}}} {{{ID}}} |
426 | 480 | # |{{{ID}}} |
427 | 481 | # }} |
| 482 | + # isbn |
| 483 | + if ( $this->citeType == 'book' |
| 484 | + && $this->notNull ( $this->dBook['isbn'] ) ) { |
| 485 | + $this->mOutput .= wfMsg ( 'ta-citebookisbn', |
| 486 | + $this->dBook['isbn'], |
| 487 | + $this->createDisplayISBN ( $this->dBook['isbn'] ) |
| 488 | + ) . $this->getSeparator ( 'section' ); |
| 489 | + } |
428 | 490 | |
429 | 491 | # more identifiers: |
430 | 492 | # TODO: Do all this crap. |
431 | 493 | /* |
432 | | - {{ |
433 | | -<!--============ ISBN ============--> |
434 | | - #if: {{{ISBN|}}} |
435 | | - |{{{Sep|,}}} {{citation/identifier |identifier=isbn |input1={{{ISBN|}}} }} |
436 | | -}}{{ |
437 | 494 | <!--============ ISSN ============--> |
438 | 495 | #if: {{{ISSN|}}} |
439 | 496 | |{{{Sep|,}}} {{citation/identifier |identifier=issn |input1={{{ISSN|}}} }} |
— | — | @@ -481,10 +538,10 @@ |
482 | 539 | } |
483 | 540 | } |
484 | 541 | if ( $this->notNull ( $this->dAccessDate ) ) { |
485 | | - if ( $this->getSeparator ( 'section' ) == '.' ) |
486 | | - $tmp = wfMsg ( 'ta-citeretrievedupper', $this->getSeparator ( 'section' ), $this->dAccessDate ); |
| 542 | + if ( $this->getSeparator ( 'section', false ) == '.' ) |
| 543 | + $tmp = wfMsg ( 'ta-citeretrievedupper', $this->dAccessDate ); |
487 | 544 | else |
488 | | - $tmp = wfMsg ( 'ta-citeretrievedlower', $this->getSeparator ( 'section' ), $this->dAccessDate ); |
| 545 | + $tmp = wfMsg ( 'ta-citeretrievedlower', $this->dAccessDate ); |
489 | 546 | $this->mOutput .= wfMsg ( 'ta-citeaccessdatespan', $tmp ); |
490 | 547 | } |
491 | 548 | } |
— | — | @@ -507,6 +564,16 @@ |
508 | 565 | # if the end 'separator' is blank, so we trim |
509 | 566 | $this->mOutput = wfMsg ( 'ta-citationspan', trim($this->mOutput), $this->citeType ); |
510 | 567 | } |
| 568 | + |
| 569 | + /** |
| 570 | + * Create the rendered version of an ISBN number. |
| 571 | + * |
| 572 | + * @param $isbn The raw ISBN number. |
| 573 | + * @return $isbn The rendered version. |
| 574 | + */ |
| 575 | + private function createDisplayISBN ( $isbn ) { |
| 576 | + return $isbn[0] . '-' . $isbn[1] . $isbn[2] . $isbn[3] . $isbn[4] . '-' . $isbn[5] . $isbn[6] . $isbn[7] . $isbn[8] . '-' . $isbn[9]; |
| 577 | + } |
511 | 578 | |
512 | 579 | /** |
513 | 580 | * Surround the string in a span tag that tells the css not to render it |
— | — | @@ -608,7 +675,7 @@ |
609 | 676 | * @return Boolean |
610 | 677 | */ |
611 | 678 | private function notNull ( $check ) { |
612 | | - return !( $check == null && $check === '' ); |
| 679 | + return !( $check == null && trim ( $check ) === '' ); |
613 | 680 | } |
614 | 681 | |
615 | 682 | /** |
— | — | @@ -788,7 +855,17 @@ |
789 | 856 | $this->dWorkLink['url'] = $value; |
790 | 857 | break; |
791 | 858 | case 'title': |
792 | | - $this->dWorkTitle['title'] = $value; |
| 859 | + switch ( $this->citeType ) { |
| 860 | + case 'book': |
| 861 | + $this->dBook['title'] = $value; |
| 862 | + break; |
| 863 | + case 'journal': |
| 864 | + case 'web': |
| 865 | + case 'news': |
| 866 | + default: |
| 867 | + $this->dWorkTitle['title'] = $value; |
| 868 | + break; |
| 869 | + } |
793 | 870 | break; |
794 | 871 | case 'transtitle': |
795 | 872 | $this->dWorkTitle['transtitle'] = $value; |
— | — | @@ -817,6 +894,25 @@ |
818 | 895 | case 'coauthors': |
819 | 896 | $this->dCoAuthors = $value; |
820 | 897 | break; |
| 898 | + case 'accessdate': |
| 899 | + $this->dAccessDate = $value; |
| 900 | + break; |
| 901 | + case 'journal': |
| 902 | + $this->dJournal['title'] = $value; |
| 903 | + break; |
| 904 | + case 'page': |
| 905 | + switch ( $this->citeType ) { |
| 906 | + case 'journal': |
| 907 | + $this->dJournal['page'] = $value; |
| 908 | + break; |
| 909 | + case 'book': |
| 910 | + $this->dBook['page'] = $value; |
| 911 | + break; |
| 912 | + } |
| 913 | + break; |
| 914 | + case 'isbn': |
| 915 | + $this->dBook['isbn'] = str_replace ( '-', '', $value ); |
| 916 | + break; |
821 | 917 | } |
822 | 918 | } |
823 | 919 | |
— | — | @@ -828,6 +924,8 @@ |
829 | 925 | * @return True if option, false if not. |
830 | 926 | */ |
831 | 927 | protected function optionParse( $var, $value ) { |
| 928 | + if ( !$this->notNull ( $value ) ) |
| 929 | + return; |
832 | 930 | $name = self::parseOptionName( $var ); |
833 | 931 | switch ( $name[0] ) { |
834 | 932 | case 'author': |
— | — | @@ -867,6 +965,10 @@ |
868 | 966 | case 'place': |
869 | 967 | case 'publisher': |
870 | 968 | case 'language': |
| 969 | + case 'accessdate': |
| 970 | + case 'journal': |
| 971 | + case 'page': |
| 972 | + case 'isbn': |
871 | 973 | $this->addOtherStringValue( $name, $value ); |
872 | 974 | break; |
873 | 975 | default: |
— | — | @@ -886,7 +988,7 @@ |
887 | 989 | * @param $item The raw item. |
888 | 990 | */ |
889 | 991 | protected function handlePrimaryItem( $item ) { |
890 | | - if ( in_array ( $item, array ( 'news' ) ) ) |
| 992 | + if ( in_array ( $item, array ( 'web', 'news', 'journal', 'book' ) ) ) |
891 | 993 | $this->citeType = $item; |
892 | 994 | } |
893 | 995 | |
— | — | @@ -915,11 +1017,13 @@ |
916 | 1018 | 'ta_cc_year', 'ta_cc_publisher', |
917 | 1019 | 'ta_cc_place', 'ta_cc_transtitle', |
918 | 1020 | 'ta_cc_language', 'ta_cc_date', |
| 1021 | + 'ta_cc_accessdate', 'ta_cc_page', |
| 1022 | + 'ta_cc_journal', 'ta_cc_isbn', |
919 | 1023 | ) ); |
920 | 1024 | } |
921 | 1025 | |
922 | 1026 | $num = preg_replace("@.*?([0-9]+)$@is", '\1', $value); |
923 | | - if (is_numeric( $num )) |
| 1027 | + if ( is_numeric( $num ) ) |
924 | 1028 | $name = preg_replace("@(.*?)[0-9]+$@is", '\1', $value); |
925 | 1029 | else { |
926 | 1030 | $name = $value; |
Index: trunk/extensions/TemplateAdventures/TemplateAdventures.i18n.magic.php |
— | — | @@ -11,9 +11,9 @@ |
12 | 12 | 'ta_cc_authorlink' => array( 0, 'authorlink' ), |
13 | 13 | 'ta_cc_coauthors' => array( 0, 'coauthors' ), |
14 | 14 | 'ta_cc_editor' => array( 0, 'editor' ), |
15 | | - 'ta_cc_editorsurname' => array( 0, 'editorsurname' ), |
16 | | - 'ta_cc_editorgiven' => array( 0, 'editorgiven' ), |
17 | | - 'ta_cc_editorlink' => array( 0, 'editorlink' ), |
| 15 | + 'ta_cc_editorsurname' => array( 0, 'editorsurname', 'editor surname', 'editorlast', 'editor last' ), |
| 16 | + 'ta_cc_editorgiven' => array( 0, 'editorgiven', 'editor given', 'editorfirst', 'editor first' ), |
| 17 | + 'ta_cc_editorlink' => array( 0, 'editorlink', 'editor link' ), |
18 | 18 | 'ta_cc_url' => array( 0, 'url' ), |
19 | 19 | 'ta_cc_title' => array( 0, 'title' ), |
20 | 20 | 'ta_cc_pmc' => array( 0, 'pmc' ), |
— | — | @@ -27,4 +27,8 @@ |
28 | 28 | 'ta_cc_transtitle' => array( 0, 'transtitle', 'trans_title' ), |
29 | 29 | 'ta_cc_language' => array( 0, 'language' ), |
30 | 30 | 'ta_cc_date' => array( 0, 'date' ), |
| 31 | + 'ta_cc_accessdate' => array( 0, 'accessdate' ), |
| 32 | + 'ta_cc_journal' => array( 0, 'journal' ), |
| 33 | + 'ta_cc_page' => array( 0, 'page' ), |
| 34 | + 'ta_cc_isbn' => array( 0, 'isbn' ), |
31 | 35 | ); |