コード例 #1
0
	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 ) );
	}
コード例 #2
0
	static function onRcQuery( &$conds, &$tables, &$join_conds, $opts ) {
		global $wmincProjectSite, $wmincTestWikiNamespaces;
		list( $projectvalue, $codevalue ) = self::getValues();
		$prefix = IncubatorTest::displayPrefix( $projectvalue, $codevalue );
		$opts->add( 'rc-testwiki-project', false );
		$opts->setValue( 'rc-testwiki-project', $projectvalue );
		$opts->add( 'rc-testwiki-code', false );
		$opts->setValue( 'rc-testwiki-code', $codevalue );
		if ( $projectvalue == 'none' || $projectvalue == '' ) {
			// If "none" is selected, display normal recent changes
			return true;
		} elseif ( $projectvalue == $wmincProjectSite['short'] ) {
			// If project site is selected, display all changes except test wiki changes
			$dbr = wfGetDB( DB_SLAVE );
			$conds[] = 'rc_title NOT ' . $dbr->buildLike( 'W', $dbr->anyChar(), '/', $dbr->anyString() );
		} elseif( IncubatorTest::validatePrefix( $prefix, true ) ) {
			// Else, display changes to the selected test wiki in the appropriate namespaces
			$dbr = wfGetDB( DB_SLAVE );
			$conds['rc_namespace'] = $wmincTestWikiNamespaces;
			$conds[] = 'rc_title ' . $dbr->buildLike( $prefix . '/', $dbr->anyString() ) .
			' OR rc_title = ' . $dbr->addQuotes( $prefix );
		} else {
			return true;
		}
		return true;
	}
コード例 #3
0
	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' );
	}
コード例 #4
0
	/**
	 * 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' )
		);
	}