Fixed some doxygen warnings
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index 7d45881..50dfefe 100644 (file)
@@ -1,22 +1,28 @@
 <?php
+/**
+ * Base class for template-based skins
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
 if ( ! defined( 'MEDIAWIKI' ) )
        die( 1 );
 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# http://www.gnu.org/copyleft/gpl.html
-
 /**
  * Wrapper object for MediaWiki's localization functions,
  * to be passed to the template engine.
@@ -110,7 +116,7 @@ class SkinTemplate extends Skin {
         * and eventually it spits out some HTML. Should have interface
         * roughly equivalent to PHPTAL 0.7.
         *
-        * @param $callback string (or file)
+        * @param $classname string (or file)
         * @param $repository string: subdirectory where we keep template files
         * @param $cache_dir string
         * @return object
@@ -297,11 +303,13 @@ class SkinTemplate extends Skin {
                $tpl->setRef( 'scriptpath', $wgScriptPath );
                $tpl->setRef( 'serverurl', $wgServer );
                $tpl->setRef( 'logopath', $wgLogo );
-               $tpl->setRef( 'lang', $wgContLanguageCode );
-               $tpl->set( 'dir', $wgContLang->getDir() );
-               $tpl->set( 'rtl', $wgContLang->isRTL() );
+
+               $lang = wfUILang();
+               $tpl->set( 'lang', $lang->getCode() );
+               $tpl->set( 'dir', $lang->getDir() );
+               $tpl->set( 'rtl', $lang->isRTL() );
+
                $tpl->set( 'capitalizeallnouns', $wgLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
-               $tpl->set( 'langname', $wgContLang->getLanguageName( $wgContLanguageCode ) );
                $tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) );
                $tpl->set( 'username', $wgUser->isAnon() ? null : $this->username );
                $tpl->setRef( 'userpage', $this->userpage );
@@ -416,6 +424,11 @@ class SkinTemplate extends Skin {
                $tpl->set( 'bottomscripts', $this->bottomScripts() );
 
                $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
+               global $wgBetterDirectionality;
+               if ( $wgBetterDirectionality ) {
+                       $realBodyAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $wgContLang->getDir() );
+                       $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
+               }
                $out->mBodytext .= $printfooter . $this->generateDebugHTML();
                $tpl->setRef( 'bodytext', $out->mBodytext );
 
@@ -433,6 +446,7 @@ class SkinTemplate extends Skin {
                                                'href' => $nt->getFullURL(),
                                                'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
                                                                        $wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
+                                               'title' => $nt->getText(),
                                                'class' => $class
                                        );
                                }
@@ -486,7 +500,7 @@ class SkinTemplate extends Skin {
         * an error object of the appropriate type.
         * For the base class, assume strings all around.
         *
-        * @param mixed $str
+        * @param $str Mixed
         * @private
         */
        function printOrError( $str ) {
@@ -703,7 +717,7 @@ class SkinTemplate extends Skin {
                                $istalkclass = $istalk?' istalk':'';
                                $content_actions['edit'] = array(
                                        'class' => ( ( ( $action == 'edit' or $action == 'submit' ) and $section != 'new' ) ? 'selected' : '' ) . $istalkclass,
-                                       'text' => $this->mTitle->exists()
+                                       'text' => ( $this->mTitle->exists() || ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $this->mTitle->getText() ) ) )
                                                ? wfMsg( 'edit' )
                                                : wfMsg( 'create' ),
                                        'href' => $this->mTitle->getLocalUrl( $this->editUrlOptions() )
@@ -719,7 +733,7 @@ class SkinTemplate extends Skin {
                                                );
                                        }
                                }
-                       } elseif ( $this->mTitle->isKnown() ) {
+                       } elseif ( $this->mTitle->hasSourceText() ) {
                                $content_actions['viewsource'] = array(
                                        'class' => ($action == 'edit') ? 'selected' : false,
                                        'text' => wfMsg( 'viewsource' ),
@@ -867,7 +881,7 @@ class SkinTemplate extends Skin {
         */
        function buildNavUrls() {
                global $wgUseTrackbacks, $wgOut, $wgUser, $wgRequest;
-               global $wgEnableUploads, $wgUploadNavigationUrl;
+               global $wgUploadNavigationUrl;
 
                wfProfileIn( __METHOD__ );
 
@@ -877,7 +891,7 @@ class SkinTemplate extends Skin {
                $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
                if( $wgUploadNavigationUrl ) {
                        $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
-               } elseif( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
+               } elseif( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
                        $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
                } else {
                        $nav_urls['upload'] = false;
@@ -930,8 +944,10 @@ class SkinTemplate extends Skin {
                }
 
                if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
-                       $id = User::idFromName( $this->mTitle->getText() );
-                       $ip = User::isIP( $this->mTitle->getText() );
+                       $parts = explode( '/', $this->mTitle->getText() );
+                       $rootUser = $parts[0];
+                       $id = User::idFromName( $rootUser );
+                       $ip = User::isIP( $rootUser );
                } else {
                        $id = 0;
                        $ip = false;
@@ -939,7 +955,7 @@ class SkinTemplate extends Skin {
 
                if( $id || $ip ) { # both anons and non-anons have contribs list
                        $nav_urls['contributions'] = array(
-                               'href' => self::makeSpecialUrlSubpage( 'Contributions', $this->mTitle->getText() )
+                               'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
                        );
 
                        if( $id ) {
@@ -947,7 +963,7 @@ class SkinTemplate extends Skin {
                                $nav_urls['log'] = array(
                                        'href' => $logPage->getLocalUrl(
                                                array(
-                                                       'user' => $this->mTitle->getText()
+                                                       'user' => $rootUser
                                                )
                                        )
                                );
@@ -957,7 +973,7 @@ class SkinTemplate extends Skin {
 
                        if ( $wgUser->isAllowed( 'block' ) ) {
                                $nav_urls['blockip'] = array(
-                                       'href' => self::makeSpecialUrlSubpage( 'Blockip', $this->mTitle->getText() )
+                                       'href' => self::makeSpecialUrlSubpage( 'Blockip', $rootUser )
                                );
                        } else {
                                $nav_urls['blockip'] = false;
@@ -970,7 +986,7 @@ class SkinTemplate extends Skin {
                $nav_urls['emailuser'] = false;
                if( $this->showEmailUser( $id ) ) {
                        $nav_urls['emailuser'] = array(
-                               'href' => self::makeSpecialUrlSubpage( 'Emailuser', $this->mTitle->getText() )
+                               'href' => self::makeSpecialUrlSubpage( 'Emailuser', $rootUser )
                        );
                }
                wfProfileOut( __METHOD__ );