Index: trunk/extensions/Wikilog/WikilogItemPager.php |
— | — | @@ -271,6 +271,7 @@ |
272 | 272 | * - 'published': empty (draft) or "*" (published) |
273 | 273 | * - 'date': article publication date |
274 | 274 | * - 'time': article publication time |
| 275 | + * - 'tz': timezone information |
275 | 276 | * - 'updatedDate': article last update date |
276 | 277 | * - 'updatedTime': article last update time |
277 | 278 | * - 'summary': article summary |
— | — | @@ -313,7 +314,7 @@ |
314 | 315 | } |
315 | 316 | |
316 | 317 | function formatRow( $row ) { |
317 | | - global $wgParser, $wgContLang; |
| 318 | + global $wgParser; |
318 | 319 | |
319 | 320 | # Retrieve article parser output and other data. |
320 | 321 | $item = WikilogItem::newFromRow( $row ); |
— | — | @@ -333,14 +334,12 @@ |
334 | 335 | $divclass = 'wl-entry' . ( $item->getIsPublished() ? '' : ' wl-draft' ); |
335 | 336 | |
336 | 337 | $itemPubdate = $item->getPublishDate(); |
337 | | - $pubdate = $wgContLang->timeanddate( $itemPubdate, true ); |
338 | | - $publishedDate = $wgContLang->date( $itemPubdate ); |
339 | | - $publishedTime = $wgContLang->time( $itemPubdate ); |
| 338 | + list( $publishedDate, $publishedTime, $publishedTz ) = |
| 339 | + WikilogUtils::getLocalDateTime( $itemPubdate ); |
340 | 340 | |
341 | 341 | $itemUpdated = $item->getUpdatedDate(); |
342 | | - $updated = $wgContLang->timeanddate( $itemUpdated, true ); |
343 | | - $updatedDate = $wgContLang->date( $itemUpdated ); |
344 | | - $updatedTime = $wgContLang->time( $itemUpdated ); |
| 342 | + list( $updatedDate, $updatedTime, ) = |
| 343 | + WikilogUtils::getLocalDateTime( $itemUpdated ); |
345 | 344 | |
346 | 345 | # Template parameters. |
347 | 346 | $vars = array( |
— | — | @@ -354,6 +353,7 @@ |
355 | 354 | 'published' => $item->getIsPublished() ? '*' : '', |
356 | 355 | 'date' => $publishedDate, |
357 | 356 | 'time' => $publishedTime, |
| 357 | + 'tz' => $publishedTz, |
358 | 358 | 'updatedDate' => $updatedDate, |
359 | 359 | 'updatedTime' => $updatedTime, |
360 | 360 | 'summary' => $wgParser->insertStripItem( $summary ), |
Index: trunk/extensions/Wikilog/RELEASE-NOTES |
— | — | @@ -11,6 +11,9 @@ |
12 | 12 | |
13 | 13 | === New features === |
14 | 14 | |
| 15 | +* Article and comment timestamps are now displayed in the wiki timezone |
| 16 | + (as defined by $wgLocaltimezone). |
| 17 | + |
15 | 18 | === Bug fixes === |
16 | 19 | |
17 | 20 | |
Index: trunk/extensions/Wikilog/Wikilog.i18n.php |
— | — | @@ -76,9 +76,9 @@ |
77 | 77 | |
78 | 78 | # Wikilog article header and footer |
79 | 79 | 'wikilog-summary-header' => '', |
80 | | - 'wikilog-summary-footer' => 'Posted by $7 to [[$1|$2]] on $8 at $9, $10.', |
| 80 | + 'wikilog-summary-footer' => 'Posted by $7 to [[$1|$2]] on $8 at $9 ($15), $10.', |
81 | 81 | 'wikilog-summary-header-single' => '', |
82 | | - 'wikilog-summary-footer-single' => 'Posted by $7 on $8 at $9, $10.', |
| 82 | + 'wikilog-summary-footer-single' => 'Posted by $7 on $8 at $9 ($15), $10.', |
83 | 83 | 'wikilog-summary-uncategorized' => 'Uncategorized', |
84 | 84 | 'wikilog-summary-categories' => 'Filed under $2', |
85 | 85 | 'wikilog-summary-more' => '[[$3|→ continue reading...]]', |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | # Comments |
100 | 100 | 'wikilog-comment-header' => '', |
101 | 101 | 'wikilog-comment-footer' => '— $2 • $5 $6', |
102 | | - 'wikilog-comment-permalink' => '$1 at $2', |
| 102 | + 'wikilog-comment-permalink' => '$1 at $2 ($3)', |
103 | 103 | 'wikilog-comment-note-item' => 'posted to $1', |
104 | 104 | 'wikilog-comment-note-edited' => 'last edited on $1 at $2', |
105 | 105 | 'wikilog-comment-anonsig' => '$3 (anonymous)', |
— | — | @@ -255,7 +255,8 @@ |
256 | 256 | * $7 is a list of authors of the article, each name formated with {{msg-mw|wikilog-author-signature}} |
257 | 257 | * $8 is the publication date |
258 | 258 | * $9 is the publication time |
259 | | -* $10 is a link to the comments page, with either {{msg-mw|wikilog-no-comments}} or {{msg-mw|wikilog-has-comments}} as link text", |
| 259 | +* $10 is a link to the comments page, with either {{msg-mw|wikilog-no-comments}} or {{msg-mw|wikilog-has-comments}} as link text |
| 260 | +* $15 is the timezone information (optional)", |
260 | 261 | 'wikilog-summary-footer-single' => "Identical to {{msg-mw|wikilog-summary-footer}}, but used when listing articles from a single wikilog, so it is not necessary to say where it was posted to. Parameters: |
261 | 262 | * $1 is a URL formatted link to the article's parent wikilog (optional) |
262 | 263 | * $2 is the article's parent wikilog name (optional) |
— | — | @@ -266,7 +267,8 @@ |
267 | 268 | * $7 is a list of authors of the article, each name formated with {{msg-mw|wikilog-author-signature}} |
268 | 269 | * $8 is the publication date |
269 | 270 | * $9 is the publication time |
270 | | -* $10 is a link to the comments page, with either {{msg-mw|wikilog-no-comments}} or {{msg-mw|wikilog-has-comments}} as link text", |
| 271 | +* $10 is a link to the comments page, with either {{msg-mw|wikilog-no-comments}} or {{msg-mw|wikilog-has-comments}} as link text |
| 272 | +* $15 is the timezone information (optional)", |
271 | 273 | 'wikilog-summary-categories' => 'Parameters: |
272 | 274 | * $1 is the number of categories listed in $2 |
273 | 275 | * $2 is a list of the categories the article is in', |
— | — | @@ -291,14 +293,16 @@ |
292 | 294 | 'wikilog-comment-permalink' => 'A permanent link to the comment. |
293 | 295 | Parameters: |
294 | 296 | * $1 is the comment date |
295 | | -* $2 is the comment time', |
| 297 | +* $2 is the comment time |
| 298 | +* $3 is the timezone information (optional)', |
296 | 299 | 'wikilog-comment-note-item' => 'The title of the article that the comment was posted to. |
297 | 300 | Parameters: |
298 | 301 | * $1 is an article title.', |
299 | 302 | 'wikilog-comment-note-edited' => 'The last time the comment was edited. |
300 | 303 | Parameters: |
301 | 304 | * $1 is the last modification date |
302 | | -* $2 is the last modification time', |
| 305 | +* $2 is the last modification time |
| 306 | +* $3 is the timezone information (optional)', |
303 | 307 | 'wikilog-comment-anonsig' => 'Signature used for anonymous users which post comments to articles. |
304 | 308 | Parameters: |
305 | 309 | * $1 is a link to the commenting user page (unused, it is an IP address) |
Index: trunk/extensions/Wikilog/WikilogItem.php |
— | — | @@ -196,6 +196,8 @@ |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
| 200 | + list( $date, $time, $tz ) = WikilogUtils::getLocalDateTime( $this->mPubDate ); |
| 201 | + |
200 | 202 | /* |
201 | 203 | * This is probably the largest amount of parameters to a |
202 | 204 | * system message in MediaWiki. This is the price of allowing |
— | — | @@ -209,13 +211,14 @@ |
210 | 212 | /* $5 */ count( $authors ), |
211 | 213 | /* $6 */ ( count( $authors ) > 0 ? $authors[0] : '' ), |
212 | 214 | /* $7 */ $authorsFmt, |
213 | | - /* $8 */ $wgContLang->date( $this->mPubDate ), |
214 | | - /* $9 */ $wgContLang->time( $this->mPubDate ), |
| 215 | + /* $8 */ $date, |
| 216 | + /* $9 */ $time, |
215 | 217 | /* $10 */ $commentsFmt, |
216 | 218 | /* $11 */ count( $categories ), |
217 | 219 | /* $12 */ $categoriesFmt, |
218 | 220 | /* $13 */ count( $tags ), |
219 | | - /* $14 */ $tagsFmt |
| 221 | + /* $14 */ $tagsFmt, |
| 222 | + /* $15 */ $tz |
220 | 223 | ); |
221 | 224 | } |
222 | 225 | |
Index: trunk/extensions/Wikilog/WikilogUtils.php |
— | — | @@ -399,6 +399,44 @@ |
400 | 400 | |
401 | 401 | return array( 'date' => $date, 'user' => $user ); |
402 | 402 | } |
| 403 | + |
| 404 | + /** |
| 405 | + * Return the given timestamp as a tuple with date, time and timezone |
| 406 | + * in the local timezone (if defined). This is meant to be compatible |
| 407 | + * with signatures produced by Parser::pstPass2(). It was based on this |
| 408 | + * same function. |
| 409 | + * |
| 410 | + * @param $timestamp Timestamp. |
| 411 | + * @return Array(3) containing date, time and timezone. |
| 412 | + */ |
| 413 | + public static function getLocalDateTime( $timestamp ) { |
| 414 | + global $wgContLang, $wgLocaltimezone; |
| 415 | + |
| 416 | + $ts = wfTimestamp( TS_UNIX, $timestamp ); |
| 417 | + |
| 418 | + if ( isset( $wgLocaltimezone ) ) { |
| 419 | + $oldtz = date_default_timezone_get(); |
| 420 | + date_default_timezone_set( $wgLocaltimezone ); |
| 421 | + } |
| 422 | + |
| 423 | + $ts = date( 'YmdHis', $ts ); |
| 424 | + $tz = date( 'T', $ts ); |
| 425 | + |
| 426 | + if ( isset( $oldtz ) ) { |
| 427 | + date_default_timezone_set( $oldtz ); |
| 428 | + } |
| 429 | + |
| 430 | + $date = $wgContLang->date( $ts, false, false ); |
| 431 | + $time = $wgContLang->time( $ts, false, false ); |
| 432 | + |
| 433 | + # Check for translation of timezones. |
| 434 | + $key = 'timezone-' . strtolower( trim( $tz ) ); |
| 435 | + $value = wfMsgForContent( $key ); |
| 436 | + if ( !wfEmptyMsg( $key, $value ) ) $tz = $value; |
| 437 | + |
| 438 | + return array( $date, $time, $tz ); |
| 439 | + } |
| 440 | + |
403 | 441 | } |
404 | 442 | |
405 | 443 | /** |
Index: trunk/extensions/Wikilog/WikilogComment.php |
— | — | @@ -721,9 +721,8 @@ |
722 | 722 | ); |
723 | 723 | } |
724 | 724 | |
725 | | - $date = $wgContLang->date( $comment->mTimestamp ); |
726 | | - $time = $wgContLang->time( $comment->mTimestamp ); |
727 | | - $permalink = $this->getCommentPermalink( $comment, $date, $time ); |
| 725 | + list( $date, $time, $tz ) = WikilogUtils::getLocalDateTime( $comment->mTimestamp ); |
| 726 | + $permalink = $this->getCommentPermalink( $comment, $date, $time, $tz ); |
728 | 727 | |
729 | 728 | $extra = array(); |
730 | 729 | if ( $this->mShowItem && $comment->mItem ) { |
— | — | @@ -737,11 +736,9 @@ |
738 | 737 | { |
739 | 738 | if ( $comment->mUpdated != $comment->mTimestamp ) { |
740 | 739 | # Comment was edited. |
| 740 | + list( $updDate, $updTime, $updTz ) = WikilogUtils::getLocalDateTime( $comment->mUpdated ); |
741 | 741 | $extra[] = $this->mSkin->link( $comment->mCommentTitle, |
742 | | - wfMsgForContent( 'wikilog-comment-note-edited', |
743 | | - $wgContLang->date( $comment->mUpdated, true ), |
744 | | - $wgContLang->time( $comment->mUpdated, true ) |
745 | | - ), |
| 742 | + wfMsgForContent( 'wikilog-comment-note-edited', $updDate, $updTime, $updTz ), |
746 | 743 | array( 'title' => wfMsg( 'wikilog-comment-history' ) ), |
747 | 744 | array( 'action' => 'history' ), 'known' |
748 | 745 | ); |
— | — | @@ -837,9 +834,10 @@ |
838 | 835 | * @param $comment Comment. |
839 | 836 | * @param $date Comment date. |
840 | 837 | * @param $time Comment time. |
| 838 | + * @param $tz Comment timezone information. |
841 | 839 | * @return HTML fragment. |
842 | 840 | */ |
843 | | - protected function getCommentPermalink( $comment, $date, $time ) { |
| 841 | + protected function getCommentPermalink( $comment, $date, $time, $tz ) { |
844 | 842 | if ( $comment->mID ) { |
845 | 843 | if ( $this->mPermalinkTitle ) { |
846 | 844 | $title = $this->mPermalinkTitle; |
— | — | @@ -848,11 +846,11 @@ |
849 | 847 | $title = $comment->mCommentTitle; |
850 | 848 | } |
851 | 849 | return $this->mSkin->link( $title, |
852 | | - wfMsg( 'wikilog-comment-permalink', $date, $time ), |
| 850 | + wfMsg( 'wikilog-comment-permalink', $date, $time, $tz ), |
853 | 851 | array( 'title' => wfMsg( 'permalink' ) ) |
854 | 852 | ); |
855 | 853 | } else { |
856 | | - return wfMsg( 'wikilog-comment-permalink', $date, $time ); |
| 854 | + return wfMsg( 'wikilog-comment-permalink', $date, $time, $tz ); |
857 | 855 | } |
858 | 856 | } |
859 | 857 | |