}
/**
- * @param $name string
- * @param $urlaction string
+ * Make a URL for a Special Page using the given query and protocol.
+ *
+ * If $proto is set to null, make a local URL. Otherwise, make a full
+ * URL with the protocol specified.
+ *
+ * @param $name string Name of the Special page
+ * @param $urlaction string Query to append
+ * @param $proto Protocol to use or null for a local URL
* @return String
*/
- static function makeSpecialUrl( $name, $urlaction = '' ) {
+ static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
$title = SpecialPage::getSafeTitleFor( $name );
- return $title->getLocalURL( $urlaction );
+ if( is_null( $proto ) ) {
+ return $title->getLocalURL( $urlaction );
+ } else {
+ return $title->getFullURL( $urlaction, false, $proto );
+ }
}
/**
$is_signup = $request->getText( 'type' ) == 'signup';
# anonlogin & login are the same
+ global $wgSecureLogin;
+ $proto = $wgSecureLogin ? PROTO_HTTPS : null;
+
$login_url = array(
'text' => $this->msg( $loginlink )->text(),
- 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
- 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup )
+ 'href' => self::makeSpecialUrl( 'Userlogin', $returnto, $proto ),
+ 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
+ 'class' => $wgSecureLogin ? 'link-https' : ''
+ );
+ $createaccount_url = array(
+ 'text' => $this->msg( 'createaccount' )->text(),
+ 'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup", $proto ),
+ 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
+ 'class' => $wgSecureLogin ? 'link-https' : ''
);
- if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
- $createaccount_url = array(
- 'text' => $this->msg( 'createaccount' )->text(),
- 'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
- 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup
- );
- }
- global $wgServer, $wgSecureLogin;
- if( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) {
- $title = SpecialPage::getTitleFor( 'Userlogin' );
- $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL() );
- $login_url['href'] = $https_url;
- # @todo FIXME: Class depends on skin
- $login_url['class'] = 'link-https';
- if ( isset( $createaccount_url ) ) {
- $https_url = preg_replace( '/^http:/', 'https:',
- $title->getFullURL( 'type=signup' ) );
- $createaccount_url['href'] = $https_url;
- # @todo FIXME: Class depends on skin
- $createaccount_url['class'] = 'link-https';
- }
- }
- if ( isset( $createaccount_url ) ) {
+ if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) {
$personal_urls['createaccount'] = $createaccount_url;
}
* See getLocalURL for the arguments.
*
* @see self::getLocalURL
+ * @see wfExpandUrl
+ * @param $proto Protocol type to use in URL
* @return String the URL
*/
- public function getFullURL( $query = '', $query2 = false ) {
+ public function getFullURL( $query = '', $query2 = false, $proto = PROTO_RELATIVE ) {
$query = self::fixUrlQueryArgs( $query, $query2 );
# Hand off all the decisions on urls to getLocalURL
# Expand the url to make it a full url. Note that getLocalURL has the
# potential to output full urls for a variety of reasons, so we use
# wfExpandUrl instead of simply prepending $wgServer
- $url = wfExpandUrl( $url, PROTO_RELATIVE );
+ $url = wfExpandUrl( $url, $proto );
# Finally, add the fragment.
$url .= $this->getFragmentForURL();