MediaWiki  1.28.0
WebInstallerDBConnect.php
Go to the documentation of this file.
1 <?php
23 
27  public function execute() {
28  if ( $this->getVar( '_ExistingDBSettings' ) ) {
29  return 'skip';
30  }
31 
32  $r = $this->parent->request;
33  if ( $r->wasPosted() ) {
34  $status = $this->submit();
35 
36  if ( $status->isGood() ) {
37  $this->setVar( '_UpgradeDone', false );
38 
39  return 'continue';
40  } else {
41  $this->parent->showStatusBox( $status );
42  }
43  }
44 
45  $this->startForm();
46 
47  $types = "<ul class=\"config-settings-block\">\n";
48  $settings = '';
49  $defaultType = $this->getVar( 'wgDBtype' );
50 
51  // Messages: config-dbsupport-mysql, config-dbsupport-postgres, config-dbsupport-oracle,
52  // config-dbsupport-sqlite, config-dbsupport-mssql
53  $dbSupport = '';
54  foreach ( Installer::getDBTypes() as $type ) {
55  $dbSupport .= wfMessage( "config-dbsupport-$type" )->plain() . "\n";
56  }
57  $this->addHTML( $this->parent->getInfoBox(
58  wfMessage( 'config-support-info', trim( $dbSupport ) )->text() ) );
59 
60  // It's possible that the library for the default DB type is not compiled in.
61  // In that case, instead select the first supported DB type in the list.
62  $compiledDBs = $this->parent->getCompiledDBs();
63  if ( !in_array( $defaultType, $compiledDBs ) ) {
64  $defaultType = $compiledDBs[0];
65  }
66 
67  foreach ( $compiledDBs as $type ) {
68  $installer = $this->parent->getDBInstaller( $type );
69  $types .=
70  '<li>' .
72  $installer->getReadableName(),
73  'DBType',
74  $type,
75  "DBType_$type",
76  $type == $defaultType,
77  [ 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" ]
78  ) .
79  "</li>\n";
80 
81  // Messages: config-header-mysql, config-header-postgres, config-header-oracle,
82  // config-header-sqlite
83  $settings .= Html::openElement(
84  'div',
85  [
86  'id' => 'DB_wrapper_' . $type,
87  'class' => 'dbWrapper'
88  ]
89  ) .
90  Html::element( 'h3', [], wfMessage( 'config-header-' . $type )->text() ) .
91  $installer->getConnectForm() .
92  "</div>\n";
93  }
94 
95  $types .= "</ul><br style=\"clear: left\"/>\n";
96 
97  $this->addHTML( $this->parent->label( 'config-db-type', false, $types ) . $settings );
98  $this->endForm();
99 
100  return null;
101  }
102 
106  public function submit() {
107  $r = $this->parent->request;
108  $type = $r->getVal( 'DBType' );
109  if ( !$type ) {
110  return Status::newFatal( 'config-invalid-db-type' );
111  }
112  $this->setVar( 'wgDBtype', $type );
113  $installer = $this->parent->getDBInstaller( $type );
114  if ( !$installer ) {
115  return Status::newFatal( 'config-invalid-db-type' );
116  }
117 
118  return $installer->submitConnectForm();
119  }
120 
121 }
Abstract class to define pages for the web installer.
setVar($name, $value)
static radioLabel($label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:445
static newFatal($message)
Factory function for fatal errors.
Definition: StatusValue.php:63
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:247
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 unsetoffset-wrap String Wrap the message in html(usually something like"&lt
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:12
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
getVar($var, $default=null)
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1046
static getDBTypes()
Get a list of known DB types.
Definition: Installer.php:456
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:229
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2491
endForm($continue= 'continue', $back= 'back')