/**
	 * Displays the main login form
	 */
	function loginForm() {
		global $wgOut, $wgOpenIDShowProviderIcons, $wgOpenIDOnly;

		$wgOut->addModules( $wgOpenIDShowProviderIcons ? 'ext.openid.icons' : 'ext.openid.plain' );

		$formsHTML = '';

		$largeButtonsHTML = '<div id="openid_large_providers">';
		foreach ( OpenIDProvider::getLargeProviders() as $provider ) {
			$largeButtonsHTML .= $provider->getLargeButtonHTML();
			$formsHTML .= $provider->getLoginFormHTML();
		}
		$largeButtonsHTML .= '</div>';

		$smallButtonsHTML = '';
		if ( $wgOpenIDShowProviderIcons ) {
			$smallButtonsHTML .= '<div id="openid_small_providers_icons">';
			foreach ( OpenIDProvider::getSmallProviders() as $provider ) {
				$smallButtonsHTML .= $provider->getSmallButtonHTML();
				$formsHTML .= $provider->getLoginFormHTML();
			}
			$smallButtonsHTML .= '</div>';
		} else {
			$smallButtonsHTML .= '<div id="openid_small_providers_links">';
			$smallButtonsHTML .= '<ul class="openid_small_providers_block">';
			$small = OpenIDProvider::getSmallProviders();

			$i = 0;
			$break = true;
			foreach ( $small as $provider ) {
				if ( $break && $i > count( $small ) / 2 ) {
					$smallButtonsHTML .= '</ul><ul class="openid_small_providers_block">';
					$break = false;
				}

				$smallButtonsHTML .= '<li>' . $provider->getSmallButtonHTML() . '</li>';

				$formsHTML .= $provider->getLoginFormHTML();
				$i++;
			}
			$smallButtonsHTML .= '</ul>';
			$smallButtonsHTML .= '</div>';
		}

		$wgOut->addHTML(
			Xml::openElement( 'form', array( 'id' => 'openid_form', 'action' => $this->getTitle()->getLocalUrl(), 'method' => 'post', 'onsubmit' => 'openid.update()' ) ) .
			Xml::fieldset( wfMsg( 'openid-login-or-create-account' ) ) .
			$largeButtonsHTML .
			'<div id="openid_input_area">' .
			$formsHTML .
			'</div>' .
			$smallButtonsHTML .
			Xml::closeElement( 'fieldset' ) . Xml::closeElement( 'form' )
		);
		$wgOut->addWikiMsg( 'openidlogininstructions' );
		if ( $wgOpenIDOnly ) {
			$wgOut->addWikiMsg( 'openidlogininstructions-openidloginonly' );
		} else {
			$wgOut->addWikiMsg( 'openidlogininstructions-passwordloginallowed' );
		}
	}
Esempio n. 2
0
 /**
  * Displays the main login form
  */
 function loginForm()
 {
     global $wgOut, $wgScriptPath, $wgOpenIDShowProviderIcons;
     $oidScriptPath = $wgScriptPath . '/extensions/OpenID';
     $wgOut->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => $oidScriptPath . ($wgOpenIDShowProviderIcons ? '/skin/openid.css' : '/skin/openid-plain.css')));
     $wgOut->addScript('<script type="text/javascript" src="' . $oidScriptPath . '/skin/openid-combined-min.js"></script>' . "\n");
     $formsHTML = '';
     $largeButtonsHTML = '<div id="openid_large_providers">';
     foreach (OpenIDProvider::getLargeProviders() as $provider) {
         $largeButtonsHTML .= $provider->getLargeButtonHTML();
         $formsHTML .= $provider->getLoginFormHTML();
     }
     $largeButtonsHTML .= '</div>';
     $smallButtonsHTML = '';
     if ($wgOpenIDShowProviderIcons) {
         $smallButtonsHTML .= '<div id="openid_small_providers_icons">';
         foreach (OpenIDProvider::getSmallProviders() as $provider) {
             $smallButtonsHTML .= $provider->getSmallButtonHTML();
             $formsHTML .= $provider->getLoginFormHTML();
         }
         $smallButtonsHTML .= '</div>';
     } else {
         $smallButtonsHTML .= '<div id="openid_small_providers_links">';
         $smallButtonsHTML .= '<ul class="openid_small_providers_block">';
         $small = OpenIDProvider::getSmallProviders();
         $i = 0;
         $break = true;
         foreach ($small as $provider) {
             if ($break && $i > count($small) / 2) {
                 $smallButtonsHTML .= '</ul><ul class="openid_small_providers_block">';
                 $break = false;
             }
             $smallButtonsHTML .= '<li>' . $provider->getSmallButtonHTML() . '</li>';
             $formsHTML .= $provider->getLoginFormHTML();
             $i++;
         }
         $smallButtonsHTML .= '</ul>';
         $smallButtonsHTML .= '</div>';
     }
     $wgOut->addHTML(Xml::openElement('form', array('id' => 'openid_form', 'action' => $this->getTitle()->getLocalUrl(), 'method' => 'post', 'onsubmit' => 'openid.update()')) . Xml::openElement('fieldset', array(), wfMsg('openidsigninorcreateaccount')) . $largeButtonsHTML . '<div id="openid_input_area">' . $formsHTML . '</div>' . $smallButtonsHTML . Xml::closeElement('fieldset') . Xml::closeElement('form'));
     $wgOut->addWikiMsg('openidlogininstructions');
 }