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; }
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 ) ); }
/** * @param $user User * @return bool */ public static function onAddNewAccount( $user ) { global $wgRequest, $wmincProjects, $wmincPref; $projectvalue = $wgRequest->getVal( 'testwiki-project' ); $codevalue = $wgRequest->getVal( 'testwiki-code' ); if ( IncubatorTest::validateLanguageCode( $codevalue ) && isset( $wmincProjects[$projectvalue] ) ) { $user->setOption( $wmincPref . '-project', $projectvalue ); $user->setOption( $wmincPref . '-code', $codevalue ); $user->saveSettings(); } return true; }
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' ); }
/** * Query */ static function onSpecialListusersQueryInfo( $pager, &$query ) { $testwiki = IncubatorTest::getUrlParam(); $project = self::getProjectInput(); if( !$project && !$testwiki ) { return true; # no input or invalid input } global $wmincPref; $query['tables']['p1'] = 'user_properties'; $query['join_conds']['p1'] = array( 'JOIN', array( 'user_id=p1.up_user', 'p1.up_property' => "$wmincPref-project", 'p1.up_value' => $project ? $project['short'] : $testwiki['project'] ) ); if( $project ) { return true; # project site doesn't need language code = returning } $query['tables']['p2'] = 'user_properties'; $query['join_conds']['p2'] = array( 'JOIN', array( 'user_id=p2.up_user', 'p2.up_property' => "$wmincPref-code", 'p2.up_value' => $testwiki['lang'] ) ); return true; }
/** * 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' ) ); }
/** * @return String */ public function showExistingWiki() { global $wgLang; $created = isset( $this->mCreated ) ? $this->mCreated : ''; # for future use $bug = isset( $this->mBug ) ? $this->mBug : ''; # for future use $subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode ); $subdomainLink = IncubatorTest::makeExternalLinkText( $subdomain, true ); if( $this->mThisLangData['type'] != 'invalid' ) { $gotoSubdomain = Html::rawElement( 'span', array( 'class' => 'wminc-infopage-entertest' ), $wgLang->getArrow() . ' ' . $subdomainLink ); } $content = Html::rawElement( 'div', array( 'class' => 'wminc-infopage-status' ), wfMsgWikiHtml( 'wminc-infopage-status-' . $this->mSubStatus, $subdomainLink ) ) . Html::rawElement( 'ul', array( 'class' => 'wminc-infopage-options' ), Html::rawElement( 'li', null, wfMsgWikiHtml( 'wminc-infopage-option-sisterprojects-other' ) . $this->listOtherProjects() ) . Html::rawElement( 'li', null, wfMsgWikiHtml( 'wminc-infopage-option-multilingual' ) . $this->listMultilingualProjects() ) ); return $this->StandardInfoPage( $this->showWelcome(), $gotoSubdomain, $content ); }
/** * Whether we should use the feature of custom logos per project * @param $title Title object * @return false or Array from analyzePrefix() */ static function shouldWeSetCustomLogo( $title ) { $prefix = IncubatorTest::analyzePrefix( $title->getText() ); # Maybe do later something like if( isContentProject() && 'recentchanges' ) { return true; } # return if the page does not have a valid prefix (info page is considered valid) if( $prefix['error'] ) { return false; } # display the custom logo only if &testwiki=wx/xx or the user's pref is set to the current test wiki if( self::displayPrefix() != $prefix['prefix'] ) { return false; } global $wmincTestWikiNamespaces; # return if the page is not in one of the test wiki namespaces if( !in_array( $title->getNamespace(), (array)$wmincTestWikiNamespaces ) ) { return false; } return $prefix; }