global $wgContLang;
$namespaces = $wgContLang->getFormattedNamespaces();
$options = array();
-
+
// Godawful hack... we'll be frequently passed selected namespaces
// as strings since PHP is such a shithole.
// But we also don't want blanks and nulls and "all"s matching 0,
if( preg_match( '/^\d+$/', $selected ) ) {
$selected = intval( $selected );
}
-
+
if( !is_null( $all ) )
$namespaces = array( $all => wfMsg( 'namespacesall' ) ) + $namespaces;
foreach( $namespaces as $index => $name ) {
$name = wfMsg( 'blanknamespace' );
$options[] = self::option( $name, $index, $index === $selected );
}
-
+
return Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => $element_name,
'class' => 'namespaceselector' ) )
. "\n"
. "\n"
. Xml::closeElement( 'select' );
}
-
+
/**
- * Create a date selector
- *
- * @param $selected Mixed: the month which should be selected, default ''
- * @param $allmonths String: value of a special item denoting all month. Null to not include (default)
- * @param string $id Element identifier
- * @return String: Html string containing the month selector
- */
- public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
- global $wgLang;
- $options = array();
- if( is_null( $selected ) )
- $selected = '';
- if( !is_null( $allmonths ) )
- $options[] = self::option( wfMsg( 'monthsall' ), $allmonths, $selected === $allmonths );
- for( $i = 1; $i < 13; $i++ )
- $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
- return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) )
- . implode( "\n", $options )
- . self::closeElement( 'select' );
+ * Create a date selector
+ *
+ * @param $selected Mixed: the month which should be selected, default ''
+ * @param $allmonths String: value of a special item denoting all month. Null to not include (default)
+ * @param string $id Element identifier
+ * @return String: Html string containing the month selector
+ */
+ public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
+ global $wgLang;
+ $options = array();
+ if( is_null( $selected ) )
+ $selected = '';
+ if( !is_null( $allmonths ) )
+ $options[] = self::option( wfMsg( 'monthsall' ), $allmonths, $selected === $allmonths );
+ for( $i = 1; $i < 13; $i++ )
+ $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
+ return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) )
+ . implode( "\n", $options )
+ . self::closeElement( 'select' );
}
/**
/**
* Build a drop-down box from a textual list.
- *
+ *
* @param mixed $name Name and id for the drop-down
* @param mixed $class CSS classes for the drop-down
* @param mixed $other Text for the "Other reasons" option
public static function listDropDown( $name= '', $list = '', $other = '', $selected = '', $class = '', $tabindex = Null ) {
$options = '';
$optgroup = false;
-
+
$options = self::option( $other, 'other', $selected === 'other' );
-
+
foreach ( explode( "\n", $list ) as $option) {
$value = trim( $option );
if ( $value == '' ) {
}
}
if( $optgroup ) $options .= self::closeElement('optgroup');
-
+
$attribs = array();
if( $name ) {
$attribs['id'] = $name;
"<" => "\\x3c",
">" => "\\x3e",
- # To avoid any complaints about bad entity refs
+ # To avoid any complaints about bad entity refs
"&" => "\\x26",
-
+
# Work around https://bugzilla.mozilla.org/show_bug.cgi?id=274152
# Encode certain Unicode formatting chars so affected
# versions of Gecko don't misinterpret our strings;
/**
* Encode a variable of unknown type to JavaScript.
- * Arrays are converted to JS arrays, objects are converted to JS associative
- * arrays (objects). So cast your PHP associative arrays to objects before
+ * Arrays are converted to JS arrays, objects are converted to JS associative
+ * arrays (objects). So cast your PHP associative arrays to objects before
* passing them to here.
*/
public static function encodeJsVar( $value ) {
if ( $s != '{' ) {
$s .= ', ';
}
- $s .= '"' . self::escapeJsString( $name ) . '": ' .
+ $s .= '"' . self::escapeJsString( $name ) . '": ' .
self::encodeJsVar( $elt );
}
$s .= '}';
}
return $s;
}
-
+
/**
* Check if a string is well-formed XML.
$in );
}
}
-