CologneBlue rewrite: output the sidebar items as <ul> lists
[lhc/web/wiklou.git] / includes / Html.php
index f4a3b55..5be67ab 100644 (file)
@@ -480,7 +480,7 @@ class Html {
                                'class', // html4, html5
                                'accesskey', // as of html5, multiple space-separated values allowed
                                // html4-spec doesn't document rel= as space-separated
-                               // but has been used like that and is now documented as such 
+                               // but has been used like that and is now documented as such
                                // in the html5-spec.
                                'rel',
                        );
@@ -493,7 +493,6 @@ class Html {
                                // values. Implode/explode to get those into the main array as well.
                                if ( is_array( $value ) ) {
                                        // If input wasn't an array, we can skip this step
-                                       
                                        $newValue = array();
                                        foreach ( $value as $k => $v ) {
                                                if ( is_string( $v ) ) {
@@ -576,7 +575,6 @@ class Html {
                                        # @todo FIXME: Is this really true?
                                        $map['<'] = '&lt;';
                                }
-                               
                                $ret .= " $key=$quote" . strtr( $value, $map ) . $quote;
                        }
                }
@@ -796,10 +794,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 +940,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 );
+       }
 }