43 $ver = WikiExporter::schemaVersion();
44 return Xml::element(
'mediawiki', [
45 'xmlns' =>
"http://www.mediawiki.org/xml/export-$ver/",
46 'xmlns:xsi' =>
"http://www.w3.org/2001/XMLSchema-instance",
57 'xsi:schemaLocation' =>
"http://www.mediawiki.org/xml/export-$ver/ " .
58 "http://www.mediawiki.org/xml/export-$ver.xsd",
60 'xml:lang' => MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() ],
77 return " <siteinfo>\n " .
78 implode(
"\n ", $info ) .
95 return Xml::element(
'dbname', [],
$wgDBname );
103 return Xml::element(
'generator', [],
"MediaWiki $wgVersion" );
110 return Xml::element(
'base', [], Title::newMainPage()->getCanonicalURL() );
120 return Xml::element(
'case', [], $sensitivity );
127 $spaces =
"<namespaces>\n";
129 MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces()
133 Xml::element(
'namespace',
136 'case' => MWNamespace::isCapitalized( $ns ) ?
'first-letter' :
'case-sensitive',
139 $spaces .=
" </namespaces>";
150 return "</mediawiki>\n";
162 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
163 $out .=
' ' . Xml::elementClean(
'title', [], self::canonicalTitle(
$title ) ) .
"\n";
164 $out .=
' ' . Xml::element(
'ns', [], strval( $row->page_namespace ) ) .
"\n";
165 $out .=
' ' . Xml::element(
'id', [], strval( $row->page_id ) ) .
"\n";
166 if ( $row->page_is_redirect ) {
167 $page = WikiPage::factory(
$title );
168 $redirect = $page->getRedirectTarget();
171 $out .= Xml::element(
'redirect', [
'title' => self::canonicalTitle( $redirect ) ] );
176 if ( $row->page_restrictions !=
'' ) {
177 $out .=
' ' . Xml::element(
'restrictions', [],
178 strval( $row->page_restrictions ) ) .
"\n";
181 Hooks::run(
'XmlDumpWriterOpenPage', [ $this, &
$out, $row,
$title ] );
205 $out =
" <revision>\n";
206 $out .=
" " . Xml::element(
'id',
null, strval( $row->rev_id ) ) .
"\n";
207 if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
208 $out .=
" " . Xml::element(
'parentid',
null, strval( $row->rev_parent_id ) ) .
"\n";
214 $out .=
" " . Xml::element(
'contributor', [
'deleted' =>
'deleted' ] ) .
"\n";
219 if ( isset( $row->rev_minor_edit ) && $row->rev_minor_edit ) {
220 $out .=
" <minor/>\n";
223 $out .=
" " . Xml::element(
'comment', [
'deleted' =>
'deleted' ] ) .
"\n";
225 $comment = CommentStore::getStore()->getComment(
'rev_comment', $row )->text;
226 if ( $comment !=
'' ) {
227 $out .=
" " . Xml::elementClean(
'comment', [], strval( $comment ) ) .
"\n";
231 if ( isset( $row->rev_content_model ) && !is_null( $row->rev_content_model ) ) {
232 $content_model = strval( $row->rev_content_model );
235 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
236 $content_model = ContentHandler::getDefaultModelFor(
$title );
239 $content_handler = ContentHandler::getForModelID( $content_model );
241 if ( isset( $row->rev_content_format ) && !is_null( $row->rev_content_format ) ) {
242 $content_format = strval( $row->rev_content_format );
245 $content_format = $content_handler->getDefaultFormat();
248 $out .=
" " . Xml::element(
'model',
null, strval( $content_model ) ) .
"\n";
249 $out .=
" " . Xml::element(
'format',
null, strval( $content_format ) ) .
"\n";
253 $out .=
" " . Xml::element(
'text', [
'deleted' =>
'deleted' ] ) .
"\n";
254 } elseif ( isset( $row->old_text ) ) {
257 $text = $content_handler->exportTransform( $text, $content_format );
258 $out .=
" " . Xml::elementClean(
'text',
259 [
'xml:space' =>
'preserve',
'bytes' => intval( $row->rev_len ) ],
260 strval( $text ) ) .
"\n";
263 $out .=
" " . Xml::element(
'text',
264 [
'id' => $row->rev_text_id,
'bytes' => intval( $row->rev_len ) ],
268 if ( isset( $row->rev_sha1 )
272 $out .=
" " . Xml::element(
'sha1',
null, strval( $row->rev_sha1 ) ) .
"\n";
274 $out .=
" <sha1/>\n";
279 Hooks::run(
'XmlDumpWriterWriteRevision', [ &$writer, &
$out, $row, $text ] );
281 $out .=
" </revision>\n";
295 $out =
" <logitem>\n";
296 $out .=
" " . Xml::element(
'id',
null, strval( $row->log_id ) ) .
"\n";
301 $out .=
" " . Xml::element(
'contributor', [
'deleted' =>
'deleted' ] ) .
"\n";
307 $out .=
" " . Xml::element(
'comment', [
'deleted' =>
'deleted' ] ) .
"\n";
309 $comment = CommentStore::getStore()->getComment(
'log_comment', $row )->text;
310 if ( $comment !=
'' ) {
311 $out .=
" " . Xml::elementClean(
'comment',
null, strval( $comment ) ) .
"\n";
315 $out .=
" " . Xml::element(
'type',
null, strval( $row->log_type ) ) .
"\n";
316 $out .=
" " . Xml::element(
'action',
null, strval( $row->log_action ) ) .
"\n";
319 $out .=
" " . Xml::element(
'text', [
'deleted' =>
'deleted' ] ) .
"\n";
321 $title = Title::makeTitle( $row->log_namespace, $row->log_title );
322 $out .=
" " . Xml::elementClean(
'logtitle',
null, self::canonicalTitle(
$title ) ) .
"\n";
323 $out .=
" " . Xml::elementClean(
'params',
324 [
'xml:space' =>
'preserve' ],
325 strval( $row->log_params ) ) .
"\n";
328 $out .=
" </logitem>\n";
340 return $indent . Xml::element(
'timestamp',
null, $ts ) .
"\n";
350 $out = $indent .
"<contributor>\n";
351 if ( $id || !IP::isValid( $text ) ) {
352 $out .= $indent .
" " . Xml::elementClean(
'username',
null, strval( $text ) ) .
"\n";
353 $out .= $indent .
" " . Xml::element(
'id',
null, strval( $id ) ) .
"\n";
355 $out .= $indent .
" " . Xml::elementClean(
'ip',
null, strval( $text ) ) .
"\n";
357 $out .= $indent .
"</contributor>\n";
368 if ( $row->page_namespace ==
NS_FILE ) {
370 if ( $img && $img->exists() ) {
372 foreach ( array_reverse( $img->getHistory() )
as $ver ) {
388 if ( $file->isOld() ) {
390 Xml::element(
'archivename',
null, $file->getArchiveName() ) .
"\n";
394 if ( $dumpContents ) {
395 $be = $file->getRepo()->getBackend();
396 # Dump file as base64
397 # Uses only XML-safe characters, so does not need escaping
398 # @todo Too bad this loads the contents into memory (script might swap)
399 $contents =
' <contents encoding="base64">' .
400 chunk_split( base64_encode(
401 $be->getFileContents( [
'src' => $file->getPath() ] ) ) ) .
407 $comment = Xml::element(
'comment', [
'deleted' =>
'deleted' ] );
409 $comment = Xml::elementClean(
'comment',
null, strval( $file->getDescription() ) );
411 return " <upload>\n" .
413 $this->
writeContributor( $file->getUser(
'id' ), $file->getUser(
'text' ) ) .
414 " " . $comment .
"\n" .
415 " " . Xml::element(
'filename',
null, $file->getName() ) .
"\n" .
417 " " . Xml::element(
'src',
null, $file->getCanonicalUrl() ) .
"\n" .
418 " " . Xml::element(
'size',
null, $file->getSize() ) .
"\n" .
419 " " . Xml::element(
'sha1base36',
null, $file->getSha1() ) .
"\n" .
420 " " . Xml::element(
'rel',
null, $file->getRel() ) .
"\n" .
436 if (
$title->isExternal() ) {
437 return $title->getPrefixedText();
440 $prefix = MediaWikiServices::getInstance()->getContentLanguage()->
441 getFormattedNsText(
$title->getNamespace() );
446 if ( $prefix !==
'' ) {
450 return $prefix .
$title->getText();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
$wgSitename
Name of the site.
$wgVersion
MediaWiki version number.
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
Represents a title within MediaWiki.
isValidRedirectTarget()
Check if this Title is a valid redirect target.
closeStream()
Closes the output stream with the closing root element.
static canonicalTitle(Title $title)
Return prefixed text form of title, but using the content language's canonical namespace.
writeUpload( $file, $dumpContents=false)
writeLogItem( $row)
Dumps a "<logitem>" section on the output stream, with data filled in from the given database row.
writeTimestamp( $timestamp, $indent=" ")
writeUploads( $row, $dumpContents=false)
Warning! This data is potentially inconsistent.
closePage()
Closes a "<page>" section on the output stream.
openStream()
Opens the XML output stream's root "<mediawiki>" element.
openPage( $row)
Opens a "<page>" section on the output stream, with data from the given database row.
writeRevision( $row)
Dumps a "<revision>" section on the output stream, with data filled in from the given database row.
writeContributor( $id, $text, $indent=" ")
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
namespace and then decline to actually register it file or subcat img or subcat $title
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 $out
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
controlled by the following MediaWiki still creates a BagOStuff but calls it to it are no ops If the cache daemon can t be it should also disable itself fairly $wgDBname