MediaWiki
REL1_20
|
00001 <?php 00030 class WebInstaller extends Installer { 00031 00035 public $output; 00036 00042 public $request; 00043 00049 protected $session; 00050 00055 protected $phpErrors; 00056 00065 public $pageSequence = array( 00066 'Language', 00067 'ExistingWiki', 00068 'Welcome', 00069 'DBConnect', 00070 'Upgrade', 00071 'DBSettings', 00072 'Name', 00073 'Options', 00074 'Install', 00075 'Complete', 00076 ); 00077 00082 protected $otherPages = array( 00083 'Restart', 00084 'Readme', 00085 'ReleaseNotes', 00086 'Copying', 00087 'UpgradeDoc', // Can't use Upgrade due to Upgrade step 00088 ); 00089 00095 protected $happyPages; 00096 00103 protected $skippedPages; 00104 00109 public $showSessionWarning = false; 00110 00115 protected $tabIndex = 1; 00116 00121 protected $currentPageName; 00122 00128 public function __construct( WebRequest $request ) { 00129 parent::__construct(); 00130 $this->output = new WebInstallerOutput( $this ); 00131 $this->request = $request; 00132 00133 // Add parser hooks 00134 global $wgParser; 00135 $wgParser->setHook( 'downloadlink', array( $this, 'downloadLinkHook' ) ); 00136 $wgParser->setHook( 'doclink', array( $this, 'docLink' ) ); 00137 } 00138 00146 public function execute( array $session ) { 00147 $this->session = $session; 00148 00149 if ( isset( $session['settings'] ) ) { 00150 $this->settings = $session['settings'] + $this->settings; 00151 } 00152 00153 $this->exportVars(); 00154 $this->setupLanguage(); 00155 00156 if( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) ) 00157 && $this->request->getVal( 'localsettings' ) ) 00158 { 00159 $this->request->response()->header( 'Content-type: application/x-httpd-php' ); 00160 $this->request->response()->header( 00161 'Content-Disposition: attachment; filename="LocalSettings.php"' 00162 ); 00163 00164 $ls = InstallerOverrides::getLocalSettingsGenerator( $this ); 00165 $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )]; 00166 foreach( $rightsProfile as $group => $rightsArr ) { 00167 $ls->setGroupRights( $group, $rightsArr ); 00168 } 00169 echo $ls->getText(); 00170 return $this->session; 00171 } 00172 00173 $cssDir = $this->request->getVal( 'css' ); 00174 if( $cssDir ) { 00175 $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' ); 00176 $this->request->response()->header( 'Content-type: text/css' ); 00177 echo $this->output->getCSS( $cssDir ); 00178 return $this->session; 00179 } 00180 00181 if ( isset( $session['happyPages'] ) ) { 00182 $this->happyPages = $session['happyPages']; 00183 } else { 00184 $this->happyPages = array(); 00185 } 00186 00187 if ( isset( $session['skippedPages'] ) ) { 00188 $this->skippedPages = $session['skippedPages']; 00189 } else { 00190 $this->skippedPages = array(); 00191 } 00192 00193 $lowestUnhappy = $this->getLowestUnhappy(); 00194 00195 # Special case for Creative Commons partner chooser box. 00196 if ( $this->request->getVal( 'SubmitCC' ) ) { 00197 $page = $this->getPageByName( 'Options' ); 00198 $this->output->useShortHeader(); 00199 $this->output->allowFrames(); 00200 $page->submitCC(); 00201 return $this->finish(); 00202 } 00203 00204 if ( $this->request->getVal( 'ShowCC' ) ) { 00205 $page = $this->getPageByName( 'Options' ); 00206 $this->output->useShortHeader(); 00207 $this->output->allowFrames(); 00208 $this->output->addHTML( $page->getCCDoneBox() ); 00209 return $this->finish(); 00210 } 00211 00212 # Get the page name. 00213 $pageName = $this->request->getVal( 'page' ); 00214 00215 if ( in_array( $pageName, $this->otherPages ) ) { 00216 # Out of sequence 00217 $pageId = false; 00218 $page = $this->getPageByName( $pageName ); 00219 } else { 00220 # Main sequence 00221 if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) { 00222 $pageId = $lowestUnhappy; 00223 } else { 00224 $pageId = array_search( $pageName, $this->pageSequence ); 00225 } 00226 00227 # If necessary, move back to the lowest-numbered unhappy page 00228 if ( $pageId > $lowestUnhappy ) { 00229 $pageId = $lowestUnhappy; 00230 if ( $lowestUnhappy == 0 ) { 00231 # Knocked back to start, possible loss of session data. 00232 $this->showSessionWarning = true; 00233 } 00234 } 00235 00236 $pageName = $this->pageSequence[$pageId]; 00237 $page = $this->getPageByName( $pageName ); 00238 } 00239 00240 # If a back button was submitted, go back without submitting the form data. 00241 if ( $this->request->wasPosted() && $this->request->getBool( 'submit-back' ) ) { 00242 if ( $this->request->getVal( 'lastPage' ) ) { 00243 $nextPage = $this->request->getVal( 'lastPage' ); 00244 } elseif ( $pageId !== false ) { 00245 # Main sequence page 00246 # Skip the skipped pages 00247 $nextPageId = $pageId; 00248 00249 do { 00250 $nextPageId--; 00251 $nextPage = $this->pageSequence[$nextPageId]; 00252 } while( isset( $this->skippedPages[$nextPage] ) ); 00253 } else { 00254 $nextPage = $this->pageSequence[$lowestUnhappy]; 00255 } 00256 00257 $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) ); 00258 return $this->finish(); 00259 } 00260 00261 # Execute the page. 00262 $this->currentPageName = $page->getName(); 00263 $this->startPageWrapper( $pageName ); 00264 00265 if( $page->isSlow() ) { 00266 $this->disableTimeLimit(); 00267 } 00268 00269 $result = $page->execute(); 00270 00271 $this->endPageWrapper(); 00272 00273 if ( $result == 'skip' ) { 00274 # Page skipped without explicit submission. 00275 # Skip it when we click "back" so that we don't just go forward again. 00276 $this->skippedPages[$pageName] = true; 00277 $result = 'continue'; 00278 } else { 00279 unset( $this->skippedPages[$pageName] ); 00280 } 00281 00282 # If it was posted, the page can request a continue to the next page. 00283 if ( $result === 'continue' && !$this->output->headerDone() ) { 00284 if ( $pageId !== false ) { 00285 $this->happyPages[$pageId] = true; 00286 } 00287 00288 $lowestUnhappy = $this->getLowestUnhappy(); 00289 00290 if ( $this->request->getVal( 'lastPage' ) ) { 00291 $nextPage = $this->request->getVal( 'lastPage' ); 00292 } elseif ( $pageId !== false ) { 00293 $nextPage = $this->pageSequence[$pageId + 1]; 00294 } else { 00295 $nextPage = $this->pageSequence[$lowestUnhappy]; 00296 } 00297 00298 if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) { 00299 $nextPage = $this->pageSequence[$lowestUnhappy]; 00300 } 00301 00302 $this->output->redirect( $this->getUrl( array( 'page' => $nextPage ) ) ); 00303 } 00304 00305 return $this->finish(); 00306 } 00307 00312 public function getLowestUnhappy() { 00313 if ( count( $this->happyPages ) == 0 ) { 00314 return 0; 00315 } else { 00316 return max( array_keys( $this->happyPages ) ) + 1; 00317 } 00318 } 00319 00325 public function startSession() { 00326 if( wfIniGetBool( 'session.auto_start' ) || session_id() ) { 00327 // Done already 00328 return true; 00329 } 00330 00331 $this->phpErrors = array(); 00332 set_error_handler( array( $this, 'errorHandler' ) ); 00333 session_start(); 00334 restore_error_handler(); 00335 00336 if ( $this->phpErrors ) { 00337 $this->showError( 'config-session-error', $this->phpErrors[0] ); 00338 return false; 00339 } 00340 00341 return true; 00342 } 00343 00352 public function getFingerprint() { 00353 // Get the base URL of the installation 00354 $url = $this->request->getFullRequestURL(); 00355 if ( preg_match( '!^(.*\?)!', $url, $m) ) { 00356 // Trim query string 00357 $url = $m[1]; 00358 } 00359 if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) { 00360 // This... seems to try to get the base path from 00361 // the /mw-config/index.php. Kinda scary though? 00362 $url = $m[1]; 00363 } 00364 return md5( serialize( array( 00365 'local path' => dirname( __DIR__ ), 00366 'url' => $url, 00367 'version' => $GLOBALS['wgVersion'] 00368 ) ) ); 00369 } 00370 00375 public function showError( $msg /*...*/ ) { 00376 $args = func_get_args(); 00377 array_shift( $args ); 00378 $args = array_map( 'htmlspecialchars', $args ); 00379 $msg = wfMessage( $msg, $args )->useDatabase( false )->plain(); 00380 $this->output->addHTML( $this->getErrorBox( $msg ) ); 00381 } 00382 00388 public function errorHandler( $errno, $errstr ) { 00389 $this->phpErrors[] = $errstr; 00390 } 00391 00397 public function finish() { 00398 $this->output->output(); 00399 00400 $this->session['happyPages'] = $this->happyPages; 00401 $this->session['skippedPages'] = $this->skippedPages; 00402 $this->session['settings'] = $this->settings; 00403 00404 return $this->session; 00405 } 00406 00410 public function reset() { 00411 $this->session = array(); 00412 $this->happyPages = array(); 00413 $this->settings = array(); 00414 } 00415 00422 public function getUrl( $query = array() ) { 00423 $url = $this->request->getRequestURL(); 00424 # Remove existing query 00425 $url = preg_replace( '/\?.*$/', '', $url ); 00426 00427 if ( $query ) { 00428 $url .= '?' . wfArrayToCGI( $query ); 00429 } 00430 00431 return $url; 00432 } 00433 00440 public function getPageByName( $pageName ) { 00441 $pageClass = 'WebInstaller_' . $pageName; 00442 00443 return new $pageClass( $this ); 00444 } 00445 00453 public function getSession( $name, $default = null ) { 00454 if ( !isset( $this->session[$name] ) ) { 00455 return $default; 00456 } else { 00457 return $this->session[$name]; 00458 } 00459 } 00460 00466 public function setSession( $name, $value ) { 00467 $this->session[$name] = $value; 00468 } 00469 00474 public function nextTabIndex() { 00475 return $this->tabIndex++; 00476 } 00477 00481 public function setupLanguage() { 00482 global $wgLang, $wgContLang, $wgLanguageCode; 00483 00484 if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) { 00485 $wgLanguageCode = $this->getAcceptLanguage(); 00486 $wgLang = $wgContLang = Language::factory( $wgLanguageCode ); 00487 $this->setVar( 'wgLanguageCode', $wgLanguageCode ); 00488 $this->setVar( '_UserLang', $wgLanguageCode ); 00489 } else { 00490 $wgLanguageCode = $this->getVar( 'wgLanguageCode' ); 00491 $wgContLang = Language::factory( $wgLanguageCode ); 00492 } 00493 } 00494 00500 public function getAcceptLanguage() { 00501 global $wgLanguageCode, $wgRequest; 00502 00503 $mwLanguages = Language::fetchLanguageNames(); 00504 $headerLanguages = array_keys( $wgRequest->getAcceptLang() ); 00505 00506 foreach ( $headerLanguages as $lang ) { 00507 if ( isset( $mwLanguages[$lang] ) ) { 00508 return $lang; 00509 } 00510 } 00511 00512 return $wgLanguageCode; 00513 } 00514 00520 private function startPageWrapper( $currentPageName ) { 00521 $s = "<div class=\"config-page-wrapper\">\n"; 00522 $s .= "<div class=\"config-page\">\n"; 00523 $s .= "<div class=\"config-page-list\"><ul>\n"; 00524 $lastHappy = -1; 00525 00526 foreach ( $this->pageSequence as $id => $pageName ) { 00527 $happy = !empty( $this->happyPages[$id] ); 00528 $s .= $this->getPageListItem( 00529 $pageName, 00530 $happy || $lastHappy == $id - 1, 00531 $currentPageName 00532 ); 00533 00534 if ( $happy ) { 00535 $lastHappy = $id; 00536 } 00537 } 00538 00539 $s .= "</ul><br/><ul>\n"; 00540 $s .= $this->getPageListItem( 'Restart', true, $currentPageName ); 00541 $s .= "</ul></div>\n"; // end list pane 00542 $s .= Html::element( 'h2', array(), 00543 wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() ); 00544 00545 $this->output->addHTMLNoFlush( $s ); 00546 } 00547 00557 private function getPageListItem( $pageName, $enabled, $currentPageName ) { 00558 $s = "<li class=\"config-page-list-item\">"; 00559 $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text(); 00560 00561 if ( $enabled ) { 00562 $query = array( 'page' => $pageName ); 00563 00564 if ( !in_array( $pageName, $this->pageSequence ) ) { 00565 if ( in_array( $currentPageName, $this->pageSequence ) ) { 00566 $query['lastPage'] = $currentPageName; 00567 } 00568 00569 $link = Html::element( 'a', 00570 array( 00571 'href' => $this->getUrl( $query ) 00572 ), 00573 $name 00574 ); 00575 } else { 00576 $link = htmlspecialchars( $name ); 00577 } 00578 00579 if ( $pageName == $currentPageName ) { 00580 $s .= "<span class=\"config-page-current\">$link</span>"; 00581 } else { 00582 $s .= $link; 00583 } 00584 } else { 00585 $s .= Html::element( 'span', 00586 array( 00587 'class' => 'config-page-disabled' 00588 ), 00589 $name 00590 ); 00591 } 00592 00593 $s .= "</li>\n"; 00594 00595 return $s; 00596 } 00597 00601 private function endPageWrapper() { 00602 $this->output->addHTMLNoFlush( 00603 "<div class=\"visualClear\"></div>\n" . 00604 "</div>\n" . 00605 "<div class=\"visualClear\"></div>\n" . 00606 "</div>" ); 00607 } 00608 00616 public function getErrorBox( $text ) { 00617 return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' ); 00618 } 00619 00627 public function getWarningBox( $text ) { 00628 return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' ); 00629 } 00630 00640 public function getInfoBox( $text, $icon = false, $class = false ) { 00641 $text = $this->parse( $text, true ); 00642 $icon = ( $icon == false ) ? '../skins/common/images/info-32.png' : '../skins/common/images/'.$icon; 00643 $alt = wfMessage( 'config-information' )->text(); 00644 return Html::infoBox( $text, $icon, $alt, $class, false ); 00645 } 00646 00654 public function getHelpBox( $msg /*, ... */ ) { 00655 $args = func_get_args(); 00656 array_shift( $args ); 00657 $args = array_map( 'htmlspecialchars', $args ); 00658 $text = wfMessage( $msg, $args )->useDatabase( false )->plain(); 00659 $html = $this->parse( $text, true ); 00660 00661 return "<div class=\"mw-help-field-container\">\n" . 00662 "<span class=\"mw-help-field-hint\">" . wfMessage( 'config-help' )->escaped() . 00663 "</span>\n" . 00664 "<span class=\"mw-help-field-data\">" . $html . "</span>\n" . 00665 "</div>\n"; 00666 } 00667 00672 public function showHelpBox( $msg /*, ... */ ) { 00673 $args = func_get_args(); 00674 $html = call_user_func_array( array( $this, 'getHelpBox' ), $args ); 00675 $this->output->addHTML( $html ); 00676 } 00677 00684 public function showMessage( $msg /*, ... */ ) { 00685 $args = func_get_args(); 00686 array_shift( $args ); 00687 $html = '<div class="config-message">' . 00688 $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) . 00689 "</div>\n"; 00690 $this->output->addHTML( $html ); 00691 } 00692 00696 public function showStatusMessage( Status $status ) { 00697 $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() ); 00698 foreach ( $errors as $error ) { 00699 call_user_func_array( array( $this, 'showMessage' ), $error ); 00700 } 00701 } 00702 00713 public function label( $msg, $forId, $contents, $helpData = "" ) { 00714 if ( strval( $msg ) == '' ) { 00715 $labelText = ' '; 00716 } else { 00717 $labelText = wfMessage( $msg )->escaped(); 00718 } 00719 00720 $attributes = array( 'class' => 'config-label' ); 00721 00722 if ( $forId ) { 00723 $attributes['for'] = $forId; 00724 } 00725 00726 return 00727 "<div class=\"config-block\">\n" . 00728 " <div class=\"config-block-label\">\n" . 00729 Xml::tags( 'label', 00730 $attributes, 00731 $labelText ) . "\n" . 00732 $helpData . 00733 " </div>\n" . 00734 " <div class=\"config-block-elements\">\n" . 00735 $contents . 00736 " </div>\n" . 00737 "</div>\n"; 00738 } 00739 00754 public function getTextBox( $params ) { 00755 if ( !isset( $params['controlName'] ) ) { 00756 $params['controlName'] = 'config_' . $params['var']; 00757 } 00758 00759 if ( !isset( $params['value'] ) ) { 00760 $params['value'] = $this->getVar( $params['var'] ); 00761 } 00762 00763 if ( !isset( $params['attribs'] ) ) { 00764 $params['attribs'] = array(); 00765 } 00766 if ( !isset( $params['help'] ) ) { 00767 $params['help'] = ""; 00768 } 00769 return 00770 $this->label( 00771 $params['label'], 00772 $params['controlName'], 00773 Xml::input( 00774 $params['controlName'], 00775 30, // intended to be overridden by CSS 00776 $params['value'], 00777 $params['attribs'] + array( 00778 'id' => $params['controlName'], 00779 'class' => 'config-input-text', 00780 'tabindex' => $this->nextTabIndex() 00781 ) 00782 ), 00783 $params['help'] 00784 ); 00785 } 00786 00801 public function getTextArea( $params ) { 00802 if ( !isset( $params['controlName'] ) ) { 00803 $params['controlName'] = 'config_' . $params['var']; 00804 } 00805 00806 if ( !isset( $params['value'] ) ) { 00807 $params['value'] = $this->getVar( $params['var'] ); 00808 } 00809 00810 if ( !isset( $params['attribs'] ) ) { 00811 $params['attribs'] = array(); 00812 } 00813 if ( !isset( $params['help'] ) ) { 00814 $params['help'] = ""; 00815 } 00816 return 00817 $this->label( 00818 $params['label'], 00819 $params['controlName'], 00820 Xml::textarea( 00821 $params['controlName'], 00822 $params['value'], 00823 30, 00824 5, 00825 $params['attribs'] + array( 00826 'id' => $params['controlName'], 00827 'class' => 'config-input-text', 00828 'tabindex' => $this->nextTabIndex() 00829 ) 00830 ), 00831 $params['help'] 00832 ); 00833 } 00834 00850 public function getPasswordBox( $params ) { 00851 if ( !isset( $params['value'] ) ) { 00852 $params['value'] = $this->getVar( $params['var'] ); 00853 } 00854 00855 if ( !isset( $params['attribs'] ) ) { 00856 $params['attribs'] = array(); 00857 } 00858 00859 $params['value'] = $this->getFakePassword( $params['value'] ); 00860 $params['attribs']['type'] = 'password'; 00861 00862 return $this->getTextBox( $params ); 00863 } 00864 00879 public function getCheckBox( $params ) { 00880 if ( !isset( $params['controlName'] ) ) { 00881 $params['controlName'] = 'config_' . $params['var']; 00882 } 00883 00884 if ( !isset( $params['value'] ) ) { 00885 $params['value'] = $this->getVar( $params['var'] ); 00886 } 00887 00888 if ( !isset( $params['attribs'] ) ) { 00889 $params['attribs'] = array(); 00890 } 00891 if ( !isset( $params['help'] ) ) { 00892 $params['help'] = ""; 00893 } 00894 if( isset( $params['rawtext'] ) ) { 00895 $labelText = $params['rawtext']; 00896 } else { 00897 $labelText = $this->parse( wfMessage( $params['label'] )->text() ); 00898 } 00899 00900 return 00901 "<div class=\"config-input-check\">\n" . 00902 $params['help'] . 00903 "<label>\n" . 00904 Xml::check( 00905 $params['controlName'], 00906 $params['value'], 00907 $params['attribs'] + array( 00908 'id' => $params['controlName'], 00909 'tabindex' => $this->nextTabIndex(), 00910 ) 00911 ) . 00912 $labelText . "\n" . 00913 "</label>\n" . 00914 "</div>\n"; 00915 } 00916 00934 public function getRadioSet( $params ) { 00935 if ( !isset( $params['controlName'] ) ) { 00936 $params['controlName'] = 'config_' . $params['var']; 00937 } 00938 00939 if ( !isset( $params['value'] ) ) { 00940 $params['value'] = $this->getVar( $params['var'] ); 00941 } 00942 00943 if ( !isset( $params['label'] ) ) { 00944 $label = ''; 00945 } else { 00946 $label = $params['label']; 00947 } 00948 if ( !isset( $params['help'] ) ) { 00949 $params['help'] = ""; 00950 } 00951 $s = "<ul>\n"; 00952 foreach ( $params['values'] as $value ) { 00953 $itemAttribs = array(); 00954 00955 if ( isset( $params['commonAttribs'] ) ) { 00956 $itemAttribs = $params['commonAttribs']; 00957 } 00958 00959 if ( isset( $params['itemAttribs'][$value] ) ) { 00960 $itemAttribs = $params['itemAttribs'][$value] + $itemAttribs; 00961 } 00962 00963 $checked = $value == $params['value']; 00964 $id = $params['controlName'] . '_' . $value; 00965 $itemAttribs['id'] = $id; 00966 $itemAttribs['tabindex'] = $this->nextTabIndex(); 00967 00968 $s .= 00969 '<li>' . 00970 Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) . 00971 ' ' . 00972 Xml::tags( 'label', array( 'for' => $id ), $this->parse( 00973 wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain() 00974 ) ) . 00975 "</li>\n"; 00976 } 00977 00978 $s .= "</ul>\n"; 00979 00980 return $this->label( $label, $params['controlName'], $s, $params['help'] ); 00981 } 00982 00988 public function showStatusBox( $status ) { 00989 if( !$status->isGood() ) { 00990 $text = $status->getWikiText(); 00991 00992 if( $status->isOk() ) { 00993 $box = $this->getWarningBox( $text ); 00994 } else { 00995 $box = $this->getErrorBox( $text ); 00996 } 00997 00998 $this->output->addHTML( $box ); 00999 } 01000 } 01001 01012 public function setVarsFromRequest( $varNames, $prefix = 'config_' ) { 01013 $newValues = array(); 01014 01015 foreach ( $varNames as $name ) { 01016 $value = trim( $this->request->getVal( $prefix . $name ) ); 01017 $newValues[$name] = $value; 01018 01019 if ( $value === null ) { 01020 // Checkbox? 01021 $this->setVar( $name, false ); 01022 } else { 01023 if ( stripos( $name, 'password' ) !== false ) { 01024 $this->setPassword( $name, $value ); 01025 } else { 01026 $this->setVar( $name, $value ); 01027 } 01028 } 01029 } 01030 01031 return $newValues; 01032 } 01033 01040 protected function getDocUrl( $page ) { 01041 $url = "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page ); 01042 01043 if ( in_array( $this->currentPageName, $this->pageSequence ) ) { 01044 $url .= '&lastPage=' . urlencode( $this->currentPageName ); 01045 } 01046 01047 return $url; 01048 } 01049 01058 public function docLink( $linkText, $attribs, $parser ) { 01059 $url = $this->getDocUrl( $attribs['href'] ); 01060 return '<a href="' . htmlspecialchars( $url ) . '">' . 01061 htmlspecialchars( $linkText ) . 01062 '</a>'; 01063 } 01064 01073 public function downloadLinkHook( $text, $attribs, $parser ) { 01074 $img = Html::element( 'img', array( 01075 'src' => '../skins/common/images/download-32.png', 01076 'width' => '32', 01077 'height' => '32', 01078 ) ); 01079 $anchor = Html::rawElement( 'a', 01080 array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ), 01081 $img . ' ' . wfMessage( 'config-download-localsettings' )->escaped() ); 01082 return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor ); 01083 } 01084 01088 public function envCheckPath( ) { 01089 // PHP_SELF isn't available sometimes, such as when PHP is CGI but 01090 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME 01091 // to get the path to the current script... hopefully it's reliable. SIGH 01092 $path = false; 01093 if ( !empty( $_SERVER['PHP_SELF'] ) ) { 01094 $path = $_SERVER['PHP_SELF']; 01095 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) { 01096 $path = $_SERVER['SCRIPT_NAME']; 01097 } 01098 if ($path !== false) { 01099 $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path ); 01100 $this->setVar( 'wgScriptPath', $uri ); 01101 } else { 01102 $this->showError( 'config-no-uri' ); 01103 return false; 01104 } 01105 return parent::envCheckPath(); 01106 } 01107 01108 protected function envGetDefaultServer() { 01109 return WebRequest::detectServer(); 01110 } 01111 }