| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
namespace MediaWiki\Installer; |
| 24 |
|
| 25 |
use MediaWiki\Html\Html; |
| 26 |
use MediaWiki\Xml\Xml; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
abstract class WebInstallerPage { |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public $parent; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
abstract public function execute(); |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public function __construct( WebInstaller $parent ) { |
| 52 |
$this->parent = $parent; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public function isSlow() { |
| 63 |
return false; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public function addHTML( $html ) { |
| 70 |
$this->parent->output->addHTML( $html ); |
| 71 |
} |
| 72 |
|
| 73 |
public function startForm() { |
| 74 |
$this->addHTML( |
| 75 |
"<div class=\"config-section\">\n" . |
| 76 |
Html::openElement( |
| 77 |
'form', |
| 78 |
[ |
| 79 |
'method' => 'post', |
| 80 |
'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] ) |
| 81 |
] |
| 82 |
) . "\n" |
| 83 |
); |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public function endForm( $continue = 'continue', $back = 'back' ) { |
| 91 |
$s = "<div class=\"config-submit\">\n"; |
| 92 |
$id = $this->getId(); |
| 93 |
|
| 94 |
if ( $id === false ) { |
| 95 |
$s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) ); |
| 96 |
} |
| 97 |
|
| 98 |
if ( $continue ) { |
| 99 |
|
| 100 |
|
| 101 |
$s .= Xml::submitButton( |
| 102 |
wfMessage( "config-$continue" )->text(), |
| 103 |
[ |
| 104 |
'name' => "enter-$continue", |
| 105 |
'style' => 'width:0;border:0;height:0;padding:0' |
| 106 |
] |
| 107 |
) . "\n"; |
| 108 |
} |
| 109 |
|
| 110 |
if ( $back ) { |
| 111 |
|
| 112 |
$s .= Xml::submitButton( |
| 113 |
wfMessage( "config-$back" )->text(), |
| 114 |
[ |
| 115 |
'name' => "submit-$back", |
| 116 |
'tabindex' => $this->parent->nextTabIndex(), |
| 117 |
'class' => 'cdx-button cdx-button--action-destructive' |
| 118 |
] |
| 119 |
) . "\n"; |
| 120 |
} |
| 121 |
|
| 122 |
if ( $continue ) { |
| 123 |
|
| 124 |
$s .= Xml::submitButton( |
| 125 |
wfMessage( "config-$continue" )->text(), |
| 126 |
[ |
| 127 |
'name' => "submit-$continue", |
| 128 |
'tabindex' => $this->parent->nextTabIndex(), |
| 129 |
'class' => 'cdx-button cdx-button--action-progressive' |
| 130 |
] |
| 131 |
) . "\n"; |
| 132 |
} |
| 133 |
|
| 134 |
$s .= "</div></form></div>\n"; |
| 135 |
$this->addHTML( $s ); |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
public function getName() { |
| 142 |
return str_replace( 'MediaWiki\\Installer\\WebInstaller', '', static::class ); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
protected function getId() { |
| 149 |
return array_search( $this->getName(), $this->parent->pageSequence ); |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
public function getVar( $var, $default = null ) { |
| 159 |
return $this->parent->getVar( $var, $default ); |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
public function setVar( $name, $value ) { |
| 167 |
$this->parent->setVar( $name, $value ); |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
protected function getFieldsetStart( $legend ) { |
| 178 |
return "\n<span class=\"cdx-card\"><span class=\"cdx-card__text\"><span class=\"cdx-card__text__title\">" . |
| 179 |
wfMessage( $legend )->escaped() . "</span><span class=\"cdx-card__text__description\">\n"; |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
protected function getFieldsetEnd() { |
| 188 |
return "</span></span></span>\n"; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
protected function startLiveBox() { |
| 195 |
$this->addHTML( |
| 196 |
'<div id="config-spinner" style="display:none;">' . |
| 197 |
'<img src="images/ajax-loader.gif" /></div>' . |
| 198 |
'<script>jQuery( "#config-spinner" ).show();</script>' . |
| 199 |
'<div id="config-live-log">' . |
| 200 |
'<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">' |
| 201 |
); |
| 202 |
$this->parent->output->flush(); |
| 203 |
} |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
protected function endLiveBox() { |
| 209 |
$this->addHTML( '</textarea></div> |
| 210 |
<script>jQuery( "#config-spinner" ).hide()</script>' ); |
| 211 |
$this->parent->output->flush(); |
| 212 |
} |
| 213 |
|
| 214 |
} |