30 $r = $this->parent->request;
31 if ( $r->wasPosted() && $this->submit() ) {
41 if ( $this->
getVar(
'wgSitename' ) ==
'MediaWiki' ) {
42 $this->
setVar(
'wgSitename',
'' );
47 $metaNS = $this->
getVar(
'wgMetaNamespace' );
50 wfMessage(
'config-ns-other-default' )->inContentLanguage()->text()
53 $pingbackInfo = (
new Pingback() )->getSystemInfo();
56 $pingbackInfo[
'database'] = $this->
getVar(
'wgDBtype' );
59 $this->parent->getTextBox( [
60 'var' =>
'wgSitename',
61 'label' =>
'config-site-name',
62 'help' => $this->parent->getHelpBox(
'config-site-name-help' )
67 $this->parent->getRadioSet( [
68 'var' =>
'_NamespaceType',
69 'label' =>
'config-project-namespace',
70 'itemLabelPrefix' =>
'config-ns-',
71 'values' => [
'site-name',
'generic',
'other' ],
72 'commonAttribs' => [
'class' =>
'enableForOther',
73 'rel' =>
'config_wgMetaNamespace' ],
74 'help' => $this->parent->getHelpBox(
'config-project-namespace-help' )
76 $this->parent->getTextBox( [
77 'var' =>
'wgMetaNamespace',
79 'attribs' => [
'class' =>
'enabledByOther' ]
81 $this->getFieldsetStart(
'config-admin-box' ) .
82 $this->parent->getTextBox( [
83 'var' =>
'_AdminName',
84 'label' =>
'config-admin-name',
85 'help' => $this->parent->getHelpBox(
'config-admin-help' )
87 $this->parent->getPasswordBox( [
88 'var' =>
'_AdminPassword',
89 'label' =>
'config-admin-password',
91 $this->parent->getPasswordBox( [
92 'var' =>
'_AdminPasswordConfirm',
93 'label' =>
'config-admin-password-confirm'
95 $this->parent->getTextBox( [
96 'var' =>
'_AdminEmail',
100 'label' =>
'config-admin-email',
101 'help' => $this->parent->getHelpBox(
'config-admin-email-help' )
103 $this->parent->getCheckBox( [
104 'var' =>
'_Subscribe',
105 'label' =>
'config-subscribe',
106 'help' => $this->parent->getHelpBox(
'config-subscribe-help' )
108 $this->parent->getCheckBox( [
109 'var' =>
'wgPingback',
110 'label' =>
'config-pingback',
111 'help' => $this->parent->getHelpBox(
112 'config-pingback-help',
113 FormatJson::encode( $pingbackInfo,
true )
117 $this->getFieldsetEnd() .
118 $this->parent->getInfoBox(
wfMessage(
'config-almost-done' )->plain() ) .
122 $this->parent->getRadioSet( [
123 'var' =>
'_SkipOptional',
124 'itemLabelPrefix' =>
'config-optional-',
125 'values' => [
'continue',
'skip' ]
130 $this->
setVar(
'wgMetaNamespace', $metaNS );
144 $this->parent->setVarsFromRequest( [
'wgSitename',
'_NamespaceType',
145 '_AdminName',
'_AdminPassword',
'_AdminPasswordConfirm',
'_AdminEmail',
146 '_Subscribe',
'_SkipOptional',
'wgMetaNamespace',
'wgPingback' ] );
149 if ( strval( $this->
getVar(
'wgSitename' ) ) ===
'' ) {
150 $this->parent->showError(
'config-site-name-blank' );
155 $nsType = $this->
getVar(
'_NamespaceType' );
156 if ( $nsType ==
'site-name' ) {
157 $name = $this->
getVar(
'wgSitename' );
160 $name = preg_replace(
'/[\[\]\{\}|#<>%+? ]/',
'_', $name );
161 $name = str_replace(
'&',
'&', $name );
162 $name = preg_replace(
'/__+/',
'_', $name );
163 $name = ucfirst( trim( $name,
'_' ) );
164 } elseif ( $nsType ==
'generic' ) {
165 $name =
wfMessage(
'config-ns-generic' )->text();
167 $name = $this->
getVar(
'wgMetaNamespace' );
171 if ( strpos( $name,
':' ) !==
false ) {
175 $title = Title::newFromText( $name );
177 $good = $nsType ==
'site-name';
179 $name =
$title->getDBkey();
184 $this->parent->showError(
'config-ns-invalid', $name );
189 $nsIndex = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $name );
190 if ( $nsIndex !==
false && $nsIndex !==
NS_PROJECT ) {
191 $this->parent->showError(
'config-ns-conflict', $name );
195 $this->
setVar(
'wgMetaNamespace', $name );
198 $name = $this->
getVar(
'_AdminName' );
199 if ( strval( $name ) ===
'' ) {
200 $this->parent->showError(
'config-admin-name-blank' );
204 $cname = User::getCanonicalName( $name,
'creatable' );
205 if ( $cname ===
false ) {
206 $this->parent->showError(
'config-admin-name-invalid', $name );
209 $this->
setVar(
'_AdminName', $cname );
215 $pwd = $this->
getVar(
'_AdminPassword' );
216 $user = User::newFromName( $cname );
222 $status = $upp->checkUserPasswordForGroups(
225 [
'bureaucrat',
'sysop',
'interface-admin' ]
227 $valid = $status->isGood() ?
true : $status->getMessage();
229 $valid =
'config-admin-name-invalid';
231 if ( strval( $pwd ) ===
'' ) {
233 $msg =
'config-admin-password-blank';
234 } elseif ( $pwd !== $this->
getVar(
'_AdminPasswordConfirm' ) ) {
235 $msg =
'config-admin-password-mismatch';
236 } elseif ( $valid !==
true ) {
239 if ( $msg !==
false ) {
240 call_user_func( [ $this->parent,
'showError' ], $msg );
241 $this->
setVar(
'_AdminPassword',
'' );
242 $this->
setVar(
'_AdminPasswordConfirm',
'' );
247 $email = $this->
getVar(
'_AdminEmail' );
248 if ( $email && !Sanitizer::validateEmail( $email ) ) {
249 $this->parent->showError(
'config-admin-error-bademail' );
254 if ( !$email && $this->
getVar(
'_Subscribe' ) ) {
255 $this->parent->showError(
'config-subscribe-noemail' );