sending the content language code as Content-language
[lhc/web/wiklou.git] / includes / Skin.php
index 28fa550..9b40f6d 100644 (file)
@@ -2,6 +2,7 @@
 
 /**
  *
+ * @package MediaWiki
  */
 
 /**
@@ -10,8 +11,6 @@
 if( defined( "MEDIAWIKI" ) ) {
 
 # See skin.doc
-
-require_once( 'Feed.php' );  // should not be called if the actual page isn't feed enabled
 require_once( 'Image.php' );
 
 # These are the INTERNAL names, which get mapped directly to class names and
@@ -54,8 +53,18 @@ unset($matches);
 
 require_once( 'RecentChange.php' );
 
+global $wgLinkHolders;
+$wgLinkHolders = array(
+       'namespaces' => array(),
+       'dbkeys' => array(),
+       'queries' => array(),
+       'texts' => array(),
+       'titles' => array()
+);
+
 /**
  * @todo document
+ * @package MediaWiki
  */
 class RCCacheEntry extends RecentChange
 {
@@ -77,6 +86,7 @@ class RCCacheEntry extends RecentChange
  * The main skin class that provide methods and properties for all other skins
  * including PHPTal skins.
  * This base class is also the "Standard" skin.
+ * @package MediaWiki
  */
 class Skin {
        /**#@+
@@ -102,9 +112,9 @@ class Skin {
        }
 
        function getStylesheet() {
-               return 'wikistandard.css';
+               return 'common/wikistandard.css';
        }
-       
+
        function getSkinName() {
                return 'standard';
        }
@@ -203,7 +213,7 @@ class Skin {
 
        function getHeadScripts() {
                global $wgStylePath, $wgUser, $wgLang, $wgAllowUserJs;
-               $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/wikibits.js\"></script>\n";
+               $r = "<script type=\"text/javascript\" src=\"{$wgStylePath}/common/wikibits.js\"></script>\n";
                if( $wgAllowUserJs && $wgUser->getID() != 0 ) { # logged in
                        $userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
                        $userjs = htmlspecialchars($this->makeUrl($userpage.'/'.$this->getSkinName().'.js', 'action=raw&ctype=text/javascript'));
@@ -218,7 +228,7 @@ class Skin {
                $sheet = $this->getStylesheet();
                $action = $wgRequest->getText('action');
                $s = "@import \"$wgStylePath/$sheet\";\n";
-               if($wgLang->isRTL()) $s .= "@import \"$wgStylePath/common_rtl.css\";\n";
+               if($wgLang->isRTL()) $s .= "@import \"$wgStylePath/common/common_rtl.css\";\n";
                if( $wgAllowUserCss && $wgUser->getID() != 0 ) { # logged in
                        if($wgTitle->isCssSubpage() and $action == 'submit' and  $wgTitle->userCanEditCssJsSubpage()) {
                                $s .= $wgRequest->getText('wpTextbox1');
@@ -230,7 +240,7 @@ class Skin {
                $s .= $this->doGetUserStyles();
                return $s."\n";
        }
-       
+
        /**
         * placeholder, returns generated js in monobook
         */
@@ -457,7 +467,7 @@ class Skin {
                # of categories an article belong to
                if($wgUseCategoryBrowser) {
                        $s .= '<br/><hr/>';
-                       
+
                        # get a big array of the parents tree
                        $parenttree = $wgTitle->getCategorieBrowser();
 
@@ -481,7 +491,7 @@ class Skin {
                                }
                                return $return;
                        }
-                       
+
                        $s .= walkThrough($parenttree);
                }
 
@@ -671,7 +681,7 @@ class Skin {
                $sub = $wgOut->getSubtitle();
                if ( '' == $sub ) {
                        global $wgExtraSubtitle;
-                       $sub = wfMsg( 'fromwikipedia' ) . $wgExtraSubtitle;
+                       $sub = wfMsg( 'tagline' ) . $wgExtraSubtitle;
                }
                $subpages = $this->subPageSubtitle();
                $sub .= !empty($subpages)?"</p><p class='subpages'>$subpages":'';
@@ -910,7 +920,7 @@ class Skin {
 
        function getPoweredBy() {
                global $wgStylePath;
-               $url = htmlspecialchars( "$wgStylePath/images/poweredby_mediawiki_88x31.png" );
+               $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
                $img = '<a href="http://www.mediawiki.org/"><img src="'.$url.'" alt="MediaWiki" /></a>';
                return $img;
        }
@@ -1144,7 +1154,7 @@ class Skin {
 
        function aboutLink() {
                $s = $this->makeKnownLink( wfMsg( 'aboutpage' ),
-                 wfMsg( 'aboutwikipedia' ) );
+                 wfMsg( 'aboutsite' ) );
                return $s;
        }
 
@@ -1496,7 +1506,7 @@ class Skin {
         * Pass a title object, not a title string
         */
        function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
-               global $wgOut, $wgUser;
+               global $wgOut, $wgUser, $wgLinkHolders;
                $fname = 'Skin::makeLinkObj';
 
                # Fail gracefully
@@ -1533,8 +1543,13 @@ class Skin {
                                }
 
                                # Allows wiki to bypass using linkcache, see OutputPage::parseLinkHolders()
-                               $retVal = '<!--LINK ' . implode( ' ', array( $nt->getNamespace(), $nt->getDBkey(),
-                                       $query, $prefix . $text . $inside ) ) . "-->{$trail}";
+                               $nr = array_push( $wgLinkHolders['namespaces'], $nt->getNamespace() );
+                               $wgLinkHolders['dbkeys'][] = $nt->getDBkey();
+                               $wgLinkHolders['queries'][] = $query;
+                               $wgLinkHolders['texts'][] = $prefix.$text.$inside;
+                               $wgLinkHolders['titles'][] = $nt;
+
+                               $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
                        } else {
                                # Work out link colour immediately
                                $aid = $nt->getArticleID() ;
@@ -1724,7 +1739,7 @@ class Skin {
                return $title->getLocalURL( $urlaction );
        }
        /*static*/ function makeI18nUrl ( $name, $urlaction='' ) {
-               $title = Title::newFromText( wfMsg($name) );
+               $title = Title::newFromText( wfMsgForContent($name) );
                $this->checkTitle($title, $name);
                return $title->getLocalURL( $urlaction );
        }
@@ -1768,7 +1783,7 @@ class Skin {
                );
        }
        /*static*/ function makeI18nUrlDetails ( $name, $urlaction='' ) {
-               $title = Title::newFromText( wfMsg($name) );
+               $title = Title::newFromText( wfMsgForContent($name) );
                $this->checkTitle($title, $name);
                return array(
                        'href' => $title->getLocalURL( $urlaction ),
@@ -2016,7 +2031,7 @@ class Skin {
                        } else {
                                $zoomicon =  '<div class="magnify" style="float:'.$magnifyalign.'">'.
                                        '<a href="'.$u.'" class="internal" title="'.$more.'">'.
-                                       '<img src="'.$wgStylePath.'/images/magnify-clip.png" ' .
+                                       '<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
                                        'width="15" height="11" alt="'.$more.'" /></a></div>';
                        }
                }
@@ -2109,7 +2124,7 @@ class Skin {
                # Spacer image
                $r = '' ;
 
-               $r .= '<img src="'.$wgStylePath.'/images/Arr_.png" width="12" height="12" border="0" />' ;
+               $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" border="0" />' ;
                $r .= '<tt>' ;
 
                if ( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
@@ -2200,8 +2215,8 @@ class Skin {
                $rcm = 'RCM'.$this->rcCacheIndex ;
                $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')" ;
                $arrowdir = $wgLang->isRTL() ? 'l' : 'r';
-               $tl  = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
-               $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/images/Arr_d.png" width="12" height="12" /></a></span>' ;
+               $tl  = '<span id="'.$rcm.'"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_'.$arrowdir.'.png" width="12" height="12" /></a></span>' ;
+               $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'"><img src="'.$wgStylePath.'/common/images/Arr_d.png" width="12" height="12" /></a></span>' ;
                $r .= $tl ;
 
                # Main line
@@ -2243,7 +2258,7 @@ class Skin {
                        # Get rc_xxxx variables
                        extract( $rcObj->mAttribs );
 
-                       $r .= '<img src="'.$wgStylePath.'/images/Arr_.png" width="12" height="12" />';
+                       $r .= '<img src="'.$wgStylePath.'/common/images/Arr_.png" width="12" height="12" />';
                        $r .= '<tt>&nbsp; &nbsp; &nbsp; &nbsp;' ;
                        if ( $rc_new ) $r .= $N ;
                        else $r .= '&nbsp;' ;
@@ -2553,10 +2568,10 @@ class Skin {
         * comments. It escapes any HTML in the comment, but adds some CSS to format
         * auto-generated comments (from section editing) and formats [[wikilinks]].
         *
-        * The &$title parameter must be a title OBJECT. It is used to generate a 
+        * The &$title parameter must be a title OBJECT. It is used to generate a
         * direct link to the section in the autocomment.
         * @author Erik Moeller <moeller@scireview.de>
-        * 
+        *
         * Note: there's not always a title to pass to this function.
         * Since you can't set a default parameter for a reference, I've turned it
         * temporarily to a value pass. Should be adjusted further. --brion
@@ -2576,7 +2591,7 @@ class Skin {
                        $link='';
                        if($title) {
                                $section=$auto;
-                               
+
                                # This is hackish but should work in most cases.
                                $section=str_replace('[[','',$section);
                                $section=str_replace(']]','',$section);
@@ -2715,6 +2730,12 @@ class Skin {
         * These two do not check for permissions: check $wgTitle->userCanEdit
         * before calling them
         */
+       function editSectionScriptForOther( $title, $section, $head ) {
+               $ttl = Title::newFromText( $title );
+               $url = $ttl->escapeLocalURL( 'action=edit&section='.$section );
+               return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
+       }
+
        function editSectionScript( $section, $head ) {
                global $wgTitle, $wgRequest;
                if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
@@ -2724,6 +2745,25 @@ class Skin {
                return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
        }
 
+       function editSectionLinkForOther( $title, $section ) {
+               global $wgRequest;
+               global $wgUser, $wgLang;
+
+               $title = Title::newFromText($title);
+               $editurl = '&section='.$section;
+               $url = $this->makeKnownLink($title->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);
+
+               if( $wgLang->isRTL() ) {
+                       $farside = 'left';
+                       $nearside = 'right';
+               } else {
+                       $farside = 'right';
+                       $nearside = 'left';
+               }
+               return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
+
+       }
+
        function editSectionLink( $section ) {
                global $wgRequest;
                global $wgTitle, $wgUser, $wgLang;
@@ -2753,7 +2793,7 @@ class Skin {
         * This function is called by EditPage.php and shows a bulletin board style
         * toolbar for common editing functions. It can be disabled in the user
         * preferences.
-        * The necsesary JavaScript code can be found in style/wikibits.js.
+        * The necessary JavaScript code can be found in style/wikibits.js.
         */
        function getEditToolbar() {
                global $wgStylePath, $wgLang, $wgMimeType;
@@ -2853,7 +2893,7 @@ class Skin {
                $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
                foreach($toolarray as $tool) {
 
-                       $image=$wgStylePath.'/images/'.$tool['image'];
+                       $image=$wgStylePath.'/common/images/'.$tool['image'];
                        $open=$tool['open'];
                        $close=$tool['close'];
                        $sample = addslashes( $tool['sample'] );