parent = $parent; } /** * Is this a slow-running page in the installer? If so, WebInstaller will * set_time_limit(0) before calling execute(). Right now this only applies * to Install and Upgrade pages * * @return bool Always false in this default implementation. */ public function isSlow() { return false; } /** * @param string $html */ public function addHTML( $html ) { $this->parent->output->addHTML( $html ); } public function startForm() { $this->addHTML( "
\n" . Html::openElement( 'form', array( 'method' => 'post', 'action' => $this->parent->getUrl( array( 'page' => $this->getName() ) ) ) ) . "\n" ); } /** * @param string|bool $continue * @param string|bool $back */ public function endForm( $continue = 'continue', $back = 'back' ) { $s = "
\n"; $id = $this->getId(); if ( $id === false ) { $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) ); } if ( $continue ) { // Fake submit button for enter keypress (bug 26267) // Messages: config-continue, config-restart, config-regenerate $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(), array( 'name' => "enter-$continue", 'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n"; } if ( $back ) { // Message: config-back $s .= Xml::submitButton( wfMessage( "config-$back" )->text(), array( 'name' => "submit-$back", 'tabindex' => $this->parent->nextTabIndex() ) ) . "\n"; } if ( $continue ) { // Messages: config-continue, config-restart, config-regenerate $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(), array( 'name' => "submit-$continue", 'tabindex' => $this->parent->nextTabIndex(), ) ) . "\n"; } $s .= "
\n"; $this->addHTML( $s ); } /** * @return string */ public function getName() { return str_replace( 'WebInstaller', '', get_class( $this ) ); } /** * @return string */ protected function getId() { return array_search( $this->getName(), $this->parent->pageSequence ); } /** * @param string $var * @param mixed $default * * @return mixed */ public function getVar( $var, $default = null ) { return $this->parent->getVar( $var, $default ); } /** * @param string $name * @param mixed $value */ public function setVar( $name, $value ) { $this->parent->setVar( $name, $value ); } /** * Get the starting tags of a fieldset. * * @param string $legend Message name * * @return string */ protected function getFieldsetStart( $legend ) { return "\n
" . wfMessage( $legend )->escaped() . "\n"; } /** * Get the end tag of a fieldset. * * @return string */ protected function getFieldsetEnd() { return "
\n"; } /** * Opens a textarea used to display the progress of a long operation */ protected function startLiveBox() { $this->addHTML( '' . '' . '
' . '
' ); $this->parent->output->flush(); } } class WebInstallerLanguage extends WebInstallerPage { /** * @return string|null */ public function execute() { global $wgLang; $r = $this->parent->request; $userLang = $r->getVal( 'uselang' ); $contLang = $r->getVal( 'ContLang' ); $languages = Language::fetchLanguageNames(); $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) ); if ( !$lifetime ) { $lifetime = 1440; // PHP default } if ( $r->wasPosted() ) { # Do session test if ( $this->parent->getSession( 'test' ) === null ) { $requestTime = $r->getVal( 'LanguageRequestTime' ); if ( !$requestTime ) { // The most likely explanation is that the user was knocked back // from another page on POST due to session expiry $msg = 'config-session-expired'; } elseif ( time() - $requestTime > $lifetime ) { $msg = 'config-session-expired'; } else { $msg = 'config-no-session'; } $this->parent->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) ); } else { if ( isset( $languages[$userLang] ) ) { $this->setVar( '_UserLang', $userLang ); } if ( isset( $languages[$contLang] ) ) { $this->setVar( 'wgLanguageCode', $contLang ); } return 'continue'; } } elseif ( $this->parent->showSessionWarning ) { # The user was knocked back from another page to the start # This probably indicates a session expiry $this->parent->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) ); } $this->parent->setSession( 'test', true ); if ( !isset( $languages[$userLang] ) ) { $userLang = $this->getVar( '_UserLang', 'en' ); } if ( !isset( $languages[$contLang] ) ) { $contLang = $this->getVar( 'wgLanguageCode', 'en' ); } $this->startForm(); $s = Html::hidden( 'LanguageRequestTime', time() ) . $this->getLanguageSelector( 'uselang', 'config-your-language', $userLang, $this->parent->getHelpBox( 'config-your-language-help' ) ) . $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang, $this->parent->getHelpBox( 'config-wiki-language-help' ) ); $this->addHTML( $s ); $this->endForm( 'continue', false ); return null; } /** * Get a "