r74176 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74175‎ | r74176 | r74177 >
Date:23:15, 2 October 2010
Author:ashley
Status:reverted
Tags:
Comment:
FBConnect: coding style tweaks, trimmed trailing spaces, etc.
Modified paths:
  • /trunk/extensions/FBConnect/FBConnect.php (modified) (history)
  • /trunk/extensions/FBConnect/FBConnectAPI.php (modified) (history)
  • /trunk/extensions/FBConnect/FBConnectDB.php (modified) (history)
  • /trunk/extensions/FBConnect/FBConnectHooks.php (modified) (history)
  • /trunk/extensions/FBConnect/FBConnectPushEvent.php (modified) (history)
  • /trunk/extensions/FBConnect/FBConnectUser.php (modified) (history)
  • /trunk/extensions/FBConnect/FBConnectXFBML.php (modified) (history)
  • /trunk/extensions/FBConnect/SpecialConnect.php (modified) (history)
  • /trunk/extensions/FBConnect/config.default.php (modified) (history)
  • /trunk/extensions/FBConnect/fbconnect.css (modified) (history)
  • /trunk/extensions/FBConnect/fbconnect.js (modified) (history)
  • /trunk/extensions/FBConnect/pushEvents/FBPush_OnAddImage.i18n.php (modified) (history)
  • /trunk/extensions/FBConnect/pushEvents/FBPush_OnAddImage.php (modified) (history)
  • /trunk/extensions/FBConnect/pushEvents/FBPush_OnLargeEdit.i18n.php (modified) (history)
  • /trunk/extensions/FBConnect/pushEvents/FBPush_OnLargeEdit.php (modified) (history)
  • /trunk/extensions/FBConnect/pushEvents/FBPush_OnWatchArticle.i18n.php (modified) (history)
  • /trunk/extensions/FBConnect/pushEvents/FBPush_OnWatchArticle.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FBConnect/FBConnectXFBML.php
@@ -1,16 +1,16 @@
22 <?php
3 -/*
 3+/**
44 * Copyright © 2008-2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin>
55 * This program is free software; you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
77 * the Free Software Foundation; either version 2 of the License, or
88 * (at your option) any later version.
9 - *
 9+ *
1010 * This program is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 * GNU General Public License for more details.
14 - *
 14+ *
1515 * You should have received a copy of the GNU General Public License along
1616 * with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
@@ -26,10 +26,10 @@
2727
2828 /**
2929 * Class FBConnectXFBML
30 - *
 30+ *
3131 * This class allows FBML (Facebook Markup Language, an extension to HTML) to
3232 * be incorporated into the wiki through XFBML.
33 - *
 33+ *
3434 * See: <http://wiki.developers.facebook.com/index.php/XFBML>
3535 */
3636 class FBConnectXFBML {
@@ -40,24 +40,24 @@
4141 * function that simply redirects to parserHook(), filling in the missing
4242 * $tag argument with the $tag provided to createParserHook.
4343 */
44 - static function parserHook($innertext, $args, &$parser, $tag = '' ) {
 44+ static function parserHook( $innertext, $args, &$parser, $tag = '' ) {
4545 global $wgFbAllowFacebookImages;
46 -
 46+
4747 // Run hook to allow modifying the default behavior. If $override is
48 - // set, it is used instead. Return false to disable the tag.
 48+ // set, it is used instead. Return false to disable the tag.
4949 $override = '';
5050 if ( !wfRunHooks('XFBMLParseTag',
51 - array( $tag, &$args, &$innertext, &$override )) ) {
 51+ array( $tag, &$args, &$innertext, &$override ) ) ) {
5252 return '';
5353 }
5454 if ( $override != '' ) {
5555 return $override;
5656 }
57 -
58 - switch ($tag) {
 57+
 58+ switch ( $tag ) {
5959 case '':
6060 break; // Error: We shouldn't be here!
61 -
 61+
6262 // To implement a custom XFBML tag handler, simply case it here like so
6363 case 'fb:add-profile-tab':
6464 // Disable these tags by returning an empty string
@@ -70,7 +70,7 @@
7171 case 'fb:profile-pic':
7272 #case 'fb:photo': // Dropped in new JavaScript SDK
7373 #case 'fb:video': // Dropped in new JavaScript SDK
74 - if (!$wgFbAllowFacebookImages) {
 74+ if ( !$wgFbAllowFacebookImages ) {
7575 break;
7676 }
7777 // Careful - no "break;" if $wgFbAllowFacebookImages is true
@@ -82,108 +82,110 @@
8383 // Strip the tag entirely
8484 return '';
8585 }
86 -
 86+
8787 /**
8888 * Helper function to create name-value pairs from the list of attributes passed to the
8989 * parser hook.
9090 */
9191 static function implodeAttrs( $args ) {
92 - $attrs = "";
 92+ $attrs = '';
9393 // The default action is to strip all event handlers and allow the tag
9494 foreach( $args as $name => $value ) {
9595 // Disable all event handlers (e.g. onClick, onligin)
96 - if ( substr( $name, 0, 2 ) == "on" )
 96+ if ( substr( $name, 0, 2 ) == 'on' ) {
9797 continue;
 98+ }
9899 // Otherwise, pass the attribute through htmlspecialchars unmodified
99100 $attrs .= " $name=\"" . htmlspecialchars( $value ) . '"';
100101 }
101102 return $attrs;
102103 }
103 -
 104+
104105 /**
105106 * Helper function for parserHook. Originally, all tags were directed to
106107 * that function, but I had no way of knowing which tag provoked the function.
107108 */
108 - static function createParserHook($tag) {
 109+ static function createParserHook( $tag ) {
109110 $args = '$text,$args,&$parser';
110 - $code = 'return FBConnectXFBML::parserHook($text,$args,$parser,\''.$tag.'\');';
111 - return create_function($args, $code);
 111+ $code = 'return FBConnectXFBML::parserHook($text,$args,$parser,\'' . $tag . '\');';
 112+ return create_function( $args, $code );
112113 }
113 -
 114+
114115 /**
115116 * Returns true if XFBML is enabled (i.e. $wgFbUseMarkup is not false).
116117 * Defaults to true if $wgFbUseMarkup is not set.
117118 */
118119 static function isEnabled() {
119120 global $wgFbUseMarkup;
120 - return !isset($wgFbUseMarkup) || $wgFbUseMarkup;
 121+ return !isset( $wgFbUseMarkup ) || $wgFbUseMarkup;
121122 }
122 -
 123+
123124 /**
124125 * Returns the availabe XFBML tags. For help on including these in your
125126 * site, please see: <http://developers.facebook.com/plugins>.
126 - *
 127+ *
127128 * If Facebook adds a new tag (or you create your own!) then this list can
128129 * be updated with the XFBMLAvailableTags hook.
129130 */
130131 static function availableTags() {
131 - if (!self::isEnabled()) {
 132+ if ( !self::isEnabled() ) {
132133 // If XFBML isn't enabled, then don't report any tags
133 - return array( );
 134+ return array();
134135 }
135136 // http://github.com/facebook/connect-js/blob/master/src/xfbml/xfbml.js#L237
136 - $tags = array('fb:activity',
137 - 'fb:add-profile-tab',
138 - 'fb:bookmark',
139 - 'fb:comments',
140 - 'fb:connect-bar',
141 - 'fb:fan',
142 - 'fb:like',
143 - 'fb:like-box',
144 - 'fb:live-stream',
145 - 'fb:login',
146 - 'fb:login-button',
147 - 'fb:facepile',
148 - 'fb:name',
149 - 'fb:profile-pic',
150 - 'fb:recommendations',
151 - 'fb:serverfbml',
152 - 'fb:share-button',
153 - 'fb:social-bar',
154 - /*
155 - * From the Facebook Developer's Wiki under the old JS library.
156 - * These may still be possible with a <fb:serverFbml> tag.
157 - * <http://wiki.developers.facebook.com/index.php/XFBML>
158 - */
159 - #'fb:connect-form',
160 - #'fb:container',
161 - #'fb:eventlink',
162 - #'fb:grouplink',
163 - #'fb:photo',
164 - #'fb:prompt-permission',
165 - #'fb:pronoun',
166 - #'fb:unconnected-friends-count',
167 - #'fb:user-status'
168 - /*
169 - * In 2008 I found these in the deprecated Facebook Connect
170 - * JavaScript library, connect.js.pkg.php, though no documentation
171 - * was available for them on the Facebook dev wiki.
172 - */
173 - #'fb:add-section-button',
174 - #'fb:share-button',
175 - #'fb:userlink',
176 - #'fb:video',
 137+ $tags = array(
 138+ 'fb:activity',
 139+ 'fb:add-profile-tab',
 140+ 'fb:bookmark',
 141+ 'fb:comments',
 142+ 'fb:connect-bar',
 143+ 'fb:fan',
 144+ 'fb:like',
 145+ 'fb:like-box',
 146+ 'fb:live-stream',
 147+ 'fb:login',
 148+ 'fb:login-button',
 149+ 'fb:facepile',
 150+ 'fb:name',
 151+ 'fb:profile-pic',
 152+ 'fb:recommendations',
 153+ 'fb:serverfbml',
 154+ 'fb:share-button',
 155+ 'fb:social-bar',
 156+ /*
 157+ * From the Facebook Developer's Wiki under the old JS library.
 158+ * These may still be possible with a <fb:serverFbml> tag.
 159+ * <http://wiki.developers.facebook.com/index.php/XFBML>
 160+ */
 161+ #'fb:connect-form',
 162+ #'fb:container',
 163+ #'fb:eventlink',
 164+ #'fb:grouplink',
 165+ #'fb:photo',
 166+ #'fb:prompt-permission',
 167+ #'fb:pronoun',
 168+ #'fb:unconnected-friends-count',
 169+ #'fb:user-status'
 170+ /*
 171+ * In 2008 I found these in the deprecated Facebook Connect
 172+ * JavaScript library, connect.js.pkg.php, though no documentation
 173+ * was available for them on the Facebook dev wiki.
 174+ */
 175+ #'fb:add-section-button',
 176+ #'fb:share-button',
 177+ #'fb:userlink',
 178+ #'fb:video',
177179 );
178 -
 180+
179181 // Reject discarded tags (that return an empty string) from Special:Version
180182 $tempParser = new DummyParser();
181183 foreach( $tags as $i => $tag ) {
182 - if ( self::parserHook('', array(), $tempParser, $tag) == '' ) {
 184+ if ( self::parserHook( '', array(), $tempParser, $tag ) == '' ) {
183185 unset( $tags[$i] );
184186 }
185187 }
186188 // Allow other functions to modify the available XFBML tags
187 - wfRunHooks( 'XFBMLAvailableTags', array( &$tags ));
 189+ wfRunHooks( 'XFBMLAvailableTags', array( &$tags ) );
188190 return $tags;
189191 }
190192 }
@@ -191,7 +193,7 @@
192194
193195 /**
194196 * Class DummyParser
195 - *
 197+ *
196198 * Allows FBConnectXML::availableTags() to pre-sanatize the list of tags reported to
197199 * MediaWiki, excluding any tags that result in the tag being replaced by an empty
198200 * string. Sorry for the confusing summary here, its really late. =)
Index: trunk/extensions/FBConnect/SpecialConnect.php
@@ -1,32 +1,34 @@
22 <?php
3 -/*
 3+/**
44 * Copyright © 2008-2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin>
55 * This program is free software; you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
77 * the Free Software Foundation; either version 2 of the License, or
88 * (at your option) any later version.
9 - *
 9+ *
1010 * This program is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 * GNU General Public License for more details.
14 - *
 14+ *
1515 * You should have received a copy of the GNU General Public License along
1616 * with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
1818
1919 /**
2020 * Class SpecialConnect
21 - *
 21+ *
2222 * This class represents the body class for the page Special:Connect.
23 - *
 23+ *
2424 * Currently, this page has one valid subpage at Special:Connect/ChooseName.
2525 * Visiting the subpage will generate an error; it is only useful when POSTed to.
2626 */
2727 class SpecialConnect extends SpecialPage {
2828 private $userNamePrefix;
29 - static private $availableUserUpdateOptions = array('fullname', 'nickname', 'email', 'language', 'timecorrection');
30 -
 29+ static private $availableUserUpdateOptions = array(
 30+ 'fullname', 'nickname', 'email', 'language', 'timecorrection'
 31+ );
 32+
3133 /**
3234 * Constructor.
3335 */
@@ -36,26 +38,26 @@
3739 parent::__construct( 'Connect' );
3840 // Add this special page to the "login" group of special pages
3941 $wgSpecialPageGroups['Connect'] = 'login';
40 -
 42+
4143 wfLoadExtensionMessages( 'FBConnect' );
42 - $this->userNamePrefix = wfMsg('fbconnect-usernameprefix');
 44+ $this->userNamePrefix = wfMsg( 'fbconnect-usernameprefix' );
4345 }
44 -
 46+
4547 /**
46 - * Allows the prefix to be changed at runtime. This is useful, for example,
47 - * to generate a username based off of a facebook name.
 48+ * Allows the prefix to be changed at runtime. This is useful, for example,
 49+ * to generate a username based off of a Facebook name.
4850 */
49 - public function setUserNamePrefix( $prefix ){
 51+ public function setUserNamePrefix( $prefix ) {
5052 $this->userNamePrefix = $prefix;
5153 }
52 -
 54+
5355 /**
54 - * Returns the list of user options that can be updated by facebook on each login.
 56+ * Returns the list of user options that can be updated by Facebook on each login.
5557 */
56 - public function getAvailableUserUpdateOptions(){
 58+ public function getAvailableUserUpdateOptions() {
5759 return self::$availableUserUpdateOptions;
5860 }
59 -
 61+
6062 /**
6163 * Overrides getDescription() in SpecialPage. Looks in a different wiki message
6264 * for this extension's description.
@@ -63,72 +65,77 @@
6466 function getDescription() {
6567 return wfMsg( 'fbconnect-title' );
6668 }
67 -
 69+
6870 /**
6971 * Performs any necessary execution and outputs the resulting Special page.
7072 */
71 - function execute( $par ) {
 73+ public function execute( $par ) {
7274 global $wgUser, $facebook, $wgRequest;
73 -
74 - if ( $wgRequest->getVal("action", "") == "disconnect" ) {
75 - self::disconnectAction();
 75+
 76+ if ( $wgRequest->getVal( 'action', '' ) == 'disconnect' ) {
 77+ self::disconnectAction();
7678 }
77 -
 79+
7880 // Check to see if the user is already logged in
7981 if ( $wgUser->getID() ) {
80 - $this->sendPage('alreadyLoggedIn');
 82+ $this->sendPage( 'alreadyLoggedIn' );
8183 return;
8284 }
83 -
 85+
8486 $fbid = $facebook->getUser();
8587 /*
8688 // Connect to the Facebook API
8789 try {
88 - $me = $facebook->api('/me');
89 -
90 - } catch (FacebookApiException $e) {
91 - error_log($e);
 90+ $me = $facebook->api( '/me' );
 91+
 92+ } catch ( FacebookApiException $e ) {
 93+ error_log( $e );
9294 }
9395 */
94 -
 96+
9597 // Look at the subpage name to discover where we are in the login process
9698 switch ( $par ) {
9799 case 'ChooseName':
98 - $choice = $wgRequest->getText('wpNameChoice');
99 - if ($wgRequest->getCheck('wpCancel')) {
100 - $this->sendError('fbconnect-cancel', 'fbconnect-canceltext');
101 - }
102 - else switch ($choice) {
 100+ $choice = $wgRequest->getText( 'wpNameChoice' );
 101+ if ( $wgRequest->getCheck( 'wpCancel' ) ) {
 102+ $this->sendError( 'fbconnect-cancel', 'fbconnect-canceltext' );
 103+ } else
 104+ switch ( $choice ) {
103105 // Check to see if the user opted to connect an existing account
104106 case 'existing':
105 - $this->attachUser($fbid, $wgRequest->getText('wpExistingName'),
106 - $wgRequest->getText('wpExistingPassword'));
 107+ $this->attachUser(
 108+ $fbid,
 109+ $wgRequest->getText( 'wpExistingName' ),
 110+ $wgRequest->getText( 'wpExistingPassword' )
 111+ );
107112 break;
108113 // Check to see if the user selected another valid option
109114 case 'nick':
110115 case 'first':
111116 case 'full':
112117 // Get the username from Facebook (Note: not from the form)
113 - $username = FBConnectUser::getOptionFromInfo($choice . 'name',
114 - $facebook->getUserInfo());
 118+ $username = FBConnectUser::getOptionFromInfo(
 119+ $choice . 'name',
 120+ $facebook->getUserInfo()
 121+ );
115122 case 'manual':
116 - if (!isset($username) || !$this->userNameOK($username)) {
 123+ if ( !isset( $username ) || !$this->userNameOK( $username ) ) {
117124 // Use manual name if no username is set, even if manual wasn't chosen
118 - $username = $wgRequest->getText('wpName2');
 125+ $username = $wgRequest->getText( 'wpName2' );
119126 }
120127 // If no valid username was found, something's not right; ask again
121 - if (!$this->userNameOK($username)) {
122 - $this->sendPage('chooseNameForm', 'fbconnect-invalidname');
 128+ if ( !$this->userNameOK( $username ) ) {
 129+ $this->sendPage( 'chooseNameForm', 'fbconnect-invalidname' );
123130 } else {
124 - $this->createUser($fbid, $username);
 131+ $this->createUser( $fbid, $username );
125132 }
126133 break;
127134 case 'auto':
128135 // Create a user with a unique generated username
129 - $this->createUser($fbid, $this->generateUserName());
 136+ $this->createUser( $fbid, $this->generateUserName() );
130137 break;
131138 default:
132 - $this->sendError('fbconnect-invalid', 'fbconnect-invalidtext');
 139+ $this->sendError( 'fbconnect-invalid', 'fbconnect-invalidtext' );
133140 }
134141 break;
135142 default:
@@ -137,12 +144,12 @@
138145 # $this->setReturnTo( $wgRequest->getText( 'returnto' ),
139146 # $wgRequest->getVal( 'returntoquery' ) );
140147 #}
141 - if ($fbid) {
 148+ if ( $fbid ) {
142149 // If the user is connected, log them in
143 - $this->login($fbid);
 150+ $this->login( $fbid );
144151 } else {
145152 // If the user isn't Connected, then show a form with the Connect button
146 - $this->sendPage('connectForm');
 153+ $this->sendPage( 'connectForm' );
147154 }
148155 }
149156 }
@@ -152,89 +159,89 @@
153160 * an account on the wiki, then they are presented with a form prompting
154161 * them to choose a wiki username.
155162 */
156 - protected function login($fb_id) {
 163+ protected function login( $fb_id ) {
157164 global $wgUser;
158 -
 165+
159166 // Check to see if the Connected user exists in the database
160 - if ($fb_id) {
161 - $user = FBConnectDB::getUser($fb_id);
 167+ if ( $fb_id ) {
 168+ $user = FBConnectDB::getUser( $fb_id );
162169 }
163 -
 170+
164171 // If the user doesn't exist yet locally, allow hooks to check to see if this is a clustered set up
165 - if ( !(isset($user) && $user instanceof User ) &&
166 - !wfRunHooks('SpecialConnect::login::notFoundLocally', array(&$this, &$user, $fb_id))) {
 172+ if ( !( isset( $user ) && $user instanceof User ) &&
 173+ !wfRunHooks( 'SpecialConnect::login::notFoundLocally', array( &$this, &$user, $fb_id ) ) ) {
167174 return;
168175 }
169 -
170 - if ( isset($user) && $user instanceof User ) {
171 - $fbUser = new FBConnectUser($user);
 176+
 177+ if ( isset( $user ) && $user instanceof User ) {
 178+ $fbUser = new FBConnectUser( $user );
172179 // Update user from facebook (see class FBConnectUser)
173180 $fbUser->updateFromFacebook();
174 -
 181+
175182 // Setup the session
176183 global $wgSessionStarted;
177 - if (!$wgSessionStarted) {
 184+ if ( !$wgSessionStarted ) {
178185 wfSetupSession();
179186 }
180 -
 187+
181188 $user->setCookies();
182189 $wgUser = $user;
183 -
 190+
184191 // Similar to what's done in LoginForm::authenticateUserData().
185192 // Load $wgUser now. This is necessary because loading $wgUser (say
186193 // by calling getName()) calls the UserLoadFromSession hook, which
187194 // potentially creates the user in the local database.
188195 $sessionUser = User::newFromSession();
189196 $sessionUser->load();
190 -
191 - $this->sendPage('displaySuccessLogin');
192 - } else if ($fb_id) {
193 - $this->sendPage('chooseNameForm');
 197+
 198+ $this->sendPage( 'displaySuccessLogin' );
 199+ } elseif ( $fb_id ) {
 200+ $this->sendPage( 'chooseNameForm' );
194201 } else {
195202 // TODO: send an error message saying only Connected users can log in
196203 // or ask them to Connect.
197 - $this->sendError('fbconnect-cancel', 'fbconnect-canceltext');
 204+ $this->sendError( 'fbconnect-cancel', 'fbconnect-canceltext' );
198205 }
199206 }
200207
201 - protected function createUser($fb_id, $name) {
 208+ protected function createUser( $fb_id, $name ) {
202209 global $wgUser, $wgOut, $wgFbConnectOnly, $wgAuth, $wgRequest, $wgMemc;
203 - wfProfileIn(__METHOD__);
204 -
 210+ wfProfileIn( __METHOD__ );
 211+
205212 // Handle accidental reposts.
206213 if ( $wgUser->isLoggedIn() ) {
207 - $this->sendPage('displaySuccessLogin');
208 - wfProfileOut(__METHOD__);
 214+ $this->sendPage( 'displaySuccessLogin' );
 215+ wfProfileOut( __METHOD__ );
209216 return;
210217 }
211 -
 218+
212219 // Make sure we're not stealing an existing user account.
213 - if (!$name || !$this->userNameOK($name)) {
 220+ if ( !$name || !$this->userNameOK( $name ) ) {
214221 // TODO: Provide an error message that explains that they need to pick a name or the name is taken.
215 - wfDebug("FBConnect: Name not OK: '$name'\n");
216 - $this->sendPage('chooseNameForm');
 222+ wfDebug( "FBConnect: Name not OK: '$name'\n" );
 223+ $this->sendPage( 'chooseNameForm' );
217224 return;
218225 }
219 -
 226+
220227 /// START OF TYPICAL VALIDATIONS AND RESTRICITONS ON ACCOUNT-CREATION. ///
221 -
 228+
222229 // Check the restrictions again to make sure that the user can create this account.
223230 $titleObj = SpecialPage::getTitleFor( 'Connect' );
224231 if ( wfReadOnly() ) {
225232 $wgOut->readOnlyPage();
226233 return;
227 - } elseif ( !isset($wgFbConnectOnly) || !$wgFbConnectOnly ) {
 234+ } elseif ( !isset( $wgFbConnectOnly ) || !$wgFbConnectOnly ) {
228235 // These two permissions don't apply in $wgFbConnectOnly mode
229236 if ( $wgUser->isBlockedFromCreateAccount() ) {
230 - wfDebug("FBConnect: Blocked user was attempting to create account via Facebook Connect.\n");
231 - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-errortext');
 237+ wfDebug( "FBConnect: Blocked user was attempting to create account via Facebook Connect.\n" );
 238+ $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' );
232239 return;
233 - } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) {
 240+ } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) ) > 0 ) {
234241 $wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' );
235242 return;
236243 }
237244 }
238 -
 245+
239246 // If we are not allowing users to login locally, we should be checking
240247 // to see if the user is actually able to authenticate to the authenti-
241248 // cation server before they create an account (otherwise, they can
@@ -243,44 +250,44 @@
244251 $mDomain = $wgRequest->getText( 'wpDomain' );
245252 if( 'local' != $mDomain && '' != $mDomain ) {
246253 if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $name ) ) ) {
247 - $wgOut->showErrorPage('fbconnect-error', 'wrongpassword');
 254+ $wgOut->showErrorPage( 'fbconnect-error', 'wrongpassword' );
248255 return false;
249256 }
250257 }
251 -
 258+
252259 // IP-blocking (and open proxy blocking) protection from SpecialUserLogin
253260 global $wgEnableSorbs, $wgProxyWhitelist;
254261 $ip = wfGetIP();
255262 if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
256263 $wgUser->inSorbsBlacklist( $ip ) )
257264 {
258 - $wgOut->showErrorPage('fbconnect-error', 'sorbs_create_account_reason');
 265+ $wgOut->showErrorPage( 'fbconnect-error', 'sorbs_create_account_reason' );
259266 return;
260267 }
261 -
 268+
262269 /**
263270 // Test to see if we are denied by $wgAuth or the user can't create an account
264271 if ( !$wgAuth->autoCreate() || !$wgAuth->userExists( $userName ) ||
265 - !$wgAuth->authenticate( $userName )) {
 272+ !$wgAuth->authenticate( $userName ) ) {
266273 $result = false;
267274 return true;
268275 }
269276 /**/
270 -
 277+
271278 // Run a hook to let custom forms make sure that it is okay to proceed with processing the form.
272279 // This hook should only check preconditions and should not store values. Values should be stored using the hook at the bottom of this function.
273 - // Can use 'this' to call sendPage('chooseNameForm', 'SOME-ERROR-MSG-CODE-HERE') if some of the preconditions are invalid.
274 - if(! wfRunHooks( 'SpecialConnect::createUser::validateForm', array( &$this ) )){
 280+ // Can use 'this' to call sendPage( 'chooseNameForm', 'SOME-ERROR-MSG-CODE-HERE' ) if some of the preconditions are invalid.
 281+ if( !wfRunHooks( 'SpecialConnect::createUser::validateForm', array( &$this ) ) ) {
275282 return;
276283 }
277284
278 - $user = User::newFromName($name);
279 - if (!$user) {
280 - wfDebug("FBConnect: Error creating new user.\n");
281 - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-error-creating-user');
 285+ $user = User::newFromName( $name );
 286+ if ( !$user ) {
 287+ wfDebug( "FBConnect: Error creating new user.\n" );
 288+ $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-error-creating-user' );
282289 return;
283290 }
284 -
 291+
285292 // Let extensions abort the account creation. If you have extensions which are expecting a Real Name or Email, you may need to disable
286293 // them since these are not requirements of Facebook Connect (so users will not have them).
287294 // NOTE: Currently this is commented out because it seems that most wikis might have a handful of restrictions that won't be needed on
@@ -290,11 +297,11 @@
291298 if( !wfRunHooks( 'AbortNewAccount', array( $user, &$abortError ) ) ) {
292299 // Hook point to add extra creation throttles and blocks
293300 wfDebug( "SpecialConnect::createUser: a hook blocked creation\n" );
294 - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-error-user-creation-hook-aborted', array($abortError));
 301+ $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-error-user-creation-hook-aborted', array( $abortError ) );
295302 return false;
296303 }
297 - /**/
298 -
 304+ */
 305+
299306 // Apply account-creation throttles
300307 global $wgAccountCreationThrottle;
301308 if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
@@ -309,71 +316,71 @@
310317 }
311318 $wgMemc->incr( $key );
312319 }
313 -
 320+
314321 /// END OF TYPICAL VALIDATIONS AND RESTRICITONS ON ACCOUNT-CREATION. ///
315 -
 322+
316323 // Create the account (locally on main cluster or via wgAuth on other clusters)
317 - $email = $realName = ""; // The real values will get filled in outside of the scope of this function.
 324+ $email = $realName = ''; // The real values will get filled in outside of the scope of this function.
318325 $pass = null;
319326 if( !$wgAuth->addUser( $user, $pass, $email, $realName ) ) {
320 - wfDebug("FBConnect: Error adding new user to database.\n");
321 - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-errortext');
 327+ wfDebug( "FBConnect: Error adding new user to database.\n" );
 328+ $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' );
322329 return;
323330 }
324 -
 331+
325332 // Adds the user to the local database (regardless of whether wgAuth was used)
326333 $user = $this->initUser( $user, true );
327 -
 334+
328335 // Attach the user to their Facebook account in the database
329336 // This must be done up here so that the data is in the database before copy-to-local is done for sharded setups
330 - FBConnectDB::addFacebookID($user, $fb_id);
331 -
 337+ FBConnectDB::addFacebookID( $user, $fb_id );
 338+
332339 wfRunHooks( 'AddNewAccount', array( $user ) );
333 -
 340+
334341 // Mark that the user is a Facebook user
335 - $user->addGroup('fb-user');
336 -
337 - // Store which fields should be auto-updated from Facebook when the user logs in.
338 - $updateFormPrefix = "wpUpdateUserInfo";
339 - foreach (self::$availableUserUpdateOptions as $option) {
340 - if($wgRequest->getVal($updateFormPrefix.$option, '') != ""){
341 - $user->setOption("fbconnect-update-on-login-$option", 1);
 342+ $user->addGroup( 'fb-user' );
 343+
 344+ // Store which fields should be auto-updated from Facebook when the user logs in.
 345+ $updateFormPrefix = 'wpUpdateUserInfo';
 346+ foreach ( self::$availableUserUpdateOptions as $option ) {
 347+ if( $wgRequest->getVal( $updateFormPrefix . $option, '' ) != '' ) {
 348+ $user->setOption( "fbconnect-update-on-login-$option", 1 );
342349 } else {
343 - $user->setOption("fbconnect-update-on-login-$option", 0);
 350+ $user->setOption( "fbconnect-update-on-login-$option", 0 );
344351 }
345352 }
346 -
 353+
347354 // Process the FBConnectPushEvent preference checkboxes if fbConnectPushEvents are enabled.
348355 global $wgFbEnablePushToFacebook;
349 - if($wgFbEnablePushToFacebook){
 356+ if( $wgFbEnablePushToFacebook ) {
350357 global $fbPushEventClasses;
351 - if(!empty($fbPushEventClasses)){
352 - foreach($fbPushEventClasses as $pushEventClassName){
 358+ if( !empty( $fbPushEventClasses ) ) {
 359+ foreach( $fbPushEventClasses as $pushEventClassName ) {
353360 $pushObj = new $pushEventClassName;
354361 $className = get_class();
355362 $prefName = $pushObj->getUserPreferenceName();
356 -
357 - $user->setOption($prefName, ($wgRequest->getCheck($prefName)?"1":"0"));
 363+
 364+ $user->setOption( $prefName, ( $wgRequest->getCheck( $prefName ) ? '1' : '0' ) );
358365 }
359366 }
360367 }
361 -
 368+
362369 // Unfortunately, performs a second database lookup
363 - $fbUser = new FBConnectUser($user);
 370+ $fbUser = new FBConnectUser( $user );
364371 // Update the user with settings from Facebook
365372 $fbUser->updateFromFacebook();
366 -
 373+
367374 // Start the session if it's not already been started
368375 global $wgSessionStarted;
369 - if (!$wgSessionStarted) {
 376+ if ( !$wgSessionStarted ) {
370377 wfSetupSession();
371378 }
372 -
 379+
373380 // Log the user in
374381 $user->setCookies();
375382 // Store the new user as the global user object
376383 $wgUser = $user;
377 -
 384+
378385 /*
379386 * Similar to what's done in LoginForm::authenticateUserData(). Load
380387 * $wgUser now. This is necessary because loading $wgUser (say by
@@ -382,93 +389,93 @@
383390 */
384391 $sessionUser = User::newFromSession();
385392 $sessionUser->load();
386 -
 393+
387394 // Allow custom form processing to store values since this form submission was successful.
388395 // This hook should not fail on invalid input, instead check the input using the SpecialConnect::createUser::validateForm hook above.
389396 wfRunHooks( 'SpecialConnect::createUser::postProcessForm', array( &$this ) );
390 -
 397+
391398 // TODO: Which MediaWiki versions can we call this function in?
392399 $user->addNewUserLogEntryAutoCreate();
393400 #$user->addNewUserLogEntry();
394 -
395 - $this->sendPage('displaySuccessLogin');
396 -
397 - wfProfileOut(__METHOD__);
 401+
 402+ $this->sendPage( 'displaySuccessLogin' );
 403+
 404+ wfProfileOut( __METHOD__ );
398405 }
399 -
400 - /**
401 - * Actually add a user to the database.
402 - * Give it a User object that has been initialised with a name.
403 - *
404 - * This is a custom version of similar code in SpecialUserLogin's LoginForm with differences
405 - * due to the fact that this code doesn't require a password, etc.
406 - *
407 - * @param $u User object.
408 - * @param $autocreate boolean -- true if this is an autocreation via auth plugin
409 - * @return User object.
410 - * @private
411 - */
 406+
 407+ /**
 408+ * Actually add a user to the database.
 409+ * Give it a User object that has been initialised with a name.
 410+ *
 411+ * This is a custom version of similar code in SpecialUserLogin's LoginForm with differences
 412+ * due to the fact that this code doesn't require a password, etc.
 413+ *
 414+ * @param $u User object.
 415+ * @param $autocreate boolean -- true if this is an autocreation via auth plugin
 416+ * @return User object.
 417+ * @private
 418+ */
412419 protected function initUser( $u, $autocreate ) {
413420 global $wgAuth;
414 -
 421+
415422 $u->addToDatabase();
416 -
 423+
417424 // No passwords for FBConnect accounts.
418425 /**
419426 if ( $wgAuth->allowPasswordChange() ) {
420 - $u->setPassword( $this->mPassword );
 427+ $u->setPassword( $this->mPassword );
421428 }
422 - /**
 429+
423430 $u->setEmail( $this->mEmail ); // emails aren't required by FBConnect extension (some customizations such as Wikia require it on their own).
424431 $u->setRealName( $this->mRealName ); // real name isn't required for FBConnect
425 - /**/
 432+ */
426433 $u->setToken();
427 -
 434+
428435 $wgAuth->initUser( $u, $autocreate );
429 - $wgAuth->updateUser($u);
430 -
 436+ $wgAuth->updateUser( $u );
 437+
431438 //$u->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
432 - $u->setOption('skinoverwrite', 1);
 439+ $u->setOption( 'skinoverwrite', 1 );
433440 $u->saveSettings();
434 -
 441+
435442 # Update user count
436443 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
437444 $ssUpdate->doUpdate();
438 -
 445+
439446 return $u;
440447 }
441 -
 448+
442449 /**
443450 * Attaches the Facebook ID to an existing wiki account. If the user does
444451 * not exist, or the supplied password does not match, then an error page
445452 * is sent. Otherwise, the accounts are matched in the database and the new
446453 * user object is logged in.
447454 */
448 - protected function attachUser($fbid, $name, $password) {
 455+ protected function attachUser( $fbid, $name, $password ) {
449456 global $wgOut, $wgUser;
450 - wfProfileIn(__METHOD__);
 457+ wfProfileIn( __METHOD__ );
451458
452459 // The user must be logged into Facebook before choosing a wiki username
453460 if ( !$fbid ) {
454 - wfDebug("FBConnect: aborting in attachUser(): no Facebook ID was reported.\n");
 461+ wfDebug( "FBConnect: aborting in attachUser(): no Facebook ID was reported.\n" );
455462 $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' );
456463 return;
457464 }
458465 // Look up the user by their name
459 - $user = new FBConnectUser(User::newFromName($name));
460 - if (!$user || !$user->checkPassword($password)) {
461 - $this->sendPage('chooseNameForm', 'wrongpassword');
 466+ $user = new FBConnectUser( User::newFromName( $name ) );
 467+ if ( !$user || !$user->checkPassword( $password ) ) {
 468+ $this->sendPage( 'chooseNameForm', 'wrongpassword' );
462469 return;
463470 }
464471 // Attach the user to their Facebook account in the database
465 - FBConnectDB::addFacebookID($user, $fbid);
 472+ FBConnectDB::addFacebookID( $user, $fbid );
466473 // Update the user with settings from Facebook
467474 $user->updateFromFacebook();
468475 // Store the user in the global user object
469476 $wgUser = $user;
470 - $this->sendPage('displaySuccessLogin');
471 -
472 - wfProfileOut(__METHOD__);
 477+ $this->sendPage( 'displaySuccessLogin' );
 478+
 479+ wfProfileOut( __METHOD__ );
473480 }
474481
475482 /**
@@ -483,9 +490,9 @@
484491 // Because $i is incremented the first time through the while loop
485492 $i = FBConnectDB::countUsers();
486493 #$i = 1; // This is the DUMB WAY to do this for large databases
487 - while ($i < PHP_INT_MAX) {
 494+ while ( $i < PHP_INT_MAX ) {
488495 $name = $this->userNamePrefix . $i;
489 - if ($this->userNameOK($name)) {
 496+ if ( $this->userNameOK( $name ) ) {
490497 return $name;
491498 }
492499 ++$i;
@@ -496,20 +503,20 @@
497504 /**
498505 * Tests whether the name is OK to use as a user name.
499506 */
500 - public function userNameOK ($name) {
 507+ public function userNameOK( $name ) {
501508 global $wgReservedUsernames;
502 - return ($name && (null == User::idFromName($name)) && !in_array($name, $wgReservedUsernames));
 509+ return ( $name && ( null == User::idFromName( $name ) ) && !in_array( $name, $wgReservedUsernames ) );
503510 }
504511
505512 /**
506513 * Displays a simple error page.
507514 */
508 - protected function sendError($titleMsg, $textMsg) {
 515+ protected function sendError( $titleMsg, $textMsg ) {
509516 global $wgOut;
510 - $wgOut->showErrorPage($titleMsg, $textMsg);
 517+ $wgOut->showErrorPage( $titleMsg, $textMsg );
511518 }
512 -
513 - public function sendPage($function, $arg = NULL) {
 519+
 520+ public function sendPage( $function, $arg = null ) {
514521 global $wgOut;
515522 // Setup the page for rendering
516523 wfLoadExtensionMessages( 'FBConnect' );
@@ -518,21 +525,24 @@
519526 $wgOut->setRobotPolicy( 'noindex,nofollow' );
520527 $wgOut->setArticleRelated( false );
521528 // Call the specified function to continue generating the page
522 - if (is_null($arg)) {
 529+ if ( is_null( $arg ) ) {
523530 $this->$function();
524531 } else {
525 - $this->$function($arg);
 532+ $this->$function( $arg );
526533 }
527534 }
528 -
 535+
529536 private function alreadyLoggedIn() {
530537 global $wgOut, $wgUser, $wgRequest, $wgSitename;
531 - $wgOut->setPageTitle(wfMsg('fbconnect-error'));
532 - $wgOut->addWikiMsg('fbconnect-alreadyloggedin', $wgUser->getName());
533 - $wgOut->addWikiMsg('fbconnect-click-to-connect-existing', $wgSitename);
534 - $wgOut->addHTML('<fb:login-button'.FBConnect::getPermissionsAttribute().FBConnect::getOnLoginAttribute().'></fb:login-button>');
 538+ $wgOut->setPageTitle( wfMsg( 'fbconnect-error' ) );
 539+ $wgOut->addWikiMsg( 'fbconnect-alreadyloggedin', $wgUser->getName() );
 540+ $wgOut->addWikiMsg( 'fbconnect-click-to-connect-existing', $wgSitename );
 541+ $wgOut->addHTML(
 542+ '<fb:login-button' . FBConnect::getPermissionsAttribute() .
 543+ FBConnect::getOnLoginAttribute() . '></fb:login-button>'
 544+ );
535545 // Render the "Return to" text retrieved from the URL
536 - $wgOut->returnToMain(false, $wgRequest->getText('returnto'), $wgRequest->getVal('returntoquery'));
 546+ $wgOut->returnToMain( false, $wgRequest->getText( 'returnto' ), $wgRequest->getVal( 'returntoquery' ) );
537547 }
538548
539549 private function displaySuccessLogin() {
@@ -544,7 +554,7 @@
545555 wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$inject_html ) );
546556 $wgOut->addHtml( $inject_html );
547557 // Render the "return to" text retrieved from the URL
548 - $wgOut->returnToMain(false, $wgRequest->getText('returnto'), $wgRequest->getVal('returntoquery'));
 558+ $wgOut->returnToMain( false, $wgRequest->getText( 'returnto' ), $wgRequest->getVal( 'returntoquery' ) );
549559 }
550560
551561 /**
@@ -556,7 +566,7 @@
557567 * NOTE: The above might be done now that we have checkboxes for which options
558568 * to update from fb. Haven't tested it though.
559569 */
560 - private function chooseNameForm($messagekey = 'fbconnect-chooseinstructions') {
 570+ private function chooseNameForm( $messagekey = 'fbconnect-chooseinstructions' ) {
561571 // Permissions restrictions.
562572 global $wgUser, $facebook, $wgOut, $wgFbConnectOnly;
563573 $titleObj = SpecialPage::getTitleFor( 'Connect' );
@@ -564,24 +574,23 @@
565575 // The wiki is in read-only mode
566576 $wgOut->readOnlyPage();
567577 return;
568 - } elseif ( !isset($wgFbConnectOnly) || !$wgFbConnectOnly ) {
 578+ } elseif ( !isset( $wgFbConnectOnly ) || !$wgFbConnectOnly ) {
569579 // These two permissions don't apply in $wgFbConnectOnly mode
570580 if ( $wgUser->isBlockedFromCreateAccount() ) {
571 - wfDebug("FBConnect: Blocked user was attempting to create account via Facebook Connect.\n");
572 - $wgOut->showErrorPage('fbconnect-error', 'fbconnect-errortext');
 581+ wfDebug( "FBConnect: Blocked user was attempting to create account via Facebook Connect.\n" );
 582+ $wgOut->showErrorPage( 'fbconnect-error', 'fbconnect-errortext' );
573583 return;
574 - } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) {
 584+ } elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) ) > 0 ) {
575585 $wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' );
576586 return;
577587 }
578588 }
579 -
580589
581590 // Allow other code to have a custom form here (so that this extension can be integrated with existing custom login screens).
582 - if( !wfRunHooks( 'SpecialConnect::chooseNameForm', array( &$this, &$messagekey ) ) ){
 591+ if( !wfRunHooks( 'SpecialConnect::chooseNameForm', array( &$this, &$messagekey ) ) ) {
583592 return;
584593 }
585 -
 594+
586595 // Connect to the Facebook API
587596 $userinfo = $facebook->getUserInfo();
588597
@@ -592,68 +601,72 @@
593602 $this->outputHeader();
594603 // If a different $messagekey was passed (like 'wrongpassword'), use it instead
595604 $wgOut->addWikiMsg( $messagekey );
596 - // TODO: Format the html a little nicer
 605+ // TODO: Format the HTML a little nicer
597606 $wgOut->addHTML('
598 - <form action="' . $this->getTitle('ChooseName')->getLocalUrl() . '" method="POST">
 607+ <form action="' . $this->getTitle( 'ChooseName' )->getLocalURL() . '" method="POST">
599608 <fieldset id="mw-fbconnect-choosename">
600 - <legend>' . wfMsg('fbconnect-chooselegend') . '</legend>
601 - <table>');
 609+ <legend>' . wfMsg( 'fbconnect-chooselegend' ) . '</legend>
 610+ <table>'
 611+ );
602612 // Let them attach to an existing user if $wgFbConnectOnly allows it
603 - if (!$wgFbConnectOnly) {
 613+ if ( !$wgFbConnectOnly ) {
604614 // Grab the UserName from the cookie if it exists
605615 global $wgCookiePrefix;
606 - $name = isset($_COOKIE[$wgCookiePrefix . 'UserName']) ?
607 - trim($_COOKIE[$wgCookiePrefix . 'UserName']) : '';
 616+ $name = isset( $_COOKIE[$wgCookiePrefix . 'UserName'] ) ?
 617+ trim( $_COOKIE[$wgCookiePrefix . 'UserName'] ) : '';
608618 // Build an array of attributes to update
609619 $updateOptions = array();
610 - foreach (self::$availableUserUpdateOptions as $option) {
 620+ foreach ( self::$availableUserUpdateOptions as $option ) {
611621 // Translate the MW parameter into a FB parameter
612 - $value = FBConnectUser::getOptionFromInfo($option, $userinfo);
 622+ $value = FBConnectUser::getOptionFromInfo( $option, $userinfo );
613623 // If no corresponding value was received from Facebook, then continue
614 - if (!$value) {
 624+ if ( !$value ) {
615625 continue;
616626 }
617627 // Build the list item for the update option
618628 $updateOptions[] = "<li><input name=\"wpUpdateUserInfo$option\" type=\"checkbox\" " .
619629 "value=\"1\" id=\"wpUpdateUserInfo$option\" /><label for=\"wpUpdateUserInfo$option\">" .
620 - wfMsgHtml("fbconnect-$option") . wfMsgExt('colon-separator', array('escapenoentities')) .
 630+ wfMsgHtml( "fbconnect-$option" ) . wfMsgExt( 'colon-separator', array( 'escapenoentities' ) ) .
621631 " <i>$value</i></label></li>";
622632 }
623633 // Implode the update options into an unordered list
624 - $updateChoices = count($updateOptions) > 0 ? "<br />\n" . wfMsgHtml('fbconnect-updateuserinfo') .
625 - "\n<ul>\n" . implode("\n", $updateOptions) . "\n</ul>\n" : '';
 634+ $updateChoices = count( $updateOptions ) > 0 ? "<br />\n" . wfMsgHtml( 'fbconnect-updateuserinfo' ) .
 635+ "\n<ul>\n" . implode( "\n", $updateOptions ) . "\n</ul>\n" : '';
626636 // Create the HTML for the "existing account" option
627637 $html = '<tr><td class="wm-label"><input name="wpNameChoice" type="radio" ' .
628638 'value="existing" id="wpNameChoiceExisting"/></td><td class="mw-input">' .
629 - '<label for="wnNameChoiceExisting">' . wfMsg('fbconnect-chooseexisting') . '<br/>' .
630 - wfMsgHtml('fbconnect-chooseusername') . '<input name="wpExistingName" size="16" value="' .
631 - $name . '" id="wpExistingName"/>' . wfMsgHtml('fbconnect-choosepassword') .
 639+ '<label for="wnNameChoiceExisting">' . wfMsg( 'fbconnect-chooseexisting' ) . '<br />' .
 640+ wfMsgHtml( 'fbconnect-chooseusername' ) . '<input name="wpExistingName" size="16" value="' .
 641+ $name . '" id="wpExistingName"/>' . wfMsgHtml( 'fbconnect-choosepassword' ) .
632642 '<input name="wpExistingPassword" ' . 'size="" value="" type="password"/>' . $updateChoices .
633643 '</td></tr>';
634 - $wgOut->addHTML($html);
 644+ $wgOut->addHTML( $html );
635645 }
636 -
 646+
637647 // Add the options for nick name, first name and full name if we can get them
638648 // TODO: Wikify the usernames (i.e. Full name should have an _ )
639 - foreach (array('nick', 'first', 'full') as $option) {
640 - $nickname = FBConnectUser::getOptionFromInfo($option . 'name', $userinfo);
641 - if ($nickname && $this->userNameOK($nickname)) {
642 - $wgOut->addHTML('<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="' .
643 - $option . ($checked ? '' : '" checked="checked') . '" id="wpNameChoice' . $option .
 649+ foreach ( array( 'nick', 'first', 'full' ) as $option ) {
 650+ $nickname = FBConnectUser::getOptionFromInfo( $option . 'name', $userinfo );
 651+ if ( $nickname && $this->userNameOK( $nickname ) ) {
 652+ $wgOut->addHTML(
 653+ '<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="' .
 654+ $option . ( $checked ? '' : '" checked="checked' ) . '" id="wpNameChoice' . $option .
644655 '"/></td><td class="mw-input"><label for="wpNameChoice' . $option . '">' .
645 - wfMsg('fbconnect-choose' . $option, $nickname) . '</label></td></tr>');
 656+ wfMsg( 'fbconnect-choose' . $option, $nickname ) . '</label></td></tr>'
 657+ );
646658 // When the first radio is checked, this flag is set and subsequent options aren't checked
647659 $checked = true;
648660 }
649661 }
650662
651663 // The options for auto and manual usernames are always available
652 - $wgOut->addHTML('<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="auto" ' .
653 - ($checked ? '' : 'checked="checked" ') . 'id="wpNameChoiceAuto"/></td><td class="mw-input">' .
654 - '<label for="wpNameChoiceAuto">' . wfMsg('fbconnect-chooseauto', $this->generateUserName()) .
 664+ $wgOut->addHTML(
 665+ '<tr><td class="mw-label"><input name="wpNameChoice" type="radio" value="auto" ' .
 666+ ( $checked ? '' : 'checked="checked" ' ) . 'id="wpNameChoiceAuto"/></td><td class="mw-input">' .
 667+ '<label for="wpNameChoiceAuto">' . wfMsg( 'fbconnect-chooseauto', $this->generateUserName() ) .
655668 '</label></td></tr><tr><td class="mw-label"><input name="wpNameChoice" type="radio" ' .
656669 'value="manual" id="wpNameChoiceManual"/></td><td class="mw-input"><label ' .
657 - 'for="wpNameChoiceManual">' . wfMsg('fbconnect-choosemanual') . '</label>&nbsp;' .
 670+ 'for="wpNameChoiceManual">' . wfMsg( 'fbconnect-choosemanual' ) . '</label>&nbsp;' .
658671 '<input name="wpName2" size="16" value="" id="wpName2"/></td></tr>' .
659672 // Finish with two options, "Log in" or "Cancel"
660673 '<tr><td></td><td class="mw-submit"><input type="submit" value="Log in" name="wpOK"/>' .
@@ -672,63 +685,68 @@
673686 $this->outputHeader();
674687
675688 // Render a humble Facebook Connect button
676 - $wgOut->addHTML('<h2>' . wfMsg( 'fbconnect' ) . '</h2>
677 - <div>'.wfMsgExt( 'fbconnect-intro', array('parse', 'content')) . '<br/>' . wfMsg( 'fbconnect-click-to-login', $wgSitename ) .'
678 - <fb:login-button size="large" background="black" length="long"'.FBConnect::getPermissionsAttribute().FBConnect::getOnLoginAttribute().'></fb:login-button>
 689+ $wgOut->addHTML(
 690+ '<h2>' . wfMsg( 'fbconnect' ) . '</h2>
 691+ <div>' . wfMsgExt( 'fbconnect-intro', array( 'parse', 'content' ) ) .
 692+ '<br />' . wfMsg( 'fbconnect-click-to-login', $wgSitename ) . '
 693+ <fb:login-button size="large" background="black" length="long"' .
 694+ FBConnect::getPermissionsAttribute() . FBConnect::getOnLoginAttribute() .
 695+ '></fb:login-button>
679696 </div>'
680697 );
681698 }
682 -
683 - /**
 699+
 700+ /**
684701 * Disconnect from Facebook
685 - */
 702+ */
686703 private function disconnectAction() {
687704 global $wgRequest, $wgOut, $wgUser;
688 -
 705+
689706 if( $wgRequest->wasPosted() ) {
690 - $id = FBConnectDB::getFacebookIDs($wgUser);
691 - if( count($id) > 0 ) {
 707+ $id = FBConnectDB::getFacebookIDs( $wgUser );
 708+ if( count( $id ) > 0 ) {
692709 FBConnectDB::removeFacebookID( $wgUser, $id['user_fbid'] );
693710 }
694711 }
695 -
 712+
696713 $title = SpecialPage::getTitleFor( 'Preferences' );
697 - $url = $title->getFullUrl("#prefsection-10");
698 - $wgOut->redirect($url);
 714+ $url = $title->getFullURL( '#prefsection-10' );
 715+ $wgOut->redirect( $url );
699716
700717 return true;
701718 }
702 -
 719+
703720 /**
704721 * Creates a Login Form template object and propogates it with parameters.
705722 *
706723 private function createLoginForm() {
707724 global $wgUser, $wgEnableEmail, $wgEmailConfirmToEdit,
708725 $wgCookiePrefix, $wgCookieExpiration, $wgAuth;
709 -
 726+
710727 $template = new UserloginTemplate();
711 -
 728+
712729 // Pull the name from $wgUser or cookies
713 - if( $wgUser->isLoggedIn() )
 730+ if( $wgUser->isLoggedIn() ) {
714731 $name = $wgUser->getName();
715 - else if( isset( $_COOKIE[$wgCookiePrefix . 'UserName'] ))
 732+ } elseif( isset( $_COOKIE[$wgCookiePrefix . 'UserName'] ) ) {
716733 $name = $_COOKIE[$wgCookiePrefix . 'UserName'];
717 - else
 734+ } else {
718735 $name = null;
 736+ }
719737 // Alias some common URLs for $action and $link
720738 $loginTitle = self::getTitleFor( 'Userlogin' );
721739 $this_href = wfUrlencode( $this->getTitle() );
722740 // Action URL that gets posted to
723741 $action = $loginTitle->getLocalUrl('action=submitlogin&type=login&returnto=' . $this_href);
724742 // Don't show a "create account" link if the user is not allowed to create an account
725 - if ($wgUser->isAllowed( 'createaccount' )) {
726 - $link_href = htmlspecialchars($loginTitle->getLocalUrl('type=signup&returnto=' . $this_href));
 743+ if ( $wgUser->isAllowed( 'createaccount' ) ) {
 744+ $link_href = htmlspecialchars( $loginTitle->getLocalURL( 'type=signup&returnto=' . $this_href ) );
727745 $link_text = wfMsgHtml( 'nologinlink' );
728746 $link = wfMsgWikiHtml( 'nologin', "<a href=\"$link_href\">$link_text</a>" );
729747 } else {
730748 $link = '';
731749 }
732 -
 750+
733751 // Set the appropriate options for this template
734752 $template->set( 'header', '' );
735753 $template->set( 'name', $name );
@@ -746,11 +764,11 @@
747765 // Give authentication and captcha plugins a chance to modify the form
748766 $type = 'login';
749767 $wgAuth->modifyUITemplate( $template, $type );
750 - wfRunHooks( 'UserLoginForm', array( &$template ));
751 -
752 -
 768+ wfRunHooks( 'UserLoginForm', array( &$template ) );
 769+
 770+
753771 // Spit out the form we just made
754772 return $template;
755773 }
756 - /**/
 774+ */
757775 }
Index: trunk/extensions/FBConnect/FBConnectAPI.php
@@ -5,12 +5,12 @@
66 * it under the terms of the GNU General Public License as published by
77 * the Free Software Foundation; either version 2 of the License, or
88 * (at your option) any later version.
9 - *
 9+ *
1010 * This program is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 * GNU General Public License for more details.
14 - *
 14+ *
1515 * You should have received a copy of the GNU General Public License along
1616 * with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
@@ -26,9 +26,9 @@
2727
2828 /**
2929 * Class FBConnectAPI
30 - *
 30+ *
3131 * This class contains the code used to interface with Facebook via the
32 - * Facebook Platform API.
 32+ * Facebook Platform API.
3333 */
3434 class FBConnectAPI extends Facebook {
3535 // Constructor
@@ -44,12 +44,12 @@
4545 'cookie' => true,
4646 );
4747 // Include the optional domain parameter if it has been set
48 - if ( !empty($wgFbDomain) && $wgFbDomain != 'BASE_DOMAIN' ) {
 48+ if ( !empty( $wgFbDomain ) && $wgFbDomain != 'BASE_DOMAIN' ) {
4949 $config['domain'] = $wgFbDomain;
5050 }
5151 parent::__construct( $config );
5252 }
53 -
 53+
5454 /**
5555 * Check to make sure config.sample.php was properly renamed to config.php
5656 * and the instructions to fill out the first two important variables were
@@ -57,23 +57,23 @@
5858 */
5959 public function isConfigSetup() {
6060 global $wgFbAppId, $wgFbSecret;
61 - $isSetup = isset($wgFbAppId) && $wgFbAppId != 'YOUR_APP_KEY' &&
62 - isset($wgFbSecret) && $wgFbSecret != 'YOUR_SECRET';
63 - if(!$isSetup) {
 61+ $isSetup = isset( $wgFbAppId ) && $wgFbAppId != 'YOUR_APP_KEY' &&
 62+ isset( $wgFbSecret ) && $wgFbSecret != 'YOUR_SECRET';
 63+ if( !$isSetup ) {
6464 // Check to see if they are still using the old variables
6565 global $fbApiKey, $fbApiSecret;
66 - if ( isset($fbApiKey) ) {
 66+ if ( isset( $fbApiKey ) ) {
6767 $wgFbAppId = $fbApiKey;
6868 }
69 - if ( isset($fbApiSecret) ) {
 69+ if ( isset( $fbApiSecret ) ) {
7070 $wgFbSecret= $fbApiSecret;
7171 }
72 - $isSetup = isset($wgFbAppId) && $wgFbAppId != 'YOUR_APP_KEY' &&
73 - isset($wgFbSecret) && $wgFbSecret != 'YOUR_SECRET';
 72+ $isSetup = isset( $wgFbAppId ) && $wgFbAppId != 'YOUR_APP_KEY' &&
 73+ isset( $wgFbSecret ) && $wgFbSecret != 'YOUR_SECRET';
7474 }
7575 return $isSetup;
7676 }
77 -
 77+
7878 /**
7979 * Calls users.getInfo. Requests information about the user from Facebook.
8080 */
@@ -86,117 +86,119 @@
8787 try {
8888 // Cache information about users to reduce the number of Facebook hits
8989 static $userinfo = array();
90 -
91 - if ( !isset($userinfo[$user]) ) {
 90+
 91+ if ( !isset( $userinfo[$user] ) ) {
9292 // Query the Facebook API with the users.getInfo method
9393 $query = array(
94 - 'method' => 'users.getInfo',
95 - 'uids' => $user,
96 - 'fields' => join(',', array(
97 - 'first_name', 'name', 'sex', 'timezone', 'locale',
98 - /*'profile_url',*/
99 - 'username', 'proxied_email', 'contact_email',
100 - )),
 94+ 'method' => 'users.getInfo',
 95+ 'uids' => $user,
 96+ 'fields' => join( ',', array(
 97+ 'first_name', 'name', 'sex', 'timezone', 'locale',
 98+ /*'profile_url',*/
 99+ 'username', 'proxied_email', 'contact_email',
 100+ )),
101101 );
102102 $user_details = $this->api( $query );
103103 // Cache the data in the $userinfo array
104104 $userinfo[$user] = $user_details[0];
105105 }
106 - return isset($userinfo[$user]) ? $userinfo[$user] : null;
107 - } catch (FacebookApiException $e) {
 106+ return isset( $userinfo[$user] ) ? $userinfo[$user] : null;
 107+ } catch ( FacebookApiException $e ) {
108108 error_log( 'Failure in the api when requesting users.getInfo ' .
109 - "on uid $user: " . $e->getMessage());
 109+ "on uid $user: " . $e->getMessage() );
110110 }
111111 return null;
112112 }
113 -
 113+
114114 /**
115115 * Retrieves group membership data from Facebook.
116116 */
117117 public function getGroupRights( $user = null ) {
118118 global $wgFbUserRightsFromGroup;
119 -
 119+
120120 // Groupies can be members, officers or admins (the latter two infer the former)
121 - $rights = array('member' => false,
122 - 'officer' => false,
123 - 'admin' => false);
124 -
125 - $gid = !empty($wgFbUserRightsFromGroup) ? $wgFbUserRightsFromGroup : false;
126 - if (// If no group ID is specified, then there's no group to belong to
 121+ $rights = array(
 122+ 'member' => false,
 123+ 'officer' => false,
 124+ 'admin' => false
 125+ );
 126+
 127+ $gid = !empty( $wgFbUserRightsFromGroup ) ? $wgFbUserRightsFromGroup : false;
 128+ if ( // If no group ID is specified, then there's no group to belong to
127129 !$gid ||
128130 // If $user wasn't specified, set it to the logged in user
129131 !$user ||
130132 // If there is no logged in user
131 - !($user = $this->getUser())
 133+ !( $user = $this->getUser() )
132134 ) {
133135 return $rights;
134136 }
135 -
 137+
136138 // If a User object was provided, translate it into a Facebook ID
137 - if ($user instanceof User) {
 139+ if ( $user instanceof User ) {
138140 // TODO: Does this call for a special api call without access_token?
139 - $users = FBConnectDB::getFacebookIDs($user);
140 - if (count($users)) {
 141+ $users = FBConnectDB::getFacebookIDs( $user );
 142+ if ( count( $users ) ) {
141143 $user = $users[0];
142144 } else {
143145 // Not a Connected user, can't be in a group
144146 return $rights;
145147 }
146148 }
147 -
 149+
148150 // Cache the rights for an individual user to prevent hitting Facebook for duplicate info
149151 static $rights_cache = array();
150 - if ( array_key_exists( $user, $rights_cache )) {
 152+ if ( array_key_exists( $user, $rights_cache ) ) {
151153 // Retrieve the rights from the cache
152154 return $rights_cache[$user];
153155 }
154 -
 156+
155157 // This can contain up to 500 IDs, avoid requesting this info twice
156158 static $members = false;
157159 // Get a random 500 group members, along with officers, admins and not_replied's
158 - if ($members === false) {
 160+ if ( $members === false ) {
159161 try {
160162 // Check to make sure our session is still valid
161 - $members = $this->api(array(
162 - 'method' => 'groups.getMembers',
163 - 'gid' => $gid
 163+ $members = $this->api( array(
 164+ 'method' => 'groups.getMembers',
 165+ 'gid' => $gid
164166 ));
165 - } catch (FacebookApiException $e) {
 167+ } catch ( FacebookApiException $e ) {
166168 // Invalid session; we're not going to be able to get the rights
167 - error_log($e);
 169+ error_log( $e );
168170 $rights_cache[$user] = $rights;
169171 return $rights;
170172 }
171173 }
172 -
 174+
173175 if ( $members ) {
174176 // Check to see if the user is an officer
175 - if (array_key_exists('officers', $members) && in_array($user, $members['officers'])) {
 177+ if ( array_key_exists( 'officers', $members ) && in_array( $user, $members['officers'] ) ) {
176178 $rights['member'] = $rights['officer'] = true;
177179 }
178180 // Check to see if the user is an admin of the group
179 - if (array_key_exists('admins', $members) && in_array($user, $members['admins'])) {
 181+ if ( array_key_exists( 'admins', $members ) && in_array( $user, $members['admins'] ) ) {
180182 $rights['member'] = $rights['admin'] = true;
181183 }
182184 // Because the latter two rights infer the former, this step isn't always necessary
183185 if( !$rights['member'] ) {
184186 // Check to see if we are one of the (up to 500) random users
185 - if ((array_key_exists('not_replied', $members) && is_array($members['not_replied']) &&
186 - in_array($user, $members['not_replied'])) || in_array($user, $members['members'])) {
 187+ if ( ( array_key_exists( 'not_replied', $members ) && is_array( $members['not_replied'] ) &&
 188+ in_array( $user, $members['not_replied'] ) ) || in_array( $user, $members['members'] ) ) {
187189 $rights['member'] = true;
188190 } else {
189191 // For groups of over 500ish, we must use this extra API call
190192 // Notice that it occurs last, because we can hopefully avoid having to call it
191193 try {
192 - $group = $this->api(array(
193 - 'method' => 'groups.get',
194 - 'uid' => $user,
195 - 'gids' => $gid
 194+ $group = $this->api( array(
 195+ 'method' => 'groups.get',
 196+ 'uid' => $user,
 197+ 'gids' => $gid
196198 ));
197 - } catch (FacebookApiException $e) {
198 - error_log($e);
 199+ } catch ( FacebookApiException $e ) {
 200+ error_log( $e );
199201 }
200 - if (is_array($group) && is_array($group[0]) && $group[0]['gid'] == "$gid") {
 202+ if ( is_array( $group ) && is_array( $group[0] ) && $group[0]['gid'] == "$gid" ) {
201203 $rights['member'] = true;
202204 }
203205 }
@@ -206,11 +208,11 @@
207209 $rights_cache[$user] = $rights;
208210 return $rights;
209211 }
210 -
211 - /*
 212+
 213+ /**
212214 * Publish message on Facebook wall.
213215 */
214 - public function publishStream($message, $link = "", $link_title ) {
 216+ public function publishStream( $message, $link = '', $link_title ) {
215217 /*
216218 $attachment = array(
217219 'name' => $message,
@@ -218,38 +220,38 @@
219221 'caption' => $caption,
220222 'description' => $description
221223 );
222 -
223 - if( count($media) > 0 ) {
 224+
 225+ if( count( $media ) > 0 ) {
224226 foreach ( $media as $value ) {
225 - $attachment[ 'media' ][] = $value;
 227+ $attachment['media'][] = $value;
226228 }
227229 }
228 - /**/
 230+ */
229231 // $api_error_descriptions
230232 $attachment = array();
231 -
 233+
232234 $query = array(
233235 'method' => 'stream.publish',
234 - 'attachment' => json_encode($attachment),
235 - 'action_links' => json_encode(array(
 236+ 'attachment' => json_encode( $attachment ),
 237+ 'action_links' => json_encode( array(
236238 'text' => $link_title,
237239 'href' => $link
238240 )),
239241 );
240 -
 242+
241243 $result = json_decode( $this->api( $query ) );
242 -
 244+
243245 if ( is_array( $result ) ) {
244246 // Error
245247 #error_log(FacebookAPIErrorCodes::$api_error_descriptions[$result]);
246 - error_log("stream.publish returned error code $result->error_code");
 248+ error_log( "stream.publish returned error code $result->error_code" );
247249 return false;
248 - } else if ( is_string( $result ) ) {
 250+ } elseif ( is_string( $result ) ) {
249251 // Success! Return value is "$UserId_$PostId"
250252 return true;
251253 } else {
252 - error_log("stream.publish: Unknown return type: " . gettype($result));
 254+ error_log( 'stream.publish: Unknown return type: ' . gettype( $result ) );
253255 return false;
254256 }
255 - }
 257+ }
256258 }
Index: trunk/extensions/FBConnect/FBConnectUser.php
@@ -1,16 +1,16 @@
22 <?php
3 -/*
 3+/**
44 * Copyright © 2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin>
55 * This program is free software; you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
77 * the Free Software Foundation; either version 2 of the License, or
88 * (at your option) any later version.
9 - *
 9+ *
1010 * This program is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 * GNU General Public License for more details.
14 - *
 14+ *
1515 * You should have received a copy of the GNU General Public License along
1616 * with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
@@ -26,19 +26,19 @@
2727
2828 /**
2929 * Class FBConnectUser
30 - *
 30+ *
3131 * Extends the User class.
3232 */
3333 class FBConnectUser extends User {
3434 /**
3535 * Constructor: Create this object from an existing User. Bonus points if
36 - * the existing User was created form an ID and has not yet been loaded!
 36+ * the existing User was created form an ID and has not yet been loaded!
3737 */
38 - function __construct($user) {
 38+ function __construct( $user ) {
3939 $this->mId = $user->getId();
4040 $this->mFrom = 'id';
4141 }
42 -
 42+
4343 /**
4444 * Update a user's settings with the values retrieved from the current
4545 * logged-in Facebook user. Settings are only updated if a different value
@@ -46,68 +46,72 @@
4747 * login.
4848 */
4949 function updateFromFacebook() {
50 - wfProfileIn(__METHOD__);
 50+ wfProfileIn( __METHOD__ );
5151 global $facebook;
52 -
 52+
5353 // Keep track of whether any settings were modified
5454 $mod = false;
55 - // Connect to the Facebook API and retrieve the user's info
 55+ // Connect to the Facebook API and retrieve the user's info
5656 $userinfo = $facebook->getUserInfo();
5757 // Update the following options if the user's settings allow it
58 - $updateOptions = array('nickname', 'fullname', 'language',
59 - 'timecorrection', 'email');
60 - foreach ($updateOptions as $option) {
 58+ $updateOptions = array(
 59+ 'nickname', 'fullname', 'language',
 60+ 'timecorrection', 'email'
 61+ );
 62+ foreach ( $updateOptions as $option ) {
6163 // Translate Facebook parameters into MediaWiki parameters
62 - $value = self::getOptionFromInfo($option, $userinfo);
63 - if ($value && ($this->getOption("fbconnect-update-on-login-$option", "0") == "1")) {
64 - switch ($option) {
 64+ $value = self::getOptionFromInfo( $option, $userinfo );
 65+ if ( $value && ( $this->getOption( "fbconnect-update-on-login-$option", '0' ) == '1' ) ) {
 66+ switch ( $option ) {
6567 case 'fullname':
66 - $this->setRealName($value);
 68+ $this->setRealName( $value );
6769 break;
6870 default:
69 - $this->setOption($option, $value);
 71+ $this->setOption( $option, $value );
7072 }
7173 $mod = true;
7274 }
7375 }
7476 // Only save the updated settings if something was changed
75 - if ($mod) {
 77+ if ( $mod ) {
7678 $this->saveSettings();
7779 }
78 -
79 - wfProfileOut(__METHOD__);
 80+
 81+ wfProfileOut( __METHOD__ );
8082 }
81 -
 83+
8284 /**
8385 * Helper function for updateFromFacebook(). Takes an array of info from
8486 * Facebook, and looks up the corresponding MediaWiki parameter.
8587 */
86 - static function getOptionFromInfo($option, $userinfo) {
 88+ static function getOptionFromInfo( $option, $userinfo ) {
8789 // Lookup table for the names of the settings
88 - $params = array('nickname' => 'username',
89 - 'fullname' => 'name',
90 - 'firstname' => 'first_name',
91 - 'gender' => 'sex',
92 - 'language' => 'locale',
93 - 'timecorrection' => 'timezone',
94 - 'email' => 'contact_email');
95 - if (empty($userinfo)) {
 90+ $params = array(
 91+ 'nickname' => 'username',
 92+ 'fullname' => 'name',
 93+ 'firstname' => 'first_name',
 94+ 'gender' => 'sex',
 95+ 'language' => 'locale',
 96+ 'timecorrection' => 'timezone',
 97+ 'email' => 'contact_email'
 98+ );
 99+ if ( empty( $userinfo ) ) {
96100 return null;
97101 }
98 - $value = array_key_exists($params[$option], $userinfo) ? $userinfo[$params[$option]] : '';
 102+ $value = array_key_exists( $params[$option], $userinfo ) ? $userinfo[$params[$option]] : '';
99103 // Special handling of several settings
100 - switch ($option) {
 104+ switch ( $option ) {
101105 case 'fullname':
102106 case 'firstname':
103107 // If real names aren't allowed, then simply ignore the parameter from Facebook
104108 global $wgAllowRealName;
105 - if (!$wgAllowRealName) {
 109+ if ( !$wgAllowRealName ) {
106110 $value = '';
107111 }
108112 break;
109113 case 'gender':
110114 // Unfortunately, Facebook genders are localized (but this might change)
111 - if ($value != 'male' || $value != 'female') {
 115+ if ( $value != 'male' || $value != 'female' ) {
112116 $value = '';
113117 }
114118 break;
@@ -119,25 +123,27 @@
120124 * For an up-to-date list of MediaWiki languages, see:
121125 * <http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/Names.php>.
122126 */
123 - if ($value == '') {
 127+ if ( $value == '' ) {
124128 break;
125129 }
126130 // These regional languages get special treatment
127 - $locales = array('en_PI' => 'en', # Pirate English
128 - 'en_GB' => 'en-gb', # British English
129 - 'en_UD' => 'en', # Upside Down English
130 - 'fr_CA' => 'fr', # Canadian French
131 - 'fb_LT' => 'en', # Leet Speak
132 - 'pt_BR' => 'pt-br', # Brazilian Portuguese
133 - 'zh_CN' => 'zh-cn', # Simplified Chinese
134 - 'es_ES' => 'es', # European Spanish
135 - 'zh_HK' => 'zh-hk', # Traditional Chinese (Hong Kong)
136 - 'zh_TW' => 'zh-tw'); # Traditional Chinese (Taiwan)
137 - if (array_key_exists($value, $locales)) {
 131+ $locales = array(
 132+ 'en_PI' => 'en', # Pirate English
 133+ 'en_GB' => 'en-gb', # British English
 134+ 'en_UD' => 'en', # Upside Down English
 135+ 'fr_CA' => 'fr', # Canadian French
 136+ 'fb_LT' => 'en', # Leet Speak
 137+ 'pt_BR' => 'pt-br', # Brazilian Portuguese
 138+ 'zh_CN' => 'zh-cn', # Simplified Chinese
 139+ 'es_ES' => 'es', # European Spanish
 140+ 'zh_HK' => 'zh-hk', # Traditional Chinese (Hong Kong)
 141+ 'zh_TW' => 'zh-tw' # Traditional Chinese (Taiwan)
 142+ );
 143+ if ( array_key_exists( $value, $locales ) ) {
138144 $value = $locales[$value];
139145 } else {
140146 // No special regional treatment exists in MW; chop it off
141 - $value = substr($value, 0, 2);
 147+ $value = substr( $value, 0, 2 );
142148 }
143149 break;
144150 case 'timecorrection':
@@ -147,7 +153,7 @@
148154 break;
149155 case 'email':
150156 // If a contact email isn't available, then use a proxied email
151 - if ($value == '') {
 157+ if ( $value == '' ) {
152158 // TODO: update the user's email from $userinfo['proxied_email']
153159 // instead (the address must stay hidden from the user)
154160 $value = '';
Index: trunk/extensions/FBConnect/FBConnect.php
@@ -5,12 +5,12 @@
66 * it under the terms of the GNU General Public License as published by
77 * the Free Software Foundation; either version 2 of the License, or
88 * (at your option) any later version.
9 - *
 9+ *
1010 * This program is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 * GNU General Public License for more details.
14 - *
 14+ *
1515 * You should have received a copy of the GNU General Public License along
1616 * with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
@@ -23,21 +23,21 @@
2424 * Info is available at http://www.mediawiki.org/wiki/Extension:FBConnect
2525 * and at http://wiki.developers.facebook.com/index.php/MediaWiki
2626 *
27 - * Limited support is available at http://www.mediawiki.org/wiki/Extension_talk:FBConnect
 27+ * Limited support is available at http://www.mediawiki.org/wiki/Extension_talk:FBConnect
2828 * and at http://wiki.developers.facebook.com/index.php/Talk:MediaWiki
2929 *
3030 * @file
 31+ * @ingroup Extensions
3132 * @author Garrett Bruin
3233 * @copyright Copyright © 2008 Garrett Brown
3334 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
34 - * @ingroup Extensions
3535 */
3636
3737
3838 /*
3939 * Not a valid entry point, skip unless MEDIAWIKI is defined.
4040 */
41 -if ( !defined( 'MEDIAWIKI' )) {
 41+if ( !defined( 'MEDIAWIKI' ) ) {
4242 die( 'This file is a MediaWiki extension, it is not a valid entry point' );
4343 }
4444
@@ -61,16 +61,16 @@
6262 /*
6363 * Initialization of the autoloaders and special extension pages.
6464 */
65 -$dir = dirname(__FILE__) . '/';
 65+$dir = dirname( __FILE__ ) . '/';
6666 require_once $dir . 'config.default.php';
6767 require_once $dir . 'php-sdk/facebook.php';
68 -if (!empty( $wgFbIncludePreferencesExtension ) && version_compare($wgVersion, '1.16', '<')) {
 68+if ( !empty( $wgFbIncludePreferencesExtension ) && version_compare( $wgVersion, '1.16', '<' ) ) {
6969 require_once $dir . 'PreferencesExtension.php';
7070 }
7171
7272 $wgExtensionFunctions[] = 'FBConnect::init';
7373
74 -if( !empty( $wgFbEnablePushToFacebook ) ){
 74+if( !empty( $wgFbEnablePushToFacebook ) ) {
7575 // Need to include it explicitly instead of autoload since it has initialization code of its own.
7676 // This should be done after FBConnect::init is added to wgExtensionFunctions so that FBConnect
7777 // gets fully initialized first.
@@ -98,7 +98,7 @@
9999 $wgGroupPermissions['fb-user'] = $wgGroupPermissions['user'];
100100
101101 // If we are configured to pull group info from Facebook, then create the group permissions
102 -if ($wgFbUserRightsFromGroup) {
 102+if ( $wgFbUserRightsFromGroup ) {
103103 $wgGroupPermissions['fb-groupie'] = $wgGroupPermissions['user'];
104104 $wgGroupPermissions['fb-officer'] = $wgGroupPermissions['bureaucrat'];
105105 $wgGroupPermissions['fb-admin'] = $wgGroupPermissions['sysop'];
@@ -119,7 +119,7 @@
120120
121121 /**
122122 * Class FBConnect
123 - *
 123+ *
124124 * This class initializes the extension, and contains the core non-hook,
125125 * non-authentification code.
126126 */
@@ -132,27 +132,27 @@
133133 public static function init() {
134134 global $wgXhtmlNamespaces, $wgSharedTables, $facebook, $wgHooks;
135135 global $wgFbOnLoginJsOverride;
136 -
 136+
137137 // The xmlns:fb attribute is required for proper rendering on IE
138138 $wgXhtmlNamespaces['fb'] = 'http://www.facebook.com/2008/fbml';
139 -
 139+
140140 // Facebook/username associations should be shared when $wgSharedDB is enabled
141141 $wgSharedTables[] = 'user_fbconnect';
142 -
 142+
143143 // Create our Facebook instance and make it available through $facebook
144144 $facebook = new FBConnectAPI();
145 -
 145+
146146 // Install all public static functions in class FBConnectHooks as MediaWiki hooks
147 - $hooks = self::enumMethods('FBConnectHooks');
 147+ $hooks = self::enumMethods( 'FBConnectHooks' );
148148 foreach( $hooks as $hookName ) {
149149 $wgHooks[$hookName][] = "FBConnectHooks::$hookName";
150150 }
151151
152152 // Allow configurable over-riding of the onLogin handler.
153 - if(!empty($wgFbOnLoginJsOverride)){
 153+ if( !empty( $wgFbOnLoginJsOverride ) ) {
154154 self::$fbOnLoginJs = $wgFbOnLoginJsOverride;
155155 } else {
156 - self::$fbOnLoginJs = "window.location.reload(true);";
 156+ self::$fbOnLoginJs = 'window.location.reload(true);';
157157 }
158158 }
159159
@@ -173,35 +173,37 @@
174174 // If PHP's version doesn't support the Reflection API, then exit
175175 die( 'PHP version (' . phpversion() . ') must be great enough to support the Reflection API' );
176176 // Or list the extensions here manually...
177 - $hooks = array('AuthPluginSetup', 'UserLoadFromSession',
178 - 'RenderPreferencesForm', 'PersonalUrls',
179 - 'ParserAfterTidy', 'BeforePageDisplay', /*...*/ );
 177+ $hooks = array(
 178+ 'AuthPluginSetup', 'UserLoadFromSession',
 179+ 'RenderPreferencesForm', 'PersonalUrls',
 180+ 'ParserAfterTidy', 'BeforePageDisplay', /*...*/
 181+ );
180182 }
181183 return $hooks;
182184 }
183 -
 185+
184186 /**
185187 * Return the code for the permissions attribute (with leading space) to use on all fb:login-buttons.
186188 */
187 - public static function getPermissionsAttribute(){
 189+ public static function getPermissionsAttribute() {
188190 global $wgFbExtendedPermissions;
189 - $attr = "";
190 - if(!empty($wgFbExtendedPermissions)){
191 - $attr = " perms=\"".implode(",", $wgFbExtendedPermissions)."\"";
 191+ $attr = '';
 192+ if( !empty( $wgFbExtendedPermissions ) ) {
 193+ $attr = ' perms="' . implode( ',', $wgFbExtendedPermissions ) . '"';
192194 }
193195 return $attr;
194196 } // end getPermissionsAttribute()
195 -
 197+
196198 /**
197199 * Return the code for the onlogin attribute which should be appended to all fb:login-button's in this
198200 * extension.
199201 *
200202 * TODO: Generate the entire fb:login-button in a function in this class. We have numerous buttons now.
201203 */
202 - public static function getOnLoginAttribute(){
203 - $attr = "";
204 - if(!empty(self::$fbOnLoginJs)){
205 - $attr = " onlogin=\"".self::$fbOnLoginJs."\"";
 204+ public static function getOnLoginAttribute() {
 205+ $attr = '';
 206+ if( !empty( self::$fbOnLoginJs ) ) {
 207+ $attr = ' onlogin="' . self::$fbOnLoginJs . '"';
206208 }
207209 return $attr;
208210 } // end getOnLoginAttribute()
Index: trunk/extensions/FBConnect/fbconnect.css
@@ -65,7 +65,7 @@
6666 padding: 1px 5px;
6767 }
6868
69 -.box_left #specialconnect_box h1, .box_left #specialconnect_box .box_content {
 69+.box_left #specialconnect_box h1, .box_left #specialconnect_box .box_content {
7070 padding-right: 120px;
7171 }
7272
Index: trunk/extensions/FBConnect/FBConnectPushEvent.php
@@ -18,13 +18,13 @@
1919 protected $isAllowedUserPreferenceName = ''; // implementing classes MUST override this with their own value.
2020
2121 // This must correspond to the name of the message for the text on the tab itself.
22 - static protected $PREFERENCES_TAB_NAME = "fbconnect-prefstext";
 22+ static protected $PREFERENCES_TAB_NAME = 'fbconnect-prefstext';
2323
2424 /**
2525 * Accessor for the user preference to which (if set to 1) allows this type of event
2626 * to be used.
2727 */
28 - public function getUserPreferenceName(){
 28+ public function getUserPreferenceName() {
2929 return $this->isAllowedUserPreferenceName;
3030 }
3131
@@ -32,44 +32,48 @@
3333 * Initialize the extension itself. This includes creating the user-preferences for
3434 * the push events.
3535 */
36 - static public function initExtension(){
37 - wfProfileIn(__METHOD__);
 36+ static public function initExtension() {
 37+ wfProfileIn( __METHOD__ );
3838
3939 // The push feature of the extension requires the publish_stream extended permission.
4040 global $wgFbExtendedPermissions;
4141 $PERMISSION_TO_PUBLISH = 'publish_stream';
42 - if(empty($wgFbExtendedPermissions) || !is_array($wgFbExtendedPermissions)){
43 - $wgFbExtendedPermissions = array($PERMISSION_TO_PUBLISH);
44 - } else if(!in_array($PERMISSION_TO_PUBLISH, $wgFbExtendedPermissions)){
 42+ if( empty( $wgFbExtendedPermissions ) || !is_array( $wgFbExtendedPermissions ) ) {
 43+ $wgFbExtendedPermissions = array( $PERMISSION_TO_PUBLISH);
 44+ } elseif( !in_array( $PERMISSION_TO_PUBLISH, $wgFbExtendedPermissions ) ) {
4545 $wgFbExtendedPermissions[] = $PERMISSION_TO_PUBLISH;
4646 }
4747
4848 // Make sure that all of the push events were configured correctly.
4949 self::initAll();
5050
51 - // TODO: This initialization should only be run if the user is fb-connected. Otherwise, the same Connect form as Special:Connect should be shown.
52 -
53 - // TODO: Can we detect if this is Special:Preferences and only add the checkboxes if that is the case? Can't think of anything else that would break.
54 -
55 - wfProfileOut(__METHOD__);
 51+ // TODO: This initialization should only be run if the user is fb-connected.
 52+ // Otherwise, the same Connect form as Special:Connect should be shown.
 53+
 54+ // TODO: Can we detect if this is Special:Preferences and only add the checkboxes if that is the case?
 55+ // Can't think of anything else that would break.
 56+
 57+ wfProfileOut( __METHOD__ );
5658 } // end initExtension()
5759
5860 /**
5961 * Adds enable/disable toggles to the Preferences form for controlling all push events.
6062 *
 63+ * @param $user Object: User object
 64+ * @param $preferences Object: Preferences object
6165 */
62 - static public function addPreferencesToggles( $user, &$preferences ){
 66+ static public function addPreferencesToggles( $user, &$preferences ) {
6367 global $fbPushEventClasses;
64 -
 68+
6569 // TODO: PREF_TOGGLE_T is not defined in v1.16
66 - /**
67 - if( !defined('PREF_TOGGLE_T') ) {
 70+ /*
 71+ if( !defined( 'PREF_TOGGLE_T' ) ) {
6872 return true;
6973 }
70 - /**/
71 -
72 - if( !empty($fbPushEventClasses) ){
73 - foreach($fbPushEventClasses as $pushEventClassName){
 74+ */
 75+
 76+ if( !empty( $fbPushEventClasses ) ) {
 77+ foreach( $fbPushEventClasses as $pushEventClassName ) {
7478 $pushObj = new $pushEventClassName;
7579 $className = get_class();
7680 $prefName = $pushObj->getUserPreferenceName();
@@ -80,9 +84,9 @@
8185 'section' => self::$PREFERENCES_TAB_NAME,
8286 'default' => '1',
8387 );
84 -
 88+
8589 // Prior to v1.16
86 - if( defined('PREF_TOGGLE_T') ) {
 90+ if( defined( 'PREF_TOGGLE_T' ) ) {
8791 $preferences[$prefName]['int-type'] = PREF_TOGGLE_T;
8892 $preferences[$prefName]['name'] = $prefName;
8993 }
@@ -91,41 +95,41 @@
9296
9397 return true;
9498 } // end addPreferencesToggles()
95 -
 99+
96100 /**
97101 * This function returns HTML which contains toggles (in a list) for setting the push
98 - * Preferences. It is designed to be used inside of a form (such as on Special:Connect).
 102+ * Preferences. It is designed to be used inside of a form (such as on Special:Connect).
99103 *
100104 * This is not used by the code which adds the form to Special:Preferences.
101105 *
102106 * If firstTime is set to true, the checkboxes will default to being checked, otherwise
103107 * they will default to the current user-option setting for the user.
104108 */
105 - static public function createPreferencesToggles($firstTime = false){
 109+ static public function createPreferencesToggles( $firstTime = false ) {
106110 global $wgUser, $wgLang, $fbPushEventClasses;
107 - wfProfileIn(__METHOD__);
 111+ wfProfileIn( __METHOD__ );
108112
109 - $html = "";
110 - if(!empty($fbPushEventClasses)){
111 - foreach($fbPushEventClasses as $pushEventClassName){
 113+ $html = '';
 114+ if( !empty( $fbPushEventClasses ) ) {
 115+ foreach( $fbPushEventClasses as $pushEventClassName ) {
112116 $pushObj = new $pushEventClassName;
113117 $className = get_class();
114118 $prefName = $pushObj->getUserPreferenceName();
115119
116120 $prefText = $wgLang->getUserToggle( $prefName );
117 - if($firstTime){
 121+ if( $firstTime ) {
118122 $checked = ' checked="checked"';
119123 } else {
120124 $checked = $wgUser->getOption( $prefName ) == 1 ? ' checked="checked"' : '';
121125 }
122 - $html .= "<div class='toggle'>";
 126+ $html .= '<div class="toggle">';
123127 $html .= "<input type='checkbox' value='1' id=\"$prefName\" name=\"$prefName\"$checked />";
124128 $html .= "<label for=\"$prefName\">$prefText</label>";
125129 $html .= "</div>\n";
126130 }
127131 }
128132
129 - wfProfileOut(__METHOD__);
 133+ wfProfileOut( __METHOD__ );
130134 return $html;
131135 } // end createPreferencesToggles()
132136
@@ -133,35 +137,35 @@
134138 * This static function is called by the FBConnect extension if push events are enabled. It checks
135139 * to make sure that the configured push-events are valid and then gives them each a chance to initialize.
136140 */
137 - static public function initAll(){
 141+ static public function initAll() {
138142 global $fbPushEventClasses, $wgUser;
139 - wfProfileIn(__METHOD__);
140 -
 143+ wfProfileIn( __METHOD__ );
 144+
141145 if( !empty( $fbPushEventClasses ) ) {
142146 // Fail fast (and hard) if a push event was coded incorrectly.
143 - foreach($fbPushEventClasses as $pushEventClassName){
 147+ foreach( $fbPushEventClasses as $pushEventClassName ) {
144148 $pushObj = new $pushEventClassName;
145149 $className = get_class();
146150 $prefName = $pushObj->getUserPreferenceName();
147 - if(empty($prefName)){
 151+ if( empty( $prefName ) ) {
148152 $dirName = dir( __FILE__ );
149153 $msg = "FATAL ERROR: The push event class <strong>\"$pushEventClassName\"</strong> does not return a valid user preference name! ";
150 - $msg.= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>";
151 - die($msg);
152 - } else if(!is_subclass_of($pushObj, $className)){
 154+ $msg .= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>";
 155+ die( $msg );
 156+ } elseif( !is_subclass_of( $pushObj, $className ) ) {
153157 $msg = "FATAL ERROR: The push event class <strong>\"$pushEventClassName\"</strong> is not a subclass of <strong>$className</strong>! ";
154 - $msg.= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>";
155 - die($msg);
 158+ $msg .= " It was probably written incorrectly. Either fix the class or remove it from being used in <strong>$dirName/config.php</strong>";
 159+ die( $msg );
156160 }
157 -
 161+
158162 // The push event is valid, let it initialize itself if needed.
159 - if( $wgUser->getOption($prefName) ) {
 163+ if( $wgUser->getOption( $prefName ) ) {
160164 $pushObj->init();
161165 }
162166 }
163167 }
164168
165 - wfProfileOut(__METHOD__);
 169+ wfProfileOut( __METHOD__ );
166170 }
167171
168172 /**
@@ -171,14 +175,14 @@
172176 * and the getUserPreferenceName() call checks out (the result must be non-empty).
173177 */
174178 public function init(){}
175 -
176 - /**
177 - * Put Facebook message.
178 - */
179 - public function pushEvent($message, $link = null, $link_title = null) {
 179+
 180+ /**
 181+ * Put Facebook message.
 182+ */
 183+ public function pushEvent( $message, $link = null, $link_title = null ) {
180184 global $facebook;
181 -
182 - return $facebook->publishStream($message, $link, $link_title);
183 - }
184 -
 185+
 186+ return $facebook->publishStream( $message, $link, $link_title );
 187+ }
 188+
185189 } // end FBConnectPushEvent class
Index: trunk/extensions/FBConnect/FBConnectHooks.php
@@ -1,23 +1,23 @@
22 <?php
3 -/*
 3+/**
44 * Copyright © 2008-2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin>
55 * This program is free software; you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
77 * the Free Software Foundation; either version 2 of the License, or
88 * (at your option) any later version.
9 - *
 9+ *
1010 * This program is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 * GNU General Public License for more details.
14 - *
 14+ *
1515 * You should have received a copy of the GNU General Public License along
1616 * with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
1818
1919 /**
2020 * Class FBConnectHooks
21 - *
 21+ *
2222 * This class contains all the hooks used in this extension. HOOKS DO NOT NEED
2323 * TO BE EXPLICITLY ADDED TO $wgHooks. Simply write a public static function
2424 * with the same name as the hook that provokes it, place it inside this class
@@ -34,13 +34,13 @@
3535 // Get the article title
3636 $nt = $article->getTitle();
3737 // If the page being viewed is a user page
38 - if ($nt && $nt->getNamespace() == NS_USER && strpos($nt->getText(), '/') === false) {
39 - $user = User::newFromName($nt->getText());
40 - if (!$user || $user->getID() == 0) {
 38+ if ( $nt && $nt->getNamespace() == NS_USER && strpos( $nt->getText(), '/' ) === false ) {
 39+ $user = User::newFromName( $nt->getText() );
 40+ if ( !$user || $user->getID() == 0 ) {
4141 return true;
4242 }
43 - $fb_id = FBConnectDB::getFacebookIDs($user->getId());
44 - if (!count($fb_id) || !($fb_id = $fb_id[0])) {
 43+ $fb_id = FBConnectDB::getFacebookIDs( $user->getId() );
 44+ if ( !count( $fb_id ) || !( $fb_id = $fb_id[0] ) ) {
4545 return true;
4646 }
4747 // TODO: Something with the Facebook ID stored in $fb_id
@@ -48,22 +48,24 @@
4949 }
5050 return true;
5151 }
52 -
 52+
5353 /**
5454 * Checks the autopromote condition for a user.
5555 */
5656 static function AutopromoteCondition( $cond_type, $args, $user, &$result ) {
5757 global $wgFbUserRightsFromGroup;
58 -
 58+
5959 // Probably a redundant check, but with PHP you can never be too sure...
60 - if (!$wgFbUserRightsFromGroup) {
 60+ if ( !$wgFbUserRightsFromGroup ) {
6161 // No group to pull rights from, so the user can't be a member
6262 $result = false;
6363 return true;
6464 }
65 - $types = array(APCOND_FB_INGROUP => 'member',
66 - APCOND_FB_ISOFFICER => 'officer',
67 - APCOND_FB_ISADMIN => 'admin');
 65+ $types = array(
 66+ APCOND_FB_INGROUP => 'member',
 67+ APCOND_FB_ISOFFICER => 'officer',
 68+ APCOND_FB_ISADMIN => 'admin'
 69+ );
6870 $type = $types[$cond_type];
6971 switch( $type ) {
7072 case 'member':
@@ -71,22 +73,22 @@
7274 case 'admin':
7375 global $facebook;
7476 // Connect to the Facebook API and ask if the user is in the group
75 - $rights = $facebook->getGroupRights($user);
 77+ $rights = $facebook->getGroupRights( $user );
7678 $result = $rights[$type];
7779 }
78 -
 80+
7981 return true;
8082 }
81 -
 83+
8284 /**
83 - * Injects some important CSS and Javascript into the <head> of the page.
 85+ * Injects some important CSS and JavaScript into the <head> of the page.
8486 */
8587 public static function BeforePageDisplay( &$out, &$sk ) {
8688 global $wgVersion, $wgFbLogo, $wgFbScript, $wgFbExtensionScript, $wgFbIncludeJquery,
8789 $wgScriptPath, $wgJsMimeType, $wgStyleVersion;
88 -
 90+
8991 // Asynchronously load the Facebook Connect JavaScript SDK before the page's content
90 - if(!empty($wgFbScript)){
 92+ if( !empty( $wgFbScript ) ) {
9193 $out->prependHTML('
9294 <div id="fb-root"></div>
9395 <script>
@@ -96,56 +98,56 @@
9799 </script>' . "\n"
98100 );
99101 }
100 -
 102+
101103 // Inserts list of global JavaScript variables if necessary
102 - if (self::MGVS_hack( $mgvs_script )) {
 104+ if ( self::MGVS_hack( $mgvs_script ) ) {
103105 $out->addInlineScript( $mgvs_script );
104106 }
105 -
 107+
106108 // Add a Facebook logo to the class .mw-fblink
107 - $style = empty($wgFbLogo) ? '' : <<<STYLE
 109+ $style = empty( $wgFbLogo ) ? '' : <<<STYLE
108110 /* Add a pretty logo to Facebook links */
109111 .mw-fblink {
110112 background: url($wgFbLogo) top left no-repeat !important;
111113 padding-left: 17px !important;
112114 }
113115 STYLE;
114 -
 116+
115117 // Things get a little simpler in 1.16...
116 - if (version_compare($wgVersion, '1.16', '>=')) {
 118+ if ( version_compare( $wgVersion, '1.16', '>=' ) ) {
117119 // Add a pretty Facebook logo if $wgFbLogo is set
118 - if ( !empty( $wgFbLogo) ) {
119 - $out->addInlineStyle($style);
 120+ if ( !empty( $wgFbLogo ) ) {
 121+ $out->addInlineStyle( $style );
120122 }
121 -
 123+
122124 // Don't include jQuery if it's already in use on the site
123125 #$out->includeJQuery();
124126 // Temporary workaround until until MW is bundled with jQuery 1.4.2:
125 - $out->addScriptFile('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
126 -
 127+ $out->addScriptFile( 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' );
 128+
127129 // Add the script file specified by $url
128 - if(!empty($wgFbExtensionScript)){
129 - $out->addScriptFile($wgFbExtensionScript);
 130+ if( !empty( $wgFbExtensionScript ) ) {
 131+ $out->addScriptFile( $wgFbExtensionScript );
130132 }
131133 } else {
132134 // Add a pretty Facebook logo if $wgFbLogo is set
133 - if ( !empty( $wgFbLogo) ) {
134 - $out->addScript('<style type="text/css">' . $style . '</style>');
 135+ if ( !empty( $wgFbLogo ) ) {
 136+ $out->addScript( '<style type="text/css">' . $style . '</style>' );
135137 }
136 -
 138+
137139 // Don't include jQuery if it's already in use on the site
138 - if (!empty($wgFbIncludeJquery)){
139 - $out->addScriptFile("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
 140+ if ( !empty( $wgFbIncludeJquery ) ) {
 141+ $out->addScriptFile( 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' );
140142 }
141 -
 143+
142144 // Add the script file specified by $url
143 - if(!empty($wgFbExtensionScript)){
144 - $out->addScript("<script type=\"$wgJsMimeType\" src=\"$wgFbExtensionScript?$wgStyleVersion\"></script>\n");
 145+ if( !empty( $wgFbExtensionScript ) ) {
 146+ $out->addScript( "<script type=\"$wgJsMimeType\" src=\"$wgFbExtensionScript?$wgStyleVersion\"></script>\n" );
145147 }
146148 }
147149 return true;
148150 }
149 -
 151+
150152 /**
151153 * Fired when MediaWiki is updated to allow FBConnect to update the database.
152154 * If the database type is supported, then a new tabled named 'user_fbconnect'
@@ -157,22 +159,22 @@
158160 global $wgDBtype, $wgDBprefix, $wgExtNewTables;
159161 $base = dirname( __FILE__ );
160162 if ( $wgDBtype == 'mysql' ) {
161 - $wgExtNewTables[] = array("{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.sql");
162 - } else if ( $wgDBtype == 'postgres' ) {
163 - $wgExtNewTables[] = array("{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.pg.sql");
 163+ $wgExtNewTables[] = array( "{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.sql" );
 164+ } elseif ( $wgDBtype == 'postgres' ) {
 165+ $wgExtNewTables[] = array( "{$wgDBprefix}user_fbconnect", "$base/fbconnect_table.pg.sql" );
164166 }
165167 return true;
166168 }
167 -
 169+
168170 /**
169171 * Adds several Facebook Connect variables to the page:
170 - *
 172+ *
171173 * fbAppId The application ID (see $wgFbAppId in config.php)
172174 * fbSession Assist the JavaScript SDK with loading the session
173175 * fbUseMarkup Should XFBML tags be rendered (see $wgFbUseMarkup in config.php)
174176 * fbLogo Facebook logo (see $wgFbLogo in config.php)
175177 * fbLogoutURL The URL to be redirected to on a disconnect
176 - *
 178+ *
177179 * This hook was added in MediaWiki version 1.14. See:
178180 * http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/Skin.php?view=log&pathrev=38397
179181 * If we are not at revision 38397 or later, this function is called from BeforePageDisplay
@@ -191,7 +193,7 @@
192194 $vars['wgPagequery'] = wfUrlencode( wfArrayToCGI( $query ) );
193195 return true;
194196 }
195 -
 197+
196198 /**
197199 * Hack: Run MakeGlobalVariablesScript for backwards compatability.
198200 * The MakeGlobalVariablesScript hook was added to MediaWiki 1.14 in revision 38397:
@@ -199,23 +201,22 @@
200202 */
201203 private static function MGVS_hack( &$script ) {
202204 global $wgVersion, $IP;
203 - if (version_compare($wgVersion, '1.14', '<')) {
204 - $svn = SpecialVersion::getSvnRevision($IP);
 205+ if ( version_compare( $wgVersion, '1.14', '<' ) ) {
 206+ $svn = SpecialVersion::getSvnRevision( $IP );
205207 // if !$svn, then we must be using 1.13.x (as opposed to 1.14alpha+)
206 - if (!$svn || $svn < 38397)
207 - {
208 - $script = "";
 208+ if ( !$svn || $svn < 38397 ) {
 209+ $script = '';
209210 $vars = array();
210 - wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
 211+ wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
211212 foreach( $vars as $name => $value ) {
212 - $script .= "\t\tvar $name = " . json_encode($value) . ";\n";
 213+ $script .= "\t\tvar $name = " . json_encode( $value ) . ";\n";
213214 }
214215 return true;
215216 }
216217 }
217218 return false;
218219 }
219 -
 220+
220221 /**
221222 * Installs a parser hook for every tag reported by FBConnectXFBML::availableTags().
222223 * Accomplishes this by asking FBConnectXFBML to create a hook function that then
@@ -224,29 +225,29 @@
225226 public static function ParserFirstCallInit( &$parser ) {
226227 $pHooks = FBConnectXFBML::availableTags();
227228 foreach( $pHooks as $tag ) {
228 - $parser->setHook( $tag, FBConnectXFBML::createParserHook( $tag ));
 229+ $parser->setHook( $tag, FBConnectXFBML::createParserHook( $tag ) );
229230 }
230231 return true;
231232 }
232 -
 233+
233234 /**
234235 * Modify the user's persinal toolbar (in the upper right).
235 - *
 236+ *
236237 * TODO: Better 'returnto' code
237238 */
238239 public static function PersonalUrls( &$personal_urls, &$wgTitle ) {
239240 global $facebook, $wgUser, $wgLang, $wgShowIPinHeader;
240241 global $wgFbPersonalUrls, $wgFbConnectOnly;
241 - wfLoadExtensionMessages('FBConnect');
242 -
 242+ wfLoadExtensionMessages( 'FBConnect' );
 243+
243244 /*
244245 * Personal URLs option: remove_user_talk_link
245246 */
246 - if ($wgFbPersonalUrls['remove_user_talk_link'] &&
247 - array_key_exists('mytalk', $personal_urls)) {
248 - unset($personal_urls['mytalk']);
 247+ if ( $wgFbPersonalUrls['remove_user_talk_link'] &&
 248+ array_key_exists( 'mytalk', $personal_urls ) ) {
 249+ unset( $personal_urls['mytalk'] );
249250 }
250 -
 251+
251252 // If the user is logged in and connected
252253 if ( $wgUser->isLoggedIn() && $facebook->getSession() ) {
253254 /*
@@ -256,37 +257,38 @@
257258 // Start with the real name in the database
258259 $name = $wgUser->getRealName();
259260 // Ask Facebook for the real name
260 - if (!$name || $name == '') {
 261+ if ( !$name || $name == '' ) {
261262 try {
262263 // This might fail if we load a stale session from cookies
263 - $fbUser = $facebook->api('/me');
 264+ $fbUser = $facebook->api( '/me' );
264265 $name = $fbUser['name'];
265 - } catch (FacebookApiException $e) {
266 - error_log($e);
 266+ } catch ( FacebookApiException $e ) {
 267+ error_log( $e );
267268 }
268269 }
269270 // Make sure we were able to get a name from the database or Facebook
270 - if ($name && $name != '') {
 271+ if ( $name && $name != '' ) {
271272 $personal_urls['userpage']['text'] = $name;
272273 }
273274 }
274275 // Replace logout link with a button to disconnect from Facebook Connect
275 - if( empty( $wgFbPersonalUrls['hide_logout_of_fb'] ) ){
 276+ if( empty( $wgFbPersonalUrls['hide_logout_of_fb'] ) ) {
276277 unset( $personal_urls['logout'] );
277278 $personal_urls['fblogout'] = array(
278279 'text' => wfMsg( 'fbconnect-logout' ),
279280 'href' => '#',
280 - 'active' => false );
 281+ 'active' => false
 282+ );
281283 }
282 -
 284+
283285 /*
284286 * Personal URLs option: link_back_to_facebook
285287 */
286 - if ($wgFbPersonalUrls['link_back_to_facebook']) {
 288+ if ( $wgFbPersonalUrls['link_back_to_facebook'] ) {
287289 try {
288 - $fbUser = $facebook->api('/me');
 290+ $fbUser = $facebook->api( '/me' );
289291 $link = $fbUser['link'];
290 - } catch (FacebookApiException $e) {
 292+ } catch ( FacebookApiException $e ) {
291293 $link = 'http://www.facebook.com/profile.php?id=' .
292294 $facebook->getUser();
293295 }
@@ -298,76 +300,74 @@
299301 }
300302 }
301303 // User is logged in but not Connected
302 - else if ($wgUser->isLoggedIn()) {
 304+ elseif ( $wgUser->isLoggedIn() ) {
303305 /*
304306 * Personal URLs option: hide_convert_button
305307 */
306 - if (!$wgFbPersonalUrls['hide_convert_button']) {
 308+ if ( !$wgFbPersonalUrls['hide_convert_button'] ) {
307309 $personal_urls['fbconvert'] = array(
308310 'text' => wfMsg( 'fbconnect-convert' ),
309 - 'href' => SpecialConnect::getTitleFor('Connect', 'Convert')->getLocalURL(
310 - 'returnto=' . $wgTitle->getPrefixedURL()),
 311+ 'href' => SpecialConnect::getTitleFor( 'Connect', 'Convert' )->getLocalURL(
 312+ 'returnto=' . $wgTitle->getPrefixedURL() ),
311313 'active' => $wgTitle->isSpecial( 'Connect' )
312314 );
313315 }
314 - }
315 - // User is not logged in
316 - else {
 316+ } else { // User is not logged in
317317 /*
318318 * Personal URLs option: hide_connect_button
319319 */
320 - if (!$wgFbPersonalUrls['hide_connect_button']) {
 320+ if ( !$wgFbPersonalUrls['hide_connect_button'] ) {
321321 // Add an option to connect via Facebook Connect
322322 $personal_urls['fbconnect'] = array(
323323 'text' => wfMsg( 'fbconnect-connect' ),
324324 'href' => SpecialPage::getTitleFor( 'Connect' )->
325 - getLocalUrl( 'returnto=' . $wgTitle->getPrefixedURL() ),
326 - 'active' => $wgTitle->isSpecial('Connect')
 325+ getLocalUrl( 'returnto=' . $wgTitle->getPrefixedURL() ),
 326+ 'active' => $wgTitle->isSpecial( 'Connect' )
327327 );
328328 }
329 -
 329+
330330 // Remove other personal toolbar links
331331 if ( !empty( $wgFbConnectOnly ) ) {
332 - foreach (array('login', 'anonlogin') as $k) {
333 - if (array_key_exists($k, $personal_urls)) {
334 - unset($personal_urls[$k]);
 332+ foreach ( array( 'login', 'anonlogin') as $k ) {
 333+ if ( array_key_exists( $k, $personal_urls ) ) {
 334+ unset( $personal_urls[$k] );
335335 }
336336 }
337337 }
338338 }
339339 return true;
340340 }
341 -
 341+
342342 /**
343343 * Modify the preferences form. At the moment, we simply turn the user name
344 - * into a link to the user's facebook profile.
345 - *
 344+ * into a link to the user's Facebook profile.
 345+ *
346346 * TODO!
347347 */
348348 public static function RenderPreferencesForm( $form, $output ) {
349349 global $facebook, $wgUser;
350 -
 350+
351351 // This hook no longer seems to work...
352352 return true;
353 -
 353+
354354 if( $facebook->getSession() ) {
355355 $html = $output->getHTML();
356356 $name = $wgUser->getName();
357357 $i = strpos( $html, $name );
358 - if ($i !== FALSE) {
 358+ if ( $i !== false ) {
359359 // If the user has a valid Facebook ID, link to the Facebook profile
360360 try {
361 - $fbUser = $facebook->api('/me');
 361+ $fbUser = $facebook->api( '/me' );
362362 // Replace the old output with the new output
363363 $html = substr( $html, 0, $i ) .
364364 preg_replace("/$name/", "$name (<a href=\"$fbUser[link]\" " .
365 - "class='mw-userlink mw-fbconnectuser'>" .
366 - wfMsg('fbconnect-link-to-profile') . "</a>",
367 - substr( $html, $i ), 1);
 365+ "class='mw-userlink mw-fbconnectuser'>" .
 366+ wfMsg('fbconnect-link-to-profile') . '</a>',
 367+ substr( $html, $i ), 1 );
368368 $output->clearHTML();
369369 $output->addHTML( $html );
370 - } catch (FacebookApiException $e) {
371 - error_log($e);
 370+ } catch ( FacebookApiException $e ) {
 371+ error_log( $e );
372372 }
373373 }
374374 }
@@ -380,17 +380,17 @@
381381 */
382382 static function SpecialListusersFormatRow( &$item, $row ) {
383383 global $fbSpecialUsers;
384 -
 384+
385385 // Only modify Facebook Connect users
386 - if (!$fbSpecialUsers ||
387 - !count(FBConnectDB::getFacebookIDs(User::newFromName($row->user_name)))) {
 386+ if ( !$fbSpecialUsers ||
 387+ !count( FBConnectDB::getFacebookIDs( User::newFromName( $row->user_name ) ) ) ) {
388388 return true;
389389 }
390 -
 390+
391391 // Look to see if class="..." appears in the link
392392 $regs = array();
393393 preg_match( '/^([^>]*?)class=(["\'])([^"]*)\2(.*)/', $item, $regs );
394 - if (count( $regs )) {
 394+ if ( count( $regs ) ) {
395395 // If so, append " mw-userlink" to the end of the class list
396396 $item = $regs[1] . "class=$regs[2]$regs[3] mw-userlink$regs[2]" . $regs[4];
397397 } else {
@@ -400,25 +400,25 @@
401401 }
402402 return true;
403403 }
404 -
 404+
405405 /**
406406 * Adds some info about the governing Facebook group to the header form of
407407 * Special:ListUsers.
408408 */
409409 static function SpecialListusersHeaderForm( &$pager, &$out ) {
410410 global $wgFbUserRightsFromGroup, $facebook, $wgFbLogo;
411 - if ( empty($wgFbUserRightsFromGroup) ) {
 411+ if ( empty( $wgFbUserRightsFromGroup ) ) {
412412 return true;
413413 }
414 -
 414+
415415 // TODO: Do we need to verify the Facebook session here?
416 -
 416+
417417 $gid = $wgFbUserRightsFromGroup;
418418 // Connect to the API and get some info about the group
419419 try {
420 - $group = $facebook->api('/' . $gid);
421 - } catch (FacebookApiException $e) {
422 - error_log($e);
 420+ $group = $facebook->api( '/' . $gid );
 421+ } catch ( FacebookApiException $e ) {
 422+ error_log( $e );
423423 }
424424 $out .= '
425425 <table style="border-collapse: collapse;">
@@ -437,7 +437,7 @@
438438 </table>";
439439 return true;
440440 }
441 -
 441+
442442 /**
443443 * Removes Special:UserLogin and Special:CreateAccount from the list of
444444 * special pages if $wgFbConnectOnly is set to true.
@@ -445,21 +445,21 @@
446446 static function SpecialPage_initList( &$aSpecialPages ) {
447447 global $wgFbConnectOnly;
448448 if ( !empty( $wgFbConnectOnly) ) {
449 - $aSpecialPages['Userlogin'] = array('SpecialRedirectToSpecial', 'UserLogin',
450 - 'Connect', false, array('returnto', 'returntoquery'));
 449+ $aSpecialPages['Userlogin'] = array( 'SpecialRedirectToSpecial', 'UserLogin',
 450+ 'Connect', false, array( 'returnto', 'returntoquery' ) );
451451 // Used in 1.12.x and above
452 - $aSpecialPages['CreateAccount'] = array('SpecialRedirectToSpecial',
453 - 'CreateAccount', 'Connect');
 452+ $aSpecialPages['CreateAccount'] = array( 'SpecialRedirectToSpecial',
 453+ 'CreateAccount', 'Connect' );
454454 }
455455 return true;
456456 }
457 -
 457+
458458 /**
459459 * HACK: Please someone fix me or explain why this is necessary!
460 - *
 460+ *
461461 * Unstub $wgUser to avoid race conditions and stop returning stupid false
462462 * negatives!
463 - *
 463+ *
464464 * This might be due to a bug in User::getRights() [called from
465465 * User::isAllowed('read'), called from Title::userCanRead()], where mRights
466466 * is retrieved from an uninitialized user. From my probing, it seems that
@@ -470,12 +470,12 @@
471471 * that instead of being null, mRights is equal to the array
472472 * (createaccount, createpage, createtalk, writeapi).
473473 */
474 - static function userCan (&$title, &$user, $action, &$result) {
 474+ static function userCan( &$title, &$user, $action, &$result ) {
475475 // Unstub $wgUser (is there a more succinct way to do this?)
476476 $user->getId();
477477 return true;
478478 }
479 -
 479+
480480 /**
481481 * Removes the 'createaccount' right from users if $wgFbConnectOnly is true.
482482 */
@@ -491,28 +491,28 @@
492492 }
493493 return true;
494494 }
495 -
 495+
496496 /**
497497 * If the user isn't logged in, try to auto-authenticate via Facebook
498498 * Connect. The Single Sign On magic of FBConnect happens in this function.
499499 */
500500 static function UserLoadFromSession( $user, &$result ) {
501501 global $facebook, $wgCookiePrefix, $wgTitle, $wgOut, $wgUser;
502 -
 502+
503503 // Check to see if the user can be logged in from Facebook
504504 $fbId = $facebook->getSession() ? $facebook->getUser() : 0;
505505 // Check to see if the user can be loaded from the session
506 - $localId = isset($_COOKIE["{$wgCookiePrefix}UserID"]) ?
507 - intval($_COOKIE["{$wgCookiePrefix}UserID"]) :
508 - (isset($_SESSION['wsUserID']) ? $_SESSION['wsUserID'] : 0);
509 -
 506+ $localId = isset( $_COOKIE["{$wgCookiePrefix}UserID"] ) ?
 507+ intval( $_COOKIE["{$wgCookiePrefix}UserID"] ) :
 508+ ( isset( $_SESSION['wsUserID'] ) ? $_SESSION['wsUserID'] : 0 );
 509+
510510 // Case: Not logged into Facebook, but logged into the wiki
511 - if (!$fbId && $localId) {
512 - $mwUser = User::newFromId($localId);
 511+ if ( !$fbId && $localId ) {
 512+ $mwUser = User::newFromId( $localId );
513513 // If the user was Connected, the JS should have logged them out...
514514 // TODO: test to see if they logged in normally (with a password)
515515 #if (FBConnectDB::userLoggedInWithPassword($mwUser)) return true;
516 - if (count(FBConnectDB::getFacebookIDs($mwUser))) {
 516+ if ( count( FBConnectDB::getFacebookIDs( $mwUser ) ) ) {
517517 // Oh well, they shouldn't be here anyways; silently log them out
518518 $mwUser->logout();
519519 // Defaults have just been loaded, so save some time
@@ -520,23 +520,23 @@
521521 }
522522 }
523523 // Case: Logged into Facebook, not logged into the wiki
524 - else if ($fbId && !$localId) {
 524+ elseif ( $fbId && !$localId ) {
525525 // Look up the MW ID of the Facebook user
526 - $mwUser = FBConnectDB::getUser($fbId);
 526+ $mwUser = FBConnectDB::getUser( $fbId );
527527 $id = $mwUser ? $mwUser->getId() : 0;
528528 // If the user doesn't exist, ask them to name their new account
529 - if (!$id) {
 529+ if ( !$id ) {
530530 // TODO: $wgTitle was empty for some strange reason...
531 - if (!empty( $wgTitle )) {
532 - $returnto = $wgTitle->isSpecial('Userlogout') || $wgTitle->isSpecial('Connect') ?
 531+ if ( !empty( $wgTitle ) ) {
 532+ $returnto = $wgTitle->isSpecial( 'Userlogout' ) || $wgTitle->isSpecial( 'Connect' ) ?
533533 '' : 'returnto=' . $wgTitle->getPrefixedURL();
534534 } else {
535535 $returnto = '';
536536 }
537537 // Don't redirect if we're on certain special pages
538 - if ($returnto != '') {
 538+ if ( $returnto != '' ) {
539539 // Redirect to Special:Connect so the Facebook user can choose a nickname
540 - $wgOut->redirect($wgUser->getSkin()->makeSpecialUrl('Connect', $returnto));
 540+ $wgOut->redirect( $wgUser->getSkin()->makeSpecialUrl( 'Connect', $returnto ) );
541541 }
542542 } else {
543543 // TODO: To complete the SSO experience, this should log the user on
@@ -546,7 +546,7 @@
547547 $user->mFrom = 'id';
548548 $user->load();
549549 // Update user's info from Facebook
550 - $fbUser = new FBConnectUser($mwUser);
 550+ $fbUser = new FBConnectUser( $mwUser );
551551 $fbUser->updateFromFacebook();
552552 // Authentification okay, no need to continue with User::loadFromSession()
553553 $result = true;
@@ -557,31 +557,35 @@
558558 // Case: Logged into Facebook, logged into the wiki
559559 return true;
560560 }
561 -
 561+
562562 /**
563 - *
564 - *
 563+ *
 564+ *
565565 */
566 - static function initPreferencesExtensionForm($user, &$wgExtensionPreferences) {
567 - $id = FBConnectDB::getFacebookIDs($user);
568 - if( count($id) > 0 ) {
 566+ static function initPreferencesExtensionForm( $user, &$wgExtensionPreferences ) {
 567+ $id = FBConnectDB::getFacebookIDs( $user );
 568+ if( count( $id ) > 0 ) {
569569 //action="/index.php?title=TechTeam_QA_8_Wiki&amp;action=submit" method="post"
570570 $action = SpecialPage::getTitleFor( 'Connect' );
571 - $action = $action->getFullURL("action=disconnect");
572 - $html = Xml::openElement("div");
573 - $html .= Xml::openElement( "form", array("submit" => "post", "action" => $action) );
574 - $html .= Xml::element( "input", array("type" => "submit", "value" => "Disconent"), '', true );
575 - $html .= Xml::closeElement( "form" );
576 - $html .= Xml::closeElement( "div" );
 571+ $action = $action->getFullURL( 'action=disconnect' );
 572+ $html = Xml::openElement( 'div' );
 573+ $html .= Xml::openElement( 'form', array( 'submit' => 'post', 'action' => $action ) );
 574+ $html .= Xml::element( 'input', array( 'type' => 'submit', 'value' => 'Disconent' ), '', true );
 575+ $html .= Xml::closeElement( 'form' );
 576+ $html .= Xml::closeElement( 'div' );
577577 $wgExtensionPreferences = array_merge(
578578 array(
579579 array(
580580 'name' => 'ssasasas',
581581 'section' => 'fbconnect-prefstext',
582582 'html' => $html,
583 - 'type' => PREF_CUSTOM_HTML_T) ), $wgExtensionPreferences);
 583+ 'type' => PREF_CUSTOM_HTML_T
 584+ )
 585+ ),
 586+ $wgExtensionPreferences
 587+ );
584588 }
585 -
 589+
586590 return true;
587591 }
588592 }
Index: trunk/extensions/FBConnect/FBConnectDB.php
@@ -1,16 +1,16 @@
22 <?php
3 -/*
 3+/**
44 * Copyright © 2010 Garrett Brown <http://www.mediawiki.org/wiki/User:Gbruin>
55 * This program is free software; you can redistribute it and/or modify
66 * it under the terms of the GNU General Public License as published by
77 * the Free Software Foundation; either version 2 of the License, or
88 * (at your option) any later version.
9 - *
 9+ *
1010 * This program is distributed in the hope that it will be useful,
1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 * GNU General Public License for more details.
14 - *
 14+ *
1515 * You should have received a copy of the GNU General Public License along
1616 * with this program. If not, see <http://www.gnu.org/licenses/>.
1717 */
@@ -26,15 +26,15 @@
2727
2828 /**
2929 * Class FBConnectDB
30 - *
 30+ *
3131 * This class abstracts the manipulation of the custom table used by this
3232 * extension. If $wgDBprefix is set, this class will pull from the translated
3333 * tables. If the table 'users_fbconnect' does not exist in your database
3434 * you will receive errors like this:
35 - *
 35+ *
3636 * Database error from within function "FBConnectDB::getUser". Database
3737 * returned error "Table 'user_fbconnect' doesn't exist".
38 - *
 38+ *
3939 * In this case, you will need to fix this by running the MW updater:
4040 * >php maintenance/update.php
4141 */
@@ -70,7 +70,7 @@
7171 $prefix = self::getPrefix();
7272 // NOTE: Do not just pass this dbr into getUserByDB since that function prevents
7373 // rewriting of the database name for shared tables.
74 - $dbr = & wfGetDB( DB_SLAVE, array(), self::sharedDB() );
 74+ $dbr = & wfGetDB( DB_SLAVE, array(), self::sharedDB() );
7575 $id = $dbr->selectField(
7676 array( "{$prefix}user_fbconnect" ),
7777 array( 'user_id' ),
@@ -84,12 +84,12 @@
8585 return null;
8686 }
8787 }
88 -
 88+
8989 /**
9090 * Add a User <-> Facebook ID association to the database.
9191 */
9292 public static function addFacebookID( $user, $fbid ) {
93 - wfProfileIn(__METHOD__);
 93+ wfProfileIn( __METHOD__ );
9494
9595 $prefix = self::getPrefix();
9696 $dbw = wfGetDB( DB_MASTER, array(), self::sharedDB() );
@@ -101,9 +101,9 @@
102102 ),
103103 __METHOD__
104104 );
105 - wfProfileOut(__METHOD__);
 105+ wfProfileOut( __METHOD__ );
106106 }
107 -
 107+
108108 /**
109109 * Remove a User <-> Facebook ID association from the database.
110110 */
@@ -120,7 +120,7 @@
121121 );
122122 return (bool) $dbw->affectedRows();
123123 }
124 -
 124+
125125 /**
126126 * Estimates the total number of User <-> Facebook ID associations in the
127127 * database. If there are no users, then the estimate will probably be 1.
@@ -129,28 +129,28 @@
130130 $prefix = self::getPrefix();
131131 $dbr = wfGetDB( DB_SLAVE, array(), self::sharedDB() );
132132 // An estimate is good enough for choosing a unique nickname
133 - $count = $dbr->estimateRowCount("{$prefix}user_fbconnect");
 133+ $count = $dbr->estimateRowCount( "{$prefix}user_fbconnect" );
134134 // Avoid returning 0 or -1
135135 return $count >= 1 ? $count : 1;
136136 }
137 -
 137+
138138 /**
139139 * Returns the name of the shared database, if one is in use for the Facebook
140140 * Connect users table. Note that 'user_fbconnect' (without respecting
141141 * $wgSharedPrefix) is added to $wgSharedTables in FBConnect::init by default.
142142 * This function can also be used as a test for whether a shared database for
143143 * Facebook Connect users is in use.
144 - *
 144+ *
145145 * See also: <http://www.mediawiki.org/wiki/Manual:Shared_database>
146146 */
147147 private static function sharedDB() {
148148 global $wgExternalSharedDB;
149 - if (!empty($wgExternalSharedDB)) {
150 - return $wgExternalSharedDB;
 149+ if ( !empty( $wgExternalSharedDB ) ) {
 150+ return $wgExternalSharedDB;
151151 }
152 - return false;
 152+ return false;
153153 }
154 -
 154+
155155 /**
156156 * Returns the table prefix name, either $wgDBprefix, $wgSharedPrefix
157157 * depending on whether a shared database is in use.
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnWatchArticle.i18n.php
@@ -1,5 +1,5 @@
22 <?php
33
44 $messages['en'] = array(
5 - 'tog-fbconnect-push-allow-OnWatchArticle' => "Post to my Facebook News Feed when I follow (watchlist) an article.",
 5+ 'tog-fbconnect-push-allow-OnWatchArticle' => 'Post to my Facebook News Feed when I follow (watchlist) an article.',
66 );
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnAddImage.i18n.php
@@ -1,5 +1,5 @@
22 <?php
33
44 $messages['en'] = array(
5 - 'tog-fbconnect-push-allow-OnAddImage' => "Post to my Facebook News Feed when I add an image.",
 5+ 'tog-fbconnect-push-allow-OnAddImage' => 'Post to my Facebook News Feed when I add an image.',
66 );
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnWatchArticle.php
@@ -6,30 +6,29 @@
77 */
88
99 global $wgExtensionMessagesFiles;
10 -$pushDir = dirname(__FILE__) . '/';
11 -$wgExtensionMessagesFiles['FBPush_OnWatchArticle'] = $pushDir . "FBPush_OnWatchArticle.i18n.php";
 10+$pushDir = dirname( __FILE__ ) . '/';
 11+$wgExtensionMessagesFiles['FBPush_OnWatchArticle'] = $pushDir . 'FBPush_OnWatchArticle.i18n.php';
1212
1313 class FBPush_OnWatchArticle extends FBConnectPushEvent {
1414 protected $isAllowedUserPreferenceName = 'fbconnect-push-allow-OnWatchArticle'; // must correspond to an i18n message that is 'tog-[the value of the string on this line]'.
15 -
16 - public function init(){
 15+
 16+ public function init() {
1717 global $wgHooks;
18 - wfProfileIn(__METHOD__);
 18+ wfProfileIn( __METHOD__ );
1919
2020 $wgHooks['ArticleSaveComplete'][] = 'FBPush_OnWatchArticle::articleCountPagesAddedInLastHour';
21 - wfLoadExtensionMessages('FBPush_OnWatchArticle');
22 -
23 - wfProfileOut(__METHOD__);
 21+ wfLoadExtensionMessages( 'FBPush_OnWatchArticle' );
 22+
 23+ wfProfileOut( __METHOD__ );
2424 }
25 -
26 -
27 - public static function articleCountPagesAddedInLastHour(&$article, &$user, $text, $summary,$flag, $fake1, $fake2, &$flags, $revision, &$status, $baseRevId){
 25+
 26+ public static function articleCountPagesAddedInLastHour( &$article, &$user, $text, $summary,$flag, $fake1, $fake2, &$flags, $revision, &$status, $baseRevId ) {
2827 global $wgContentNamespaces;
29 - wfProfileIn(__METHOD__);
30 - if( in_array($article->getTitle()->getNamespace(), $wgContentNamespaces) ) {
31 - self::pushEvent($article->getTitle()->getText(), $article->getTitle()->getFullURL(), "Read more");
 28+ wfProfileIn( __METHOD__ );
 29+ if( in_array( $article->getTitle()->getNamespace(), $wgContentNamespaces ) ) {
 30+ self::pushEvent( $article->getTitle()->getText(), $article->getTitle()->getFullURL(), 'Read more' );
3231 }
33 - wfProfileOut(__METHOD__);
 32+ wfProfileOut( __METHOD__ );
3433 return true;
3534 }
3635 }
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnAddImage.php
@@ -6,17 +6,17 @@
77 */
88
99 global $wgExtensionMessagesFiles;
10 -$pushDir = dirname(__FILE__) . '/';
11 -$wgExtensionMessagesFiles['FBPush_OnAddImage'] = $pushDir . "FBPush_OnAddImage.i18n.php";
 10+$pushDir = dirname( __FILE__ ) . '/';
 11+$wgExtensionMessagesFiles['FBPush_OnAddImage'] = $pushDir . 'FBPush_OnAddImage.i18n.php';
1212
1313 class FBPush_OnAddImage extends FBConnectPushEvent {
1414 protected $isAllowedUserPreferenceName = 'fbconnect-push-allow-OnAddImage'; // must correspond to an i18n message that is 'tog-[the value of the string on this line]'.
15 -
16 - public function init(){
17 - wfProfileIn(__METHOD__);
1815
19 - wfLoadExtensionMessages('FBPush_OnAddImage');
20 -
21 - wfProfileOut(__METHOD__);
 16+ public function init() {
 17+ wfProfileIn( __METHOD__ );
 18+
 19+ wfLoadExtensionMessages( 'FBPush_OnAddImage' );
 20+
 21+ wfProfileOut( __METHOD__ );
2222 }
2323 }
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnLargeEdit.i18n.php
@@ -1,5 +1,5 @@
22 <?php
33
44 $messages['en'] = array(
5 - 'tog-fbconnect-push-allow-OnLargeEdit' => "Post to my Facebook News Feed when I make an edit over ".FBPush_OnLargeEdit::getMinCharsToPush()." characters.",
 5+ 'tog-fbconnect-push-allow-OnLargeEdit' => 'Post to my Facebook News Feed when I make an edit over ' . FBPush_OnLargeEdit::getMinCharsToPush() . ' characters.',
66 );
Index: trunk/extensions/FBConnect/pushEvents/FBPush_OnLargeEdit.php
@@ -6,22 +6,22 @@
77 */
88
99 global $wgExtensionMessagesFiles;
10 -$pushDir = dirname(__FILE__) . '/';
11 -$wgExtensionMessagesFiles['FBPush_OnLargeEdit'] = $pushDir . "FBPush_OnLargeEdit.i18n.php";
 10+$pushDir = dirname( __FILE__ ) . '/';
 11+$wgExtensionMessagesFiles['FBPush_OnLargeEdit'] = $pushDir . 'FBPush_OnLargeEdit.i18n.php';
1212
1313 class FBPush_OnLargeEdit extends FBConnectPushEvent {
1414 protected $isAllowedUserPreferenceName = 'fbconnect-push-allow-OnLargeEdit'; // must correspond to an i18n message that is 'tog-[the value of the string on this line]'.
1515 static private $MIN_CHARS_TO_PUSH = 300; // number of chars that need to be changed
16 -
17 - static public function getMinCharsToPush(){
 16+
 17+ static public function getMinCharsToPush() {
1818 return self::$MIN_CHARS_TO_PUSH;
1919 }
20 -
21 - public function init(){
22 - wfProfileIn(__METHOD__);
2320
24 - wfLoadExtensionMessages('FBPush_OnLargeEdit');
25 -
26 - wfProfileOut(__METHOD__);
 21+ public function init() {
 22+ wfProfileIn( __METHOD__ );
 23+
 24+ wfLoadExtensionMessages( 'FBPush_OnLargeEdit' );
 25+
 26+ wfProfileOut( __METHOD__ );
2727 }
2828 }
Index: trunk/extensions/FBConnect/fbconnect.js
@@ -4,36 +4,36 @@
55 * it under the terms of the GNU General Public License as published by
66 * the Free Software Foundation; either version 2 of the License, or
77 * (at your option) any later version.
8 - *
 8+ *
99 * This program is distributed in the hope that it will be useful,
1010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 * GNU General Public License for more details.
13 - *
 13+ *
1414 * You should have received a copy of the GNU General Public License along
1515 * with this program. If not, see <http://www.gnu.org/licenses/>.
1616 */
1717
1818 /**
1919 * fbconnect.js and fbconnect-min.js
20 - *
 20+ *
2121 * FBConnect relies on several different libraries and frameworks for its
2222 * JavaScript code. Each framework has its own method to verify that the proper
2323 * code won't be called before it's ready. (Below, lambda represents a named or
2424 * anonymous function.)
25 - *
 25+ *
2626 * MediaWiki: addOnloadHook(lambda);
2727 * This function manages an array of window.onLoad event handlers to be
2828 * called be called by a MediaWiki script when the window is fully loaded.
2929 * Because the DOM may be ready before the window (due to large images to
3030 * be downloaded), a faster alternative is JQuery's document-ready function.
31 - *
 31+ *
3232 * Facebook JavaScript SDK: window.fbAsyncInit = lambda;
3333 * This global variable is called when the JavaScript SDK is fully
3434 * initialized asynchronously to the document's state. This might be long
3535 * after the document is finished rendering the first time the script is
3636 * downloaded. Subsequently, it may even be called before the DOM is ready.
37 - *
 37+ *
3838 * jQuery: $(document).ready(lambda);
3939 * Self-explanatory; to be called when the DOM is ready to be manipulated.
4040 * Typically this should occur sooner than MediaWiki's addOnloadHook
@@ -56,15 +56,17 @@
5757
5858 // NOTE: Auth.login doesn't appear to work anymore.
5959 // The onlogin attribute of the fb:login-buttons is being used instead.
60 -
 60+
6161 // Register a function for when the user logs out of Facebook
62 - FB.Event.subscribe('auth.logout', function(response) {
 62+ FB.Event.subscribe( 'auth.logout', function( response ) {
6363 // TODO: Internationalize
64 - var login = confirm("Not logged in.\n\nYou have been loggout out of " +
65 - "Facebook. Press OK to log in via Facebook Connect " +
66 - "again, or press Cancel to stay on the current page.");
67 - if (login) {
68 - window.location = window.wgArticlePath.replace(/\$1/, "Special:Connect");
 64+ var login = confirm(
 65+ "Not logged in.\n\nYou have been loggout out of " +
 66+ "Facebook. Press OK to log in via Facebook Connect " +
 67+ "again, or press Cancel to stay on the current page."
 68+ );
 69+ if ( login ) {
 70+ window.location = window.wgArticlePath.replace( /\$1/, 'Special:Connect' );
6971 }
7072 });
7173 };
@@ -74,15 +76,15 @@
7577 */
7678 $(document).ready(function() {
7779 // Add a pretty logo to Facebook links
78 - $('#pt-fbconnect,#pt-fblink,#pt-fbconvert').addClass('mw-fblink');
79 -
 80+ $( '#pt-fbconnect,#pt-fblink,#pt-fbconvert' ).addClass( 'mw-fblink' );
 81+
8082 // Add the logout behavior to the "Logout of Facebook" button
81 - $('#pt-fblogout').click(function() {
 83+ $( '#pt-fblogout' ).click( function() {
8284 // TODO: Where did the fancy DHTML window go? Maybe consider jQuery Alert Dialogs:
8385 // http://abeautifulsite.net/2008/12/jquery-alert-dialogs/
84 - var logout = confirm("You are logging out of both this site and Facebook.");
85 - if (logout) {
86 - FB.logout(function(response) {
 86+ var logout = confirm( 'You are logging out of both this site and Facebook.' );
 87+ if ( logout ) {
 88+ FB.logout( function( response ) {
8789 window.location = window.fbLogoutURL;
8890 });
8991 }
@@ -96,7 +98,7 @@
9799 *
98100 * TODO: Also set the value for 'returntoquery'!!
99101 */
100 -function sendToConnectOnLogin(){
101 - var destUrl = wgServer + wgScript + "?title=Special:Connect&returnto=" + wgPageName + "&returntoquery=" + wgPagequery;
 102+function sendToConnectOnLogin() {
 103+ var destUrl = wgServer + wgScript + '?title=Special:Connect&returnto=' + wgPageName + '&returntoquery=' + wgPagequery;
102104 window.location.href = destUrl;
103105 }
Index: trunk/extensions/FBConnect/config.default.php
@@ -9,7 +9,7 @@
1010 * This will be seen by users when they sign up for your site.
1111 * 3. Enter the Site URL and Locale, then click "Create application".
1212 * 4. Copy the displayed App ID and Secret into this config file.
13 - *
 13+ *
1414 * Optionally, you may customize your application:
1515 * A. Click "developer dashboard" link on the previous screen or visit:
1616 * http://www.facebook.com/developers/apps.php
@@ -43,7 +43,7 @@
4444 * $wgAllowExternalImages with the added benefit that all photos are screened
4545 * against Facebook's Code of Conduct <http://www.facebook.com/codeofconduct.php>
4646 * and subject to dynamic privacy. To disable just <fb:photo> tags, set this to false.
47 - *
 47+ *
4848 * Disabled until the JavaScript SDK supports <fb:photo> tags.
4949 */
5050 #$wgFbAllowFacebookImages = true;
@@ -51,11 +51,11 @@
5252 /**
5353 * For easier wiki rights management, create a group on Facebook and place the
5454 * group ID here. Three new implicit groups will be created:
55 - *
 55+ *
5656 * fb-groupie A member of the specified group
5757 * fb-officer A group member with an officer title
5858 * fb-admin An administrator of the Facebook group
59 - *
 59+ *
6060 * By default, they map to User, Bureaucrat and Sysop privileges, respectively.
6161 * Users will automatically be promoted or demoted when their membership, title
6262 * or admin status is modified from the group page within Facebook.
@@ -68,7 +68,7 @@
6969
7070 /**
7171 * Options regarding the personal toolbar (in the upper right).
72 - *
 72+ *
7373 * == Key == == Effect ==
7474 * hide_connect_button Hides the "Log in with Facebook Connect" button.
7575 * hide_convert_button Hides "Connect this account with Facebook" for non-
@@ -80,7 +80,7 @@
8181 * "in front" of Facebook.
8282 * remove_user_talk_link Remove link to user's talk page
8383 * use_real_name_from_fb Show the real name for all Connected users
84 - *
 84+ *
8585 * Additionally, use $wgShowIPinHeader to hide the IP and its talk link.
8686 * For more information, see <http://www.mediawiki.org/wiki/Manual:$wgShowIPinHeader>.
8787 */
@@ -105,7 +105,7 @@
106106 * a beta release, changes to the APIs may be made on a regular basis. If you
107107 * use FBConnect on your production website, you may wish to insulate yourself
108108 * from these changes by downloading and hosting your own copy of the library.
109 - *
 109+ *
110110 * For more info, see <http://developers.facebook.com/docs/reference/javascript/>
111111 */
112112 $wgFbScript = 'http://connect.facebook.net/en_US/all.js';
@@ -173,9 +173,9 @@
174174 * of the push events to use.
175175 */
176176 $wgFbEnablePushToFacebook = false;
177 -if(!empty($wgFbEnablePushToFacebook)){
178 - $fbPushDir = dirname(__FILE__) . '/pushEvents/';
179 -
 177+if( !empty( $wgFbEnablePushToFacebook ) ) {
 178+ $fbPushDir = dirname( __FILE__ ) . '/pushEvents/';
 179+
180180 // Convenience loop for push event classes in the fbPushDir directory
181181 // whose file-name corresponds to the class-name. To add a push event
182182 // which does not meet these criteria, just explicitly add it below.
@@ -184,7 +184,7 @@
185185 'FBPush_OnLargeEdit',
186186 'FBPush_OnWatchArticle',
187187 );
188 - foreach($pushEventClassNames as $pClassName){
 188+ foreach( $pushEventClassNames as $pClassName ) {
189189 $fbPushEventClasses[] = $pClassName;
190190 $wgAutoloadClasses[$pClassName] = $fbPushDir . "$pClassName.php";
191191 }

Status & tagging log