43 return Xml::element(
'mediawiki', [
44 'xmlns' =>
"http://www.mediawiki.org/xml/export-$ver/",
45 'xmlns:xsi' =>
"http://www.w3.org/2001/XMLSchema-instance",
56 'xsi:schemaLocation' =>
"http://www.mediawiki.org/xml/export-$ver/ " .
57 "http://www.mediawiki.org/xml/export-$ver.xsd",
76 return " <siteinfo>\n " .
77 implode(
"\n ", $info ) .
94 return Xml::element(
'dbname', [],
$wgDBname );
102 return Xml::element(
'generator', [],
"MediaWiki $wgVersion" );
109 return Xml::element(
'base', [], Title::newMainPage()->getCanonicalURL() );
119 return Xml::element(
'case', [], $sensitivity );
127 $spaces =
"<namespaces>\n";
128 foreach (
$wgContLang->getFormattedNamespaces() as $ns => $title ) {
130 Xml::element(
'namespace',
133 'case' => MWNamespace::isCapitalized( $ns ) ?
'first-letter' :
'case-sensitive',
136 $spaces .=
" </namespaces>";
147 return "</mediawiki>\n";
159 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
160 $out .=
' ' . Xml::elementClean(
'title', [], self::canonicalTitle( $title ) ) .
"\n";
161 $out .=
' ' . Xml::element(
'ns', [], strval( $row->page_namespace ) ) .
"\n";
162 $out .=
' ' . Xml::element(
'id', [], strval( $row->page_id ) ) .
"\n";
163 if ( $row->page_is_redirect ) {
165 $redirect = $page->getRedirectTarget();
168 $out .= Xml::element(
'redirect', [
'title' => self::canonicalTitle( $redirect ) ] );
173 if ( $row->page_restrictions !=
'' ) {
174 $out .=
' ' . Xml::element(
'restrictions', [],
175 strval( $row->page_restrictions ) ) .
"\n";
178 Hooks::run(
'XmlDumpWriterOpenPage', [ $this, &
$out, $row, $title ] );
202 $out =
" <revision>\n";
203 $out .=
" " . Xml::element(
'id',
null, strval( $row->rev_id ) ) .
"\n";
204 if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
205 $out .=
" " . Xml::element(
'parentid',
null, strval( $row->rev_parent_id ) ) .
"\n";
211 $out .=
" " . Xml::element(
'contributor', [
'deleted' =>
'deleted' ] ) .
"\n";
216 if ( isset( $row->rev_minor_edit ) && $row->rev_minor_edit ) {
217 $out .=
" <minor/>\n";
220 $out .=
" " . Xml::element(
'comment', [
'deleted' =>
'deleted' ] ) .
"\n";
223 if ( $comment !=
'' ) {
224 $out .=
" " . Xml::elementClean(
'comment', [], strval( $comment ) ) .
"\n";
228 if ( isset( $row->rev_content_model ) && !is_null( $row->rev_content_model ) ) {
229 $content_model = strval( $row->rev_content_model );
232 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
238 if ( isset( $row->rev_content_format ) && !is_null( $row->rev_content_format ) ) {
239 $content_format = strval( $row->rev_content_format );
242 $content_format = $content_handler->getDefaultFormat();
245 $out .=
" " . Xml::element(
'model',
null, strval( $content_model ) ) .
"\n";
246 $out .=
" " . Xml::element(
'format',
null, strval( $content_format ) ) .
"\n";
250 $out .=
" " . Xml::element(
'text', [
'deleted' =>
'deleted' ] ) .
"\n";
251 } elseif ( isset( $row->old_text ) ) {
254 $text = $content_handler->exportTransform( $text, $content_format );
255 $out .=
" " . Xml::elementClean(
'text',
256 [
'xml:space' =>
'preserve',
'bytes' => intval( $row->rev_len ) ],
257 strval( $text ) ) .
"\n";
260 $out .=
" " . Xml::element(
'text',
261 [
'id' => $row->rev_text_id,
'bytes' => intval( $row->rev_len ) ],
265 if ( isset( $row->rev_sha1 )
269 $out .=
" " . Xml::element(
'sha1',
null, strval( $row->rev_sha1 ) ) .
"\n";
271 $out .=
" <sha1/>\n";
276 Hooks::run(
'XmlDumpWriterWriteRevision', [ &$writer, &
$out, $row, $text ] );
278 $out .=
" </revision>\n";
292 $out =
" <logitem>\n";
293 $out .=
" " . Xml::element(
'id',
null, strval( $row->log_id ) ) .
"\n";
298 $out .=
" " . Xml::element(
'contributor', [
'deleted' =>
'deleted' ] ) .
"\n";
304 $out .=
" " . Xml::element(
'comment', [
'deleted' =>
'deleted' ] ) .
"\n";
307 if ( $comment !=
'' ) {
308 $out .=
" " . Xml::elementClean(
'comment',
null, strval( $comment ) ) .
"\n";
312 $out .=
" " . Xml::element(
'type',
null, strval( $row->log_type ) ) .
"\n";
313 $out .=
" " . Xml::element(
'action',
null, strval( $row->log_action ) ) .
"\n";
316 $out .=
" " . Xml::element(
'text', [
'deleted' =>
'deleted' ] ) .
"\n";
318 $title = Title::makeTitle( $row->log_namespace, $row->log_title );
319 $out .=
" " . Xml::elementClean(
'logtitle',
null, self::canonicalTitle( $title ) ) .
"\n";
320 $out .=
" " . Xml::elementClean(
'params',
321 [
'xml:space' =>
'preserve' ],
322 strval( $row->log_params ) ) .
"\n";
325 $out .=
" </logitem>\n";
337 return $indent . Xml::element(
'timestamp',
null, $ts ) .
"\n";
347 $out = $indent .
"<contributor>\n";
348 if ( $id || !IP::isValid( $text ) ) {
349 $out .= $indent .
" " . Xml::elementClean(
'username',
null, strval( $text ) ) .
"\n";
350 $out .= $indent .
" " . Xml::element(
'id',
null, strval( $id ) ) .
"\n";
352 $out .= $indent .
" " . Xml::elementClean(
'ip',
null, strval( $text ) ) .
"\n";
354 $out .= $indent .
"</contributor>\n";
365 if ( $row->page_namespace ==
NS_FILE ) {
367 if ( $img && $img->exists() ) {
369 foreach ( array_reverse( $img->getHistory() ) as $ver ) {
385 if ( $file->isOld() ) {
387 Xml::element(
'archivename',
null, $file->getArchiveName() ) .
"\n";
391 if ( $dumpContents ) {
392 $be = $file->getRepo()->getBackend();
393 # Dump file as base64
394 # Uses only XML-safe characters, so does not need escaping
395 # @todo Too bad this loads the contents into memory (script might swap)
396 $contents =
' <contents encoding="base64">' .
397 chunk_split( base64_encode(
398 $be->getFileContents( [
'src' => $file->getPath() ] ) ) ) .
404 $comment = Xml::element(
'comment', [
'deleted' =>
'deleted' ] );
406 $comment = Xml::elementClean(
'comment',
null, strval( $file->getDescription() ) );
408 return " <upload>\n" .
410 $this->
writeContributor( $file->getUser(
'id' ), $file->getUser(
'text' ) ) .
411 " " . $comment .
"\n" .
412 " " . Xml::element(
'filename',
null, $file->getName() ) .
"\n" .
414 " " . Xml::element(
'src',
null, $file->getCanonicalUrl() ) .
"\n" .
415 " " . Xml::element(
'size',
null, $file->getSize() ) .
"\n" .
416 " " . Xml::element(
'sha1base36',
null, $file->getSha1() ) .
"\n" .
417 " " . Xml::element(
'rel',
null, $file->getRel() ) .
"\n" .
433 if ( $title->isExternal() ) {
434 return $title->getPrefixedText();
438 $prefix =
$wgContLang->getFormattedNsText( $title->getNamespace() );
443 if ( $prefix !==
'' ) {
447 return $prefix . $title->getText();
$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 getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
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.
static schemaVersion()
Returns the export schema version.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
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 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 and the local content language as $wgContLang
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
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $wgDBname