Followup r91672: remove commented-out reference to removed file (rtl.css)
[lhc/web/wiklou.git] / includes / Skin.php
index 64bfa95..3dc7a3c 100644 (file)
@@ -282,6 +282,8 @@ abstract class Skin {
         * as their "relevant" title, this allows the skin system to display things
         * such as content tabs which belong to to that page instead of displaying
         * a basic special page tab which has almost no meaning.
+        *
+        * @return Title
         */
        public function getRelevantTitle() {
                if ( isset($this->mRelevantTitle) ) {
@@ -329,7 +331,7 @@ abstract class Skin {
 
        /**
         * Outputs the HTML generated by other functions.
-        * @param $out Object: instance of OutputPage
+        * @param $out OutputPage
         */
        abstract function outputPage( OutputPage $out );
 
@@ -398,6 +400,8 @@ abstract class Skin {
 
        /**
         * @private
+        * @todo document
+        * @param $out OutputPage
         */
        function setupUserCss( OutputPage $out ) {
                global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
@@ -469,6 +473,7 @@ abstract class Skin {
         * @return String
         */
        function getPageClasses( $title ) {
+               global $wgRequest;
                $numeric = 'ns-' . $title->getNamespace();
 
                if ( $title->getNamespace() == NS_SPECIAL ) {
@@ -487,14 +492,21 @@ abstract class Skin {
                }
 
                $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
-
-               return "$numeric $type $name";
+               
+               if ( $wgRequest->getVal('action') ) {
+                       $action = 'action-' . $wgRequest->getVal('action');
+               } else {
+                       $action = 'action-view';
+               }
+               return "$numeric $type $name $action";
        }
 
        /**
         * This will be called by OutputPage::headElement when it is creating the
         * <body> tag, skins can override it if they have a need to add in any
         * body attributes or classes of their own.
+        * @param $out OutputPage
+        * @param $bodyAttrs Array
         */
        function addToBodyAttributes( $out, &$bodyAttrs ) {
                // does nothing by default
@@ -502,6 +514,7 @@ abstract class Skin {
 
        /**
         * URL to the logo
+        * @return String
         */
        function getLogo() {
                global $wgLogo;
@@ -509,7 +522,7 @@ abstract class Skin {
        }
 
        function getCategoryLinks() {
-               global $wgUseCategoryBrowser, $wgContLang;
+               global $wgUseCategoryBrowser;
 
                $out = $this->getContext()->getOutput();
 
@@ -517,26 +530,20 @@ abstract class Skin {
                        return '';
                }
 
-               # Separator
-               $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
-
-               // Use Unicode bidi embedding override characters,
-               // to make sure links don't smash each other up in ugly ways.
-               $dir = $wgContLang->getDir();
-               $embed = "<span dir='$dir'>";
-               $pop = '</span>';
+               $embed = "<li>";
+               $pop = "</li>";
 
                $allCats = $out->getCategoryLinks();
                $s = '';
                $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
 
                if ( !empty( $allCats['normal'] ) ) {
-                       $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
+                       $t = $embed . implode( "{$pop}{$embed}" , $allCats['normal'] ) . $pop;
 
                        $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
                        $s .= '<div id="mw-normal-catlinks">' .
                                Linker::link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
-                               . $colon . $t . '</div>';
+                               . $colon . '<ul>' . $t . '</ul>' . '</div>';
                }
 
                # Hidden categories
@@ -551,7 +558,7 @@ abstract class Skin {
 
                        $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
                                wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
-                               $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
+                               $colon . '<ul>' . $embed . implode( "{$pop}{$embed}" , $allCats['hidden'] ) . $pop . '</ul>' .
                                '</div>';
                }
 
@@ -564,7 +571,7 @@ abstract class Skin {
                        $parenttree = $this->getTitle()->getParentCategoryTree();
                        # Skin object passed by reference cause it can not be
                        # accessed under the method subfunction drawCategoryBrowser
-                       $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
+                       $tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree ) );
                        # Clean out bogus first entry and sort them
                        unset( $tempout[0] );
                        asort( $tempout );
@@ -631,7 +638,7 @@ abstract class Skin {
         * The output of this function gets processed in SkinTemplate::outputPage() for
         * the SkinTemplate based skins, all other skins should directly echo it.
         *
-        * Returns an empty string by default, if not changed by any hook function.
+        * @return String, empty by default, if not changed by any hook function.
         */
        protected function afterContentHook() {
                $data = '';
@@ -747,7 +754,9 @@ abstract class Skin {
 
                if ( $this->getContext()->getUser()->isAllowed( 'deletedhistory' ) &&
                        ( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
-                       $n = $this->getTitle()->isDeleted();
+
+                       $includeSuppressed = $this->getContext()->getUser()->isAllowed( 'suppressrevision' );
+                       $n = $this->getTitle()->isDeleted( $includeSuppressed );
 
                        if ( $n ) {
                                if ( $this->getContext()->getUser()->isAllowed( 'undelete' ) ) {
@@ -826,6 +835,7 @@ abstract class Skin {
 
        /**
         * Returns true if the IP should be shown in the header
+        * @return Bool
         */
        function showIPinHeader() {
                global $wgShowIPinHeader;
@@ -975,7 +985,8 @@ abstract class Skin {
        /**
         * Renders a $wgFooterIcons icon acording to the method's arguments
         * @param $icon Array: The icon to build the html for, see $wgFooterIcons for the format of this array
-        * @param $withImage Boolean: Whether to use the icon's image or output a text-only footericon
+        * @param $withImage Bool|String: Whether to use the icon's image or output a text-only footericon
+        * @return String HTML
         */
        function makeFooterIcon( $icon, $withImage = 'withImage' ) {
                if ( is_string( $icon ) ) {
@@ -1031,6 +1042,7 @@ abstract class Skin {
 
        /**
         * Gets the link to the wiki's privacy policy page.
+        * @return String HTML
         */
        function privacyLink() {
                return $this->footerLink( 'privacy', 'privacypage' );
@@ -1038,6 +1050,7 @@ abstract class Skin {
 
        /**
         * Gets the link to the wiki's about page.
+        * @return String HTML
         */
        function aboutLink() {
                return $this->footerLink( 'aboutsite', 'aboutpage' );
@@ -1045,6 +1058,7 @@ abstract class Skin {
 
        /**
         * Gets the link to the wiki's general disclaimers page.
+        * @return String HTML
         */
        function disclaimerLink() {
                return $this->footerLink( 'disclaimers', 'disclaimerpage' );
@@ -1131,6 +1145,8 @@ abstract class Skin {
        /**
         * If url string starts with http, consider as external URL, else
         * internal
+        * @param $name String
+        * @return String URL
         */
        static function makeInternalOrExternalUrl( $name ) {
                if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
@@ -1161,6 +1177,9 @@ abstract class Skin {
 
        /**
         * Make URL details where the article exists (or at least it's convenient to think so)
+        * @param $name String Article name
+        * @param $urlaction String
+        * @return Array
         */
        static function makeKnownUrlDetails( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
@@ -1230,6 +1249,7 @@ abstract class Skin {
         * @since 1.17
         * @param &$bar array
         * @param $text string
+        * @return Array
         */
        function addToSidebarPlain( &$bar, $text ) {
                $lines = explode( "\n", $text );
@@ -1253,6 +1273,7 @@ abstract class Skin {
                                if ( strpos( $line, '|' ) !== false ) { // sanity check
                                        $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
                                        $line = array_map( 'trim', explode( '|', $line, 2 ) );
+                                       $extraAttribs = array();
 
                                        $msgLink = wfMessage( $line[0] )->inContentLanguage();
                                        if ( $msgLink->exists() ) {
@@ -1273,6 +1294,28 @@ abstract class Skin {
 
                                        if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
                                                $href = $link;
+                                               //Parser::getExternalLinkAttribs won't work here because of the Namespace things
+                                               global $wgNoFollowLinks;
+                                               if ( $wgNoFollowLinks ) {
+                                                       $extraAttribs['rel'] = 'nofollow';
+
+                                                       global $wgNoFollowDomainExceptions;
+                                                       if ( $wgNoFollowDomainExceptions ) {
+                                                               $bits = wfParseUrl( $url );
+                                                               if ( is_array( $bits ) && isset( $bits['host'] ) ) {
+                                                                       foreach ( $wgNoFollowDomainExceptions as $domain ) {
+                                                                               if ( substr( $bits['host'], -strlen( $domain ) ) == $domain ) {
+                                                                                       unset( $extraAttribs['rel'] );
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                               global $wgExternalLinkTarget;
+                                               if ( $wgExternalLinkTarget) {
+                                                       $extraAttribs['target'] = $wgExternalLinkTarget;
+                                               }
                                        } else {
                                                $title = Title::newFromText( $link );
 
@@ -1284,12 +1327,12 @@ abstract class Skin {
                                                }
                                        }
 
-                                       $bar[$heading][] = array(
+                                       $bar[$heading][] = array_merge( array(
                                                'text' => $text,
                                                'href' => $href,
-                                               'id' => 'n-' . strtr( $line[1], ' ', '-' ),
+                                               'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], ' ', '-' ), 'noninitial' ),
                                                'active' => false
-                                       );
+                                       ), $extraAttribs );
                                } elseif ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr( $line, -2 ) == '}}' ) ) {
                                        global $wgParser;
 
@@ -1389,7 +1432,7 @@ abstract class Skin {
         * @return String: HTML fragment
         */
        private function getCachedNotice( $name ) {
-               global $wgRenderHashAppend, $parserMemc;
+               global $wgRenderHashAppend, $parserMemc, $wgContLang;
 
                wfProfileIn( __METHOD__ );
 
@@ -1431,7 +1474,8 @@ abstract class Skin {
                        $notice = $parsed;
                }
 
-               $notice = '<div id="localNotice">' .$notice . '</div>';
+               $notice = Html::rawElement( 'div', array( 'id' => 'localNotice',
+                       'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), $notice );
                wfProfileOut( __METHOD__ );
                return $notice;
        }