r111562 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111561‎ | r111562 | r111563 >
Date:18:46, 15 February 2012
Author:yonishostak
Status:resolved (Comments)
Tags:
Comment:
AFTv5: activity feature - another sync-up commit
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -74,7 +74,7 @@
7575 'articlefeedbackv5-special-showing' => '{{PLURAL:$1|1 feedback post|$1 feedback posts}} on this article',
7676 'articleFeedbackv5-comment-ago' => '$1 ago',
7777 'articlefeedbackv5-updates-since' => '{{PLURAL:$1|1 edit|$1 edits}} since post',
78 - 'articlefeedbackv5-revision-link' => 'View original version',
 78+ 'articlefeedbackv5-revision-link' => 'View article revision',
7979 'articlefeedbackv5-special-more' => 'Show more posts',
8080 'articlefeedbackv5-special-pagetitle' => 'Feedback: $1',
8181 'articlefeedbackv5-form-optionid' => 'Option $1',
@@ -135,7 +135,12 @@
136136 'articlefeedbackv5-comment-less' => 'Less',
137137 'articlefeedbackv5-beta-notice' => 'Beta',
138138 'articlefeedbackv5-viewactivity' => 'View activity',
 139+ 'articlefeedbackv5-timestamp-years' => '{{PLURAL:$1|$1 year|$1 years}}',
 140+ 'articlefeedbackv5-timestamp-months' => '{{PLURAL:$1|$1 month|$1 months}}',
 141+ 'articlefeedbackv5-timestamp-weeks' => '{{PLURAL:$1|$1 week|$1 weeks}}',
 142+ 'articlefeedbackv5-timestamp-seconds' => 'less than 1 minute',
139143
 144+
140145 /* Special page flyover panels */
141146 /* Hide this post panel */
142147 'articlefeedbackv5-noteflyover-hide-caption' => 'Hide this post',
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css
@@ -208,12 +208,15 @@
209209 width: 140px;
210210 }
211211 .articleFeedbackv5-feedback .articleFeedbackv5-comment-details-updates {
212 - float: right;
213 - margin-right: 10px;
 212+ float: left;
 213+ display: block;
 214+ line-height: 24px;
 215+ margin: 0 5px 0 30px;
 216+ position: relative;
 217+ top: 18px;
214218 }
215219 .articleFeedbackv5-comment-details-date {
216220 float: left;
217 - clear: right;
218221 display: block;
219222 line-height: 24px;
220223 margin: 0 5px 0 0;
@@ -257,7 +260,7 @@
258261 #articleFeedbackv5-show-feedback .articleFeedbackv5-comment-foot {
259262 line-height: 22px;
260263 float: left;
261 - width: 520px;
 264+ width: 450px;
262265 }
263266 .articleFeedbackv5-vote-wrapper {
264267 float: left;
@@ -313,7 +316,7 @@
314317 .articleFeedbackv5-feedback .articleFeedbackv5-comment-wrap h3 {
315318 display: block;
316319 float: left;
317 - width: 520px;
 320+ width: 450px;
318321 line-height: 24px;
319322 }
320323 .articleFeedbackv5-feedback .articleFeedbackv5-comment-wrap h3 .icon {
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js
@@ -376,6 +376,14 @@
377377 $.articleFeedbackv5special.currentPanelHostId = undefined;
378378 } );
379379
 380+ // flyover panel close button
 381+ $( '#articlefeedbackv5-noteflyover-close' ).live( 'click', function( e ) {
 382+ e.preventDefault();
 383+ var $l = $( '#' + $.articleFeedbackv5special.currentPanelHostId );
 384+ $l.tipsy( 'hide' );
 385+ $.articleFeedbackv5special.currentPanelHostId = undefined;
 386+ } );
 387+
380388 // Delete/Undelete this post
381389 /*$( '.articleFeedbackv5-delete-link' ).live( 'click', function( e ) {
382390 e.preventDefault();
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -331,17 +331,6 @@
332332 $can_hide = $wgUser->isAllowed( 'aftv5-hide-feedback' );
333333 $can_delete = $wgUser->isAllowed( 'aftv5-delete-feedback' );
334334
335 - $details = Html::openElement( 'div', array(
336 - 'class' => 'articleFeedbackv5-comment-details-updates'
337 - ) );
338 - $details .= Linker::link(
339 - Title::newFromRow( $record[0] ),
340 - wfMessage( 'articlefeedbackv5-revision-link' )->escaped(),
341 - array(),
342 - array( 'oldid' => $record[0]->af_revision_id )
343 - );
344 - $details .= Html::closeElement( 'div' );
345 -
346335 $footer_links = Html::openElement( 'div', array(
347336 'class' => 'articleFeedbackv5-vote-wrapper'
348337 ) )
@@ -383,7 +372,7 @@
384373 'rel' => $record[0]->af_abuse_count
385374 ), wfMessage( $msg, $wgLang->formatNum( $record[0]->af_abuse_count ) )->text() );
386375 }
387 - $footer_links .= $details . Html::closeElement( 'div' );
 376+ $footer_links .= Html::closeElement( 'div' );
388377
389378 /*$footer_links .= Html::element( 'span', array(
390379 'class' => 'articleFeedbackv5-helpful-votes'
@@ -504,33 +493,66 @@
505494 global $wgLang;
506495 $id = $record->af_id;
507496 $title = $record->page_title;
 497+
 498+ $blocks = array(
 499+ array( 'total' => 60 * 60 * 24 * 365, 'name' => 'years' ),
 500+ array( 'total' => 60 * 60 * 24 * 30, 'name' => 'months'),
 501+ array( 'total' => 60 * 60 * 24 * 7, 'name' => 'weeks'),
 502+ array( 'total' => 60 * 60 * 24, 'name' => 'days'),
 503+ array( 'total' => 60 * 60, 'name' => 'hours'),
 504+ array( 'total' => 60, 'name' => 'minutes') );
 505+
 506+ $since = wfTimestamp( TS_UNIX ) - wfTimestamp( TS_UNIX, $record->af_created );
 507+ $displayTime = 0;
 508+ $displayBlock = '';
 509+
 510+ // get the largest time block, 1 minute 35 seconds -> 2 minutes
 511+ for( $i = 0, $count = count( $blocks ); $i < $count; $i++ ) {
 512+ $seconds = $blocks[$i]['total'];
 513+ $displayTime = floor( $since / $seconds );
508514
509 - // Taken from the Moodbar extension.
510 - $now = wfTimestamp( TS_UNIX );
511 - $timestamp = wfTimestamp( TS_UNIX, $record->af_created );
512 - $date = '';
 515+ if ( $displayTime > 0 ) {
 516+ $displayBlock = $blocks[$i]['name'];
 517+ // round up if the remaining time is greater than
 518+ // half of the time unit
 519+ if ( ( $since % $seconds ) >= ( $seconds / 2 ) ) {
 520+ $displayTime++;
513521
514 - // Relative dates for 48 hours, normal timestamps later.
515 - if ( $timestamp > ( $now - ( 86400 * 2 ) ) ) {
516 - $time = $wgLang->formatTimePeriod(
517 - ( $now - $timestamp ),
518 - array( 'avoid' => 'avoidseconds', 'noabbrevs' => true )
519 - );
520 - $date = wfMessage( 'articleFeedbackv5-comment-ago', $time )->escaped();
521 - } elseif( $timestamp ) {
522 - $date = $wgLang->timeanddate($record->af_created );
 522+ //advance to upper unit if possible, eg, 24 hours to 1 day
 523+ if ( isset( $blocks[$i-1] ) && $displayTime * $seconds == $blocks[$i-1]['total'] ) {
 524+ $displayTime = 1;
 525+ $displayBlock = $blocks[$i-1]['name'];
 526+ }
 527+ }
 528+ break;
 529+ }
523530 }
524531
 532+ $date = '';
 533+ if ( $displayTime > 0 ) {
 534+ if ( in_array( $displayBlock, array( 'years', 'months', 'weeks' ) ) ) {
 535+ $messageKey = 'articlefeedbackv5-timestamp-' . $displayBlock;
 536+ } else {
 537+ $messageKey = $displayBlock;
 538+ }
 539+ $date = wfMessage( $messageKey )->params( $wgLang->formatNum( $displayTime ) )->escaped();
 540+ } else {
 541+ $date = wfMessage( 'articlefeedbackv5-timestamp-seconds' )->escaped();
 542+ }
 543+
 544+ $message = wfMessage( 'articleFeedbackv5-comment-ago', $date )->escaped();
 545+
525546 // format the element
526547 return Html::openElement( 'span', array(
527548 'class' => 'articleFeedbackv5-comment-details-date'
528549 ) )
529550 . Linker::link(
530551 SpecialPage::getTitleFor( 'ArticleFeedbackv5', "$title/$id" ),
531 - $date
 552+ $message
532553 )
533554 . Html::closeElement( 'span' );
534555 }
 556+
535557
536558 private function renderBucket1( $record ) {
537559 if ( $record['found']->aa_response_boolean == 1 ) {
@@ -676,6 +698,17 @@
677699 if( !$title->exists() ) {
678700 $title = SpecialPage::getTitleFor( 'Contributions', $record->user_name );
679701 }
 702+
 703+ $details = Html::openElement( 'span', array(
 704+ 'class' => 'articleFeedbackv5-comment-details-updates'
 705+ ) );
 706+ $details .= Linker::link(
 707+ Title::newFromRow( $record ),
 708+ wfMessage( 'articlefeedbackv5-revision-link' )->escaped(),
 709+ array(),
 710+ array( 'oldid' => $record->af_revision_id )
 711+ );
 712+ $details .= Html::closeElement( 'span' );
680713
681714 return Html::openElement( 'h3', array( 'class' => $class) )
682715 . Html::element( 'span', array( 'class' => 'icon' ) )
@@ -686,7 +719,8 @@
687720 )->escaped()
688721 )
689722 . Html::closeElement( 'h3' )
690 - . $this->renderPermalinkTimestamp( $record );
 723+ . $this->renderPermalinkTimestamp( $record )
 724+ . $details;
691725 }
692726
693727 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r112328AFTv5: fix r111562yonishostak15:54, 24 February 2012
r112336AFTv5: fix r111562 again, misclosed commentyonishostak18:17, 24 February 2012

Comments

#Comment by Siebrand (talk | contribs)   18:53, 15 February 2012

Please add message documentation for the newly added messages. Thanks.

Status & tagging log