Index: trunk/extensions/TemplateAdventures/Templates/Citation.php |
— | — | @@ -69,8 +69,7 @@ |
70 | 70 | 'isbn' => null, |
71 | 71 | 'page' => null |
72 | 72 | ); |
73 | | - private $dISBN = null; # isbn number |
74 | | - private $dLay = array( # an article of the same publication, but |
| 73 | + private $dLayman = array( # an article of the same publication, but |
75 | 74 | # written in more layman friendly fashion. |
76 | 75 | 'data' => null, |
77 | 76 | 'summary' => null |
— | — | @@ -88,6 +87,9 @@ |
89 | 88 | 'page' => null, |
90 | 89 | ); |
91 | 90 | private $dOther = null; # other stuff |
| 91 | + |
| 92 | + private $mSections = array(); # sections of the citation. |
| 93 | + private $mTags = array(); # all tags |
92 | 94 | |
93 | 95 | /** |
94 | 96 | * Our construct function. |
— | — | @@ -104,6 +106,45 @@ |
105 | 107 | $this->readOptions( ); |
106 | 108 | $this->parseData(); |
107 | 109 | } |
| 110 | + |
| 111 | + /** |
| 112 | + * Add a section to mSections. |
| 113 | + * |
| 114 | + * @param $content The content of section. |
| 115 | + * @param $tags [default: array()] Some information regarding the content. |
| 116 | + */ |
| 117 | + private function addCiteSection ( $content, $tags = array () ) { |
| 118 | + $this->mSections[] = array ( |
| 119 | + $tags, |
| 120 | + $content |
| 121 | + ); |
| 122 | + $this->mTags = array_merge ( $this->mTags, $tags ); |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Detect if a tag has been set in a section. |
| 127 | + * |
| 128 | + * Note that parent means the first tag of a section's array tag, which |
| 129 | + * describes - in most cases at least - what the content is, while the |
| 130 | + * other tags further details this. It may sometimes be important to find |
| 131 | + * a tag only if its parent tag is something specific. |
| 132 | + * |
| 133 | + * @param $tag Tag to search for. |
| 134 | + * @param $parent [optional] The tag's parent. |
| 135 | + * @return Boolean True if found, false if not. |
| 136 | + */ |
| 137 | + private function isTagInSections ( $tag, $parent = null ) { |
| 138 | + if ( $this->notNull ( $parent ) ) { |
| 139 | + foreach ( $this->mSection as $section ) { |
| 140 | + if ( in_array ( $tag, $section[0] ) |
| 141 | + && $section[0][0] == $parent ) |
| 142 | + return true; |
| 143 | + } |
| 144 | + return false; |
| 145 | + } else { |
| 146 | + return in_array ( $tag, $this->mTags ); |
| 147 | + } |
| 148 | + } |
108 | 149 | |
109 | 150 | /** |
110 | 151 | * Render the data after the data have been read. |
— | — | @@ -112,6 +153,8 @@ |
113 | 154 | */ |
114 | 155 | public function render() { |
115 | 156 | # boolean variables to keep track of output |
| 157 | + # TODO: Once the section system is entirely written into this function, |
| 158 | + # these can be replaced by the isTagInSections() function. |
116 | 159 | $urlDisplayed = false; # whether the url has been displayed |
117 | 160 | $authorDisplayed = false; # whether authors or editors have been |
118 | 161 | # displayed |
— | — | @@ -141,6 +184,8 @@ |
142 | 185 | $authorArea, |
143 | 186 | $this->dYearNote ); |
144 | 187 | } |
| 188 | + $this->addSection ( $authorArea, array ( 'writer', 'author' ) ); |
| 189 | + # TODO: remove this |
145 | 190 | $this->mOutput .= $authorArea . $this->getSeparator ( 'section' ); |
146 | 191 | $authorDisplayed = true; |
147 | 192 | # editors |
— | — | @@ -164,6 +209,8 @@ |
165 | 210 | $editorArea .= wfMsg ( 'ta-citeauthoryearnote', |
166 | 211 | $editorArea, $this->dYearNote ); |
167 | 212 | } |
| 213 | + $this->addSection ( $editorArea, array ( 'writer', 'editor' ) ); |
| 214 | + # TODO: remove this |
168 | 215 | $this->mOutput .= $editorArea . $this->getSeparator ( 'section' ); |
169 | 216 | $authorDisplayed = true; |
170 | 217 | } |
— | — | @@ -202,6 +249,9 @@ |
203 | 250 | } |
204 | 251 | $title = $tmp; |
205 | 252 | } |
| 253 | + $this->addSection ( $this->makeLink ( $url, $title ), |
| 254 | + array ( 'title', 'includedlink' ) ); |
| 255 | + # TODO: Remove this |
206 | 256 | $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
207 | 257 | $urlDisplayed = true; |
208 | 258 | } else if ( $this->notNull ( $this->dWorkTitle['title'] ) ) { |
— | — | @@ -212,18 +262,31 @@ |
213 | 263 | $this->dWorkTitle['title'], |
214 | 264 | $this->dWorkTitle['transtitle'] ); |
215 | 265 | if ( $this->notNull ( $this->dLanguage ) ) { |
| 266 | + $this->addSection ( wfMsg ( 'ta-citeinlanguage', |
| 267 | + $this->makeLink ( $url, $title ), $this->dLanguage ), |
| 268 | + array ( 'title', 'transtitle', 'language' ) ); |
| 269 | + # TODO: Remove this |
216 | 270 | $this->mOutput .= wfMsg ( 'ta-citeinlanguage', $this->makeLink ( $url, $title ), $this->dLanguage ) . $this->getSeparator( 'section' ); |
217 | 271 | $languageDisplayed = true; |
218 | 272 | } else { |
| 273 | + $this->addSection ( $this->makeLink ( $url, $title ), |
| 274 | + array ( 'title', 'transtitle' ) ); |
| 275 | + # TODO: Remove this |
219 | 276 | $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
220 | 277 | } |
221 | 278 | } else { |
222 | 279 | $title = $this->dWorkTitle['title']; |
| 280 | + $this->addSection ( $this->makeLink ( $url, $title ), |
| 281 | + array ( 'title' ) ); |
| 282 | + # TODO: Remove this |
223 | 283 | $this->mOutput .= $this->makeLink ( $url, $title ) . $this->getSeparator( 'section' ); |
224 | 284 | } |
225 | 285 | $urlDisplayed = true; |
226 | 286 | } else if ( $this->citeType == 'book' |
227 | 287 | && $this->notNull ( $this->dBook['title'] ) ) { |
| 288 | + $this->addSection ( wfMsg ( 'ta-citebooktitle', $this->dBook['title'] ), |
| 289 | + array ( 'title', 'book' ) ); |
| 290 | + # TODO: Remove this |
228 | 291 | $this->mOutput .= wfMsg ( 'ta-citebooktitle', $this->dBook['title'] ) .$this->getSeparator ( 'section' ); |
229 | 292 | } |
230 | 293 | # place, but only if different from publication place. |
— | — | @@ -238,9 +301,16 @@ |
239 | 302 | ) { |
240 | 303 | if ( $this->notNull ( $this->dPublisher ) |
241 | 304 | && ( $this->citeType != 'news' ) ) { |
| 305 | + $this->addSection ( wfMsg ( 'ta-citeplacepublisher', |
| 306 | + $this->dPlace, $this->dPublisher ), |
| 307 | + array ( 'place', 'publisher' ) ); |
| 308 | + # TODO: Remove this |
242 | 309 | $this->mOutput .= wfMsg ( 'ta-citeplacepublisher', $this->dPlace,$this->dPublisher ) . $this->getSeparator ( 'section' ); |
243 | 310 | $publisherDisplayed = true; |
244 | 311 | } else { |
| 312 | + $this->addSection ( wfMsg ( 'ta-citewrittenat', $this->dPlace ), |
| 313 | + array ( 'place' ) ); |
| 314 | + # TODO: Remove this |
245 | 315 | $this->mOutput .= wfMsg ( 'ta-citewrittenat', $this->dPlace ) . $this->getSeparator ( 'section' ); |
246 | 316 | } |
247 | 317 | } |