WebInstallerInstall.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. * http://www.gnu.org/copyleft/gpl.html
  17. *
  18. * @file
  19. * @ingroup Deployment
  20. */
  21. class WebInstallerInstall extends WebInstallerPage {
  22. /**
  23. * @return bool Always true.
  24. */
  25. public function isSlow() {
  26. return true;
  27. }
  28. /**
  29. * @return string|bool
  30. */
  31. public function execute() {
  32. if ( $this->getVar( '_UpgradeDone' ) ) {
  33. return 'skip';
  34. } elseif ( $this->getVar( '_InstallDone' ) ) {
  35. return 'continue';
  36. } elseif ( $this->parent->request->wasPosted() ) {
  37. $this->startForm();
  38. $this->addHTML( "<ul>" );
  39. $results = $this->parent->performInstallation(
  40. [ $this, 'startStage' ],
  41. [ $this, 'endStage' ]
  42. );
  43. $this->addHTML( "</ul>" );
  44. // PerformInstallation bails on a fatal, so make sure the last item
  45. // completed before giving 'next.' Likewise, only provide back on failure
  46. $lastStep = end( $results );
  47. $continue = $lastStep->isOK() ? 'continue' : false;
  48. $back = $lastStep->isOK() ? false : 'back';
  49. $this->endForm( $continue, $back );
  50. } else {
  51. $this->startForm();
  52. $this->addHTML( $this->parent->getInfoBox( wfMessage( 'config-install-begin' )->plain() ) );
  53. $this->endForm();
  54. }
  55. return true;
  56. }
  57. /**
  58. * @param string $step
  59. */
  60. public function startStage( $step ) {
  61. // Messages: config-install-database, config-install-tables, config-install-interwiki,
  62. // config-install-stats, config-install-keys, config-install-sysop, config-install-mainpage
  63. $this->addHTML( "<li>" . wfMessage( "config-install-$step" )->escaped() .
  64. wfMessage( 'ellipsis' )->escaped() );
  65. if ( $step == 'extension-tables' ) {
  66. $this->startLiveBox();
  67. }
  68. }
  69. /**
  70. * @param string $step
  71. * @param Status $status
  72. */
  73. public function endStage( $step, $status ) {
  74. if ( $step == 'extension-tables' ) {
  75. $this->endLiveBox();
  76. }
  77. $msg = $status->isOK() ? 'config-install-step-done' : 'config-install-step-failed';
  78. $html = wfMessage( 'word-separator' )->escaped() . wfMessage( $msg )->escaped();
  79. if ( !$status->isOK() ) {
  80. $html = "<span class=\"error\">$html</span>";
  81. }
  82. $this->addHTML( $html . "</li>\n" );
  83. if ( !$status->isGood() ) {
  84. $this->parent->showStatusBox( $status );
  85. }
  86. }
  87. }