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
25 * Abstract class to define pages for the web installer.
30 abstract class WebInstallerPage
{
33 * The WebInstaller object this WebInstallerPage belongs to.
42 abstract public function execute();
45 * @param WebInstaller $parent
47 public function __construct( WebInstaller
$parent ) {
48 $this->parent
= $parent;
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() {
65 public function addHTML( $html ) {
66 $this->parent
->output
->addHTML( $html );
69 public function startForm() {
71 "<div class=\"config-section\">\n" .
76 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
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";
90 if ( $id === false ) {
91 $s .= Html
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
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' => 'visibility:hidden;overflow:hidden;width:1px;margin:0'
107 // Message: config-back
108 $s .= Xml
::submitButton(
109 wfMessage( "config-$back" )->text(),
111 'name' => "submit-$back",
112 'tabindex' => $this->parent
->nextTabIndex()
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(),
128 $s .= "</div></form></div>\n";
129 $this->addHTML( $s );
135 public function getName() {
136 return str_replace( 'WebInstaller', '', get_class( $this ) );
142 protected function getId() {
143 return array_search( $this->getName(), $this->parent
->pageSequence
);
148 * @param mixed $default
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
171 protected function getFieldsetStart( $legend ) {
172 return "\n<fieldset><legend>" . wfMessage( $legend )->escaped() . "</legend>\n";
176 * Get the end tag of a fieldset.
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() {
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();