* Wont work
[lhc/web/wiklou.git] / includes / Xml.php
index e0548ed..fe4bb0c 100644 (file)
@@ -42,11 +42,15 @@ class Xml {
         */
        private static function expandAttributes( $attribs ) {
                $out = '';
-               if( is_array( $attribs ) ) {
+               if( is_null( $attribs ) ) {
+                       return null;
+               } elseif( is_array( $attribs ) ) {
                        foreach( $attribs as $name => $val )
                                $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
+                       return $out;
+               } else {
+                       throw new MWException( 'Expected attribute array, got something else in ' . __METHOD__ );
                }
-               return $out;
        }
 
        /**
@@ -95,7 +99,7 @@ class Xml {
         * @param bool $hidden Include hidden namespaces? [WTF? --RC]
         * @return string
         */
-       public static function namespaceSelector( $selected = '', $all = null, $hidden = false ) {
+       public static function namespaceSelector( $selected = '', $all = null, $hidden = false, $element_name = 'namespace' ) {
                global $wgContLang;
                $namespaces = $wgContLang->getFormattedNamespaces();
                $options = array();
@@ -110,7 +114,7 @@ class Xml {
                        $options[] = self::option( $name, $index, $index === $selected );
                }
                
-               return Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => 'namespace',
+               return Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => $element_name,
                        'class' => 'namespaceselector' ) )
                        . "\n"
                        . implode( "\n", $options )