public function execute( $par ) { global $wgOut; $title = ''; $params = array(); if( IncubatorTest::isContentProject() ) { global $wgRequest; $title = Title::newFromText( IncubatorTest::displayPrefix() ); if( $wgRequest->getVal( 'goto' ) != 'infopage' ) { $params['goto'] = 'mainpage'; } $url = IncubatorTest::getUrlParam(); if( $url ) { $params['testwiki'] = $url['prefix']; } } # Go to the main page if given invalid title, or if it's not a content project if ( !$title ) { $title = Title::newMainPage(); } $wgOut->redirect( $title->getLocalURL( $params ) ); }
public function __construct() { global $wgUser, $wgRequest, $wmincPref, $wmincProjectSite; $target = $wgRequest->getVal( 'testwiki' ); $target = IncubatorTest::analyzePrefix( $target ); $project = isset( $target['project'] ) ? $target['project'] : ''; $lang = isset( $target['lang'] ) ? $target['lang'] : ''; if( IncubatorTest::isContentProject() || ( $project && $lang ) ) { $dbr = wfGetDB( DB_SLAVE ); $this->extra[] = 'page_title' . $dbr->buildLike( IncubatorTest::displayPrefix( $project, $lang ) . '/', $dbr->anyString() ); } elseif( $wgUser->getOption($wmincPref . '-project') == $wmincProjectSite['short'] ) { # project or help namespace $this->extra['page_namespace'] = array( 4, 12 ); } parent::__construct( 'RandomByTest' ); }
/** * Retrieves and shows the user language and test wiki * @param $target Mixed: user whose language and test wiki we're looking up */ function showInfo( $target ) { global $wgOut, $wmincPref, $wmincProjectSite; if( User::isIP( $target ) ) { # show error if it is an IP address $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) ); return; } $user = User::newFromName( $target ); $name = $user->getName(); $id = $user->getId(); $langNames = Language::getLanguageNames(); $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker; if ( $user == null || $id == 0 ) { # show error if a user with that name does not exist $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) ); return; } $userproject = $user->getOption( $wmincPref . '-project' ); $userproject = ( $userproject ? $userproject : 'none' ); $usercode = $user->getOption( $wmincPref . '-code' ); $prefix = IncubatorTest::displayPrefix( $userproject, $usercode ? $usercode : 'none' ); if ( IncubatorTest::isContentProject( $userproject ) ) { $testwiki = $linker->link( Title::newFromText( $prefix ) ); } elseif ( $prefix == $wmincProjectSite['short'] ) { $testwiki = htmlspecialchars( $wmincProjectSite['name'] ); } else { $testwiki = wfMsgHtml( 'wminc-testwiki-none' ); } $wgOut->addHtml( Xml::openElement( 'ul' ) . '<li>' . wfMsgHtml( 'username' ) . ' ' . $linker->userLink( $id, $name ) . $linker->userToolLinks( $id, $name, true ) . '</li>' . '<li>' . wfMsgHtml( 'loginlanguagelabel', $langNames[$user->getOption( 'language' )] . ' (' . $user->getOption( 'language' ) . ')' ) . '</li>' . '<li>' . wfMsgHtml( 'wminc-testwiki' ) . ' ' . $testwiki . '</li>' . Xml::closeElement( 'ul' ) ); }