MediaWiki REL1_30
WebInstallerOptions.php
Go to the documentation of this file.
1<?php
23
27 public function execute() {
28 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
29 $this->submitSkins();
30 return 'skip';
31 }
32 if ( $this->parent->request->wasPosted() ) {
33 if ( $this->submit() ) {
34 return 'continue';
35 }
36 }
37
38 $emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
39 $this->startForm();
40 $this->addHTML(
41 # User Rights
42 // getRadioSet() builds a set of labeled radio buttons.
43 // For grep: The following messages are used as the item labels:
44 // config-profile-wiki, config-profile-no-anon, config-profile-fishbowl, config-profile-private
45 $this->parent->getRadioSet( [
46 'var' => '_RightsProfile',
47 'label' => 'config-profile',
48 'itemLabelPrefix' => 'config-profile-',
49 'values' => array_keys( $this->parent->rightsProfiles ),
50 ] ) .
51 $this->parent->getInfoBox( wfMessage( 'config-profile-help' )->plain() ) .
52
53 # Licensing
54 // getRadioSet() builds a set of labeled radio buttons.
55 // For grep: The following messages are used as the item labels:
56 // config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa,
57 // config-license-cc-0, config-license-pd, config-license-gfdl,
58 // config-license-none, config-license-cc-choose
59 $this->parent->getRadioSet( [
60 'var' => '_LicenseCode',
61 'label' => 'config-license',
62 'itemLabelPrefix' => 'config-license-',
63 'values' => array_keys( $this->parent->licenses ),
64 'commonAttribs' => [ 'class' => 'licenseRadio' ],
65 ] ) .
66 $this->getCCChooser() .
67 $this->parent->getHelpBox( 'config-license-help' ) .
68
69 # E-mail
70 $this->getFieldsetStart( 'config-email-settings' ) .
71 $this->parent->getCheckBox( [
72 'var' => 'wgEnableEmail',
73 'label' => 'config-enable-email',
74 'attribs' => [ 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ],
75 ] ) .
76 $this->parent->getHelpBox( 'config-enable-email-help' ) .
77 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
78 $this->parent->getTextBox( [
79 'var' => 'wgPasswordSender',
80 'label' => 'config-email-sender'
81 ] ) .
82 $this->parent->getHelpBox( 'config-email-sender-help' ) .
83 $this->parent->getCheckBox( [
84 'var' => 'wgEnableUserEmail',
85 'label' => 'config-email-user',
86 ] ) .
87 $this->parent->getHelpBox( 'config-email-user-help' ) .
88 $this->parent->getCheckBox( [
89 'var' => 'wgEnotifUserTalk',
90 'label' => 'config-email-usertalk',
91 ] ) .
92 $this->parent->getHelpBox( 'config-email-usertalk-help' ) .
93 $this->parent->getCheckBox( [
94 'var' => 'wgEnotifWatchlist',
95 'label' => 'config-email-watchlist',
96 ] ) .
97 $this->parent->getHelpBox( 'config-email-watchlist-help' ) .
98 $this->parent->getCheckBox( [
99 'var' => 'wgEmailAuthentication',
100 'label' => 'config-email-auth',
101 ] ) .
102 $this->parent->getHelpBox( 'config-email-auth-help' ) .
103 "</div>" .
104 $this->getFieldsetEnd()
105 );
106
107 $skins = $this->parent->findExtensions( 'skins' );
108 $skinHtml = $this->getFieldsetStart( 'config-skins' );
109
110 $skinNames = array_map( 'strtolower', array_keys( $skins ) );
111 $chosenSkinName = $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
112
113 if ( $skins ) {
114 $radioButtons = $this->parent->getRadioElements( [
115 'var' => 'wgDefaultSkin',
116 'itemLabels' => array_fill_keys( $skinNames, 'config-skins-use-as-default' ),
117 'values' => $skinNames,
118 'value' => $chosenSkinName,
119 ] );
120
121 foreach ( $skins as $skin => $info ) {
122 if ( isset( $info['screenshots'] ) ) {
123 $screenshotText = $this->makeScreenshotsLink( $skin, $info['screenshots'] );
124 } else {
125 $screenshotText = htmlspecialchars( $skin );
126 }
127 $skinHtml .=
128 '<div class="config-skins-item">' .
129 $this->parent->getCheckBox( [
130 'var' => "skin-$skin",
131 'rawtext' => $screenshotText,
132 'value' => $this->getVar( "skin-$skin", true ), // all found skins enabled by default
133 ] ) .
134 '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] . '</div>' .
135 '</div>';
136 }
137 } else {
138 $skinHtml .=
139 $this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() ) .
140 Html::hidden( 'config_wgDefaultSkin', $chosenSkinName );
141 }
142
143 $skinHtml .= $this->parent->getHelpBox( 'config-skins-help' ) .
144 $this->getFieldsetEnd();
145 $this->addHTML( $skinHtml );
146
147 $extensions = $this->parent->findExtensions();
148
149 if ( $extensions ) {
150 $extHtml = $this->getFieldsetStart( 'config-extensions' );
151
152 foreach ( $extensions as $ext => $info ) {
153 $extHtml .= $this->parent->getCheckBox( [
154 'var' => "ext-$ext",
155 'rawtext' => $ext,
156 ] );
157 }
158
159 $extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) .
160 $this->getFieldsetEnd();
161 $this->addHTML( $extHtml );
162 }
163
164 // Having / in paths in Windows looks funny :)
165 $this->setVar( 'wgDeletedDirectory',
166 str_replace(
167 '/', DIRECTORY_SEPARATOR,
168 $this->getVar( 'wgDeletedDirectory' )
169 )
170 );
171
172 $uploadwrapperStyle = $this->getVar( 'wgEnableUploads' ) ? '' : 'display: none';
173 $this->addHTML(
174 # Uploading
175 $this->getFieldsetStart( 'config-upload-settings' ) .
176 $this->parent->getCheckBox( [
177 'var' => 'wgEnableUploads',
178 'label' => 'config-upload-enable',
179 'attribs' => [ 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ],
180 'help' => $this->parent->getHelpBox( 'config-upload-help' )
181 ] ) .
182 '<div id="uploadwrapper" style="' . $uploadwrapperStyle . '">' .
183 $this->parent->getTextBox( [
184 'var' => 'wgDeletedDirectory',
185 'label' => 'config-upload-deleted',
186 'attribs' => [ 'dir' => 'ltr' ],
187 'help' => $this->parent->getHelpBox( 'config-upload-deleted-help' )
188 ] ) .
189 '</div>' .
190 $this->parent->getTextBox( [
191 'var' => 'wgLogo',
192 'label' => 'config-logo',
193 'attribs' => [ 'dir' => 'ltr' ],
194 'help' => $this->parent->getHelpBox( 'config-logo-help' )
195 ] )
196 );
197 $this->addHTML(
198 $this->parent->getCheckBox( [
199 'var' => 'wgUseInstantCommons',
200 'label' => 'config-instantcommons',
201 'help' => $this->parent->getHelpBox( 'config-instantcommons-help' )
202 ] ) .
203 $this->getFieldsetEnd()
204 );
205
206 $caches = [ 'none' ];
207 $cachevalDefault = 'none';
208
209 if ( count( $this->getVar( '_Caches' ) ) ) {
210 // A CACHE_ACCEL implementation is available
211 $caches[] = 'accel';
212 $cachevalDefault = 'accel';
213 }
214 $caches[] = 'memcached';
215
216 // We'll hide/show this on demand when the value changes, see config.js.
217 $cacheval = $this->getVar( '_MainCacheType' );
218 if ( !$cacheval ) {
219 // We need to set a default here; but don't hardcode it
220 // or we lose it every time we reload the page for validation
221 // or going back!
222 $cacheval = $cachevalDefault;
223 }
224 $hidden = ( $cacheval == 'memcached' ) ? '' : 'display: none';
225 $this->addHTML(
226 # Advanced settings
227 $this->getFieldsetStart( 'config-advanced-settings' ) .
228 # Object cache settings
229 // getRadioSet() builds a set of labeled radio buttons.
230 // For grep: The following messages are used as the item labels:
231 // config-cache-none, config-cache-accel, config-cache-memcached
232 $this->parent->getRadioSet( [
233 'var' => '_MainCacheType',
234 'label' => 'config-cache-options',
235 'itemLabelPrefix' => 'config-cache-',
236 'values' => $caches,
237 'value' => $cacheval,
238 ] ) .
239 $this->parent->getHelpBox( 'config-cache-help' ) .
240 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
241 $this->parent->getTextArea( [
242 'var' => '_MemCachedServers',
243 'label' => 'config-memcached-servers',
244 'help' => $this->parent->getHelpBox( 'config-memcached-help' )
245 ] ) .
246 '</div>' .
247 $this->getFieldsetEnd()
248 );
249 $this->endForm();
250
251 return null;
252 }
253
254 private function makeScreenshotsLink( $name, $screenshots ) {
255 global $wgLang;
256 if ( count( $screenshots ) > 1 ) {
257 $links = [];
258 $counter = 1;
259 foreach ( $screenshots as $shot ) {
260 $links[] = Html::element(
261 'a',
262 [ 'href' => $shot ],
263 $wgLang->formatNum( $counter++ )
264 );
265 }
266 return wfMessage( 'config-skins-screenshots' )
267 ->rawParams( $name, $wgLang->commaList( $links ) )
268 ->escaped();
269 } else {
270 $link = Html::element(
271 'a',
272 [ 'href' => $screenshots[0] ],
273 wfMessage( 'config-screenshot' )->text()
274 );
275 return wfMessage( 'config-skins-screenshot', $name )->rawParams( $link )->escaped();
276 }
277 }
278
282 public function getCCPartnerUrl() {
283 $server = $this->getVar( 'wgServer' );
284 $exitUrl = $server . $this->parent->getUrl( [
285 'page' => 'Options',
286 'SubmitCC' => 'indeed',
287 'config__LicenseCode' => 'cc',
288 'config_wgRightsUrl' => '[license_url]',
289 'config_wgRightsText' => '[license_name]',
290 'config_wgRightsIcon' => '[license_button]',
291 ] );
292 $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
293 '/mw-config/config-cc.css';
294 $iframeUrl = '//creativecommons.org/license/?' .
295 wfArrayToCgi( [
296 'partner' => 'MediaWiki',
297 'exit_url' => $exitUrl,
298 'lang' => $this->getVar( '_UserLang' ),
299 'stylesheet' => $styleUrl,
300 ] );
301
302 return $iframeUrl;
303 }
304
308 public function getCCChooser() {
309 $iframeAttribs = [
310 'class' => 'config-cc-iframe',
311 'name' => 'config-cc-iframe',
312 'id' => 'config-cc-iframe',
313 'frameborder' => 0,
314 'width' => '100%',
315 'height' => '100%',
316 ];
317 if ( $this->getVar( '_CCDone' ) ) {
318 $iframeAttribs['src'] = $this->parent->getUrl( [ 'ShowCC' => 'yes' ] );
319 } else {
320 $iframeAttribs['src'] = $this->getCCPartnerUrl();
321 }
322 $wrapperStyle = ( $this->getVar( '_LicenseCode' ) == 'cc-choose' ) ? '' : 'display: none';
323
324 return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
325 Html::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
326 "</div>\n";
327 }
328
332 public function getCCDoneBox() {
333 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
334 // If you change this height, also change it in config.css
335 $expandJs = str_replace( '$1', '54em', $js );
336 $reduceJs = str_replace( '$1', '70px', $js );
337
338 return '<p>' .
339 Html::element( 'img', [ 'src' => $this->getVar( 'wgRightsIcon' ) ] ) .
340 '&#160;&#160;' .
341 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
342 "</p>\n" .
343 "<p style=\"text-align: center;\">" .
344 Html::element( 'a',
345 [
346 'href' => $this->getCCPartnerUrl(),
347 'onclick' => $expandJs,
348 ],
349 wfMessage( 'config-cc-again' )->text()
350 ) .
351 "</p>\n" .
352 "<script>\n" .
353 # Reduce the wrapper div height
354 htmlspecialchars( $reduceJs ) .
355 "\n" .
356 "</script>\n";
357 }
358
359 public function submitCC() {
360 $newValues = $this->parent->setVarsFromRequest(
361 [ 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ] );
362 if ( count( $newValues ) != 3 ) {
363 $this->parent->showError( 'config-cc-error' );
364
365 return;
366 }
367 $this->setVar( '_CCDone', true );
368 $this->addHTML( $this->getCCDoneBox() );
369 }
370
377 public function submitSkins() {
378 $skins = array_keys( $this->parent->findExtensions( 'skins' ) );
379 $this->parent->setVar( '_Skins', $skins );
380
381 if ( $skins ) {
382 $skinNames = array_map( 'strtolower', $skins );
383 $this->parent->setVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
384 }
385
386 return true;
387 }
388
392 public function submit() {
393 $this->parent->setVarsFromRequest( [ '_RightsProfile', '_LicenseCode',
394 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
395 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
396 'wgEmailAuthentication', '_MainCacheType', '_MemCachedServers',
397 'wgUseInstantCommons', 'wgDefaultSkin' ] );
398
399 $retVal = true;
400
401 if ( !array_key_exists( $this->getVar( '_RightsProfile' ), $this->parent->rightsProfiles ) ) {
402 reset( $this->parent->rightsProfiles );
403 $this->setVar( '_RightsProfile', key( $this->parent->rightsProfiles ) );
404 }
405
406 $code = $this->getVar( '_LicenseCode' );
407 if ( $code == 'cc-choose' ) {
408 if ( !$this->getVar( '_CCDone' ) ) {
409 $this->parent->showError( 'config-cc-not-chosen' );
410 $retVal = false;
411 }
412 } elseif ( array_key_exists( $code, $this->parent->licenses ) ) {
413 // Messages:
414 // config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa,
415 // config-license-cc-0, config-license-pd, config-license-gfdl, config-license-none,
416 // config-license-cc-choose
417 $entry = $this->parent->licenses[$code];
418 if ( isset( $entry['text'] ) ) {
419 $this->setVar( 'wgRightsText', $entry['text'] );
420 } else {
421 $this->setVar( 'wgRightsText', wfMessage( 'config-license-' . $code )->text() );
422 }
423 $this->setVar( 'wgRightsUrl', $entry['url'] );
424 $this->setVar( 'wgRightsIcon', $entry['icon'] );
425 } else {
426 $this->setVar( 'wgRightsText', '' );
427 $this->setVar( 'wgRightsUrl', '' );
428 $this->setVar( 'wgRightsIcon', '' );
429 }
430
431 $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' ) );
432 $skinsToInstall = [];
433 foreach ( $skinsAvailable as $skin ) {
434 $this->parent->setVarsFromRequest( [ "skin-$skin" ] );
435 if ( $this->getVar( "skin-$skin" ) ) {
436 $skinsToInstall[] = $skin;
437 }
438 }
439 $this->parent->setVar( '_Skins', $skinsToInstall );
440
441 if ( !$skinsToInstall && $skinsAvailable ) {
442 $this->parent->showError( 'config-skins-must-enable-some' );
443 $retVal = false;
444 }
445 $defaultSkin = $this->getVar( 'wgDefaultSkin' );
446 $skinsToInstallLowercase = array_map( 'strtolower', $skinsToInstall );
447 if ( $skinsToInstall && array_search( $defaultSkin, $skinsToInstallLowercase ) === false ) {
448 $this->parent->showError( 'config-skins-must-enable-default' );
449 $retVal = false;
450 }
451
452 $extsAvailable = array_keys( $this->parent->findExtensions() );
453 $extsToInstall = [];
454 foreach ( $extsAvailable as $ext ) {
455 $this->parent->setVarsFromRequest( [ "ext-$ext" ] );
456 if ( $this->getVar( "ext-$ext" ) ) {
457 $extsToInstall[] = $ext;
458 }
459 }
460 $this->parent->setVar( '_Extensions', $extsToInstall );
461
462 if ( $this->getVar( '_MainCacheType' ) == 'memcached' ) {
463 $memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) );
464 if ( !$memcServers ) {
465 $this->parent->showError( 'config-memcache-needservers' );
466 $retVal = false;
467 }
468
469 foreach ( $memcServers as $server ) {
470 $memcParts = explode( ":", $server, 2 );
471 if ( !isset( $memcParts[0] )
472 || ( !IP::isValid( $memcParts[0] )
473 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
474 ) {
475 $this->parent->showError( 'config-memcache-badip', $memcParts[0] );
476 $retVal = false;
477 } elseif ( !isset( $memcParts[1] ) ) {
478 $this->parent->showError( 'config-memcache-noport', $memcParts[0] );
479 $retVal = false;
480 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
481 $this->parent->showError( 'config-memcache-badport', 1, 65535 );
482 $retVal = false;
483 }
484 }
485 }
486
487 return $retVal;
488 }
489
490}
address of the mail
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:51
makeScreenshotsLink( $name, $screenshots)
submitSkins()
If the user skips this installer page, we still need to set up the default skins, but ignore everythi...
Abstract class to define pages for the web installer.
getFieldsetEnd()
Get the end tag of a fieldset.
setVar( $name, $value)
endForm( $continue='continue', $back='back')
getVar( $var, $default=null)
getFieldsetStart( $legend)
Get the starting tags of a fieldset.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition design.txt:26
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition design.txt:56
either a plain
Definition hooks.txt:2026
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition hooks.txt:863
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2989
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition hooks.txt:1981
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings
Definition globals.txt:37
you have access to all of the normal MediaWiki so you can get a DB use the cache