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' )
104 $this->parent->getCheckBox( [
105 'var' =>
'_Subscribe',
106 'label' =>
'config-subscribe',
107 'help' => $this->parent->getHelpBox(
'config-subscribe-help' )
110 $this->parent->getCheckBox( [
111 'var' =>
'wgPingback',
112 'label' =>
'config-pingback',
113 'help' => $this->parent->getHelpBox(
114 'config-pingback-help',
115 FormatJson::encode( $pingbackInfo,
true )
119 $this->getFieldsetEnd() .
120 $this->parent->getInfoBox(
wfMessage(
'config-almost-done' )->plain() ) .
124 $this->parent->getRadioSet( [
125 'var' =>
'_SkipOptional',
126 'itemLabelPrefix' =>
'config-optional-',
127 'values' => [
'continue',
'skip' ]
132 $this->
setVar(
'wgMetaNamespace', $metaNS );
146 $this->parent->setVarsFromRequest( [
'wgSitename',
'_NamespaceType',
147 '_AdminName',
'_AdminPassword',
'_AdminPasswordConfirm',
'_AdminEmail',
148 '_Subscribe',
'_SkipOptional',
'wgMetaNamespace',
'wgPingback' ] );
151 if ( strval( $this->
getVar(
'wgSitename' ) ) ===
'' ) {
152 $this->parent->showError(
'config-site-name-blank' );
157 $nsType = $this->
getVar(
'_NamespaceType' );
158 if ( $nsType ==
'site-name' ) {
159 $name = $this->
getVar(
'wgSitename' );
162 $name = preg_replace(
'/[\[\]\{\}|#<>%+? ]/',
'_', $name );
163 $name = str_replace(
'&',
'&', $name );
164 $name = preg_replace(
'/__+/',
'_', $name );
165 $name = ucfirst( trim( $name,
'_' ) );
166 } elseif ( $nsType ==
'generic' ) {
167 $name =
wfMessage(
'config-ns-generic' )->text();
169 $name = $this->
getVar(
'wgMetaNamespace' );
173 if ( strpos( $name,
':' ) !==
false ) {
177 $title = Title::newFromText( $name );
179 $good = $nsType ==
'site-name';
181 $name =
$title->getDBkey();
186 $this->parent->showError(
'config-ns-invalid', $name );
191 $nsIndex = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $name );
192 if ( $nsIndex !==
false && $nsIndex !==
NS_PROJECT ) {
193 $this->parent->showError(
'config-ns-conflict', $name );
197 $this->
setVar(
'wgMetaNamespace', $name );
200 $name = $this->
getVar(
'_AdminName' );
201 if ( strval( $name ) ===
'' ) {
202 $this->parent->showError(
'config-admin-name-blank' );
206 $cname = User::getCanonicalName( $name,
'creatable' );
207 if ( $cname ===
false ) {
208 $this->parent->showError(
'config-admin-name-invalid', $name );
211 $this->
setVar(
'_AdminName', $cname );
217 $pwd = $this->
getVar(
'_AdminPassword' );
218 $user = User::newFromName( $cname );
224 $status = $upp->checkUserPasswordForGroups(
227 [
'bureaucrat',
'sysop',
'interface-admin' ]
229 $valid = $status->isGood() ?
true : $status->getMessage();
231 $valid =
'config-admin-name-invalid';
233 if ( strval( $pwd ) ===
'' ) {
235 $msg =
'config-admin-password-blank';
236 } elseif ( $pwd !== $this->
getVar(
'_AdminPasswordConfirm' ) ) {
237 $msg =
'config-admin-password-mismatch';
238 } elseif ( $valid !==
true ) {
241 if ( $msg !==
false ) {
242 call_user_func( [ $this->parent,
'showError' ], $msg );
243 $this->
setVar(
'_AdminPassword',
'' );
244 $this->
setVar(
'_AdminPasswordConfirm',
'' );
249 $email = $this->
getVar(
'_AdminEmail' );
250 if ( $email && !Sanitizer::validateEmail( $email ) ) {
251 $this->parent->showError(
'config-admin-error-bademail' );
256 if ( !$email && $this->
getVar(
'_Subscribe' ) ) {
257 $this->parent->showError(
'config-subscribe-noemail' );