X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Finstaller%2FWebInstaller.php;h=97fa245c41d70bb768ec1dc93c8a4fc199f28d98;hb=fb7b3eebeb8de47eb42e8d6ccf204106a2d6d9e4;hp=67a4defd2c39e287d3b5c8cbab5def855c353af7;hpb=63016a107324acdd2fbeb203aa8a2fc44a6fb9ba;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 67a4defd2c..97fa245c41 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -65,7 +65,7 @@ class WebInstaller extends Installer { * * @var string[] */ - public $pageSequence = array( + public $pageSequence = [ 'Language', 'ExistingWiki', 'Welcome', @@ -76,20 +76,20 @@ class WebInstaller extends Installer { 'Options', 'Install', 'Complete', - ); + ]; /** * Out of sequence pages, selectable by the user at any time. * * @var string[] */ - protected $otherPages = array( + protected $otherPages = [ 'Restart', 'Readme', 'ReleaseNotes', 'Copying', 'UpgradeDoc', // Can't use Upgrade due to Upgrade step - ); + ]; /** * Array of pages which have declared that they have been submitted, have validated @@ -141,8 +141,8 @@ class WebInstaller extends Installer { // Add parser hooks global $wgParser; - $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) ); - $wgParser->setHook( 'doclink', array( $this, 'docLink' ) ); + $wgParser->setHook( 'downloadlink', [ $this, 'downloadLinkHook' ] ); + $wgParser->setHook( 'doclink', [ $this, 'docLink' ] ); } /** @@ -159,7 +159,6 @@ class WebInstaller extends Installer { $this->settings = $session['settings'] + $this->settings; } - $this->exportVars(); $this->setupLanguage(); if ( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) ) @@ -189,13 +188,13 @@ class WebInstaller extends Installer { if ( isset( $session['happyPages'] ) ) { $this->happyPages = $session['happyPages']; } else { - $this->happyPages = array(); + $this->happyPages = []; } if ( isset( $session['skippedPages'] ) ) { $this->skippedPages = $session['skippedPages']; } else { - $this->skippedPages = array(); + $this->skippedPages = []; } $lowestUnhappy = $this->getLowestUnhappy(); @@ -264,7 +263,7 @@ class WebInstaller extends Installer { $nextPage = $this->pageSequence[$lowestUnhappy]; } - $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) ); + $this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) ); return $this->finish(); } @@ -310,7 +309,7 @@ class WebInstaller extends Installer { $nextPage = $this->pageSequence[$lowestUnhappy]; } - $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) ); + $this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) ); } return $this->finish(); @@ -340,8 +339,8 @@ class WebInstaller extends Installer { return true; } - $this->phpErrors = array(); - set_error_handler( array( $this, 'errorHandler' ) ); + $this->phpErrors = []; + set_error_handler( [ $this, 'errorHandler' ] ); try { session_name( 'mw_installer_session' ); session_start(); @@ -379,23 +378,27 @@ class WebInstaller extends Installer { $url = $m[1]; } - return md5( serialize( array( + return md5( serialize( [ 'local path' => dirname( __DIR__ ), 'url' => $url, 'version' => $GLOBALS['wgVersion'] - ) ) ); + ] ) ); } /** - * Show an error message in a box. Parameters are like wfMessage(). - * @param string $msg + * Show an error message in a box. Parameters are like wfMessage(), or + * alternatively, pass a Message object in. + * @param string|Message $msg */ public function showError( $msg /*...*/ ) { - $args = func_get_args(); - array_shift( $args ); - $args = array_map( 'htmlspecialchars', $args ); - $msg = wfMessage( $msg, $args )->useDatabase( false )->plain(); - $this->output->addHTML( $this->getErrorBox( $msg ) ); + if ( !( $msg instanceof Message ) ) { + $args = func_get_args(); + array_shift( $args ); + $args = array_map( 'htmlspecialchars', $args ); + $msg = wfMessage( $msg, $args ); + } + $text = $msg->useDatabase( false )->plain(); + $this->output->addHTML( $this->getErrorBox( $text ) ); } /** @@ -427,9 +430,9 @@ class WebInstaller extends Installer { * We're restarting the installation, reset the session, happyPages, etc */ public function reset() { - $this->session = array(); - $this->happyPages = array(); - $this->settings = array(); + $this->session = []; + $this->happyPages = []; + $this->settings = []; } /** @@ -439,7 +442,7 @@ class WebInstaller extends Installer { * * @return string */ - public function getUrl( $query = array() ) { + public function getUrl( $query = [] ) { $url = $this->request->getRequestURL(); # Remove existing query $url = preg_replace( '/\?.*$/', '', $url ); @@ -569,7 +572,7 @@ class WebInstaller extends Installer { // config-page-dbsettings, config-page-name, config-page-options, config-page-install, // config-page-complete, config-page-restart, config-page-readme, config-page-releasenotes, // config-page-copying, config-page-upgradedoc, config-page-existingwiki - $s .= Html::element( 'h2', array(), + $s .= Html::element( 'h2', [], wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() ); $this->output->addHTMLNoFlush( $s ); @@ -595,7 +598,7 @@ class WebInstaller extends Installer { $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text(); if ( $enabled ) { - $query = array( 'page' => $pageName ); + $query = [ 'page' => $pageName ]; if ( !in_array( $pageName, $this->pageSequence ) ) { if ( in_array( $currentPageName, $this->pageSequence ) ) { @@ -603,9 +606,9 @@ class WebInstaller extends Installer { } $link = Html::element( 'a', - array( + [ 'href' => $this->getUrl( $query ) - ), + ], $name ); } else { @@ -619,9 +622,9 @@ class WebInstaller extends Installer { } } else { $s .= Html::element( 'span', - array( + [ 'class' => 'config-page-disabled' - ), + ], $name ); } @@ -711,7 +714,7 @@ class WebInstaller extends Installer { */ public function showHelpBox( $msg /*, ... */ ) { $args = func_get_args(); - $html = call_user_func_array( array( $this, 'getHelpBox' ), $args ); + $html = call_user_func_array( [ $this, 'getHelpBox' ], $args ); $this->output->addHTML( $html ); } @@ -736,7 +739,7 @@ class WebInstaller extends Installer { public function showStatusMessage( Status $status ) { $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() ); foreach ( $errors as $error ) { - call_user_func_array( array( $this, 'showMessage' ), $error ); + call_user_func_array( [ $this, 'showMessage' ], $error ); } } @@ -757,7 +760,7 @@ class WebInstaller extends Installer { $labelText = wfMessage( $msg )->escaped(); } - $attributes = array( 'class' => 'config-label' ); + $attributes = [ 'class' => 'config-label' ]; if ( $forId ) { $attributes['for'] = $forId; @@ -801,7 +804,7 @@ class WebInstaller extends Installer { } if ( !isset( $params['attribs'] ) ) { - $params['attribs'] = array(); + $params['attribs'] = []; } if ( !isset( $params['help'] ) ) { $params['help'] = ""; @@ -814,11 +817,11 @@ class WebInstaller extends Installer { $params['controlName'], 30, // intended to be overridden by CSS $params['value'], - $params['attribs'] + array( + $params['attribs'] + [ 'id' => $params['controlName'], 'class' => 'config-input-text', 'tabindex' => $this->nextTabIndex() - ) + ] ), $params['help'] ); @@ -848,7 +851,7 @@ class WebInstaller extends Installer { } if ( !isset( $params['attribs'] ) ) { - $params['attribs'] = array(); + $params['attribs'] = []; } if ( !isset( $params['help'] ) ) { $params['help'] = ""; @@ -862,11 +865,11 @@ class WebInstaller extends Installer { $params['value'], 30, 5, - $params['attribs'] + array( + $params['attribs'] + [ 'id' => $params['controlName'], 'class' => 'config-input-text', 'tabindex' => $this->nextTabIndex() - ) + ] ), $params['help'] ); @@ -893,7 +896,7 @@ class WebInstaller extends Installer { } if ( !isset( $params['attribs'] ) ) { - $params['attribs'] = array(); + $params['attribs'] = []; } $params['value'] = $this->getFakePassword( $params['value'] ); @@ -926,7 +929,7 @@ class WebInstaller extends Installer { } if ( !isset( $params['attribs'] ) ) { - $params['attribs'] = array(); + $params['attribs'] = []; } if ( !isset( $params['help'] ) ) { $params['help'] = ""; @@ -943,10 +946,10 @@ class WebInstaller extends Installer { Xml::check( $params['controlName'], $params['value'], - $params['attribs'] + array( + $params['attribs'] + [ 'id' => $params['controlName'], 'tabindex' => $this->nextTabIndex(), - ) + ] ) . $labelText . "\n" . "\n" . @@ -1014,10 +1017,10 @@ class WebInstaller extends Installer { $params['value'] = $this->getVar( $params['var'] ); } - $items = array(); + $items = []; foreach ( $params['values'] as $value ) { - $itemAttribs = array(); + $itemAttribs = []; if ( isset( $params['commonAttribs'] ) ) { $itemAttribs = $params['commonAttribs']; @@ -1035,7 +1038,7 @@ class WebInstaller extends Installer { $items[$value] = Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) . ' ' . - Xml::tags( 'label', array( 'for' => $id ), $this->parse( + Xml::tags( 'label', [ 'for' => $id ], $this->parse( isset( $params['itemLabels'] ) ? wfMessage( $params['itemLabels'][$value] )->plain() : wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain() @@ -1075,7 +1078,7 @@ class WebInstaller extends Installer { * @return string[] */ public function setVarsFromRequest( $varNames, $prefix = 'config_' ) { - $newValues = array(); + $newValues = []; foreach ( $varNames as $name ) { $value = $this->request->getVal( $prefix . $name ); @@ -1145,11 +1148,11 @@ class WebInstaller extends Installer { */ public function downloadLinkHook( $text, $attribs, $parser ) { $anchor = Html::rawElement( 'a', - array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ), + [ 'href' => $this->getURL( [ 'localsettings' => 1 ] ) ], wfMessage( 'config-download-localsettings' )->parse() ); - return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor ); + return Html::rawElement( 'div', [ 'class' => 'config-download-link' ], $anchor ); } /**