Merge "Add support for PHP7 random_bytes in favor of mcrypt_create_iv"
[lhc/web/wiklou.git] / includes / skins / Skin.php
index 96812ea..52678d4 100644 (file)
@@ -149,6 +149,9 @@ abstract class Skin extends ContextSource {
         * Defines the ResourceLoader modules that should be added to the skin
         * It is recommended that skins wishing to override call parent::getDefaultModules()
         * and substitute out any modules they wish to change by using a key to look them up
+        *
+        * For style modules, use setupSkinUserCss() instead.
+        *
         * @return array Array of modules with helper keys for easy overriding
         */
        public function getDefaultModules() {
@@ -171,6 +174,16 @@ abstract class Skin extends ContextSource {
                        'user' => [],
                ];
 
+               // Preload jquery.tablesorter for mediawiki.page.ready
+               if ( strpos( $out->getHTML(), 'sortable' ) !== false ) {
+                       $modules['content'][] = 'jquery.tablesorter';
+               }
+
+               // Preload jquery.makeCollapsible for mediawiki.page.ready
+               if ( strpos( $out->getHTML(), 'mw-collapsible' ) !== false ) {
+                       $modules['content'][] = 'jquery.makeCollapsible';
+               }
+
                // Add various resources if required
                if ( $wgUseAjax && $wgEnableAPI ) {
                        if ( $wgEnableWriteAPI && $user->isLoggedIn()
@@ -381,7 +394,7 @@ abstract class Skin extends ContextSource {
 
                if ( $title->isSpecialPage() ) {
                        $type = 'ns-special';
-                       // bug 23315: provide a class based on the canonical special page name without subpages
+                       // T25315: provide a class based on the canonical special page name without subpages
                        list( $canonicalName ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
                        if ( $canonicalName ) {
                                $type .= ' ' . Sanitizer::escapeClass( "mw-special-$canonicalName" );
@@ -906,7 +919,10 @@ abstract class Skin extends ContextSource {
                                $html = htmlspecialchars( $icon["alt"] );
                        }
                        if ( $url ) {
-                               $html = Html::rawElement( 'a', [ "href" => $url ], $html );
+                               global $wgExternalLinkTarget;
+                               $html = Html::rawElement( 'a',
+                                       [ "href" => $url, "target" => $wgExternalLinkTarget ],
+                                       $html );
                        }
                }
                return $html;
@@ -1035,7 +1051,7 @@ abstract class Skin extends ContextSource {
                global $wgStylePath, $wgStyleVersion;
 
                if ( $this->stylename === null ) {
-                       $class = get_class( $this );
+                       $class = static::class;
                        throw new MWException( "$class::\$stylename must be set to use getSkinStylePath()" );
                }
 
@@ -1283,7 +1299,7 @@ abstract class Skin extends ContextSource {
                                        $line = array_map( 'trim', explode( '|', $line, 2 ) );
                                        if ( count( $line ) !== 2 ) {
                                                // Second sanity check, could be hit by people doing
-                                               // funky stuff with parserfuncs... (bug 33321)
+                                               // funky stuff with parserfuncs... (T35321)
                                                continue;
                                        }
 
@@ -1538,7 +1554,7 @@ abstract class Skin extends ContextSource {
 
                $attribs = [];
                if ( !is_null( $tooltip ) ) {
-                       # Bug 25462: undo double-escaping.
+                       # T27462: undo double-escaping.
                        $tooltip = Sanitizer::decodeCharReferences( $tooltip );
                        $attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
                                ->inLanguage( $lang )->text();