Extension:FBConnect/SpecialConnect.php

Source code for my Facebook Connect extension until it gets committed to SVN, at which point it will be available here. ';		$wgOut->addWikiText( $heading ); }	/**	 * Renders two side-by-side boxes that differ based on who is logged in. * 	 * Anonymous user:    Draws the Special:Userlogin box and a Connect button. * Non-connected user: Draws the Special:Userlogin and a Merge box. * Connected user:    Draws some info about the user and a Logout box. */	function renderForms { global $wgOut, $wgAuth, $wgUser; $wgOut->addHTML('			 '); }	/**	 * Draws a Facebook-style info box. *	 * @param string $h1  The name of the message for the title of the box * @param string $msg The name of the message for the content, or blank to use $html * @param string $html The HTML to use if $msg is blank, or the $1 argument of the given message */	function drawBox( $h1, $msg, $html = '' ) { global $wgOut; $wgOut->addHTML('							 '); if( $html !== '' ) { $wgOut->addHTML( '' ); }					$wgOut->addHTML('				 '); $wgOut->addWikiText( wfMsg( $h1 )); $wgOut->addHTML('				'); $button = ''; if( $msg !== '' ) { $wgOut->addWikiText( wfMsg( $msg, $button )); } else { if( $html == '' ) $html = $button; $wgOut->addHTML( ' ' . $html . ' ' ); }					$wgOut->addHTML('			 '); }	/**	 * Creates a Login Form template object and propogates it with parameters. */	function createLoginForm { global $wgUser, $wgEnableEmail, $wgEmailConfirmToEdit, $wgCookiePrefix, $wgCookieExpiration, $wgAuth; $template = new UserloginTemplate; // Pull the name from $wgUser or cookies if( $wgUser->isLoggedIn ) $name = $wgUser->getName; else if( isset( $_COOKIE[$wgCookiePrefix. 'UserName'] )) $name = $_COOKIE[$wgCookiePrefix. 'UserName']; else $name = null; // Alias some common URLs for $action and $link $loginTitle = self::getTitleFor( 'Userlogin' ); $this_href = wfUrlencode( $this->getTitle ); // Action URL that gets posted to $action = $loginTitle->getLocalUrl( 'action=submitlogin&type=login&returnto=' . $this_href ); // Don't show a "create account" link if the user is not allowed to create an account if ($wgUser->isAllowed( 'createaccount' )) { $link_href = htmlspecialchars( $loginTitle->getLocalUrl( 'type=signup&returnto='. $this_href )); $link_text = wfMsgHtml( 'nologinlink' ); $link = wfMsgHtml( 'nologin', "$link_text" ); } else $link = ''; // Set the appropriate options for this template $template->set( 'header', '' ); $template->set( 'name', $name ); $template->set( 'action', $action ); $template->set( 'link', $link ); $template->set( 'message', '' ); $template->set( 'messagetype', 'none' ); $template->set( 'useemail', $wgEnableEmail ); $template->set( 'emailrequired', $wgEmailConfirmToEdit ); $template->set( 'canreset', $wgAuth->allowPasswordChange ); $template->set( 'canremember', ( $wgCookieExpiration > 0 ) ); $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) ); // Spit out the form we just made return $template; } }