https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113456

Revision: 113456
Author:   santhosh
Date:     2012-03-09 06:21:33 +0000 (Fri, 09 Mar 2012)
Log Message:
-----------
Stylize

Modified Paths:
--------------
    trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php
    trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
    trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
    trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php
    trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php

Modified: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php     
2012-03-09 06:05:35 UTC (rev 113455)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php     
2012-03-09 06:21:33 UTC (rev 113456)
@@ -109,7 +109,7 @@
 
                // Per Fabrice 1/25, FeedbackPage only cares about option 1, so
                // don't bother updating the rollups if this is a different one.
-               if( $bucket == 1 ) {
+               if ( $bucket == 1 ) {
                        $this->updateRollupTables( $pageId, $revisionId, 
$userAnswers );
                        $this->updateFilterCounts( $dbw, $pageId, $userAnswers 
);
                }
@@ -284,7 +284,7 @@
        public function updateFilterCounts( $dbw, $pageId, $answers ) {
 
                // a new item should be in all and visible by default, 
increment those counters
-               $filters = array( 'all' => 1, 'visible' => 1, 'notdeleted' => 
1);
+               $filters = array( 'all' => 1, 'visible' => 1, 'notdeleted' => 1 
);
 
                // if this record has a comment attached then increment comment 
as well
                // notice we do not need to walk the entire array, since any 
one hit

Modified: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php        
2012-03-09 06:05:35 UTC (rev 113455)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php        
2012-03-09 06:21:33 UTC (rev 113456)
@@ -162,11 +162,11 @@
        public static function updateFilterCounts( $dbw, $pageId, $filters ) {
 
                // Don't do anything unless we have filters to process.
-               if( empty( $filters ) || count($filters) < 1 ) {
-                       return; 
+               if ( empty( $filters ) || count( $filters ) < 1 ) {
+                       return;
                }
 
-               foreach ( $filters as $filter => $direction) {
+               foreach ( $filters as $filter => $direction ) {
                        $rows[] = array(
                                'afc_page_id'      => $pageId,
                                'afc_filter_name'  => $filter,
@@ -183,8 +183,8 @@
                        array( 'IGNORE' )
                );
 
-               foreach ( $filters as $filter => $direction) {
-                       $value = ($direction > 0) ? 'afc_filter_count + 1' : 
'GREATEST(0, CONVERT(afc_filter_count, SIGNED) - 1)';
+               foreach ( $filters as $filter => $direction ) {
+                       $value = ( $direction > 0 ) ? 'afc_filter_count + 1' : 
'GREATEST(0, CONVERT(afc_filter_count, SIGNED) - 1)';
 
                        # Update each row with the new count.
                        $dbw->update(
@@ -209,14 +209,14 @@
         * @param $notes     string any notes that were stored with the activity
         * @param $auto      boolean true if this was an "automatic" action, if 
so the log doer is changed
         */
-       public static function logActivity( $type, $pageId, $itemId, $notes, 
$auto = false) {
+       public static function logActivity( $type, $pageId, $itemId, $notes, 
$auto = false ) {
 
                // These are our valid activity log actions
                $valid = array( 'oversight', 'unoversight', 'hidden', 
'unhidden',
-                               'decline', 'request', 
'unrequest','flag','unflag' );
+                               'decline', 'request', 'unrequest', 'flag', 
'unflag' );
 
                // if we do not have a valid action, return immediately
-               if ( !in_array( $type, $valid )) {
+               if ( !in_array( $type, $valid ) ) {
                        return;
                }
 
@@ -224,7 +224,7 @@
                $title_object = Title::newFromID( $pageId );
 
                // no title object? no page? well then no logging
-               if (!$title_object) {
+               if ( !$title_object ) {
                        return;
                }
 
@@ -240,11 +240,11 @@
                $notes = $wgLang->truncate( $notes, 
$wgArticleFeedbackv5MaxActivityNoteLength );
 
                // if this is an automatic action, we create our special 
extension doer and send
-               if ($auto) {
+               if ( $auto ) {
                        $default_user = wfMessage( 
'articlefeedbackv5-default-user' )->text();
                        $doer = User::newFromName( $default_user );
                        // I cannot see how this could fail, but if it does do 
not log
-                       if (!$doer) {
+                       if ( !$doer ) {
                                return;
                        }
                } else {
@@ -253,7 +253,7 @@
 
                $log = new LogPage( 'articlefeedbackv5' );
                // comments become the notes section from the feedback
-               $log->addEntry( $type, $permalink, $notes, array(), $doer);
+               $log->addEntry( $type, $permalink, $notes, array(), $doer );
 
                // update our log count by 1
                $dbw = wfGetDB( DB_MASTER );
@@ -278,9 +278,9 @@
         * @param string $user_ip (name works too)
         * @return anchor tag link to user
         */
-       public static function getUserLink($user_id, $user_ip = null) {
+       public static function getUserLink( $user_id, $user_ip = null ) {
                // if $user is not an object
-               if ( !($user_id instanceof User) ){
+               if ( !( $user_id instanceof User ) ) {
                        $userId = (int) $user_id;
                        if ( $userId !== 0 ) { // logged-in users
                                $user = User::newFromId( $userId );

Modified: 
trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php 
2012-03-09 06:05:35 UTC (rev 113455)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php 
2012-03-09 06:21:33 UTC (rev 113456)
@@ -26,7 +26,7 @@
         * a piece of feedback
         *
         * A feedback request consists of
-        * 1. 
+        * 1.
         */
        public function execute() {
 
@@ -63,13 +63,13 @@
                        // no-op, because this is already broken
                        $error = 'articlefeedbackv5-invalid-feedback-id';
 
-               } elseif ( 'delete' == $flag && $wgUser->isAllowed( 
'aftv5-delete-feedback' )) {
+               } elseif ( 'delete' == $flag && $wgUser->isAllowed( 
'aftv5-delete-feedback' ) ) {
 
                        // deleting means to "mark as oversighted" and "delete" 
it
                        // oversighting also auto-hides the item
 
                        // increase means "oversight this"
-                       if( $direction == 'increase' ) {
+                       if ( $direction == 'increase' ) {
                                $activity = 'oversight';
 
                                // delete
@@ -81,16 +81,16 @@
                                // delete specific filters
                                $filters['deleted'] = 1;
                                $filters['notdeleted'] = -1;
-                               if (true == $record->af_is_undeleted ) {
+                               if ( true == $record->af_is_undeleted ) {
                                        $filters['undeleted'] = -1;
                                }
 
                                // This is data for the "hidden by, oversighted 
by" red line
-                               $results['oversight-user'] = 
ApiArticleFeedbackv5Utils::getUserLink($wgUser);
+                               $results['oversight-user'] = 
ApiArticleFeedbackv5Utils::getUserLink( $wgUser );
                                $results['oversight-timestamp'] = wfTimestamp( 
TS_RFC2822, $timestamp );
 
                                // autohide if not hidden
-                               if (false == $record->af_is_hidden ) {
+                               if ( false == $record->af_is_hidden ) {
                                        $update['af_is_hidden'] = true;
                                        $update['af_is_unhidden'] = false;
                                        $filters = $this->changeFilterCounts( 
$record, $filters, 'hide' );
@@ -101,7 +101,7 @@
                                        // tell front-end autohiding was done
                                        $results['autohidden'] = 1;
                                        // This is data for the "hidden by, 
oversighted by" red line
-                                       $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink(null, $default_user);
+                                       $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink( null, $default_user );
                                        $results['hide-timestamp'] = 
wfTimestamp( TS_RFC2822, $timestamp );
                                }
 
@@ -118,10 +118,10 @@
                                $filters['notdeleted'] = 1;
                        }
 
-               } elseif ( 'hide' == $flag && $wgUser->isAllowed( 
'aftv5-hide-feedback' )) {
+               } elseif ( 'hide' == $flag && $wgUser->isAllowed( 
'aftv5-hide-feedback' ) ) {
 
                        // increase means "hide this"
-                       if( $direction == 'increase' ) {
+                       if ( $direction == 'increase' ) {
                                $activity = 'hidden';
 
                                // hide
@@ -133,7 +133,7 @@
                                $filters = $this->changeFilterCounts( $record, 
$filters, 'hide' );
 
                                // This is data for the "hidden by, oversighted 
by" red line
-                               $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink($wgUser);
+                               $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink( $wgUser );
                                $results['hide-timestamp'] = wfTimestamp( 
TS_RFC2822, $timestamp );
 
                        } else {
@@ -146,7 +146,7 @@
                                $filters = $this->changeFilterCounts( $record, 
$filters, 'show' );
                        }
 
-               } elseif( 'resetoversight' === $flag && $wgUser->isAllowed( 
'aftv5-delete-feedback' )) {
+               } elseif ( 'resetoversight' === $flag && $wgUser->isAllowed( 
'aftv5-delete-feedback' ) ) {
 
                        $activity = 'decline';
                        // oversight request count becomes 0
@@ -155,11 +155,11 @@
                        $update['af_is_declined'] = true;
                        $filters['declined'] = 1;
                        // if the oversight count was greater then 1
-                       if(0 < $record->af_oversight_count) {
+                       if ( 0 < $record->af_oversight_count ) {
                                $filters['needsoversight'] = -1;
                        }
 
-               } elseif( 'abuse' === $flag) {
+               } elseif ( 'abuse' === $flag ) {
 
                        // Conditional formatting for abuse flag
                        global $wgArticleFeedbackv5AbusiveThreshold,
@@ -168,28 +168,28 @@
                        $results['abuse_count'] = $record->af_abuse_count;
 
                        // Make the abuse count in the result reflect this vote.
-                       if( $direction == 'increase' ) {
-                               $results['abuse_count']++; 
-                       } else { 
-                               $results['abuse_count']--; 
+                       if ( $direction == 'increase' ) {
+                               $results['abuse_count']++;
+                       } else {
+                               $results['abuse_count']--;
                        }
                        // no negative numbers
-                       $results['abuse_count'] = max(0, 
$results['abuse_count']);
+                       $results['abuse_count'] = max( 0, 
$results['abuse_count'] );
 
                        // Return a flag in the JSON, that turns the link red.
-                       if( $results['abuse_count'] >= 
$wgArticleFeedbackv5AbusiveThreshold ) {
+                       if ( $results['abuse_count'] >= 
$wgArticleFeedbackv5AbusiveThreshold ) {
                                $results['abusive'] = 1;
                        }
 
                        // Adding a new abuse flag: abusive++
-                       if($direction == 'increase') {
+                       if ( $direction == 'increase' ) {
                                $activity = 'flag';
                                $filters['abusive'] = 1;
                                // NOTE: we are bypassing traditional sql 
escaping here
                                $update[] = "af_abuse_count = af_abuse_count + 
1";
 
                                // Auto-hide after threshold flags
-                               if( $record->af_abuse_count > 
$wgArticleFeedbackv5HideAbuseThreshold
+                               if ( $record->af_abuse_count > 
$wgArticleFeedbackv5HideAbuseThreshold
                                   && false == $record->af_is_hidden ) {
                                        // hide
                                        $update['af_is_hidden'] = true;
@@ -205,20 +205,20 @@
                                        // tell front-end autohiding was done
                                        $results['autohidden'] = 1;
                                        // This is data for the "hidden by, 
oversighted by" red line
-                                       $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink(null, $default_user);
+                                       $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink( null, $default_user );
                                        $results['hide-timestamp'] = 
wfTimestamp( TS_RFC2822, $timestamp );
                                }
                        }
-       
+
                        // Removing the last abuse flag: abusive--
-                       elseif($direction == 'decrease') {
+                       elseif ( $direction == 'decrease' ) {
                                $activity = 'unflag';
                                $filters['abusive'] = -1;
                                // NOTE: we are bypassing traditional sql 
escaping here
                                $update[] = "af_abuse_count = 
GREATEST(CONVERT(af_abuse_count, SIGNED) -1, 0)";
 
                                // Un-hide if we don't have 5 flags anymore
-                               if( $record->af_abuse_count == 5 && true == 
$record->af_is_hidden ) {
+                               if ( $record->af_abuse_count == 5 && true == 
$record->af_is_hidden ) {
                                        $update['af_is_hidden'] = false;
                                        $update['af_is_unhidden'] = true;
 
@@ -232,16 +232,16 @@
                        }
 
                // NOTE: this is actually request/unrequest oversight and works 
similar to abuse
-               } elseif( 'oversight' === $flag && $wgUser->isAllowed( 
'aftv5-hide-feedback' )) {
+               } elseif ( 'oversight' === $flag && $wgUser->isAllowed( 
'aftv5-hide-feedback' ) ) {
 
-                       if($direction == 'increase') {
+                       if ( $direction == 'increase' ) {
                                $activity = 'request';
                                $filters['needsoversight'] = 1;
                                // NOTE: we are bypassing traditional sql 
escaping here
                                $update[] = "af_oversight_count = 
af_oversight_count + 1";
 
                                // autohide if not hidden
-                               if (false == $record->af_is_hidden ) {
+                               if ( false == $record->af_is_hidden ) {
                                        $update['af_is_hidden'] = true;
                                        $update['af_is_unhidden'] = false;
                                        // 0 is used for "autohidden" purposes, 
we'll explicitly set it to overwrite last hider
@@ -253,17 +253,17 @@
                                        // tell front-end autohiding was done
                                        $results['autohidden'] = 1;
                                        // This is data for the "hidden by, 
oversighted by" red line
-                                       $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink(null, $default_user);
+                                       $results['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink( null, $default_user );
                                        $results['hide-timestamp'] = 
wfTimestamp( TS_RFC2822, $timestamp );
                                }
 
                                // IF the previous setting was 0, send an email
-                               if ( $record->af_oversight_count < 1) {
+                               if ( $record->af_oversight_count < 1 ) {
 
                                         $this->sendOversightEmail( 
$record->af_page_id , $feedbackId );
 
                                }
-                       } elseif($direction == 'decrease') {
+                       } elseif ( $direction == 'decrease' ) {
                                $activity = 'unrequest';
                                $filters['needsoversight'] = -1;
                                // NOTE: we are bypassing traditional sql 
escaping here
@@ -274,7 +274,7 @@
                        }
 
                // helpful and unhelpful flagging
-               } elseif( 'unhelpful' === $flag || 'helpful' === $flag) {
+               } elseif ( 'unhelpful' === $flag || 'helpful' === $flag ) {
 
                        $results['toggle'] = $toggle;
                        $helpful = $record->af_helpful_count;
@@ -282,10 +282,10 @@
 
                        // if toggle is on, we are decreasing one and 
increasing the other atomically
                        // means one less http request and the counts don't 
mess up
-                       if (true == $toggle) {
+                       if ( true == $toggle ) {
 
-                               if( ( ($flag == 'helpful' && $direction == 
'increase' )
-                                || ($flag == 'unhelpful' && $direction == 
'decrease' ) )
+                               if ( ( ( $flag == 'helpful' && $direction == 
'increase' )
+                                || ( $flag == 'unhelpful' && $direction == 
'decrease' ) )
                                ) {
                                        // NOTE: we are bypassing traditional 
sql escaping here
                                        $update[] = "af_helpful_count = 
af_helpful_count + 1";
@@ -293,8 +293,8 @@
                                        $helpful++;
                                        $unhelpful--;
 
-                               } elseif ( ( ($flag == 'unhelpful' && 
$direction == 'increase' )
-                                || ($flag == 'helpful' && $direction == 
'decrease' ) )
+                               } elseif ( ( ( $flag == 'unhelpful' && 
$direction == 'increase' )
+                                || ( $flag == 'helpful' && $direction == 
'decrease' ) )
                                ) {
                                        // NOTE: we are bypassing traditional 
sql escaping here
                                        $update[] = "af_unhelpful_count = 
af_unhelpful_count + 1";
@@ -305,11 +305,11 @@
 
                        } else {
 
-                               if ( 'unhelpful' === $flag && $direction == 
'increase') {
+                               if ( 'unhelpful' === $flag && $direction == 
'increase' ) {
                                        // NOTE: we are bypassing traditional 
sql escaping here
                                        $update[] = "af_unhelpful_count = 
af_unhelpful_count + 1";
                                        $unhelpful++;
-                               } elseif ( 'unhelpful' === $flag && $direction 
== 'decrease') {
+                               } elseif ( 'unhelpful' === $flag && $direction 
== 'decrease' ) {
                                        // NOTE: we are bypassing traditional 
sql escaping here
                                        $update[] = "af_unhelpful_count = 
GREATEST(0, CONVERT(af_unhelpful_count, SIGNED) - 1)";
                                        $unhelpful--;
@@ -328,31 +328,31 @@
                        $netHelpfulness = $helpful - $unhelpful;
 
                        // increase helpful OR decrease unhelpful
-                       if( ( ($flag == 'helpful' && $direction == 'increase' )
-                        || ($flag == 'unhelpful' && $direction == 'decrease' ) 
)
+                       if ( ( ( $flag == 'helpful' && $direction == 'increase' 
)
+                        || ( $flag == 'unhelpful' && $direction == 'decrease' 
) )
                        ) {
                                // net was -1: no longer unhelpful
-                               if( $netHelpfulness == -1 ) {
+                               if ( $netHelpfulness == -1 ) {
                                        $filters['unhelpful'] = -1;
                                }
-       
+
                                // net was 0: now helpful
-                               if( $netHelpfulness == 0 ) {
+                               if ( $netHelpfulness == 0 ) {
                                        $filters['helpful'] = 1;
                                }
                        }
 
                        // increase unhelpful OR decrease unhelpful
-                       if( ( ($flag == 'unhelpful' && $direction == 'increase' 
)
-                        || ($flag == 'helpful' && $direction == 'decrease' ) )
+                       if ( ( ( $flag == 'unhelpful' && $direction == 
'increase' )
+                        || ( $flag == 'helpful' && $direction == 'decrease' ) )
                        ) {
                                // net was 1: no longer helpful
-                               if( $netHelpfulness == 1 ) {
+                               if ( $netHelpfulness == 1 ) {
                                        $filters['helpful'] = -1;
                                }
-       
+
                                // net was 0: now unhelpful
-                               if( $netHelpfulness == 0 ) {
+                               if ( $netHelpfulness == 0 ) {
                                        $filters['unhelpful'] = 1;
                                }
                        }
@@ -362,7 +362,7 @@
                }
 
                // we were valid
-               if ( !isset($error) ) {
+               if ( !isset( $error ) ) {
 
                        $success = $dbw->update(
                                'aft_article_feedback',
@@ -377,27 +377,27 @@
                        $dbw->commit(); // everything went well, so we commit 
our db changes
 
                        // helpfulness counts are NOT logged, no activity is set
-                       if (isset($activity)) {
+                       if ( isset( $activity ) ) {
                                ApiArticleFeedbackv5Utils::logActivity( 
$activity , $pageId, $feedbackId, $notes );
                        }
 
                        // handle implicit hide/show logging
                        if ( isset( $implicit_hide ) && $implicit_hide ) {
-                               ApiArticleFeedbackv5Utils::logActivity( 
'hidden' , $pageId, $feedbackId, '', true);
+                               ApiArticleFeedbackv5Utils::logActivity( 
'hidden' , $pageId, $feedbackId, '', true );
                        }
 
                        // Update helpful/unhelpful display count after 
submission.
                        if ( $flag == 'helpful' || $flag == 'unhelpful' ) {
 
                                // no negative numbers please
-                               $helpful = max(0, $helpful);
-                               $unhelpful = max(0, $unhelpful);
+                               $helpful = max( 0, $helpful );
+                               $unhelpful = max( 0, $unhelpful );
 
-                               $results['helpful'] = wfMessage( 
+                               $results['helpful'] = wfMessage(
                                        'articlefeedbackv5-form-helpful-votes',
                                        $helpful, $unhelpful
                                )->escaped();
-       
+
                                // Update net_helpfulness after flagging as 
helpful/unhelpful.
                                $dbw->update(
                                        'aft_article_feedback',
@@ -449,7 +449,7 @@
                                'af_is_undeleted',
                                'af_is_declined',
                                'af_has_comment',
-                               'af_oversight_count'),
+                               'af_oversight_count' ),
                        array( 'af_id' => $id )
                );
                return $record;
@@ -468,7 +468,7 @@
                // all, deleted, undeleted, and notdeleted
 
                // use -1 (decrement) for hide, 1 for increment (show) - 
default is hide
-               switch($action) {
+               switch( $action ) {
                        case 'show':
                                $int = 1;
                                // if we're showing, this will increment
@@ -476,7 +476,7 @@
                                break;
                        default:
                                // if we're hiding, and was unhidden, decrement
-                               if(true == $record->af_is_unhidden) {
+                               if ( true == $record->af_is_unhidden ) {
                                        $filters['unhidden'] = -1;
                                }
                                $int = -1;
@@ -488,18 +488,18 @@
                $filters['invisible'] = -$int; // opposite of int
 
                // comment
-               if(true == $record->af_has_comment) {
+               if ( true == $record->af_has_comment ) {
                        $filters['comment'] = $int;
                }
 
                // abusive
-               if( $record->af_abuse_count > 1 ) {
+               if ( $record->af_abuse_count > 1 ) {
                        $filters['abusive'] = $int;
                }
                // helpful and unhelpful
-               if( $record->af_net_helpfulness > 1 ) {
+               if ( $record->af_net_helpfulness > 1 ) {
                        $filters['helpful'] = $int;
-               } elseif( $record->af_net_helpfulness < 1 ) {
+               } elseif ( $record->af_net_helpfulness < 1 ) {
                        $filters['unhelpful'] = $int;
                }
 
@@ -618,7 +618,7 @@
         * @param int $page_id page id to grab info on
         * @param int $feedback_id identifier for the feedback item
         */
-       protected function sendOversightEmail( $page_id, $feedback_id) {
+       protected function sendOversightEmail( $page_id, $feedback_id ) {
                global $wgUser;
 
                // jobs need a title object
@@ -650,7 +650,7 @@
                                'user_url' => $user_page->getCanonicalUrl(),
                                'page_name' => $title_object->getText(),
                                'page_url' => $title_object->getCanonicalUrl(),
-                               'permalink' => $permalink->getCanonicalUrl());
+                               'permalink' => $permalink->getCanonicalUrl() );
 
                $job = new ArticleFeedbackv5MailerJob( $title_object, $params );
                $job->insert();

Modified: 
trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php 
2012-03-09 06:05:35 UTC (rev 113455)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php 
2012-03-09 06:21:33 UTC (rev 113456)
@@ -32,13 +32,13 @@
 
                // If we can't hide, we can't see activity, return an empty 
string
                // front-end should never let you get here, but just in case
-               if( !$wgUser->isAllowed( 'aftv5-hide-feedback' )) {
+               if ( !$wgUser->isAllowed( 'aftv5-hide-feedback' ) ) {
                        $this->dieUsage( "You don't have permission to hide 
feedback", 'permissiondenied' );
                }
 
                // These are our valid activity log actions
                $valid = array( 'oversight', 'unoversight', 'hidden', 
'unhidden',
-                               'decline', 'request', 
'unrequest','flag','unflag' );
+                               'decline', 'request', 'unrequest', 'flag', 
'unflag' );
 
                // get our parameter information
                $params = $this->extractRequestParams();
@@ -50,19 +50,19 @@
                // fetch our activity database information
                $feedback    = $this->fetchFeedback( $feedbackId );
                // if this is false, this is bad feedback - move along
-               if( !$feedback ) {
+               if ( !$feedback ) {
                        $this->dieUsage( "Feedback does not exist", 
'invalidfeedbackid' );
                }
 
                // get the string title for the page
                $page = Title::newFromID( $feedback->af_page_id );
-               if( !$page ) {
+               if ( !$page ) {
                        $this->dieUsage( "Page for feedback does not exist", 
'invalidfeedbackid' );
                }
                $title = $page->getDBKey();
 
                // get our activities
-               $activities = $this->fetchActivity( $title, $feedbackId, 
$limit, $continue);
+               $activities = $this->fetchActivity( $title, $feedbackId, 
$limit, $continue );
 
                // generate our html
                $html = '';
@@ -75,49 +75,49 @@
                        $html .= Html::openElement( 'div', array(
                                'class' => 'articleFeedbackv5-activity-pane'
                        ) );
-       
+
                        // <div class="articleFeedbackv5-activity-feedback">
                        $html .= Html::openElement( 'div', array(
                                'class' => 'articleFeedbackv5-activity-feedback'
                        ) );
-       
+
                        // <div>Feedback Post #{$feedbackid} by 
{$user_link}</div>
                        $html .= Html::openElement( 'div', array() );
                        $html .= wfMessage( 
'articlefeedbackv5-activity-feedback-info',
-                                               array($feedback->af_id))
-                                       
->rawParams(ApiArticleFeedbackv5Utils::getUserLink($feedback->af_user_id, 
$feedback->af_user_ip))
+                                               array( $feedback->af_id ) )
+                                       ->rawParams( 
ApiArticleFeedbackv5Utils::getUserLink( $feedback->af_user_id, 
$feedback->af_user_ip ) )
                                        ->text();
                        $html .= Html::closeElement( 'div' );
-       
-                       //<div>Posted on {$date} (UTC)</div>
+
+                       // <div>Posted on {$date} (UTC)</div>
                        $html .= Html::element( 'div', array(),
                                wfMessage( 
'articlefeedbackv5-activity-feedback-date',
-                                               array( $wgLang->timeanddate( 
$feedback->af_created ) ))->text() );
-       
+                                               array( $wgLang->timeanddate( 
$feedback->af_created ) ) )->text() );
+
                        // <div 
class="articleFeedbackv5-activity-feedback-permalink">
                        $html .= Html::openElement( 'div', array(
                                'class' => 
'articleFeedbackv5-activity-feedback-permalink'
                        ) );
-       
+
                        // <a href="{$permalink}">permalink</a>
                        $html .= Linker::link(
-                               SpecialPage::getTitleFor( 'ArticleFeedbackv5', 
$title . '/'. $feedback->af_id ),
-                               wfMessage( 
'articlefeedbackv5-activity-permalink' )->text());
-       
+                               SpecialPage::getTitleFor( 'ArticleFeedbackv5', 
$title . '/' . $feedback->af_id ),
+                               wfMessage( 
'articlefeedbackv5-activity-permalink' )->text() );
+
                        // </div> for 
class="articleFeedbackv5-activity-feedback-permalink"
                        $html .= Html::closeElement( 'div' );
-       
+
                        // </div> for 
class="articleFeedbackv5-activity-feedback"
                        $html .= Html::closeElement( 'div' );
-       
-                       //<div class="articleFeedbackv5-activity-count">$n 
actions on this post</div>
-                       $html .= Html::element( 'div', array('class' => 
'articleFeedbackv5-activity-count'),
+
+                       // <div class="articleFeedbackv5-activity-count">$n 
actions on this post</div>
+                       $html .= Html::element( 'div', array( 'class' => 
'articleFeedbackv5-activity-count' ),
                                        wfMessage( 
'articlefeedbackv5-activity-count' )->numParams( $feedback->af_activity_count 
)->text() );
-                       
+
                        // </div> for class="articleFeedbackv5-activity-pane"
                        $html .= Html::closeElement( 'div' );
-       
-                       //<div class="articleFeedbackv5-activity-log-items">
+
+                       // <div class="articleFeedbackv5-activity-log-items">
                        $html .= Html::openElement( 'div', array(
                                'class' => 
'articleFeedbackv5-activity-log-items'
                        ) );
@@ -126,17 +126,17 @@
                $count = 0;
 
                // divs of activity items
-               foreach($activities as $item) {
+               foreach ( $activities as $item ) {
 
                        // if we do not have a valid action, skip this item
-                       if ( !in_array( $item->log_action, $valid )) {
+                       if ( !in_array( $item->log_action, $valid ) ) {
                                continue;
                        }
 
                        $count++;
 
                        // figure out if we have more if we have another row 
past our limit
-                       if($count > $limit) {
+                       if ( $count > $limit ) {
                                break;
                        }
 
@@ -150,30 +150,30 @@
                        // or the $user $did_something_on $date : $comment
                        // because the colon hanging around would look utterly 
stupid
 
-                       if ($item->log_comment == '') {
+                       if ( $item->log_comment == '' ) {
                                $html .= wfMessage( 
'articlefeedbackv5-activity-item' )
                                        ->rawParams(
-                                               
ApiArticleFeedbackv5Utils::getUserLink($item->log_user, $item->log_user_text),
+                                               
ApiArticleFeedbackv5Utils::getUserLink( $item->log_user, $item->log_user_text ),
                                                Html::element( 'span', array(
                                                        'class' => 
'articleFeedbackv5-activity-item-action'
                                                        ),
                                                        wfMessage( 
'articlefeedbackv5-activity-' . $item->log_action,
-                                                               
array())->text()),
-                                               $wgLang->timeanddate( 
$item->log_timestamp ))
+                                                               array() 
)->text() ),
+                                               $wgLang->timeanddate( 
$item->log_timestamp ) )
                                        ->text();
                        } else {
                                $html .= wfMessage( 
'articlefeedbackv5-activity-item-comment' )
                                        ->rawParams(
-                                               
ApiArticleFeedbackv5Utils::getUserLink($item->log_user, $item->log_user_text),
+                                               
ApiArticleFeedbackv5Utils::getUserLink( $item->log_user, $item->log_user_text ),
                                                Html::element( 'span', array(
                                                'class' => 
'articleFeedbackv5-activity-item-action'
                                                        ),
                                                        wfMessage( 
'articlefeedbackv5-activity-' . $item->log_action,
-                                                               
array())->text()),
+                                                               array() 
)->text() ),
                                                $wgLang->timeanddate( 
$item->log_timestamp ),
                                                Html::element( 'span',
-                                                       array('class' => 
'articlefeedbackv5-activity-notes'),
-                                                       $item->log_comment))
+                                                       array( 'class' => 
'articlefeedbackv5-activity-notes' ),
+                                                       $item->log_comment ) )
                                        ->text();
                        }
 
@@ -181,8 +181,8 @@
                        $html .= Html::closeElement( 'div' );
                }
 
-               //optional <a href="#" 
class="articleFeedbackv5-activity-more">Show more Activity</a>
-               if ($count > $limit) {
+               // optional <a href="#" 
class="articleFeedbackv5-activity-more">Show more Activity</a>
+               if ( $count > $limit ) {
                        $html .= Html::element( 'a', array(
                                        'class' => 
"articleFeedbackv5-activity-more",
                                        'href' => '#',
@@ -191,19 +191,19 @@
 
                // </div> for class="acticleFeedbackv5-activity-log-items"
                $html .= Html::closeElement( 'div' );
-               
+
                // finally add our generated html data
                $result->addValue( $this->getModuleName(), 'limit', $limit );
                $result->addValue( $this->getModuleName(), 'activity', $html );
 
                // continue only goes in if it's not empty
-               if ($count > $limit) {
+               if ( $count > $limit ) {
                        $this->setContinueEnumParameter( 'continue', 
$this->getContinue( $item ) );
                }
        }
 
        /**
-        * Gets some base feedback information 
+        * Gets some base feedback information
         *
         * @param int $feedbackId identifier for the feedback item we are 
fetching activity for
         * @return int total number of activity items for feedback item
@@ -218,7 +218,7 @@
                                'af_user_id',
                                'af_user_ip',
                                'af_created',
-                               'af_activity_count'),
+                               'af_activity_count' ),
                        array(
                                'af_id'     => $feedbackId,
                        ),
@@ -241,7 +241,7 @@
         * @param mixed $continue used for offsets
         * @return array db record rows
         */
-       protected function fetchActivity( $title, $feedbackId, $limit = 25, 
$continue = null) {
+       protected function fetchActivity( $title, $feedbackId, $limit = 25, 
$continue = null ) {
 
                $where = array (
                                'log_type' => 'articlefeedbackv5',
@@ -260,7 +260,7 @@
                                'log_user',
                                'log_user_text',
                                'log_title',
-                               'log_comment'),
+                               'log_comment' ),
                        $where,
                        __METHOD__,
                        array(

Modified: 
trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php 
2012-03-09 06:05:35 UTC (rev 113455)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php 
2012-03-09 06:21:33 UTC (rev 113456)
@@ -95,11 +95,11 @@
                // This is in memcache so I don't feel that bad re-fetching it.
                // Needed to join in the comment and rating tables, for 
filtering
                // and sorting, respectively.
-               foreach( ApiArticleFeedbackv5Utils::getFields() as $field ) {
-                       if( $field['afi_bucket_id'] == 1 && $field['afi_name'] 
== 'comment' ) {
+               foreach ( ApiArticleFeedbackv5Utils::getFields() as $field ) {
+                       if ( $field['afi_bucket_id'] == 1 && $field['afi_name'] 
== 'comment' ) {
                                $commentField = $field['afi_id'];
                        }
-                       if( $field['afi_bucket_id'] == 1 && $field['afi_name'] 
== 'found' ) {
+                       if ( $field['afi_bucket_id'] == 1 && $field['afi_name'] 
== 'found' ) {
                                $ratingField = $field['afi_id'];
                        }
                }
@@ -107,26 +107,26 @@
                // Build ORDER BY clause.
                switch( $sort ) {
                        case 'helpful':
-                               $sortField   = 'af_net_helpfulness'; 
+                               $sortField   = 'af_net_helpfulness';
                                $order       = "af_net_helpfulness $direction, 
af_id $direction";
-                               $continueSql = "(af_net_helpfulness 
$continueDirection ".intVal( $continue )
-                                ." OR (af_net_helpfulness = ".intVal( 
$continue )
-                                ." AND af_id $continueDirection ".intval( 
$continueId ).") )";
+                               $continueSql = "(af_net_helpfulness 
$continueDirection " . intVal( $continue )
+                                . " OR (af_net_helpfulness = " . intVal( 
$continue )
+                                . " AND af_id $continueDirection " . intval( 
$continueId ) . ") )";
                                break;
                        case 'rating':
                                # TODO: null ratings don't seem to show up at 
all. Need to sort that one out.
                                $sortField   = 'rating';
                                $order       = "yes_no $direction, af_id 
$direction";
-                               $continueSql = "(rating.aa_response_boolean 
$continueDirection ".intVal( $continue )
-                                ." OR (rating.aa_response_boolean = ".intVal( 
$continue )
-                                ." AND af_id $continueDirection ".intval( 
$continueId ).") )";
+                               $continueSql = "(rating.aa_response_boolean 
$continueDirection " . intVal( $continue )
+                                . " OR (rating.aa_response_boolean = " . 
intVal( $continue )
+                                . " AND af_id $continueDirection " . intval( 
$continueId ) . ") )";
                                break;
                        case 'age':
                                # Default field, fall through
                        default:
-                               $sortField   = 'af_id'; 
+                               $sortField   = 'af_id';
                                $order       = "af_id $direction";
-                               $continueSql = "af_id $continueDirection 
".intVal( $continue );
+                               $continueSql = "af_id $continueDirection " . 
intVal( $continue );
                                break;
                }
 
@@ -162,17 +162,17 @@
                        $where,
                        __METHOD__,
                        array(
-                               'LIMIT'    => ($limit + 1),
+                               'LIMIT'    => ( $limit + 1 ),
                                'ORDER BY' => $order
                        ),
                        array(
                                'rating'  => array(
                                        'LEFT JOIN',
-                                       'rating.aa_feedback_id = af_id AND 
rating.aa_field_id = '.intval( $ratingField )
+                                       'rating.aa_feedback_id = af_id AND 
rating.aa_field_id = ' . intval( $ratingField )
                                ),
                                'comment' => array(
                                        'LEFT JOIN',
-                                       'comment.aa_feedback_id = af_id AND 
comment.aa_field_id = '.intval( $commentField )
+                                       'comment.aa_feedback_id = af_id AND 
comment.aa_field_id = ' . intval( $commentField )
                                )
                        )
                );
@@ -180,7 +180,7 @@
                foreach ( $id_query as $id ) {
                        $ids[$id->af_id] = $id->af_id;
                        // Get the continue values from the last counted item.
-                       if( count( $ids ) == $limit ) {
+                       if ( count( $ids ) == $limit ) {
                                $this->continue   = $id->$sortField;
                                $this->continueId = $id->af_id;
                        }
@@ -252,7 +252,7 @@
                foreach ( $rows as $row ) {
                        if ( !array_key_exists( $row->af_id, $ids ) ) {
                                continue; // something has gone dreadfully 
wrong actually
-                       } elseif ( !is_array( $ids[$row->af_id] )) {
+                       } elseif ( !is_array( $ids[$row->af_id] ) ) {
                                $ids[$row->af_id] = array();
                                $ids[$row->af_id][0] = $row;
                                $ids[$row->af_id][0]->user_name = 
$row->user_name ? $row->user_name : $row->af_user_ip;
@@ -271,12 +271,12 @@
 
                // Never show hidden or deleted posts unless specifically 
requested
                // and user has access.
-               if( !in_array( $filter, $deletedFilters ) 
+               if ( !in_array( $filter, $deletedFilters )
                 || !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
                        $where[] = 'af_is_deleted IS FALSE';
                }
 
-               if( !in_array( $filter, $hiddenFilters ) 
+               if ( !in_array( $filter, $hiddenFilters )
                 || !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
                        $where[] = 'af_is_hidden IS FALSE';
                }
@@ -357,7 +357,7 @@
                if ( $can_vote ) {
                        $footer_links .= Html::element( 'span', array(
                                'class' => 'articleFeedbackv5-helpful-caption'
-                       ), wfMessage( 'articlefeedbackv5-form-helpful-label' 
)->text() 
+                       ), wfMessage( 'articlefeedbackv5-form-helpful-label' 
)->text()
                        )
                        . Html::element( 'a', array(
                                'id'    => "articleFeedbackv5-helpful-link-$id",
@@ -371,9 +371,9 @@
                $footer_links .= Html::element( 'span', array(
                        'class' => 'articleFeedbackv5-helpful-votes',
                        'id'    => "articleFeedbackv5-helpful-votes-$id"
-               ), wfMessage( 'articlefeedbackv5-form-helpful-votes', 
+               ), wfMessage( 'articlefeedbackv5-form-helpful-votes',
                        $wgLang->formatNum( $record[0]->af_helpful_count ),
-                       $wgLang->formatNum( $record[0]->af_unhelpful_count ) 
+                       $wgLang->formatNum( $record[0]->af_unhelpful_count )
                )->text() );
                $footer_links .= Html::closeElement( 'div' );
                if ( $can_flag ) {
@@ -433,7 +433,7 @@
                        }
 
                        // !can delete == request oversight
-                       if ( $can_hide && !$can_delete) {
+                       if ( $can_hide && !$can_delete ) {
                                if ( $record[0]->af_oversight_count > 0 ) {
                                        $msg = 'unoversight';
                                        $class = 'unrequestoversight';
@@ -457,7 +457,7 @@
                                                'id'    => 
"articleFeedbackv5-declineoversight-link-$id",
                                                'class' => 
"articleFeedbackv5-declineoversight-link",
                                                'href' => '#',
-                                               ), wfMessage( 
"articlefeedbackv5-form-decline")->text() ) );
+                                               ), wfMessage( 
"articlefeedbackv5-form-decline" )->text() ) );
                                }
 
                                if ( $record[0]->af_is_deleted > 0 ) {
@@ -499,12 +499,12 @@
                );
                if ( $record[0]->af_is_hidden ) {
 
-                       $attributes['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink($record[0]->af_hide_user_id, 
$default_user);
+                       $attributes['hide-user'] = 
ApiArticleFeedbackv5Utils::getUserLink( $record[0]->af_hide_user_id, 
$default_user );
                        $attributes['hide-timestamp'] =  wfTimestamp( 
TS_RFC2822, $record[0]->af_hide_timestamp );
                }
                if ( $record[0]->af_is_deleted ) {
 
-                       $attributes['oversight-user'] = 
ApiArticleFeedbackv5Utils::getUserLink($record[0]->af_oversight_user_id, 
$default_user);
+                       $attributes['oversight-user'] = 
ApiArticleFeedbackv5Utils::getUserLink( $record[0]->af_oversight_user_id, 
$default_user );
                        $attributes['oversight-timestamp'] =  wfTimestamp( 
TS_RFC2822, $record[0]->af_oversight_timestamp );
                }
 
@@ -515,7 +515,7 @@
                . $content
                . $footer_links
                . Html::closeElement( 'div' )
-               //. $details
+               // . $details
                . $tools
                . Html::closeElement( 'div' );
        }
@@ -524,21 +524,21 @@
                global $wgLang;
                $id    = $record->af_id;
                $title = $record->page_title;
-                       
+
                $blocks = array(
                        array( 'total' => 60 * 60 * 24 * 365, 'name' => 'years' 
),
-                       array( 'total' => 60 * 60 * 24 * 30, 'name' => 
'months'),
-                       array( 'total' => 60 * 60 * 24 * 7, 'name' => 'weeks'),
-                       array( 'total' => 60 * 60 * 24, 'name' => 'days'),
-                       array( 'total' => 60 * 60, 'name' => 'hours'),
-                       array( 'total' => 60, 'name' => 'minutes') );
-               
+                       array( 'total' => 60 * 60 * 24 * 30, 'name' => 'months' 
),
+                       array( 'total' => 60 * 60 * 24 * 7, 'name' => 'weeks' ),
+                       array( 'total' => 60 * 60 * 24, 'name' => 'days' ),
+                       array( 'total' => 60 * 60, 'name' => 'hours' ),
+                       array( 'total' => 60, 'name' => 'minutes' ) );
+
                $since = wfTimestamp( TS_UNIX ) - wfTimestamp( TS_UNIX, 
$record->af_created );
                $displayTime = 0;
                $displayBlock = '';
-               
+
                // get the largest time block, 1 minute 35 seconds -> 2 minutes
-               for( $i = 0, $count = count( $blocks ); $i < $count; $i++ ) {
+               for ( $i = 0, $count = count( $blocks ); $i < $count; $i++ ) {
                        $seconds = $blocks[$i]['total'];
                        $displayTime = floor( $since / $seconds );
 
@@ -549,10 +549,10 @@
                                if ( ( $since % $seconds ) >= ( $seconds / 2 ) 
) {
                                        $displayTime++;
 
-                                       //advance to upper unit if possible, 
eg, 24 hours to 1 day
-                                       if ( isset( $blocks[$i-1] ) && 
$displayTime * $seconds ==  $blocks[$i-1]['total'] ) {
+                                       // advance to upper unit if possible, 
eg, 24 hours to 1 day
+                                       if ( isset( $blocks[$i -1] ) && 
$displayTime * $seconds ==  $blocks[$i -1]['total'] ) {
                                                $displayTime = 1;
-                                               $displayBlock = 
$blocks[$i-1]['name'];
+                                               $displayBlock = $blocks[$i 
-1]['name'];
                                        }
                                }
                                break;
@@ -583,13 +583,13 @@
                )
                . Html::closeElement( 'span' );
        }
-       
 
+
        private function renderBucket1( $record ) {
                if ( $record['found']->aa_response_boolean == 1 ) {
                        $msg   = 'articlefeedbackv5-form1-header-found';
                        $class = 'positive';
-               } elseif( $record['found']->aa_response_boolean !== null ) {
+               } elseif ( $record['found']->aa_response_boolean !== null ) {
                        $msg   = 'articlefeedbackv5-form1-header-not-found';
                        $class = 'negative';
                } else {
@@ -716,7 +716,7 @@
 
        private function feedbackHead( $message, $class, $record, $extra = '' ) 
{
                $name = htmlspecialchars( $record->user_name );
-               if( $record->af_user_ip ) {
+               if ( $record->af_user_ip ) {
                        // Anonymous user, go to contributions page.
                        $title =  SpecialPage::getTitleFor( 'Contributions', 
$record->user_name );
                } else {
@@ -726,10 +726,10 @@
 
                // If user page doesn't exist, go someplace else.
                // Use the contributions page for now, but it's really up to 
Fabrice.
-               if( !$title->exists() ) {
+               if ( !$title->exists() ) {
                        $title = SpecialPage::getTitleFor( 'Contributions', 
$record->user_name );
                }
-               
+
                $details = Html::openElement( 'span', array(
                        'class' => 'articleFeedbackv5-comment-details-updates'
                ) );
@@ -741,11 +741,11 @@
                );
                $details .= Html::closeElement( 'span' );
 
-               return Html::openElement( 'h3', array( 'class' => $class) )
+               return Html::openElement( 'h3', array( 'class' => $class ) )
                . Html::element( 'span', array( 'class' => 'icon' ) )
                . Html::rawElement( 'span',
                        array( 'class' => 'result' ),
-                       wfMessage( $message, $name )->rawParams( 
+                       wfMessage( $message, $name )->rawParams(
                                Linker::link( $title, $name )
                        )->escaped()
                )


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to