global $wgHtml5;
$attribs['name'] = $name;
if ( !$wgHtml5 ) {
- if ( !isset( $attribs['cols'] ) )
+ if ( !isset( $attribs['cols'] ) ) {
$attribs['cols'] = "";
- if ( !isset( $attribs['rows'] ) )
+ }
+ if ( !isset( $attribs['rows'] ) ) {
$attribs['rows'] = "";
+ }
}
return self::element( 'textarea', $attribs, $value );
}
}
}
$html = Html::openElement( 'html', $attribs );
- if ( $html ) $html .= "\n";
+ if ( $html ) {
+ $html .= "\n";
+ }
$ret .= $html;
return $ret;
}
*/
public static function isXmlMimeType( $mimetype ) {
switch ( $mimetype ) {
- case 'text/xml':
- case 'application/xhtml+xml':
- case 'application/xml':
- return true;
- default:
- return false;
+ case 'text/xml':
+ case 'application/xhtml+xml':
+ case 'application/xml':
+ return true;
+ default:
+ return false;
}
}
}
$titles = array();
if( !is_array( $list ) ) {
$list = explode( "\n", trim( $list ) );
- if( !is_array( $list ) )
+ if( !is_array( $list ) ) {
return array();
+ }
}
foreach( $list as $text ) {
$text = trim( $text );
if( strlen( $text ) > 0 ) {
$title = Title::newFromText( $text );
- if( $title instanceof Title && $title->isWatchable() )
+ if( $title instanceof Title && $title->isWatchable() ) {
$titles[] = $title->getPrefixedText();
+ }
}
}
return array_unique( $titles );
// Do a batch existence check
$batch = new LinkBatch();
foreach( $titles as $title ) {
- if( !$title instanceof Title )
+ if( !$title instanceof Title ) {
$title = Title::newFromText( $title );
+ }
if( $title instanceof Title ) {
$batch->addObj( $title );
$batch->addObj( $title->getTalkPage() );
// Print out the list
$output->addHTML( "<ul>\n" );
foreach( $titles as $title ) {
- if( !$title instanceof Title )
+ if( !$title instanceof Title ) {
$title = Title::newFromText( $title );
+ }
if( $title instanceof Title ) {
$output->addHTML( "<li>" . $skin->link( $title )
. ' (' . $skin->link( $title->getTalkPage(), $talk ) . ")</li>\n" );
$cache->addBadLinkObj( $title );
}
// Ignore non-talk
- if( !$title->isTalkPage() )
+ if( !$title->isTalkPage() ) {
$titles[$row->wl_namespace][$row->wl_title] = $row->page_is_redirect;
+ }
}
}
}
$dbw = wfGetDB( DB_MASTER );
$rows = array();
foreach( $titles as $title ) {
- if( !$title instanceof Title )
+ if( !$title instanceof Title ) {
$title = Title::newFromText( $title );
+ }
if( $title instanceof Title ) {
$rows[] = array(
'wl_user' => $user->getId(),
private function unwatchTitles( $titles, $user ) {
$dbw = wfGetDB( DB_MASTER );
foreach( $titles as $title ) {
- if( !$title instanceof Title )
+ if( !$title instanceof Title ) {
$title = Title::newFromText( $title );
+ }
if( $title instanceof Title ) {
$dbw->delete(
'watchlist',
global $wgLang;
$link = $skin->link( $title );
- if( $redirect )
+ if( $redirect ) {
$link = '<span class="watchlistredir">' . $link . '</span>';
+ }
$tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) );
if( $title->exists() ) {
$tools[] = $skin->link(
$form .= Xml::openElement( 'textarea', array( 'id' => 'titles', 'name' => 'titles',
'rows' => $wgUser->getIntOption( 'rows' ), 'cols' => $wgUser->getIntOption( 'cols' ) ) );
$titles = $this->getWatchlist( $user );
- foreach( $titles as $title )
+ foreach( $titles as $title ) {
$form .= htmlspecialchars( $title ) . "\n";
+ }
$form .= '</textarea>';
$form .= '<p>' . Xml::submitButton( wfMsg( 'watchlistedit-raw-submit' ) ) . '</p>';
$form .= '</fieldset></form>';
global $wgUser;
$limit = $this->getInt( 'limit', 0 );
- if( $limit < 0 ) $limit = 0;
+ if( $limit < 0 ) {
+ $limit = 0;
+ }
if( ( $limit == 0 ) && ( $optionname != '' ) ) {
$limit = (int)$wgUser->getOption( $optionname );
}
- if( $limit <= 0 ) $limit = $deflimit;
- if( $limit > 5000 ) $limit = 5000; # We have *some* limits...
+ if( $limit <= 0 ) {
+ $limit = $deflimit;
+ }
+ if( $limit > 5000 ) {
+ $limit = 5000; # We have *some* limits...
+ }
$offset = $this->getInt( 'offset', 0 );
- if( $offset < 0 ) $offset = 0;
+ if( $offset < 0 ) {
+ $offset = 0;
+ }
return array( $limit, $offset );
}
* @return Mixed
*/
public function getSessionData( $key ) {
- if( !isset( $_SESSION[$key] ) )
+ if( !isset( $_SESSION[$key] ) ) {
return null;
+ }
return $_SESSION[$key];
}
global $wgTitle;
$basequery = '';
foreach( $this->data as $var => $val ) {
- if ( $var == 'title' )
+ if ( $var == 'title' ) {
continue;
- if ( is_array( $val ) )
+ }
+ if ( is_array( $val ) ) {
/* This will happen given a request like
* http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page
*/
continue;
+ }
$basequery .= '&' . urlencode( $var ) . '=' . urlencode( $val );
}
$basequery .= '&' . $query;
global $wgUser;
$sk = $wgUser->getSkin();
- if ( !$text )
+ if ( !$text ) {
$text = $page;
+ }
$url = self::getForeignURL( $wikiID, $page );
- if ( $url === false )
+ if ( $url === false ) {
return false;
+ }
return $sk->makeExternalLink( $url, $text );
}
public static function getForeignURL( $wikiID, $page ) {
$wiki = WikiMap::getWiki( $wikiID );
- if ( $wiki )
+ if ( $wiki ) {
return $wiki->getUrl( $page );
+ }
return false;
}
if( is_null( $attribs ) ) {
return null;
} elseif( is_array( $attribs ) ) {
- foreach( $attribs as $name => $val )
+ foreach( $attribs as $name => $val ) {
$out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
+ }
return $out;
} else {
throw new MWException( 'Expected attribute array, got something else in ' . __METHOD__ );
if( !is_null( $all ) )
$namespaces = array( $all => wfMsg( 'namespacesall' ) ) + $namespaces;
foreach( $namespaces as $index => $name ) {
- if( $index < NS_MAIN )
+ if( $index < NS_MAIN ) {
continue;
- if( $index === 0 )
+ }
+ if( $index === 0 ) {
$name = wfMsg( 'blanknamespace' );
+ }
$options[] = self::option( $name, $index, $index === $selected );
}
protected $attributes = array();
public function __construct( $name = false, $id = false, $default = false ) {
- if ( $name ) $this->setAttribute( 'name', $name );
- if ( $id ) $this->setAttribute( 'id', $id );
- if ( $default !== false ) $this->default = $default;
+ if ( $name ) {
+ $this->setAttribute( 'name', $name );
+ }
+ if ( $id ) {
+ $this->setAttribute( 'id', $id );
+ }
+ if ( $default !== false ) {
+ $this->default = $default;
+ }
}
public function setDefault( $default ) {
$errno = $errstr = '';
$this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30);
wfRestoreWarnings();
- if(!$this->mFP) {
+ if ( !$this->mFP ) {
return false;
}
return true;
* @access private
*/
function query($request) {
- if(!$this->mConnected)
+ if ( !$this->mConnected ) {
return false;
+ }
fwrite($this->mFP, $request);
$data .= $str;
}
//data should be of length $len. otherwise something is wrong
- if(strlen($data) != $len)
+ if ( strlen($data) != $len ) {
return false;
+ }
return $data;
}
$len = strlen($text);
$q = "CONV $tolang $len\n$text";
$result = $this->query($q);
- if(!$result)
+ if ( !$result ) {
$result = $text;
+ }
return $result;
}
$len = strlen($text);
$q = "CONV ALL $len\n$text";
$result = $this->query($q);
- if(!$result)
+ if ( !$result ) {
return false;
+ }
list($infoline, $data) = explode('|', $result, 2);
$info = explode(";", $infoline);
$ret = array();
$len = strlen($text);
$q = "SEG $len\n$text";
$result = $this->query($q);
- if(!$result) {// fallback to character based segmentation
+ if ( !$result ) {// fallback to character based segmentation
$result = $this->segment($text);
}
return $result;