Use AuthManager on special pages
[lhc/web/wiklou.git] / includes / skins / SkinTemplate.php
index d6e0377..10d9cb9 100644 (file)
@@ -45,6 +45,14 @@ class SkinTemplate extends Skin {
         */
        public $template = 'QuickTemplate';
 
+       public $thispage;
+       public $titletxt;
+       public $userpage;
+       public $thisquery;
+       public $loggedin;
+       public $username;
+       public $userpageUrlDetails;
+
        /**
         * Add specific styles for this skin
         *
@@ -248,6 +256,31 @@ class SkinTemplate extends Skin {
 
        }
 
+       /**
+        * Wrap the body text with language information and identifiable element
+        *
+        * @param Title $title
+        * @param string $html body text
+        * @return string html
+        */
+       protected function wrapHTML( $title, $html ) {
+               # An ID that includes the actual body text; without categories, contentSub, ...
+               $realBodyAttribs = [ 'id' => 'mw-content-text' ];
+
+               # Add a mw-content-ltr/rtl class to be able to style based on text direction
+               # when the content is different from the UI language, i.e.:
+               # not for special pages or file pages AND only when viewing
+               if ( !in_array( $title->getNamespace(), [ NS_SPECIAL, NS_FILE ] ) &&
+                       Action::getActionName( $this ) === 'view' ) {
+                       $pageLang = $title->getPageViewLanguage();
+                       $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
+                       $realBodyAttribs['dir'] = $pageLang->getDir();
+                       $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
+               }
+
+               return Html::rawElement( 'div', $realBodyAttribs, $html );
+       }
+
        /**
         * initialize various variables and generate the template
         *
@@ -424,22 +457,8 @@ class SkinTemplate extends Skin {
                $tpl->set( 'sitenotice', $this->getSiteNotice() );
                $tpl->set( 'bottomscripts', $this->bottomScripts() );
                $tpl->set( 'printfooter', $this->printSource() );
-
-               # An ID that includes the actual body text; without categories, contentSub, ...
-               $realBodyAttribs = [ 'id' => 'mw-content-text' ];
-
-               # Add a mw-content-ltr/rtl class to be able to style based on text direction
-               # when the content is different from the UI language, i.e.:
-               # not for special pages or file pages AND only when viewing
-               if ( !in_array( $title->getNamespace(), [ NS_SPECIAL, NS_FILE ] ) &&
-                       Action::getActionName( $this ) === 'view' ) {
-                       $pageLang = $title->getPageViewLanguage();
-                       $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
-                       $realBodyAttribs['dir'] = $pageLang->getDir();
-                       $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
-               }
-
-               $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
+               // Wrap the bodyText with #mw-content-text element
+               $out->mBodytext = $this->wrapHTML( $title, $out->mBodytext );
                $tpl->setRef( 'bodytext', $out->mBodytext );
 
                $language_urls = $this->getLanguages();
@@ -644,19 +663,35 @@ class SkinTemplate extends Skin {
                        $loginlink = $this->getUser()->isAllowed( 'createaccount' ) && $useCombinedLoginLink
                                ? 'nav-login-createaccount'
                                : 'pt-login';
-                       $is_signup = $request->getText( 'type' ) == 'signup';
 
-                       $login_url = [
-                               'text' => $this->msg( $loginlink )->text(),
-                               'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
-                               'active' => $title->isSpecial( 'Userlogin' )
-                                       && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
-                       ];
-                       $createaccount_url = [
-                               'text' => $this->msg( 'pt-createaccount' )->text(),
-                               'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
-                               'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
-                       ];
+                       // TODO remove this after AuthManager is stable
+                       global $wgDisableAuthManager;
+                       if ( $wgDisableAuthManager ) {
+                               $is_signup = $request->getText( 'type' ) == 'signup';
+                               $login_url = [
+                                       'text' => $this->msg( $loginlink )->text(),
+                                       'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
+                                       'active' => $title->isSpecial( 'Userlogin' )
+                                               && ( $loginlink == 'nav-login-createaccount' || !$is_signup ),
+                               ];
+                               $createaccount_url = [
+                                       'text' => $this->msg( 'pt-createaccount' )->text(),
+                                       'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ),
+                                       'active' => $title->isSpecial( 'Userlogin' ) && $is_signup,
+                               ];
+                       } else {
+                               $login_url = [
+                                       'text' => $this->msg( $loginlink )->text(),
+                                       'href' => self::makeSpecialUrl( 'Userlogin', $returnto ),
+                                       'active' => $title->isSpecial( 'Userlogin' ) ||
+                                               $title->isSpecial( 'CreateAccount' ) && $useCombinedLoginLink,
+                               ];
+                               $createaccount_url = [
+                                       'text' => $this->msg( 'pt-createaccount' )->text(),
+                                       'href' => self::makeSpecialUrl( 'CreateAccount', $returnto ),
+                                       'active' => $title->isSpecial( 'CreateAccount' ),
+                               ];
+                       }
 
                        // No need to show Talk and Contributions to anons if they can't contribute!
                        if ( User::groupHasPermission( '*', 'edit' ) ) {