r89381 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89380‎ | r89381 | r89382 >
Date:02:44, 3 June 2011
Author:demon
Status:deferred
Tags:
Comment:
Minor tweaks to OpenIDProvider: visibility, remove bool param, raw $_COOKIE usage, docs
Modified paths:
  • /trunk/extensions/OpenID/OpenIDProvider.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/OpenIDProvider.body.php
@@ -1,12 +1,26 @@
22 <?php
3 -if ( !defined( 'MEDIAWIKI' ) )
4 - exit( 1 );
5 -
 3+/**
 4+ * OpenIDProvider.php -- Class referring to an individual OpenID provider
 5+ *
 6+ * This program is free software; you can redistribute it and/or modify
 7+ * it under the terms of the GNU General Public License as published by
 8+ * the Free Software Foundation; either version 2 of the License, or
 9+ * (at your option) any later version.
 10+ *
 11+ * This program is distributed in the hope that it will be useful,
 12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14+ * GNU General Public License for more details.
 15+ *
 16+ * You should have received a copy of the GNU General Public License
 17+ * along with this program; if not, write to the Free Software
 18+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 19+ *
 20+ * @file
 21+ * @ingroup Extensions
 22+ */
623 class OpenIDProvider {
7 - var $id;
8 - var $name;
9 - var $label;
10 - var $url;
 24+ protected $id, $name, $label, $url;
1125
1226 function __construct( $id, $name, $label, $url ) {
1327 $this->id = $id;
@@ -15,36 +29,41 @@
1630 $this->url = $url;
1731 }
1832
19 - function getButtonHTML( $isLarge ) {
 33+ /**
 34+ * Get the HTML for the OpenID provider buttons
 35+ * @param $classSize String Size for the openid_ class, either large or small
 36+ * @return string
 37+ */
 38+ private function getButtonHTML( $classSize ) {
2039 global $wgOpenIDShowProviderIcons, $wgOpenIDIconPath;
2140
2241 if ( $wgOpenIDShowProviderIcons )
2342 {
2443 return '<a id="openid_provider_' . $this->id . '_icon" title="' . $this->name . '"' .
2544 ' href="javascript: openid.show(\'' . $this->id . '\');"' .
26 - ' class="openid_' . ( $isLarge ? 'large' : 'small' ) . '_btn' .
 45+ ' class="openid_' . $classSize . '_btn' .
2746 ( $this->id == 'openid' ? ' openid_selected' : '' ) . '"></a>';
2847 }
2948 else
3049 {
3150 return '<a id="openid_provider_' . $this->id . '_link" title="' . $this->name . '"' .
3251 ' href="javascript: openid.show(\'' . $this->id . '\');"' .
33 - ' class="openid_' . ( $isLarge ? 'large' : 'small' ) . '_link' .
 52+ ' class="openid_' . $classSize . '_link' .
3453 ( $this->id == 'openid' ? ' openid_selected' : '' ) . '">' . $this->name . '</a>';
3554 }
3655 }
37 - function getLargeButtonHTML() { return $this->getButtonHTML( true ); }
38 - function getSmallButtonHTML() { return $this->getButtonHTML( false ); }
3956
40 - function getLoginFormHTML() {
41 - global $wgCookiePrefix;
 57+ public function getLargeButtonHTML() { return $this->getButtonHTML( 'large' ); }
 58+ public function getSmallButtonHTML() { return $this->getButtonHTML( 'small' ); }
4259
 60+ public function getLoginFormHTML() {
4361 $html = '<div id="provider_form_' . $this->id . '"' .
4462 ( $this->id == 'openid' ? '' : ' style="display:none"' ) . '>' .
4563 '<div><label for="openid_url">' . $this->label . '</label></div>';
4664
4765 if ( $this->id == 'openid' ) {
48 - $url = isset( $_COOKIE[$wgCookiePrefix.'OpenID'] ) ? htmlspecialchars( $_COOKIE[$wgCookiePrefix.'OpenID'] ) : '';
 66+ global $wgRequest;
 67+ $url = htmlspecialchars( $wgRequest->getCookie( 'OpenID', null, '' ) );
4968 $html .= '<input type="text" name="openid_url" id="openid_url" size="45" value="' . $url . '" />';
5069 $html .= Xml::submitButton( wfMsg( 'userlogin' ) );
5170 } else {
@@ -61,8 +80,11 @@
6281 return $html;
6382 }
6483
65 - # large ones
66 - static function getLargeProviders() {
 84+ /**
 85+ * Get the list of major OpenID providers
 86+ * @return array of OpenIDProvider
 87+ */
 88+ public static function getLargeProviders() {
6789 return array(
6890 new self( 'openid', 'OpenID', wfMsg( 'openid-provider-label-openid' ), '{URL}' ),
6991 new self( 'google', 'Google', wfMsg( 'openid-provider-label-google' ), 'https://www.google.com/accounts/o8/id' ),
@@ -71,8 +93,11 @@
7294 );
7395 }
7496
75 - # smaller ones
76 - static function getSmallProviders() {
 97+ /**
 98+ * Get a list of lesser-known OpenID providers
 99+ * @return array of OpenIDProvider
 100+ */
 101+ public static function getSmallProviders() {
77102 return array(
78103 new self( 'myopenid', 'MyOpenID', wfMsg( 'openid-provider-label-other-username', 'MyOpenID' ),
79104 'http://{username}.myopenid.com/' ),
@@ -80,9 +105,6 @@
81106 'http://{username}.livejournal.com/' ),
82107 new self( 'vox', 'VOX', wfMsg( 'openid-provider-label-other-username', 'VOX' ),
83108 'http://{username}.vox.com/' ),
84 -# wordpress.com doesn't work for some reason
85 -# new self('wordpress', 'Wordpress.com', wfMsg('openid-provider-label-other-username', 'Wordpress.com'),
86 -# 'http://{username}.wordpress.com/'),
87109 new self( 'blogger', 'Blogger', wfMsg( 'openid-provider-label-other-username', 'Blogger' ),
88110 'http://{username}.blogspot.com/' ),
89111 new self( 'flickr', 'Flickr', wfMsg( 'openid-provider-label-other-username', 'Flickr' ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r89382Forgot to press save, last bit of r89381demon02:45, 3 June 2011

Status & tagging log