33 $r = $this->parent->request;
34 if ( $r->wasPosted() && $this->submit() ) {
44 if ( $this->
getVar(
'wgSitename' ) ==
'MediaWiki' ) {
45 $this->
setVar(
'wgSitename',
'' );
50 $metaNS = $this->
getVar(
'wgMetaNamespace' );
53 wfMessage(
'config-ns-other-default' )->inContentLanguage()->text()
59 MainConfigNames::DBtype => $this->
getVar(
'wgDBtype' ),
64 $this->parent->getTextBox( [
65 'var' =>
'wgSitename',
66 'label' =>
'config-site-name',
67 'help' => $this->parent->getHelpBox(
'config-site-name-help' )
72 $this->parent->getRadioSet( [
73 'var' =>
'_NamespaceType',
74 'label' =>
'config-project-namespace',
75 'itemLabelPrefix' =>
'config-ns-',
76 'values' => [
'site-name',
'generic',
'other' ],
77 'commonAttribs' => [
'class' =>
'enableForOther',
78 'rel' =>
'config_wgMetaNamespace' ],
79 'help' => $this->parent->getHelpBox(
'config-project-namespace-help' )
81 $this->parent->getTextBox( [
82 'var' =>
'wgMetaNamespace',
84 'attribs' => [
'class' =>
'enabledByOther' ]
86 $this->getFieldsetStart(
'config-admin-box' ) .
87 $this->parent->getTextBox( [
88 'var' =>
'_AdminName',
89 'label' =>
'config-admin-name',
90 'help' => $this->parent->getHelpBox(
'config-admin-help' )
92 $this->parent->getPasswordBox( [
93 'var' =>
'_AdminPassword',
94 'label' =>
'config-admin-password',
96 $this->parent->getPasswordBox( [
97 'var' =>
'_AdminPasswordConfirm',
98 'label' =>
'config-admin-password-confirm'
100 $this->parent->getTextBox( [
101 'var' =>
'_AdminEmail',
105 'label' =>
'config-admin-email',
106 'help' => $this->parent->getHelpBox(
'config-admin-email-help' )
108 $this->parent->getCheckBox( [
109 'var' =>
'_Subscribe',
110 'label' =>
'config-subscribe',
111 'help' => $this->parent->getHelpBox(
'config-subscribe-help' )
113 $this->parent->getCheckBox( [
114 'var' =>
'wgPingback',
115 'label' =>
'config-pingback',
116 'help' => $this->parent->getHelpBox(
117 'config-pingback-help',
118 FormatJson::encode( $pingbackInfo,
true )
122 $this->getFieldsetEnd() .
123 $this->parent->getInfoBox(
wfMessage(
'config-almost-done' )->plain() ) .
127 $this->parent->getRadioSet( [
128 'var' =>
'_SkipOptional',
129 'itemLabelPrefix' =>
'config-optional-',
130 'values' => [
'continue',
'skip' ]
135 $this->
setVar(
'wgMetaNamespace', $metaNS );
149 $this->parent->setVarsFromRequest( [
'wgSitename',
'_NamespaceType',
150 '_AdminName',
'_AdminPassword',
'_AdminPasswordConfirm',
'_AdminEmail',
151 '_Subscribe',
'_SkipOptional',
'wgMetaNamespace',
'wgPingback' ] );
154 if ( strval( $this->
getVar(
'wgSitename' ) ) ===
'' ) {
155 $this->parent->showError(
'config-site-name-blank' );
160 $nsType = $this->
getVar(
'_NamespaceType' );
161 if ( $nsType ==
'site-name' ) {
162 $name = $this->
getVar(
'wgSitename' );
165 $name = preg_replace(
'/[\[\]\{\}|#<>%+? ]/',
'_', $name );
166 $name = str_replace(
'&',
'&', $name );
167 $name = preg_replace(
'/__+/',
'_', $name );
168 $name = ucfirst( trim( $name,
'_' ) );
169 } elseif ( $nsType ==
'generic' ) {
170 $name =
wfMessage(
'config-ns-generic' )->text();
172 $name = $this->
getVar(
'wgMetaNamespace' );
176 if ( strpos( $name,
':' ) !==
false ) {
180 $title = Title::newFromText( $name );
182 $good = $nsType ==
'site-name';
184 $name =
$title->getDBkey();
189 $this->parent->showError(
'config-ns-invalid', $name );
194 $nsIndex = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $name );
195 if ( $nsIndex !==
false && $nsIndex !==
NS_PROJECT ) {
196 $this->parent->showError(
'config-ns-conflict', $name );
200 $this->
setVar(
'wgMetaNamespace', $name );
203 $name = $this->
getVar(
'_AdminName' );
204 if ( strval( $name ) ===
'' ) {
205 $this->parent->showError(
'config-admin-name-blank' );
209 $userNameUtils = MediaWikiServices::getInstance()->getUserNameUtils();
210 $cname = $userNameUtils->getCanonical( $name, UserRigorOptions::RIGOR_CREATABLE );
211 if ( $cname ===
false ) {
212 $this->parent->showError(
'config-admin-name-invalid', $name );
215 $this->
setVar(
'_AdminName', $cname );
221 $pwd = $this->
getVar(
'_AdminPassword' );
228 $status = $upp->checkUserPasswordForGroups(
231 [
'bureaucrat',
'sysop',
'interface-admin' ]
233 $valid = $status->isGood() ?
true : $status->getMessage();
235 $valid =
'config-admin-name-invalid';
237 if ( strval( $pwd ) ===
'' ) {
239 $msg =
'config-admin-password-blank';
240 } elseif ( $pwd !== $this->
getVar(
'_AdminPasswordConfirm' ) ) {
241 $msg =
'config-admin-password-mismatch';
242 } elseif ( $valid !==
true ) {
245 if ( $msg !==
false ) {
246 call_user_func( [ $this->parent,
'showError' ], $msg );
247 $this->
setVar(
'_AdminPassword',
'' );
248 $this->
setVar(
'_AdminPasswordConfirm',
'' );
253 $email = $this->
getVar(
'_AdminEmail' );
254 if ( $email && !Sanitizer::validateEmail( $email ) ) {
255 $this->parent->showError(
'config-admin-error-bademail' );
260 if ( !$email && $this->
getVar(
'_Subscribe' ) ) {
261 $this->parent->showError(
'config-subscribe-noemail' );