-wfProfileIn( "main-action" );
-$search = $wgRequest->getText( 'search' );
-if( !is_null( $search ) && $search !== '' ) {
- require_once( 'SearchEngine.php' );
- $wgTitle = Title::makeTitle( NS_SPECIAL, "Search" );
- $searchEngine = new SearchEngine( $search );
- if( $wgRequest->getVal( 'fulltext' ) ||
- !is_null( $wgRequest->getVal( 'offset' ) ) ||
- !is_null ($wgRequest->getVal( 'searchx' ) ) ) {
- $searchEngine->showResults();
- } else {
- $searchEngine->goResult();
- }
-} else if( !$wgTitle or $wgTitle->getDBkey() == "" ) {
- $wgTitle = Title::newFromText( wfMsgForContent( "badtitle" ) );
- $wgOut->errorpage( "badtitle", "badtitletext" );
-} else if ( $wgTitle->getInterwiki() != "" ) {
- $url = $wgTitle->getFullURL();
- # Check for a redirect loop
- if ( !preg_match( "/^" . preg_quote( $wgServer, "/" ) . "/", $url ) && $wgTitle->isLocal() ) {
- $wgOut->redirect( $url );
- } else {
- $wgTitle = Title::newFromText( wfMsgForContent( "badtitle" ) );
- $wgOut->errorpage( "badtitle", "badtitletext" );
- }
-} else if ( ( $action == "view" ) &&
- (!isset( $_GET['title'] ) || $wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
- !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
-{
- /* redirect to canonical url, make it a 301 to allow caching */
- $wgOut->redirect( $wgTitle->getFullURL(), '301');
-} else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
- # actions that need to be made when we have a special pages
- require_once( 'includes/SpecialPage.php' );
- if ( !$wgAllowSysopQueries ) {SpecialPage::removePage( 'Asksql' ); }
- SpecialPage::executePath( $wgTitle );
-} else {
- if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
- $wgTitle = Title::makeTitle( NS_IMAGE, $wgTitle->getDBkey() );
- }