BUG#93 Fix handling of <nowiki> in templates
[lhc/web/wiklou.git] / includes / Skin.php
index 3fc0b84..262c497 100644 (file)
@@ -1,18 +1,24 @@
 <?php
 
-# This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
+/**
+ *
+ * @package MediaWiki
+ */
+
+/**
+ * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
+ */
 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
 # file names in ./skins/. For display purposes, the Language class has
 # internationalized names
 #
-/* private */ $wgValidSkinNames = array(
+/*
+$wgValidSkinNames = array(
        'standard'      => 'Standard',
        'nostalgia'     => 'Nostalgia',
        'cologneblue'   => 'CologneBlue'
@@ -26,9 +32,31 @@ if( $wgUsePHPTal ) {
        $wgValidSkinNames['myskin'] = 'MySkin';
        $wgValidSkinNames['chick'] = 'Chick';
 }
+*/
+
+# Get a list of all skins available in /skins/
+# Build using the regular expression '^(.*).php$'
+# Array keys are all lower case, array value keep the case used by filename
+#
+
+$skinDir = dir($IP.'/skins');
+
+# while code from www.php.net
+while (false !== ($file = $skinDir->read())) {
+       if(preg_match('/^(.*).php$/',$file, $matches)) {
+               $aSkin = $matches[1];
+       $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
+       }
+}
+$skinDir->close();
+unset($matches);
 
 require_once( 'RecentChange.php' );
 
+/**
+ * @todo document
+ * @package MediaWiki
+ */
 class RCCacheEntry extends RecentChange
 {
        var $secureName, $link;
@@ -45,18 +73,23 @@ 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.
-
+/**
+ * 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 {
-
-       /* private */ var $lastdate, $lastline;
+       /**#@+
+        * @access private
+        */
+       var $lastdate, $lastline;
        var $linktrail ; # linktrail regexp
        var $rc_cache ; # Cache for Enhanced Recent Changes
        var $rcCacheIndex ; # Recent Changes Cache Counter for visibility toggle
        var $rcMoveIndex;
        var $postParseLinkColour = true;
+       /**#@-*/
 
        function Skin() {
                global $wgUseOldExistenceCheck;
@@ -70,14 +103,16 @@ class Skin {
        }
 
        function getStylesheet() {
-               return 'wikistandard.css';
+               return 'common/wikistandard.css';
        }
-       
+
        function getSkinName() {
                return 'standard';
        }
 
-       # Get/set accessor for delayed link colouring
+       /**
+        * Get/set accessor for delayed link colouring
+        */
        function postParseLinkColour( $setting = NULL ) {
                return wfSetVar( $this->postParseLinkColour, $setting );
        }
@@ -169,7 +204,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'));
@@ -184,7 +219,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');
@@ -196,11 +231,15 @@ class Skin {
                $s .= $this->doGetUserStyles();
                return $s."\n";
        }
-       
-       # placeholder, returns generated js in monobook
+
+       /**
+        * placeholder, returns generated js in monobook
+        */
        function getUserJs() { return; }
 
-       # Return html code that include User stylesheets
+       /**
+        * Return html code that include User stylesheets
+        */
        function getUserStyles() {
                global $wgOut, $wgStylePath, $wgLang;
                $s = "<style type='text/css'>\n";
@@ -211,7 +250,9 @@ class Skin {
                return $s;
        }
 
-       # Some styles that are set by user through the user settings interface.
+       /**
+        * Some styles that are set by user through the user settings interface.
+        */
        function doGetUserStyles() {
                global $wgUser, $wgLang;
 
@@ -234,8 +275,7 @@ class Skin {
                return $s;
        }
 
-       function getBodyOptions()
-       {
+       function getBodyOptions() {
                global $wgUser, $wgTitle, $wgNamespaceBackgrounds, $wgOut, $wgRequest;
 
                extract( $wgRequest->getValues( 'oldid', 'redirect', 'diff' ) );
@@ -263,8 +303,7 @@ class Skin {
                return $a;
        }
 
-       function getExternalLinkAttributes( $link, $text, $class='' )
-       {
+       function getExternalLinkAttributes( $link, $text, $class='' ) {
                global $wgUser, $wgOut, $wgLang;
 
                $link = urldecode( $link );
@@ -280,8 +319,7 @@ class Skin {
                return $r;
        }
 
-       function getInternalLinkAttributes( $link, $text, $broken = false )
-       {
+       function getInternalLinkAttributes( $link, $text, $broken = false ) {
                global $wgUser, $wgOut;
 
                $link = urldecode( $link );
@@ -302,8 +340,10 @@ class Skin {
                return $r;
        }
 
-       function getInternalLinkAttributesObj( &$nt, $text, $broken = false )
-       {
+       /**
+        * @param bool $broken
+        */
+       function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) {
                global $wgUser, $wgOut;
 
                if ( $broken == 'stub' ) {
@@ -320,24 +360,25 @@ class Skin {
                return $r;
        }
 
-       # URL to the logo
+       /**
+        * URL to the logo
+        */
        function getLogo() {
                global $wgLogo;
                return $wgLogo;
        }
 
-       # This will be called immediately after the <body> tag.  Split into
-       # two functions to make it easier to subclass.
-       #
-       function beforeContent()
-       {
+       /**
+        * This will be called immediately after the <body> tag.  Split into
+        * two functions to make it easier to subclass.
+        */
+       function beforeContent() {
                global $wgUser, $wgOut;
 
                return $this->doBeforeContent();
        }
 
-       function doBeforeContent()
-       {
+       function doBeforeContent() {
                global $wgUser, $wgOut, $wgTitle, $wgLang, $wgSiteNotice;
                $fname = 'Skin::doBeforeContent';
                wfProfileIn( $fname );
@@ -417,7 +458,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();
 
@@ -441,7 +482,7 @@ class Skin {
                                }
                                return $return;
                        }
-                       
+
                        $s .= walkThrough($parenttree);
                }
 
@@ -570,6 +611,8 @@ class Skin {
                                                        Namespace::getTalk( Namespace::getUser() ) ) . ":{$n}",
                                                wfMsg('newmessageslink') );
                                $s.= ' | <strong>'. wfMsg( 'newmessages', $tl ) . '</strong>';
+                               # disable caching
+                               $wgOut->setSquidMaxage(0);
                        }
                }
 
@@ -629,7 +672,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":'';
@@ -868,7 +911,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;
        }
@@ -1102,7 +1145,7 @@ class Skin {
 
        function aboutLink() {
                $s = $this->makeKnownLink( wfMsg( 'aboutpage' ),
-                 wfMsg( 'aboutwikipedia' ) );
+                 wfMsg( 'aboutsite' ) );
                return $s;
        }
 
@@ -1393,16 +1436,19 @@ class Skin {
                return $s;
        }
 
-       # After all the page content is transformed into HTML, it makes
-       # a final pass through here for things like table backgrounds.
-       #
+       /**
+        * After all the page content is transformed into HTML, it makes
+        * a final pass through here for things like table backgrounds.
+        * @todo probably deprecated [AV]
+        */
        function transformContent( $text ) {
                return $text;
        }
 
-       # Note: This function MUST call getArticleID() on the link,
-       # otherwise the cache won't get updated properly.  See LINKCACHE.DOC.
-       #
+       /**
+        * Note: This function MUST call getArticleID() on the link,
+        * otherwise the cache won't get updated properly.  See LINKCACHE.DOC.
+        */
        function makeLink( $title, $text = '', $query = '', $trail = '' ) {
                wfProfileIn( 'Skin::makeLink' );
                $nt = Title::newFromText( $title );
@@ -1447,7 +1493,9 @@ class Skin {
                }
        }
 
-       # Pass a title object, not a title string
+       /**
+        * Pass a title object, not a title string
+        */
        function makeLinkObj( &$nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
                global $wgOut, $wgUser;
                $fname = 'Skin::makeLinkObj';
@@ -1522,7 +1570,9 @@ class Skin {
                return $retVal;
        }
 
-       # Pass a title object, not a title string
+       /**
+        * Pass a title object, not a title string
+        */
        function makeKnownLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '' ) {
                global $wgOut, $wgTitle, $wgInputEncoding;
 
@@ -1569,7 +1619,9 @@ class Skin {
                return $r;
        }
 
-       # Pass a title object, not a title string
+       /**
+        * Pass a title object, not a title string
+        */
        function makeBrokenLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                global $wgOut, $wgUser;
 
@@ -1609,7 +1661,9 @@ class Skin {
                return $s;
        }
 
-       # Pass a title object, not a title string
+       /**
+        * Pass a title object, not a title string
+        */
        function makeStubLinkObj( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                global $wgOut, $wgUser;
 
@@ -1883,8 +1937,10 @@ class Skin {
                return str_replace("\n", ' ',$prefix.$s.$postfix);
        }
 
-       # Make HTML for a thumbnail including image, border and caption
-       # $img is an Image object
+       /**
+        * Make HTML for a thumbnail including image, border and caption
+        * $img is an Image object
+        */
        function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
                global $wgStylePath, $wgLang;
                # $image = Title::makeTitleSafe( NS_IMAGE, $name );
@@ -1961,7 +2017,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>';
                        }
                }
@@ -2029,8 +2085,10 @@ class Skin {
                return $s;
        }
 
-       # Returns text for the end of RC
-       # If enhanced RC is in use, returns pretty much all the text
+       /**
+        * Returns text for the end of RC
+        * If enhanced RC is in use, returns pretty much all the text
+        */
        function endRecentChangesList() {
                $s = $this->recentChangesBlock() ;
                if( $this->rclistOpen ) {
@@ -2039,7 +2097,9 @@ class Skin {
                return $s;
        }
 
-       # Enhanced RC ungrouped line
+       /**
+        * Enhanced RC ungrouped line
+        */
        function recentChangesBlockLine ( $rcObj ) {
                global $wgStylePath, $wgLang ;
 
@@ -2050,7 +2110,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 ) {
@@ -2103,7 +2163,9 @@ class Skin {
                return $r ;
        }
 
-       # Enhanced RC group
+       /**
+        * Enhanced RC group
+        */
        function recentChangesBlockGroup ( $block ) {
                global $wgStylePath, $wgLang ;
 
@@ -2139,8 +2201,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
@@ -2182,7 +2244,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;' ;
@@ -2220,8 +2282,10 @@ class Skin {
                return $r ;
        }
 
-       # If enhanced RC is in use, this function takes the previously cached
-       # RC lines, arranges them, and outputs the HTML
+       /**
+        * If enhanced RC is in use, this function takes the previously cached
+        * RC lines, arranges them, and outputs the HTML
+        */
        function recentChangesBlock () {
                global $wgStylePath ;
                if ( count ( $this->rc_cache ) == 0 ) return '' ;
@@ -2237,8 +2301,10 @@ class Skin {
                return '<div>'.$blockOut.'</div>' ;
        }
 
-       # Called in a loop over all displayed RC entries
-       # Either returns the line, or caches it for later use
+       /**
+        * Called in a loop over all displayed RC entries
+        * Either returns the line, or caches it for later use
+        */
        function recentChangesLine( &$rc, $watched = false ) {
                global $wgUser ;
                $usenew = $wgUser->getOption( 'usenewrc' );
@@ -2482,18 +2548,20 @@ class Skin {
                return $s;
        }
 
-       /* This function is called by all recent changes variants, by the page history,
-          and by the user contributions list. It is responsible for formatting edit
-          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 
-          direct link to the section in the autocomment.
-          Main 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
+       /**
+        * This function is called by all recent changes variants, by the page history,
+        * and by the user contributions list. It is responsible for formatting edit
+        * 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
+        * 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
+        */
        function formatComment($comment, $title = NULL) {
                global $wgLang;
                $comment = htmlspecialchars( $comment );
@@ -2509,7 +2577,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);
@@ -2619,7 +2687,9 @@ class Skin {
                return str_repeat( "</div>\n", $level>0 ? $level : 0 );
        }
 
-       # parameter level defines if we are on an indentation level
+       /**
+        * parameter level defines if we are on an indentation level
+        */
        function tocLine( $anchor, $tocline, $level ) {
                $link = '<a href="#'.$anchor.'">'.$tocline.'</a><br />';
                if($level) {
@@ -2642,7 +2712,10 @@ class Skin {
                $toc."</td></tr></table>\n";
        }
 
-       # These two do not check for permissions: check $wgTitle->userCanEdit before calling them
+       /**
+        * These two do not check for permissions: check $wgTitle->userCanEdit
+        * before calling them
+        */
        function editSectionScript( $section, $head ) {
                global $wgTitle, $wgRequest;
                if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
@@ -2677,21 +2750,26 @@ 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.
+       /**
+        * 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 necessary JavaScript code can be found in style/wikibits.js.
+        */
        function getEditToolbar() {
                global $wgStylePath, $wgLang, $wgMimeType;
 
-               // toolarray an array of arrays which each include the filename of
-               // the button image (without path), the opening tag, the closing tag,
-               // and optionally a sample text that is inserted between the two when no
-               // selection is highlighted.
-               // The tip text is shown when the user moves the mouse over the button.
-
-               // Already here are accesskeys (key), which are not used yet until someone
-               // can figure out a way to make them work in IE. However, we should make
-               // sure these keys are not defined on the edit page.
+               /**
+                * toolarray an array of arrays which each include the filename of
+                * the button image (without path), the opening tag, the closing tag,
+                * and optionally a sample text that is inserted between the two when no
+                * selection is highlighted.
+                * The tip text is shown when the user moves the mouse over the button.
+                *
+                * Already here are accesskeys (key), which are not used yet until someone
+                * can figure out a way to make them work in IE. However, we should make
+                * sure these keys are not defined on the edit page.
+                */
                $toolarray=array(
                        array(  'image'=>'button_bold.png',
                                        'open'  =>      "\'\'\'",
@@ -2776,7 +2854,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'] );
@@ -2799,7 +2877,10 @@ class Skin {
                return $toolbar;
        }
 
-       /* public */ function suppressUrlExpansion() {
+       /**
+        * @access public
+        */
+       function suppressUrlExpansion() {
                return false;
        }
 }