MediaWiki
REL1_19
|
00001 <?php 00015 class WebInstaller extends Installer { 00016 00020 public $output; 00021 00027 public $request; 00028 00034 protected $session; 00035 00040 protected $phpErrors; 00041 00050 public $pageSequence = array( 00051 'Language', 00052 'ExistingWiki', 00053 'Welcome', 00054 'DBConnect', 00055 'Upgrade', 00056 'DBSettings', 00057 'Name', 00058 'Options', 00059 'Install', 00060 'Complete', 00061 ); 00062 00067 protected $otherPages = array( 00068 'Restart', 00069 'Readme', 00070 'ReleaseNotes', 00071 'Copying', 00072 'UpgradeDoc', // Can't use Upgrade due to Upgrade step 00073 ); 00074 00080 protected $happyPages; 00081 00088 protected $skippedPages; 00089 00094 public $showSessionWarning = false; 00095 00100 protected $tabIndex = 1; 00101 00106 protected $currentPageName; 00107 00113 public function __construct( WebRequest $request ) { 00114 parent::__construct(); 00115 $this->output = new WebInstallerOutput( $this ); 00116 $this->request = $request; 00117 00118 // Add parser hooks 00119 global $wgParser; 00120 $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) ); 00121 $wgParser->setHook( 'doclink', array( $this, 'docLink' ) ); 00122 } 00123 00131 public function execute( array $session ) { 00132 $this->session = $session; 00133 00134 if ( isset( $session['settings'] ) ) { 00135 $this->settings = $session['settings'] + $this->settings; 00136 } 00137 00138 $this->exportVars(); 00139 $this->setupLanguage(); 00140 00141 if( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) ) 00142 && $this->request->getVal( 'localsettings' ) ) 00143 { 00144 $this->request->response()->header( 'Content-type: application/x-httpd-php' ); 00145 $this->request->response()->header( 00146 'Content-Disposition: attachment; filename="LocalSettings.php"' 00147 ); 00148 00149 $ls = new LocalSettingsGenerator( $this ); 00150 $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )]; 00151 foreach( $rightsProfile as $group => $rightsArr ) { 00152 $ls->setGroupRights( $group, $rightsArr ); 00153 } 00154 echo $ls->getText(); 00155 return $this->session; 00156 } 00157 00158 $cssDir = $this->request->getVal( 'css' ); 00159 if( $cssDir ) { 00160 $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' ); 00161 $this->request->response()->header( 'Content-type: text/css' ); 00162 echo $this->output->getCSS( $cssDir ); 00163 return $this->session; 00164 } 00165 00166 if ( isset( $session['happyPages'] ) ) { 00167 $this->happyPages = $session['happyPages']; 00168 } else { 00169 $this->happyPages = array(); 00170 } 00171 00172 if ( isset( $session['skippedPages'] ) ) { 00173 $this->skippedPages = $session['skippedPages']; 00174 } else { 00175 $this->skippedPages = array(); 00176 } 00177 00178 $lowestUnhappy = $this->getLowestUnhappy(); 00179 00180 # Special case for Creative Commons partner chooser box. 00181 if ( $this->request->getVal( 'SubmitCC' ) ) { 00182 $page = $this->getPageByName( 'Options' ); 00183 $this->output->useShortHeader(); 00184 $this->output->allowFrames(); 00185 $page->submitCC(); 00186 return $this->finish(); 00187 } 00188 00189 if ( $this->request->getVal( 'ShowCC' ) ) { 00190 $page = $this->getPageByName( 'Options' ); 00191 $this->output->useShortHeader(); 00192 $this->output->allowFrames(); 00193 $this->output->addHTML( $page->getCCDoneBox() ); 00194 return $this->finish(); 00195 } 00196 00197 # Get the page name. 00198 $pageName = $this->request->getVal( 'page' ); 00199 00200 if ( in_array( $pageName, $this->otherPages ) ) { 00201 # Out of sequence 00202 $pageId = false; 00203 $page = $this->getPageByName( $pageName ); 00204 } else { 00205 # Main sequence 00206 if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) { 00207 $pageId = $lowestUnhappy; 00208 } else { 00209 $pageId = array_search( $pageName, $this->pageSequence ); 00210 } 00211 00212 # If necessary, move back to the lowest-numbered unhappy page 00213 if ( $pageId > $lowestUnhappy ) { 00214 $pageId = $lowestUnhappy; 00215 if ( $lowestUnhappy == 0 ) { 00216 # Knocked back to start, possible loss of session data. 00217 $this->showSessionWarning = true; 00218 } 00219 } 00220 00221 $pageName = $this->pageSequence[$pageId]; 00222 $page = $this->getPageByName( $pageName ); 00223 } 00224 00225 # If a back button was submitted, go back without submitting the form data. 00226 if ( $this->request->wasPosted() && $this->request->getBool( 'submit-back' ) ) { 00227 if ( $this->request->getVal( 'lastPage' ) ) { 00228 $nextPage = $this->request->getVal( 'lastPage' ); 00229 } elseif ( $pageId !== false ) { 00230 # Main sequence page 00231 # Skip the skipped pages 00232 $nextPageId = $pageId; 00233 00234 do { 00235 $nextPageId--; 00236 $nextPage = $this->pageSequence[$nextPageId]; 00237 } while( isset( $this->skippedPages[$nextPage] ) ); 00238 } else { 00239 $nextPage = $this->pageSequence[$lowestUnhappy]; 00240 } 00241 00242 $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) ); 00243 return $this->finish(); 00244 } 00245 00246 # Execute the page. 00247 $this->currentPageName = $page->getName(); 00248 $this->startPageWrapper( $pageName ); 00249 00250 if( $page->isSlow() ) { 00251 $this->disableTimeLimit(); 00252 } 00253 00254 $result = $page->execute(); 00255 00256 $this->endPageWrapper(); 00257 00258 if ( $result == 'skip' ) { 00259 # Page skipped without explicit submission. 00260 # Skip it when we click "back" so that we don't just go forward again. 00261 $this->skippedPages[$pageName] = true; 00262 $result = 'continue'; 00263 } else { 00264 unset( $this->skippedPages[$pageName] ); 00265 } 00266 00267 # If it was posted, the page can request a continue to the next page. 00268 if ( $result === 'continue' && !$this->output->headerDone() ) { 00269 if ( $pageId !== false ) { 00270 $this->happyPages[$pageId] = true; 00271 } 00272 00273 $lowestUnhappy = $this->getLowestUnhappy(); 00274 00275 if ( $this->request->getVal( 'lastPage' ) ) { 00276 $nextPage = $this->request->getVal( 'lastPage' ); 00277 } elseif ( $pageId !== false ) { 00278 $nextPage = $this->pageSequence[$pageId + 1]; 00279 } else { 00280 $nextPage = $this->pageSequence[$lowestUnhappy]; 00281 } 00282 00283 if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) { 00284 $nextPage = $this->pageSequence[$lowestUnhappy]; 00285 } 00286 00287 $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) ); 00288 } 00289 00290 return $this->finish(); 00291 } 00292 00297 public function getLowestUnhappy() { 00298 if ( count( $this->happyPages ) == 0 ) { 00299 return 0; 00300 } else { 00301 return max( array_keys( $this->happyPages ) ) + 1; 00302 } 00303 } 00304 00310 public function startSession() { 00311 if( wfIniGetBool( 'session.auto_start' ) || session_id() ) { 00312 // Done already 00313 return true; 00314 } 00315 00316 $this->phpErrors = array(); 00317 set_error_handler( array( $this, 'errorHandler' ) ); 00318 session_start(); 00319 restore_error_handler(); 00320 00321 if ( $this->phpErrors ) { 00322 $this->showError( 'config-session-error', $this->phpErrors[0] ); 00323 return false; 00324 } 00325 00326 return true; 00327 } 00328 00337 public function getFingerprint() { 00338 // Get the base URL of the installation 00339 $url = $this->request->getFullRequestURL(); 00340 if ( preg_match( '!^(.*\?)!', $url, $m) ) { 00341 // Trim query string 00342 $url = $m[1]; 00343 } 00344 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) { 00345 // This... seems to try to get the base path from 00346 // the /mw-config/index.php. Kinda scary though? 00347 $url = $m[1]; 00348 } 00349 return md5( serialize( array( 00350 'local path' => dirname( dirname( __FILE__ ) ), 00351 'url' => $url, 00352 'version' => $GLOBALS['wgVersion'] 00353 ) ) ); 00354 } 00355 00360 public function showError( $msg /*...*/ ) { 00361 $args = func_get_args(); 00362 array_shift( $args ); 00363 $args = array_map( 'htmlspecialchars', $args ); 00364 $msg = wfMsgReal( $msg, $args, false, false, false ); 00365 $this->output->addHTML( $this->getErrorBox( $msg ) ); 00366 } 00367 00373 public function errorHandler( $errno, $errstr ) { 00374 $this->phpErrors[] = $errstr; 00375 } 00376 00382 public function finish() { 00383 $this->output->output(); 00384 00385 $this->session['happyPages'] = $this->happyPages; 00386 $this->session['skippedPages'] = $this->skippedPages; 00387 $this->session['settings'] = $this->settings; 00388 00389 return $this->session; 00390 } 00391 00395 public function reset() { 00396 $this->session = array(); 00397 $this->happyPages = array(); 00398 $this->settings = array(); 00399 } 00400 00407 public function getUrl( $query = array() ) { 00408 $url = $this->request->getRequestURL(); 00409 # Remove existing query 00410 $url = preg_replace( '/\?.*$/', '', $url ); 00411 00412 if ( $query ) { 00413 $url .= '?' . wfArrayToCGI( $query ); 00414 } 00415 00416 return $url; 00417 } 00418 00425 public function getPageByName( $pageName ) { 00426 $pageClass = 'WebInstaller_' . $pageName; 00427 00428 return new $pageClass( $this ); 00429 } 00430 00437 public function getSession( $name, $default = null ) { 00438 if ( !isset( $this->session[$name] ) ) { 00439 return $default; 00440 } else { 00441 return $this->session[$name]; 00442 } 00443 } 00444 00450 public function setSession( $name, $value ) { 00451 $this->session[$name] = $value; 00452 } 00453 00458 public function nextTabIndex() { 00459 return $this->tabIndex++; 00460 } 00461 00465 public function setupLanguage() { 00466 global $wgLang, $wgContLang, $wgLanguageCode; 00467 00468 if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) { 00469 $wgLanguageCode = $this->getAcceptLanguage(); 00470 $wgLang = $wgContLang = Language::factory( $wgLanguageCode ); 00471 $this->setVar( 'wgLanguageCode', $wgLanguageCode ); 00472 $this->setVar( '_UserLang', $wgLanguageCode ); 00473 } else { 00474 $wgLanguageCode = $this->getVar( 'wgLanguageCode' ); 00475 $wgContLang = Language::factory( $wgLanguageCode ); 00476 } 00477 } 00478 00484 public function getAcceptLanguage() { 00485 global $wgLanguageCode, $wgRequest; 00486 00487 $mwLanguages = Language::getLanguageNames(); 00488 $headerLanguages = array_keys( $wgRequest->getAcceptLang() ); 00489 00490 foreach ( $headerLanguages as $lang ) { 00491 if ( isset( $mwLanguages[$lang] ) ) { 00492 return $lang; 00493 } 00494 } 00495 00496 return $wgLanguageCode; 00497 } 00498 00504 private function startPageWrapper( $currentPageName ) { 00505 $s = "<div class=\"config-page-wrapper\">\n"; 00506 $s .= "<div class=\"config-page\">\n"; 00507 $s .= "<div class=\"config-page-list\"><ul>\n"; 00508 $lastHappy = -1; 00509 00510 foreach ( $this->pageSequence as $id => $pageName ) { 00511 $happy = !empty( $this->happyPages[$id] ); 00512 $s .= $this->getPageListItem( 00513 $pageName, 00514 $happy || $lastHappy == $id - 1, 00515 $currentPageName 00516 ); 00517 00518 if ( $happy ) { 00519 $lastHappy = $id; 00520 } 00521 } 00522 00523 $s .= "</ul><br/><ul>\n"; 00524 $s .= $this->getPageListItem( 'Restart', true, $currentPageName ); 00525 $s .= "</ul></div>\n"; // end list pane 00526 $s .= Html::element( 'h2', array(), 00527 wfMsg( 'config-page-' . strtolower( $currentPageName ) ) ); 00528 00529 $this->output->addHTMLNoFlush( $s ); 00530 } 00531 00541 private function getPageListItem( $pageName, $enabled, $currentPageName ) { 00542 $s = "<li class=\"config-page-list-item\">"; 00543 $name = wfMsg( 'config-page-' . strtolower( $pageName ) ); 00544 00545 if ( $enabled ) { 00546 $query = array( 'page' => $pageName ); 00547 00548 if ( !in_array( $pageName, $this->pageSequence ) ) { 00549 if ( in_array( $currentPageName, $this->pageSequence ) ) { 00550 $query['lastPage'] = $currentPageName; 00551 } 00552 00553 $link = Html::element( 'a', 00554 array( 00555 'href' => $this->getUrl( $query ) 00556 ), 00557 $name 00558 ); 00559 } else { 00560 $link = htmlspecialchars( $name ); 00561 } 00562 00563 if ( $pageName == $currentPageName ) { 00564 $s .= "<span class=\"config-page-current\">$link</span>"; 00565 } else { 00566 $s .= $link; 00567 } 00568 } else { 00569 $s .= Html::element( 'span', 00570 array( 00571 'class' => 'config-page-disabled' 00572 ), 00573 $name 00574 ); 00575 } 00576 00577 $s .= "</li>\n"; 00578 00579 return $s; 00580 } 00581 00585 private function endPageWrapper() { 00586 $this->output->addHTMLNoFlush( 00587 "<div class=\"visualClear\"></div>\n" . 00588 "</div>\n" . 00589 "<div class=\"visualClear\"></div>\n" . 00590 "</div>" ); 00591 } 00592 00600 public function getErrorBox( $text ) { 00601 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' ); 00602 } 00603 00611 public function getWarningBox( $text ) { 00612 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' ); 00613 } 00614 00624 public function getInfoBox( $text, $icon = false, $class = false ) { 00625 $text = $this->parse( $text, true ); 00626 $icon = ( $icon == false ) ? '../skins/common/images/info-32.png' : '../skins/common/images/'.$icon; 00627 $alt = wfMsg( 'config-information' ); 00628 return Html::infoBox( $text, $icon, $alt, $class, false ); 00629 } 00630 00638 public function getHelpBox( $msg /*, ... */ ) { 00639 $args = func_get_args(); 00640 array_shift( $args ); 00641 $args = array_map( 'htmlspecialchars', $args ); 00642 $text = wfMsgReal( $msg, $args, false, false, false ); 00643 $html = $this->parse( $text, true ); 00644 00645 return "<div class=\"mw-help-field-container\">\n" . 00646 "<span class=\"mw-help-field-hint\">" . wfMsgHtml( 'config-help' ) . "</span>\n" . 00647 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" . 00648 "</div>\n"; 00649 } 00650 00655 public function showHelpBox( $msg /*, ... */ ) { 00656 $args = func_get_args(); 00657 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args ); 00658 $this->output->addHTML( $html ); 00659 } 00660 00667 public function showMessage( $msg /*, ... */ ) { 00668 $args = func_get_args(); 00669 array_shift( $args ); 00670 $html = '<div class="config-message">' . 00671 $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) . 00672 "</div>\n"; 00673 $this->output->addHTML( $html ); 00674 } 00675 00679 public function showStatusMessage( Status $status ) { 00680 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() ); 00681 foreach ( $errors as $error ) { 00682 call_user_func_array( array( $this, 'showMessage' ), $error ); 00683 } 00684 } 00685 00696 public function label( $msg, $forId, $contents, $helpData = "" ) { 00697 if ( strval( $msg ) == '' ) { 00698 $labelText = ' '; 00699 } else { 00700 $labelText = wfMsgHtml( $msg ); 00701 } 00702 00703 $attributes = array( 'class' => 'config-label' ); 00704 00705 if ( $forId ) { 00706 $attributes['for'] = $forId; 00707 } 00708 00709 return 00710 "<div class=\"config-block\">\n" . 00711 " <div class=\"config-block-label\">\n" . 00712 Xml::tags( 'label', 00713 $attributes, 00714 $labelText ) . "\n" . 00715 $helpData . 00716 " </div>\n" . 00717 " <div class=\"config-block-elements\">\n" . 00718 $contents . 00719 " </div>\n" . 00720 "</div>\n"; 00721 } 00722 00737 public function getTextBox( $params ) { 00738 if ( !isset( $params['controlName'] ) ) { 00739 $params['controlName'] = 'config_' . $params['var']; 00740 } 00741 00742 if ( !isset( $params['value'] ) ) { 00743 $params['value'] = $this->getVar( $params['var'] ); 00744 } 00745 00746 if ( !isset( $params['attribs'] ) ) { 00747 $params['attribs'] = array(); 00748 } 00749 if ( !isset( $params['help'] ) ) { 00750 $params['help'] = ""; 00751 } 00752 return 00753 $this->label( 00754 $params['label'], 00755 $params['controlName'], 00756 Xml::input( 00757 $params['controlName'], 00758 30, // intended to be overridden by CSS 00759 $params['value'], 00760 $params['attribs'] + array( 00761 'id' => $params['controlName'], 00762 'class' => 'config-input-text', 00763 'tabindex' => $this->nextTabIndex() 00764 ) 00765 ), 00766 $params['help'] 00767 ); 00768 } 00769 00784 public function getTextArea( $params ) { 00785 if ( !isset( $params['controlName'] ) ) { 00786 $params['controlName'] = 'config_' . $params['var']; 00787 } 00788 00789 if ( !isset( $params['value'] ) ) { 00790 $params['value'] = $this->getVar( $params['var'] ); 00791 } 00792 00793 if ( !isset( $params['attribs'] ) ) { 00794 $params['attribs'] = array(); 00795 } 00796 if ( !isset( $params['help'] ) ) { 00797 $params['help'] = ""; 00798 } 00799 return 00800 $this->label( 00801 $params['label'], 00802 $params['controlName'], 00803 Xml::textarea( 00804 $params['controlName'], 00805 $params['value'], 00806 30, 00807 5, 00808 $params['attribs'] + array( 00809 'id' => $params['controlName'], 00810 'class' => 'config-input-text', 00811 'tabindex' => $this->nextTabIndex() 00812 ) 00813 ), 00814 $params['help'] 00815 ); 00816 } 00817 00833 public function getPasswordBox( $params ) { 00834 if ( !isset( $params['value'] ) ) { 00835 $params['value'] = $this->getVar( $params['var'] ); 00836 } 00837 00838 if ( !isset( $params['attribs'] ) ) { 00839 $params['attribs'] = array(); 00840 } 00841 00842 $params['value'] = $this->getFakePassword( $params['value'] ); 00843 $params['attribs']['type'] = 'password'; 00844 00845 return $this->getTextBox( $params ); 00846 } 00847 00862 public function getCheckBox( $params ) { 00863 if ( !isset( $params['controlName'] ) ) { 00864 $params['controlName'] = 'config_' . $params['var']; 00865 } 00866 00867 if ( !isset( $params['value'] ) ) { 00868 $params['value'] = $this->getVar( $params['var'] ); 00869 } 00870 00871 if ( !isset( $params['attribs'] ) ) { 00872 $params['attribs'] = array(); 00873 } 00874 if ( !isset( $params['help'] ) ) { 00875 $params['help'] = ""; 00876 } 00877 if( isset( $params['rawtext'] ) ) { 00878 $labelText = $params['rawtext']; 00879 } else { 00880 $labelText = $this->parse( wfMsg( $params['label'] ) ); 00881 } 00882 00883 return 00884 "<div class=\"config-input-check\">\n" . 00885 $params['help'] . 00886 "<label>\n" . 00887 Xml::check( 00888 $params['controlName'], 00889 $params['value'], 00890 $params['attribs'] + array( 00891 'id' => $params['controlName'], 00892 'tabindex' => $this->nextTabIndex(), 00893 ) 00894 ) . 00895 $labelText . "\n" . 00896 "</label>\n" . 00897 "</div>\n"; 00898 } 00899 00917 public function getRadioSet( $params ) { 00918 if ( !isset( $params['controlName'] ) ) { 00919 $params['controlName'] = 'config_' . $params['var']; 00920 } 00921 00922 if ( !isset( $params['value'] ) ) { 00923 $params['value'] = $this->getVar( $params['var'] ); 00924 } 00925 00926 if ( !isset( $params['label'] ) ) { 00927 $label = ''; 00928 } else { 00929 $label = $params['label']; 00930 } 00931 if ( !isset( $params['help'] ) ) { 00932 $params['help'] = ""; 00933 } 00934 $s = "<ul>\n"; 00935 foreach ( $params['values'] as $value ) { 00936 $itemAttribs = array(); 00937 00938 if ( isset( $params['commonAttribs'] ) ) { 00939 $itemAttribs = $params['commonAttribs']; 00940 } 00941 00942 if ( isset( $params['itemAttribs'][$value] ) ) { 00943 $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs; 00944 } 00945 00946 $checked = $value == $params['value']; 00947 $id = $params['controlName'] . '_' . $value; 00948 $itemAttribs['id'] = $id; 00949 $itemAttribs['tabindex'] = $this->nextTabIndex(); 00950 00951 $s .= 00952 '<li>' . 00953 Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) . 00954 ' ' . 00955 Xml::tags( 'label', array( 'for' => $id ), $this->parse( 00956 wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) ) 00957 ) ) . 00958 "</li>\n"; 00959 } 00960 00961 $s .= "</ul>\n"; 00962 00963 return $this->label( $label, $params['controlName'], $s, $params['help'] ); 00964 } 00965 00971 public function showStatusBox( $status ) { 00972 if( !$status->isGood() ) { 00973 $text = $status->getWikiText(); 00974 00975 if( $status->isOk() ) { 00976 $box = $this->getWarningBox( $text ); 00977 } else { 00978 $box = $this->getErrorBox( $text ); 00979 } 00980 00981 $this->output->addHTML( $box ); 00982 } 00983 } 00984 00995 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) { 00996 $newValues = array(); 00997 00998 foreach ( $varNames as $name ) { 00999 $value = trim( $this->request->getVal( $prefix . $name ) ); 01000 $newValues[$name] = $value; 01001 01002 if ( $value === null ) { 01003 // Checkbox? 01004 $this->setVar( $name, false ); 01005 } else { 01006 if ( stripos( $name, 'password' ) !== false ) { 01007 $this->setPassword( $name, $value ); 01008 } else { 01009 $this->setVar( $name, $value ); 01010 } 01011 } 01012 } 01013 01014 return $newValues; 01015 } 01016 01023 protected function getDocUrl( $page ) { 01024 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page ); 01025 01026 if ( in_array( $this->currentPageName, $this->pageSequence ) ) { 01027 $url .= '&lastPage=' . urlencode( $this->currentPageName ); 01028 } 01029 01030 return $url; 01031 } 01032 01041 public function docLink( $linkText, $attribs, $parser ) { 01042 $url = $this->getDocUrl( $attribs['href'] ); 01043 return '<a href="' . htmlspecialchars( $url ) . '">' . 01044 htmlspecialchars( $linkText ) . 01045 '</a>'; 01046 } 01047 01056 public function downloadLinkHook( $text, $attribs, $parser ) { 01057 $img = Html::element( 'img', array( 01058 'src' => '../skins/common/images/download-32.png', 01059 'width' => '32', 01060 'height' => '32', 01061 ) ); 01062 $anchor = Html::rawElement( 'a', 01063 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ), 01064 $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) ); 01065 return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor ); 01066 } 01067 01071 public function envCheckPath( ) { 01072 // PHP_SELF isn't available sometimes, such as when PHP is CGI but 01073 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME 01074 // to get the path to the current script... hopefully it's reliable. SIGH 01075 $path = false; 01076 if ( !empty( $_SERVER['PHP_SELF'] ) ) { 01077 $path = $_SERVER['PHP_SELF']; 01078 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) { 01079 $path = $_SERVER['SCRIPT_NAME']; 01080 } 01081 if ($path !== false) { 01082 $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path ); 01083 $this->setVar( 'wgScriptPath', $uri ); 01084 } else { 01085 $this->showError( 'config-no-uri' ); 01086 return false; 01087 } 01088 return parent::envCheckPath(); 01089 } 01090 01091 protected function envGetDefaultServer() { 01092 return WebRequest::detectServer(); 01093 } 01094 }