Expose $wgMaxArticleSize in siteinfo query api
[mediawiki.git] / includes / installer / WebInstallerPage.php
blob2ab055464dce2e4983fa0513bc08e7fe89b78b08
1 <?php
2 /**
3 * Base code for web installer pages.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Deployment
24 /**
25 * Abstract class to define pages for the web installer.
27 * @ingroup Deployment
28 * @since 1.17
30 abstract class WebInstallerPage {
32 /**
33 * The WebInstaller object this WebInstallerPage belongs to.
35 * @var WebInstaller
37 public $parent;
39 /**
40 * @return string
42 abstract public function execute();
44 /**
45 * @param WebInstaller $parent
47 public function __construct( WebInstaller $parent ) {
48 $this->parent = $parent;
51 /**
52 * Is this a slow-running page in the installer? If so, WebInstaller will
53 * set_time_limit(0) before calling execute(). Right now this only applies
54 * to Install and Upgrade pages
56 * @return bool Always false in this default implementation.
58 public function isSlow() {
59 return false;
62 /**
63 * @param string $html
65 public function addHTML( $html ) {
66 $this->parent->output->addHTML( $html );
69 public function startForm() {
70 $this->addHTML(
71 "<div class=\"config-section\">\n" .
72 Html::openElement(
73 'form',
75 'method' => 'post',
76 'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] )
78 ) . "\n"
82 /**
83 * @param string|bool $continue
84 * @param string|bool $back
86 public function endForm( $continue = 'continue', $back = 'back' ) {
87 $s = "<div class=\"config-submit\">\n";
88 $id = $this->getId();
90 if ( $id === false ) {
91 $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
94 if ( $continue ) {
95 // Fake submit button for enter keypress (bug 26267)
96 // Messages: config-continue, config-restart, config-regenerate
97 $s .= Xml::submitButton(
98 wfMessage( "config-$continue" )->text(),
100 'name' => "enter-$continue",
101 'style' => 'width:0;border:0;height:0;padding:0'
103 ) . "\n";
106 if ( $back ) {
107 // Message: config-back
108 $s .= Xml::submitButton(
109 wfMessage( "config-$back" )->text(),
111 'name' => "submit-$back",
112 'tabindex' => $this->parent->nextTabIndex()
114 ) . "\n";
117 if ( $continue ) {
118 // Messages: config-continue, config-restart, config-regenerate
119 $s .= Xml::submitButton(
120 wfMessage( "config-$continue" )->text(),
122 'name' => "submit-$continue",
123 'tabindex' => $this->parent->nextTabIndex(),
125 ) . "\n";
128 $s .= "</div></form></div>\n";
129 $this->addHTML( $s );
133 * @return string
135 public function getName() {
136 return str_replace( 'WebInstaller', '', get_class( $this ) );
140 * @return string
142 protected function getId() {
143 return array_search( $this->getName(), $this->parent->pageSequence );
147 * @param string $var
148 * @param mixed $default
150 * @return mixed
152 public function getVar( $var, $default = null ) {
153 return $this->parent->getVar( $var, $default );
157 * @param string $name
158 * @param mixed $value
160 public function setVar( $name, $value ) {
161 $this->parent->setVar( $name, $value );
165 * Get the starting tags of a fieldset.
167 * @param string $legend Message name
169 * @return string
171 protected function getFieldsetStart( $legend ) {
172 return "\n<fieldset><legend>" . wfMessage( $legend )->escaped() . "</legend>\n";
176 * Get the end tag of a fieldset.
178 * @return string
180 protected function getFieldsetEnd() {
181 return "</fieldset>\n";
185 * Opens a textarea used to display the progress of a long operation
187 protected function startLiveBox() {
188 $this->addHTML(
189 '<div id="config-spinner" style="display:none;">' .
190 '<img src="images/ajax-loader.gif" /></div>' .
191 '<script>jQuery( "#config-spinner" ).show();</script>' .
192 '<div id="config-live-log">' .
193 '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
195 $this->parent->output->flush();
199 * Opposite to WebInstallerPage::startLiveBox
201 protected function endLiveBox() {
202 $this->addHTML( '</textarea></div>
203 <script>jQuery( "#config-spinner" ).hide()</script>' );
204 $this->parent->output->flush();