Fixes bug #2632 : new image height when zooming without using "thumb" was not computed.
[lhc/web/wiklou.git] / includes / Skin.php
index 9d63c40..ad48e25 100644 (file)
@@ -11,7 +11,7 @@
  */
 if( defined( "MEDIAWIKI" ) ) {
 
-# See skin.doc
+# See skin.txt
 require_once( 'Linker.php' );
 require_once( 'Image.php' );
 
@@ -34,17 +34,6 @@ unset($matches);
 
 require_once( 'RecentChange.php' );
 
-global $wgLinkHolders;
-$wgLinkHolders = array(
-       'namespaces' => array(),
-       'dbkeys' => array(),
-       'queries' => array(),
-       'texts' => array(),
-       'titles' => array()
-);
-global $wgInterwikiLinkHolders;
-$wgInterwikiLinkHolders = array();
-
 /**
  * @todo document
  * @package MediaWiki
@@ -158,6 +147,7 @@ class Skin extends Linker {
 
                wfProfileIn( 'Skin::outputPage' );
                $this->initPage( $out );
+
                $out->out( $out->headElement() );
 
                $out->out( "\n<body" );
@@ -170,6 +160,7 @@ class Skin extends Linker {
                        $out->out( "<!-- Wiki debugging output:\n" .
                          $out->mDebugtext . "-->\n" );
                }
+
                $out->out( $this->beforeContent() );
 
                $out->out( $out->mBodytext . "\n" );
@@ -183,14 +174,14 @@ class Skin extends Linker {
        }
 
        function getHeadScripts() {
-               global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs;
-               $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
+               global $wgStylePath, $wgUser, $wgContLang, $wgAllowUserJs, $wgJsMimeType;
+               $r = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
                if( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
                        $userpage = $wgUser->getUserPage();
                        $userjs = htmlspecialchars( $this->makeUrl(
                                $userpage->getPrefixedText().'/'.$this->getSkinName().'.js',
-                               'action=raw&ctype=text/javascript'));
-                       $r .= '<script type="text/javascript" src="'.$userjs."\"></script>\n";
+                               'action=raw&ctype='.$wgJsMimeType));
+                       $r .= '<script type="'.$wgJsMimeType.'" src="'.$userjs."\"></script>\n";
                }
                return $r;
        }
@@ -208,17 +199,17 @@ class Skin extends Linker {
         */
        function userCanPreview( $action ) {
                global $wgTitle, $wgRequest, $wgUser;
-               
+
                if( $action != 'submit' )
                        return false;
                if( !$wgRequest->wasPosted() )
                        return false;
-               if( !$wgTitle->userCanEditCssJsSubpage() ) 
+               if( !$wgTitle->userCanEditCssJsSubpage() )
                        return false;
                return $wgUser->matchEditToken(
                        $wgRequest->getVal( 'wpEditToken' ) );
        }
-       
+
        # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
        function getUserStylesheet() {
                global $wgOut, $wgStylePath, $wgContLang, $wgUser, $wgRequest, $wgTitle, $wgAllowUserCss;
@@ -269,7 +260,7 @@ class Skin extends Linker {
 
                return $s . $this->reallyDoGetUserStyles();
        }
-       
+
        function reallyDoGetUserStyles() {
                global $wgUser;
                $s = '';
@@ -297,7 +288,7 @@ a.stub:after, #quickbar a.stub:after {
 END;
                }
                if( $wgUser->getOption( 'justify' ) ) {
-                       $s .= "#article { text-align: justify; }\n";
+                       $s .= "#article, #bodyContent { text-align: justify; }\n";
                }
                if( !$wgUser->getOption( 'showtoc' ) ) {
                        $s .= "#toc { display: none; }\n";
@@ -330,6 +321,12 @@ END;
 
                }
                $a['onload'] = $wgOut->getOnloadHandler();
+               if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
+                       if( $a['onload'] != '' ) {
+                               $a['onload'] .= ';';
+                       }
+                       $a['onload'] .= 'setupRightClickEdit()';
+               }
                return $a;
        }
 
@@ -350,7 +347,7 @@ END;
        }
 
        function doBeforeContent() {
-               global $wgOut, $wgTitle, $wgContLang, $wgSiteNotice;
+               global $wgOut, $wgTitle, $wgContLang;
                $fname = 'Skin::doBeforeContent';
                wfProfileIn( $fname );
 
@@ -400,8 +397,9 @@ END;
                $s .= "</tr>\n</table>\n</div>\n";
                $s .= "\n<div id='article'>\n";
 
-               if( $wgSiteNotice ) {
-                       $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
+               $notice = wfGetSiteNotice();
+               if( $notice ) {
+                       $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
                $s .= $this->pageTitle();
                $s .= $this->pageSubtitle() ;
@@ -410,7 +408,7 @@ END;
                return $s;
        }
 
-       
+
        function getCategoryLinks () {
                global $wgOut, $wgTitle, $wgParser;
                global $wgUseCategoryMagic, $wgUseCategoryBrowser, $wgLang;
@@ -434,34 +432,33 @@ END;
                        # get a big array of the parents tree
                        $parenttree = $wgTitle->getParentCategoryTree();
 
-                       # Render the array as a serie of links
-                       # Need to give skin cause $this is undefined at this level
-                       function walkThrough ($tree, &$skin) {
-                               $return = '';
-                               foreach($tree as $element => $parent) {
-                                       if(empty($parent)) {
-                                               # element start a new list
-                                               $return .= '<br />';
-                                       } else {
-                                               # grab the others elements
-                                               $return .= walkThrough($parent, $skin);
-                                       }
-                                       # add our current element to the list
-                                       $eltitle = Title::NewFromText($element);
-                                       if(!empty($parent)) $return .= ' &gt; ';
-                                       $return .=  $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
-                               }
-                               return $return;
-                       }
-
                        # Skin object passed by reference cause it can not be
                        # accessed under the method subfunction walkThrough.
-                       $s .= walkThrough($parenttree, $this);
+                       $s .= Skin::drawCategoryBrowser($parenttree, $this);
                }
 
                return $s;
        }
 
+       # Render the array as a serie of links
+       function drawCategoryBrowser ($tree, &$skin) {
+               $return = '';
+               foreach ($tree as $element => $parent) {
+                       if (empty($parent)) {
+                               # element start a new list
+                               $return .= '<br />';
+                       } else {
+                               # grab the others elements
+                               $return .= Skin::drawCategoryBrowser($parent, $skin);
+                       }
+                       # add our current element to the list
+                       $eltitle = Title::NewFromText($element);
+                       if (!empty($parent)) $return .= ' &gt; ';
+                       $return .=  $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ;
+               }
+               return $return;
+       }
+
        function getCategories() {
                $catlinks=$this->getCategoryLinks();
                if(!empty($catlinks)) {
@@ -512,7 +509,7 @@ END;
                if ( $wgOut->isArticleRelated() ) {
                        if ( $wgTitle->getNamespace() == NS_IMAGE ) {
                                $name = $wgTitle->getDBkey();
-                               $image = new Image( $wgTitle->getDBkey() );
+                               $image = new Image( $wgTitle );
                                if( $image->exists() ) {
                                        $link = htmlspecialchars( $image->getURL() );
                                        $style = $this->getInternalLinkAttributes( $link, $name );
@@ -539,7 +536,7 @@ END;
                # do not show "You have new messages" text when we are viewing our
                # own talk page
 
-                       if( $wgTitle->equals( $wgUser->getTalkPage() ) ) {
+                       if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
                                $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
                                                wfMsg('newmessageslink') );
                                $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
@@ -595,7 +592,6 @@ END;
                global $wgOut, $wgTitle, $wgUser;
 
                $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
-               if($wgUser->getOption( 'editsectiononrightclick' ) && $wgTitle->userCanEdit()) { $s=$this->editSectionScript($wgTitle, 0,$s);}
                return $s;
        }
 
@@ -932,7 +928,7 @@ END;
                                }
                        }
                }
-               
+
                $go = wfMsg( 'go' );
                $sp = wfMsg( 'specialpages' );
                $spp = $wgContLang->specialPage( 'Specialpages' );
@@ -942,7 +938,7 @@ END;
                $s .= "<select name=\"wpDropdown\">\n";
                $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
 
-               
+
                foreach ( $a as $name => $desc ) {
                        $p = $wgContLang->specialPage( $name );
                        $s .= "<option value=\"{$p}\">{$desc}</option>\n";
@@ -1103,7 +1099,7 @@ END;
 #                     0 != $id->getEmailauthenticationtimestamp() && # .. which is authenticated
 #                     1 != $wgUser->getOption('disablemail'); # and not disabled
        }
-       
+
        function emailUserLink() {
                global $wgTitle;
 
@@ -1124,7 +1120,11 @@ END;
        }
 
        function otherLanguages() {
-               global $wgOut, $wgContLang, $wgTitle;
+               global $wgOut, $wgContLang, $wgTitle, $wgHideInterlanguageLinks;
+
+               if ( $wgHideInterlanguageLinks ) {
+                       return '';
+               }
 
                $a = $wgOut->getLanguageLinks();
                if ( 0 == count( $a ) ) {
@@ -1237,13 +1237,13 @@ END;
                $title = Title::makeTitle( NS_SPECIAL, $name );
                return $title->getLocalURL( $urlaction );
        }
-       
+
        /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
                $title = Title::newFromText( wfMsgForContent($name) );
                $this->checkTitle($title, $name);
                return $title->getLocalURL( $urlaction );
        }
-       
+
        /*static*/ function makeUrl ( $name, $urlaction='' ) {
                $title = Title::newFromText( $name );
                $this->checkTitle($title, $name);
@@ -1287,6 +1287,42 @@ END;
                }
        }
 
+       /**
+        * Build an array that represents the sidebar(s), the navigation bar among them
+        *
+        * @return array
+        * @access private
+        */
+       function buildSidebar() {
+               $fname = 'SkinTemplate::buildSidebar';
+               wfProfileIn( $fname );
+
+               $bar = array();
+               $lines = explode( "\n", wfMsgForContent( 'sidebar' ) );
+               foreach ($lines as $line) {
+                       if (strpos($line, '*') !== 0)
+                               continue;
+                       if (strpos($line, '**') !== 0) {
+                               $line = trim($line, '* ');
+                               $heading = $line;
+                       } else {
+                               if (strpos($line, '|') !== false) { // sanity check
+                                       $line = explode( '|' , trim($line, '* '), 2 );
+                                       $link = wfMsgForContent( $line[0] );
+                                       if ($link == '-')
+                                               continue;
+                                       $bar[$heading][] = array(
+                                               'text' => wfMsg( $line[1] ),
+                                               'href' => $this->makeInternalOrExternalUrl( $link ),
+                                               'id' => 'n-' . $line[1],
+                                       );
+                               } else { continue; }
+                       }
+               }
+
+               wfProfileOut( $fname );
+               return $bar;
+       }
 }
 
 }