Index: trunk/extensions/OpenID/OpenIDProvider.body.php |
— | — | @@ -1,12 +1,26 @@ |
2 | 2 | <?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 | + */ |
6 | 23 | class OpenIDProvider { |
7 | | - var $id; |
8 | | - var $name; |
9 | | - var $label; |
10 | | - var $url; |
| 24 | + protected $id, $name, $label, $url; |
11 | 25 | |
12 | 26 | function __construct( $id, $name, $label, $url ) { |
13 | 27 | $this->id = $id; |
— | — | @@ -15,36 +29,41 @@ |
16 | 30 | $this->url = $url; |
17 | 31 | } |
18 | 32 | |
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 ) { |
20 | 39 | global $wgOpenIDShowProviderIcons, $wgOpenIDIconPath; |
21 | 40 | |
22 | 41 | if ( $wgOpenIDShowProviderIcons ) |
23 | 42 | { |
24 | 43 | return '<a id="openid_provider_' . $this->id . '_icon" title="' . $this->name . '"' . |
25 | 44 | ' href="javascript: openid.show(\'' . $this->id . '\');"' . |
26 | | - ' class="openid_' . ( $isLarge ? 'large' : 'small' ) . '_btn' . |
| 45 | + ' class="openid_' . $classSize . '_btn' . |
27 | 46 | ( $this->id == 'openid' ? ' openid_selected' : '' ) . '"></a>'; |
28 | 47 | } |
29 | 48 | else |
30 | 49 | { |
31 | 50 | return '<a id="openid_provider_' . $this->id . '_link" title="' . $this->name . '"' . |
32 | 51 | ' href="javascript: openid.show(\'' . $this->id . '\');"' . |
33 | | - ' class="openid_' . ( $isLarge ? 'large' : 'small' ) . '_link' . |
| 52 | + ' class="openid_' . $classSize . '_link' . |
34 | 53 | ( $this->id == 'openid' ? ' openid_selected' : '' ) . '">' . $this->name . '</a>'; |
35 | 54 | } |
36 | 55 | } |
37 | | - function getLargeButtonHTML() { return $this->getButtonHTML( true ); } |
38 | | - function getSmallButtonHTML() { return $this->getButtonHTML( false ); } |
39 | 56 | |
40 | | - function getLoginFormHTML() { |
41 | | - global $wgCookiePrefix; |
| 57 | + public function getLargeButtonHTML() { return $this->getButtonHTML( 'large' ); } |
| 58 | + public function getSmallButtonHTML() { return $this->getButtonHTML( 'small' ); } |
42 | 59 | |
| 60 | + public function getLoginFormHTML() { |
43 | 61 | $html = '<div id="provider_form_' . $this->id . '"' . |
44 | 62 | ( $this->id == 'openid' ? '' : ' style="display:none"' ) . '>' . |
45 | 63 | '<div><label for="openid_url">' . $this->label . '</label></div>'; |
46 | 64 | |
47 | 65 | if ( $this->id == 'openid' ) { |
48 | | - $url = isset( $_COOKIE[$wgCookiePrefix.'OpenID'] ) ? htmlspecialchars( $_COOKIE[$wgCookiePrefix.'OpenID'] ) : ''; |
| 66 | + global $wgRequest; |
| 67 | + $url = htmlspecialchars( $wgRequest->getCookie( 'OpenID', null, '' ) ); |
49 | 68 | $html .= '<input type="text" name="openid_url" id="openid_url" size="45" value="' . $url . '" />'; |
50 | 69 | $html .= Xml::submitButton( wfMsg( 'userlogin' ) ); |
51 | 70 | } else { |
— | — | @@ -61,8 +80,11 @@ |
62 | 81 | return $html; |
63 | 82 | } |
64 | 83 | |
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() { |
67 | 89 | return array( |
68 | 90 | new self( 'openid', 'OpenID', wfMsg( 'openid-provider-label-openid' ), '{URL}' ), |
69 | 91 | new self( 'google', 'Google', wfMsg( 'openid-provider-label-google' ), 'https://www.google.com/accounts/o8/id' ), |
— | — | @@ -71,8 +93,11 @@ |
72 | 94 | ); |
73 | 95 | } |
74 | 96 | |
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() { |
77 | 102 | return array( |
78 | 103 | new self( 'myopenid', 'MyOpenID', wfMsg( 'openid-provider-label-other-username', 'MyOpenID' ), |
79 | 104 | 'http://{username}.myopenid.com/' ), |
— | — | @@ -80,9 +105,6 @@ |
81 | 106 | 'http://{username}.livejournal.com/' ), |
82 | 107 | new self( 'vox', 'VOX', wfMsg( 'openid-provider-label-other-username', 'VOX' ), |
83 | 108 | '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/'), |
87 | 109 | new self( 'blogger', 'Blogger', wfMsg( 'openid-provider-label-other-username', 'Blogger' ), |
88 | 110 | 'http://{username}.blogspot.com/' ), |
89 | 111 | new self( 'flickr', 'Flickr', wfMsg( 'openid-provider-label-other-username', 'Flickr' ), |