/** * Special page entry point. */ public function execute( $parameters ) { $this->setHeaders(); // Security and validity checks if ( !$this->userCanExecute( $this->user ) ) { $this->displayRestrictionError(); return; } if ( !$this->request->wasPosted() ) { $this->outputForm(); return; } if ( !$this->user->matchEditToken( $this->request->getVal( 'token' ) ) ) { $this->out->addWikiMsg( 'session_fail_preview' ); $this->outputForm(); return; } if ( $this->request->getCheck( 'process' ) ) { $data = $this->getCachedData(); if ( !$data ) { $this->out->addWikiMsg( 'session_fail_preview' ); $this->outputForm(); return; } } else { /** * Proceed to loading and parsing if possible * @todo: use a Status object instead? */ $file = null; $msg = $this->loadFile( $file ); if ( $this->checkError( $msg ) ) return; $msg = $this->parseFile( $file ); if ( $this->checkError( $msg ) ) return; $data = $msg[1]; $this->setCachedData( $data ); } $messages = $data['MESSAGES']; $group = $data['METADATA']['group']; $code = $data['METADATA']['code']; if ( !MessageGroups::exists( $group ) ) { $errorWrap = "<div class='error'>\n$1\n</div>"; $this->out->wrapWikiMsg( $errorWrap, 'translate-import-err-stale-group' ); return; } $importer = new MessageWebImporter( $this->getTitle(), $group, $code ); $alldone = $importer->execute( $messages ); if ( $alldone ) { $this->deleteCachedData(); } }