MediaWiki  master
WebInstallerPage.php
Go to the documentation of this file.
1 <?php
25 
32 abstract class WebInstallerPage {
33 
39  public $parent;
40 
44  abstract public function execute();
45 
49  public function __construct( WebInstaller $parent ) {
50  $this->parent = $parent;
51  }
52 
60  public function isSlow() {
61  return false;
62  }
63 
67  public function addHTML( $html ) {
68  $this->parent->output->addHTML( $html );
69  }
70 
71  public function startForm() {
72  $this->addHTML(
73  "<div class=\"config-section\">\n" .
74  Html::openElement(
75  'form',
76  [
77  'method' => 'post',
78  'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] )
79  ]
80  ) . "\n"
81  );
82  }
83 
88  public function endForm( $continue = 'continue', $back = 'back' ) {
89  $s = "<div class=\"config-submit\">\n";
90  $id = $this->getId();
91 
92  if ( $id === false ) {
93  $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
94  }
95 
96  if ( $continue ) {
97  // Fake submit button for enter keypress (T28267)
98  // Messages: config-continue, config-restart, config-regenerate
99  $s .= Xml::submitButton(
100  wfMessage( "config-$continue" )->text(),
101  [
102  'name' => "enter-$continue",
103  'style' => 'width:0;border:0;height:0;padding:0'
104  ]
105  ) . "\n";
106  }
107 
108  if ( $back ) {
109  // Message: config-back
110  $s .= Xml::submitButton(
111  wfMessage( "config-$back" )->text(),
112  [
113  'name' => "submit-$back",
114  'tabindex' => $this->parent->nextTabIndex()
115  ]
116  ) . "\n";
117  }
118 
119  if ( $continue ) {
120  // Messages: config-continue, config-restart, config-regenerate
121  $s .= Xml::submitButton(
122  wfMessage( "config-$continue" )->text(),
123  [
124  'name' => "submit-$continue",
125  'tabindex' => $this->parent->nextTabIndex(),
126  ]
127  ) . "\n";
128  }
129 
130  $s .= "</div></form></div>\n";
131  $this->addHTML( $s );
132  }
133 
137  public function getName() {
138  return str_replace( 'WebInstaller', '', static::class );
139  }
140 
144  protected function getId() {
145  return array_search( $this->getName(), $this->parent->pageSequence );
146  }
147 
154  public function getVar( $var, $default = null ) {
155  return $this->parent->getVar( $var, $default );
156  }
157 
162  public function setVar( $name, $value ) {
163  $this->parent->setVar( $name, $value );
164  }
165 
173  protected function getFieldsetStart( $legend ) {
174  return "\n<fieldset><legend>" . wfMessage( $legend )->escaped() . "</legend>\n";
175  }
176 
182  protected function getFieldsetEnd() {
183  return "</fieldset>\n";
184  }
185 
189  protected function startLiveBox() {
190  $this->addHTML(
191  '<div id="config-spinner" style="display:none;">' .
192  '<img src="images/ajax-loader.gif" /></div>' .
193  '<script>jQuery( "#config-spinner" ).show();</script>' .
194  '<div id="config-live-log">' .
195  '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
196  );
197  $this->parent->output->flush();
198  }
199 
203  protected function endLiveBox() {
204  $this->addHTML( '</textarea></div>
205 <script>jQuery( "#config-spinner" ).hide()</script>' );
206  $this->parent->output->flush();
207  }
208 
209 }
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This class is a collection of static functions that serve two purposes:
Definition: Html.php:57
Abstract class to define pages for the web installer.
WebInstaller $parent
The WebInstaller object this WebInstallerPage belongs to.
getFieldsetEnd()
Get the end tag of a fieldset.
setVar( $name, $value)
endForm( $continue='continue', $back='back')
getVar( $var, $default=null)
startLiveBox()
Opens a textarea used to display the progress of a long operation.
__construct(WebInstaller $parent)
getFieldsetStart( $legend)
Get the starting tags of a fieldset.
endLiveBox()
Opposite to WebInstallerPage::startLiveBox.
isSlow()
Is this a slow-running page in the installer? If so, WebInstaller will set_time_limit(0) before calli...
Class for the core installer web interface.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:473