Fixing dump tests for non-wikitext in NS_MAIN.
[lhc/web/wiklou.git] / includes / Html.php
index f4a3b55..a07dd4c 100644 (file)
@@ -796,10 +796,12 @@ class Html {
                        if ( $nsId < NS_MAIN || in_array( $nsId, $params['exclude'] ) ) {
                                continue;
                        }
-                       if ( $nsId === 0 ) {
+                       if ( $nsId === NS_MAIN ) {
                                // For other namespaces use use the namespace prefix as label, but for
                                // main we don't use "" but the user message descripting it (e.g. "(Main)" or "(Article)")
                                $nsName = wfMessage( 'blanknamespace' )->text();
+                       } elseif ( is_int( $nsId ) ) {
+                               $nsName = $wgContLang->convertNamespace( $nsId );
                        }
                        $optionsHtml[] = Html::element(
                                'option', array(
@@ -940,4 +942,22 @@ class Html {
 
                return $s;
        }
+
+       /**
+        * Generate a srcset attribute value from an array mapping pixel densities
+        * to URLs. Note that srcset supports width and height values as well, which
+        * are not used here.
+        *
+        * @param array $urls
+        * @return string
+        */
+       static function srcSet( $urls ) {
+               $candidates = array();
+               foreach( $urls as $density => $url ) {
+                       // Image candidate syntax per current whatwg live spec, 2012-09-23:
+                       // http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#attr-img-srcset
+                       $candidates[] = "{$url} {$density}x";
+               }
+               return implode( ", ", $candidates );
+       }
 }