https://www.mediawiki.org/wiki/Special:Code/MediaWiki/110068
Revision: 110068 Author: gregchiasson Date: 2012-01-26 19:23:00 +0000 (Thu, 26 Jan 2012) Log Message: ----------- AFT5: - Fix some translation issues: remove a few unused messages (take them out of hooks.php as well), add missing qqq doucmentation for others. - Tweak text for up/down voting message, per requirements - Add active class in CSS/JS for clicked 'is this helpful' yes/no buttons, per requirements. - Don't display sort direction arrow on page load, per requirements. - Make permalink filter take affect immediately, instead of just changing URL and requiring a reload. - Comment out AFT5 special page display (was uncommented in dev, but needs to be commented out for committing - fixes a bug in r108881). - Escape $continue value before using it in a query. Fixes the other bug in r108881. - Use relative timestamps ('2 hours 19 minutes ago') for feedback posts less than 48 hours old (Taken largely from the way Moodbar does it). - Remove the old commented-out permalinks, since the timestamp is the new link . - Only show the 'X edits since' links (goes to diff page) if there have been edits since. - Stop double-escaping feedbackHead (r109254), and add gender back into the me ssage. - Replace 'all' filter with 'visible' - there is no 'all' filter anymore. Remo ve 'needs oversight' filter, as the 'request oversight' functionality is off t he table for initial release. Will remove the links to it as well, but this co mmit only takes out the filter. Modified Paths: -------------- trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js Modified: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php =================================================================== --- trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php 2012-01-26 19:23:00 UTC (rev 110068) @@ -175,9 +175,6 @@ 'articlefeedbackv5-undelete-saved', 'articlefeedbackv5-oversight-saved', 'articlefeedbackv5-unoversight-saved', - 'articlefeedbackv5-comment-link', - 'articlefeedbackv5-special-sort-asc', - 'articlefeedbackv5-special-sort-desc', 'articlefeedbackv5-comment-more', 'articlefeedbackv5-comment-less' ), Modified: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php =================================================================== --- trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php 2012-01-26 19:23:00 UTC (rev 110068) @@ -52,19 +52,17 @@ 'articlefeedbackv5-form-helpful-label' => 'Is this feedback helpful?', 'articlefeedbackv5-form-helpful-yes-label' => 'Yes', 'articlefeedbackv5-form-helpful-no-label' => 'No', - 'articlefeedbackv5-form-helpful-votes' => '({{PLURAL:$1|1 response|$1 responses}}: {{PLURAL:$2|1 yes|$2 yes}} / {{PLURAL:$3|1 no|$3 no}})', + 'articlefeedbackv5-form-helpful-votes' => '{{PLURAL:$1|1 yes|$1 yes}} / {{PLURAL:$2|1 no|$2 no}}', 'articlefeedbackv5-special-add-feedback' => 'Add your feedback', 'articlefeedbackv5-special-filter-all' => 'All ($1)', 'articlefeedbackv5-special-filter-comment' => 'Comments only ($1)', - 'articlefeedbackv5-special-filter-abusive' => 'Abusive ($1)', + 'articlefeedbackv5-special-filter-abusive' => 'Flagged as abuse ($1)', 'articlefeedbackv5-special-filter-helpful' => 'Helpful ($1)', 'articlefeedbackv5-special-filter-unhelpful' => 'Unhelpful ($1)', 'articlefeedbackv5-special-filter-needsoversight' => 'Oversight requested ($1)', - 'articlefeedbackv5-special-filter-visible' => 'Visible ($1)', + 'articlefeedbackv5-special-filter-visible' => 'All visible ($1)', 'articlefeedbackv5-special-filter-invisible' => 'Hidden ($1)', 'articlefeedbackv5-special-filter-deleted' => 'Deleted ($1)', - 'articlefeedbackv5-special-sort-asc' => '^', - 'articlefeedbackv5-special-sort-desc' => 'v', 'articlefeedbackv5-special-sort-age' => 'Date', 'articlefeedbackv5-special-sort-helpful' => 'Helpful', 'articlefeedbackv5-special-sort-rating' => 'Rating', @@ -74,6 +72,7 @@ 'articlefeedbackv5-special-filter-label-after' => '', 'articlefeedbackv5-special-showing' => '{{PLURAL:$1|1 feedback post|$1 feedback posts }} on this article', 'articlefeedbackv5-comment-link' => 'Permalink', + 'articleFeedbackv5-comment-ago' => '$1 ago', 'articlefeedbackv5-updates-since' => '{{PLURAL:$1|1 edit|$1 edits}} since post', 'articlefeedbackv5-special-more' => 'Show more posts', 'articlefeedbackv5-special-pagetitle' => 'Feedback: $1', @@ -102,8 +101,8 @@ 'articlefeedbackv5-delete-saved' => 'Feedback deleted', 'articlefeedbackv5-abuse-saved' => 'Flagged as abuse', 'articlefeedbackv5-hide-saved' => 'Hide flag saved', - 'articlefeedbackv5-unhelpful-saved' => 'Marked as unhelpful', - 'articlefeedbackv5-helpful-saved' => 'Marked as helpful', + 'articlefeedbackv5-unhelpful-saved' => 'No', + 'articlefeedbackv5-helpful-saved' => 'Yes', 'articlefeedbackv5-unhide-saved' => 'Feedback shown', 'articlefeedbackv5-undelete-saved' => 'Feedback shown', 'articlefeedbackv5-oversight-saved' => 'Marked for oversight', @@ -331,6 +330,13 @@ 'articlefeedbackv5-special-filter-deleted' => '{{Identical|Deleted}}', 'articlefeedbackv5-special-sort-age' => '{{Identical|Date}}', 'articlefeedbackv5-special-sort-rating' => '{{Identical|Rating}}', + 'articlefeedbackv5-special-sort-label-before' => 'Place to put a label before the sort options', + 'articlefeedbackv5-special-sort-label-after' => 'Place to put a label after the sort options', + 'articlefeedbackv5-special-filter-label-before' => 'Place to put a label before the filter select box', + 'articlefeedbackv5-special-filter-label-after' => 'Place to put a label after the filter select box', + 'articlefeedbackv5-special-showing' => 'Text to show how many feedback psots have been posted to this article. $1 is the number of posts (needs plural support)', + 'articleFeedbackv5-comment-ago' => 'For posts less than 48 hours old, display a relative timestamp ("2 hours 19 minutes ago", eg). Formatting timestamp is in $1', + 'articlefeedbackv5-updates-since' => 'Number of edits made to this article since this feedback was posted. $1 is the number of edits. Requires plural support', 'articlefeedbackv5-special-more' => '{{Identical|More}}', 'articlefeedbackv5-special-pagetitle' => 'Page title for [[Special:ArticleFeedbackv5]]. Parameters: * $1 is the title of the article for which we show the feedback', Modified: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php =================================================================== --- trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php 2012-01-26 19:23:00 UTC (rev 110068) @@ -242,14 +242,14 @@ $wgHooks['ArticleSaveComplete'][] = 'ArticleFeedbackv5Hooks::trackEditSuccess'; // API Registration -$wgAPIListModules['articlefeedbackv5-view-ratings'] = 'ApiViewRatingsArticleFeedbackv5'; -$wgAPIListModules['articlefeedbackv5-view-feedback'] = 'ApiViewFeedbackArticleFeedbackv5'; -$wgAPIModules['articlefeedbackv5-flag-feedback'] = 'ApiFlagFeedbackArticleFeedbackv5'; +#$wgAPIListModules['articlefeedbackv5-view-ratings'] = 'ApiViewRatingsArticleFeedbackv5'; +#$wgAPIListModules['articlefeedbackv5-view-feedback'] = 'ApiViewFeedbackArticleFeedbackv5'; +#$wgAPIModules['articlefeedbackv5-flag-feedback'] = 'ApiFlagFeedbackArticleFeedbackv5'; $wgAPIModules['articlefeedbackv5'] = 'ApiArticleFeedbackv5'; // Special Page -$wgSpecialPages['ArticleFeedbackv5'] = 'SpecialArticleFeedbackv5'; -$wgSpecialPageGroups['ArticleFeedbackv5'] = 'other'; +#$wgSpecialPages['ArticleFeedbackv5'] = 'SpecialArticleFeedbackv5'; +#$wgSpecialPageGroups['ArticleFeedbackv5'] = 'other'; $wgAvailableRights[] = 'aftv5-hide-feedback'; $wgAvailableRights[] = 'aftv5-delete-feedback'; Modified: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php =================================================================== --- trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php 2012-01-26 19:23:00 UTC (rev 110068) @@ -18,7 +18,7 @@ private $filters = array( 'comment', 'helpful', - 'all' + 'visible' ); private $sorts = array( 'age', @@ -41,8 +41,9 @@ if( $wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) { array_push( $this->filters, - 'invisible', 'unhelpful', 'abusive', 'needsoversight' + 'unhelpful', 'abusive', 'invisible' ); + # removing the 'needsoversight' filter, per Fabrice } if( $wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) { Modified: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php =================================================================== --- trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php 2012-01-26 19:23:00 UTC (rev 110068) @@ -141,8 +141,7 @@ $unhelpful = $record->af_unhelpful_count; $helpful = wfMessage( 'articlefeedbackv5-form-helpful-votes', - ( $helpful + $unhelpful ), - $helpful, $unhelpful + $helpful, $unhelpful )->escaped(); } } Modified: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php =================================================================== --- trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php 2012-01-26 19:23:00 UTC (rev 110068) @@ -112,7 +112,7 @@ $where[] = 'af_id = aa_feedback_id'; if ( $continue !== null ) { - $where[] = "$continueSql $continue"; + $where[] = $continueSql.' '.intVal( $continue ); } /* I'd really love to do this in one big query, but MySQL @@ -269,7 +269,7 @@ } protected function renderFeedback( $record ) { - global $wgArticlePath, $wgUser; + global $wgArticlePath, $wgUser, $wgLang; $id = $record[0]->af_id; switch( $record[0]->af_bucket_id ) { @@ -282,13 +282,27 @@ default: $content .= $this->renderNoBucket( $record ); break; } - // These two are the same for now, but may now always be, + // These two are the same for now, but may not always be, // so set them each separately. $can_flag = !$wgUser->isBlocked(); $can_vote = !$wgUser->isBlocked(); $can_hide = $wgUser->isAllowed( 'aftv5-hide-feedback' ); $can_delete = $wgUser->isAllowed( 'aftv5-delete-feedback' ); + // Taken from the Moodbar extension. + $now = wfTimestamp( TS_UNIX ); + $timestamp = wfTimestamp( TS_UNIX, $record[0]->af_created ); + // Relative dates for 48 hours, normal timestamps later. + if( $timestamp > ( $now - ( 86400 * 2 ) ) ) { + // TODO: relative dates. + $time = $wgLang->formatTimePeriod( + ( $now - $timestamp ), 'avoidseconds' + ); + $date = wfMessage( 'articleFeedbackv5-comment-ago', $time )->escaped(); + } else { + $date = $wgLang->timeanddate($record[0]->af_created ); + } + $details = Html::openElement( 'div', array( 'class' => 'articleFeedbackv5-comment-details' ) ) @@ -296,32 +310,29 @@ 'class' => 'articleFeedbackv5-comment-details-date' ) ) . Html::element( 'a', array( - 'href' => "#id=$id" - ), date( 'M j, Y H:i', strtotime( $record[0]->af_created ) ) ) + 'class' => 'articleFeedbackv5-permalink', + 'id' => "articleFeedbackv5-permalink-$id", + 'href' => "#id=$id" + ), $date ) . Html::closeElement( 'div' ) -# Remove for now, pending feedback. -# . Html::openElement( 'div', array( -# 'class' => 'articleFeedbackv5-comment-details-permalink' -# ) ) -# .Html::element( 'a', array( -# 'href' => "#id=$id" -# ), wfMessage( 'articlefeedbackv5-comment-link' ) ) -# . Html::closeElement( 'div' ) - . Html::openElement( 'div', array( 'class' => 'articleFeedbackv5-comment-details-updates' - ) ) - . Linker::link( - Title::newFromText( $record[0]->page_title ), - wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age ), - array(), - array( - 'action' => 'historysubmit', - 'diff' => $record[0]->page_latest, - 'oldid' => $record[0]->af_revision_id - ) - ) - . Html::closeElement( 'div' ) + ) ); + + if( $record[0]->age > 0 ) { + $details .= Linker::link( + Title::newFromText( $record[0]->page_title ), + wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age ), + array(), + array( + 'action' => 'historysubmit', + 'diff' => $record[0]->page_latest, + 'oldid' => $record[0]->af_revision_id + ) + ); + } + + $details .= Html::closeElement( 'div' ) . Html::closeElement( 'div' ); ; @@ -346,7 +357,7 @@ $footer_links .= Html::element( 'span', array( 'class' => 'articleFeedbackv5-helpful-votes', 'id' => "articleFeedbackv5-helpful-votes-$id" - ), wfMessage( 'articlefeedbackv5-form-helpful-votes', ( $record[0]->af_helpful_count + $record[0]->af_unhelpful_count ), $record[0]->af_helpful_count, $record[0]->af_unhelpful_count ) ); + ), wfMessage( 'articlefeedbackv5-form-helpful-votes', $record[0]->af_helpful_count, $record[0]->af_unhelpful_count ) ); if ( $can_flag ) { $footer_links .= Html::element( 'a', array( 'id' => "articleFeedbackv5-abuse-link-$id", @@ -570,18 +581,18 @@ } private function feedbackHead( $message, $class, $record, $extra = '' ) { - $gender = ''; # ? $name = htmlspecialchars( $record->user_name ); $link = $record->af_user_id ? "User:$name" : "Special:Contributions/$name"; + $gender = $name; return Html::openElement( 'h3', array( 'class' => $class ) ) . Linker::link( Title::newFromText( $link ), $name ) . Html::element( 'span', array( 'class' => 'icon' ) ) - . Html::element( 'span', - array( 'class' => 'result' ), - wfMessage( $message, $gender, $extra )->escaped() + . Html::element( 'span', + array( 'class' => 'result' ), + wfMessage( $message, $gender, $extra ) ) . Html::closeElement( 'h3' ); } Modified: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css =================================================================== --- trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.css 2012-01-26 19:23:00 UTC (rev 110068) @@ -321,3 +321,8 @@ .articleFeedbackv5-comment-full { display: none; } + +a.helpful-active { + background: url(images/bg-button.png) !important; + color: white !important; +} Modified: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js =================================================================== --- trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js 2012-01-26 18:41:42 UTC (rev 110067) +++ trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js 2012-01-26 19:23:00 UTC (rev 110068) @@ -98,7 +98,6 @@ // Initial load $.articleFeedbackv5special.loadFeedback( true ); - $.articleFeedbackv5special.drawSortArrow(); }; // }}} @@ -142,14 +141,31 @@ return false; } ); + $( '.articleFeedbackv5-permalink' ).live( 'click', function( e ) { + id = $.articleFeedbackv5special.stripID( this, 'articleFeedbackv5-permalink-' ); + $.articleFeedbackv5special.filter = 'id'; + $.articleFeedbackv5special.filterValue = id; + $.articleFeedbackv5special.continue = null; + $.articleFeedbackv5special.loadFeedback( true ); + } ); + $( '.articleFeedbackv5-comment-toggle' ).live( 'click', function( e ) { $.articleFeedbackv5special.toggleComment( $.articleFeedbackv5special.stripID( this, 'articleFeedbackv5-comment-toggle-' ) ); return false; } ); - $.each( ['unhide', 'undelete', 'oversight', 'hide', 'abuse', 'delete', 'helpful', 'unhelpful', 'unoversight'], - function ( index, value ) { + // Helpful and unhelpful have their own special logic, so break those out. + $.each( ['helpful', 'unhelpful' ], function ( index, value ) { $( '.articleFeedbackv5-' + value + '-link' ).live( 'click', function( e ) { + id = $.articleFeedbackv5special.stripID( this, 'articleFeedbackv5-' + value + '-link-' ); + $.articleFeedbackv5special.flagFeedback( id, value ); + // add highlighted class + $( this ).addClass( 'helpful-active' ); + } ) + } ); + + $.each( ['unhide', 'undelete', 'oversight', 'hide', 'abuse', 'delete', 'unoversight'], function ( index, value ) { + $( '.articleFeedbackv5-' + value + '-link' ).live( 'click', function( e ) { $.articleFeedbackv5special.flagFeedback( $.articleFeedbackv5special.stripID( this, 'articleFeedbackv5-' + value + '-link-' ), value ); } ) } ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs