array_shift( $args );
array_shift( $args );
$options = (array)$options;
+ $validOptions = array( 'parse', 'parseinline', 'escape', 'escapenoentities', 'replaceafter',
+ 'parsemag', 'content' );
foreach ( $options as $arrayKey => $option ) {
if ( !preg_match( '/^[0-9]+|language$/', $arrayKey ) ) {
- # An unknown index, neither numeric nor "language"
+ // An unknown index, neither numeric nor "language"
wfWarn( "wfMsgExt called with incorrect parameter key $arrayKey", 1, E_USER_WARNING );
- } elseif ( preg_match( '/^[0-9]+$/', $arrayKey ) && !in_array( $option,
- array( 'parse', 'parseinline', 'escape', 'escapenoentities',
- 'replaceafter', 'parsemag', 'content' ) ) ) {
- # A numeric index with unknown value
+ } elseif ( preg_match( '/^[0-9]+$/', $arrayKey ) && !in_array( $option, $validOptions ) ) {
+ // A numeric index with unknown value
wfWarn( "wfMsgExt called with incorrect parameter $option", 1, E_USER_WARNING );
}
}
// In text/html, initial <html> and <head> tags can be omitted under
// pretty much any sane circumstances, if they have no attributes. See:
// <http://www.whatwg.org/html/syntax.html#optional-tags>
- if ( !$wgWellFormedXml && !$attribs
- && in_array( $element, array( 'html', 'head' ) ) ) {
+ if ( !$wgWellFormedXml && !$attribs && in_array( $element, array( 'html', 'head' ) ) ) {
return '';
}
'tel',
'color',
);
- if ( isset( $attribs['type'] )
- && !in_array( $attribs['type'], $validTypes ) ) {
+ if ( isset( $attribs['type'] ) && !in_array( $attribs['type'], $validTypes ) ) {
unset( $attribs['type'] );
}
}
}
// Simple checks using $attribDefaults
- if ( isset( $attribDefaults[$element][$lcattrib] ) &&
- $attribDefaults[$element][$lcattrib] == $value ) {
+ if ( isset( $attribDefaults[$element][$lcattrib] )
+ && $attribDefaults[$element][$lcattrib] == $value
+ ) {
unset( $attribs[$attrib] );
}
}
// More subtle checks
- if ( $element === 'link' && isset( $attribs['type'] )
- && strval( $attribs['type'] ) == 'text/css' ) {
+ if ( $element === 'link'
+ && isset( $attribs['type'] ) && strval( $attribs['type'] ) == 'text/css'
+ ) {
unset( $attribs['type'] );
}
if ( $element === 'input' ) {
// For boolean attributes, support array( 'foo' ) instead of
// requiring array( 'foo' => 'meaningless' ).
- if ( is_int( $key )
- && in_array( strtolower( $value ), self::$boolAttribs ) ) {
+ if ( is_int( $key ) && in_array( strtolower( $value ), self::$boolAttribs ) ) {
$key = $value;
}
// marks omitted, but not all. (Although a literal " is not
// permitted, we don't check for that, since it will be escaped
// anyway.)
- #
+
// See also research done on further characters that need to be
// escaped: http://code.google.com/p/html5lib/issues/detail?id=93
$badChars = "\\x00- '=<>`/\x{00a0}\x{1680}\x{180e}\x{180F}\x{2000}\x{2001}"
. "\x{2002}\x{2003}\x{2004}\x{2005}\x{2006}\x{2007}\x{2008}\x{2009}"
. "\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}";
- if ( $wgWellFormedXml || $value === ''
- || preg_match( "![$badChars]!u", $value ) ) {
+ if ( $wgWellFormedXml || $value === '' || preg_match( "![$badChars]!u", $value ) ) {
$quote = '"';
} else {
$quote = '';
$dummy = new DummyLinker; // dummy linker instance for bc on the hooks
$ret = null;
- if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$html,
- &$customAttribs, &$query, &$options, &$ret ) ) ) {
+ if ( !wfRunHooks( 'LinkBegin',
+ array( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) )
+ ) {
wfProfileOut( __METHOD__ );
return $ret;
}
$newparams = '';
} else {
# Keep track for later
- if ( isset( $tabletags[$t] ) &&
- !in_array( 'table', $tagstack ) ) {
+ if ( isset( $tabletags[$t] ) && !in_array( 'table', $tagstack ) ) {
$badtag = true;
- } elseif ( in_array( $t, $tagstack ) &&
- !isset( $htmlnest[$t] ) ) {
+ } elseif ( in_array( $t, $tagstack ) && !isset( $htmlnest[$t] ) ) {
$badtag = true;
# Is it a self closed htmlpair ? (bug 5487)
- } elseif ( $brace == '/>' &&
- isset( $htmlpairs[$t] ) ) {
+ } elseif ( $brace == '/>' && isset( $htmlpairs[$t] ) ) {
$badtag = true;
} elseif ( isset( $htmlsingleonly[$t] ) ) {
# Hack to force empty tag for unclosable elements
# the tag stack so that we can match end tags
# instead of marking them as bad.
array_push( $tagstack, $t );
- } elseif ( isset( $tabletags[$t] )
- && in_array( $t, $tagstack ) ) {
+ } elseif ( isset( $tabletags[$t] ) && in_array( $t, $tagstack ) ) {
// New table tag but forgot to close the previous one
$text .= "</$t>";
} else {
$id = preg_replace( '/[ \t\n\r\f_\'"&#%]+/', '_', $id );
$id = trim( $id, '_' );
if ( $id === '' ) {
- # Must have been all whitespace to start with.
+ // Must have been all whitespace to start with.
return '_';
} else {
return $id;
}
}
- # HTML4-style escaping
+ // HTML4-style escaping
static $replace = array(
'%3A' => ':',
'%' => '.'
$id = urlencode( strtr( $id, ' ', '_' ) );
$id = str_replace( array_keys( $replace ), array_values( $replace ), $id );
- if ( !preg_match( '/^[a-zA-Z]/', $id )
- && !in_array( 'noninitial', $options ) ) {
+ if ( !preg_match( '/^[a-zA-Z]/', $id ) && !in_array( 'noninitial', $options ) ) {
// Initial character must be a letter!
$id = "x$id";
}
static function normalizeEntity( $name ) {
if ( isset( self::$htmlEntityAliases[$name] ) ) {
return '&' . self::$htmlEntityAliases[$name] . ';';
- } elseif ( in_array( $name,
- array( 'lt', 'gt', 'amp', 'quot' ) ) ) {
+ } elseif ( in_array( $name, array( 'lt', 'gt', 'amp', 'quot' ) ) ) {
return "&$name;";
} elseif ( isset( self::$htmlEntities[$name] ) ) {
return '&#' . self::$htmlEntities[$name] . ';';
global $wgContLang, $wgMaxNameChars;
if ( $name == ''
- || User::isIP( $name )
- || strpos( $name, '/' ) !== false
- || strlen( $name ) > $wgMaxNameChars
- || $name != $wgContLang->ucfirst( $name ) ) {
+ || User::isIP( $name )
+ || strpos( $name, '/' ) !== false
+ || strlen( $name ) > $wgMaxNameChars
+ || $name != $wgContLang->ucfirst( $name )
+ ) {
wfDebugLog( 'username', __METHOD__ .
": '$name' invalid due to empty, IP, slash, length, or lowercase" );
return false;
// Same thing for remove
if ( empty( $wgRemoveGroups[$group] ) ) {
+ // Do nothing
} elseif ( $wgRemoveGroups[$group] === true ) {
$groups['remove'] = self::getAllGroups();
} elseif ( is_array( $wgRemoveGroups[$group] ) ) {
// Now figure out what groups the user can add to him/herself
if ( empty( $wgGroupsAddToSelf[$group] ) ) {
+ // Do nothing
} elseif ( $wgGroupsAddToSelf[$group] === true ) {
// No idea WHY this would be used, but it's there
$groups['add-self'] = User::getAllGroups();
}
if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
+ // Do nothing
} elseif ( $wgGroupsRemoveFromSelf[$group] === true ) {
$groups['remove-self'] = User::getAllGroups();
} elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
# phone numbers when you know that they are integers (the HTML5 type=tel
# input does not require its value to be numeric). If you want a tidier
# value to, eg, save in the DB, clean it up with intval().
- if ( !preg_match( '/^((\+|\-)?\d+)?$/', trim( $value ) )
- ) {
+ if ( !preg_match( '/^((\+|\-)?\d+)?$/', trim( $value ) ) ) {
return $this->msg( 'htmlform-int-invalid' )->parseAsBlock();
}
class HTMLSelectAndOtherField extends HTMLSelectField {
function __construct( $params ) {
if ( array_key_exists( 'other', $params ) ) {
+ // Do nothing
} elseif ( array_key_exists( 'other-message', $params ) ) {
$params['other'] = wfMessage( $params['other-message'] )->plain();
} else {
parent::__construct( $params );
if ( $this->getOptions() === null ) {
- # Sulk
+ // Sulk
throw new MWException( 'HTMLSelectAndOtherField called without any options' );
}
if ( !in_array( 'other', $this->mOptions, true ) ) {
$retVal = true;
- if ( !array_key_exists( $this->getVar( '_RightsProfile' ), $this->parent->rightsProfiles )
- ) {
+ if ( !array_key_exists( $this->getVar( '_RightsProfile' ), $this->parent->rightsProfiles ) ) {
reset( $this->parent->rightsProfiles );
$this->setVar( '_RightsProfile', key( $this->parent->rightsProfiles ) );
}