42 if ( !is_resource( $sink ) || get_resource_type( $sink ) !==
'stream' ) {
43 throw new InvalidArgumentException(
'$sink must be a file handle' );
58 'xmlns' =>
'http://www.mediawiki.org/xml/sitelist-1.0/',
61 fwrite( $this->sink, Xml::openElement(
'sites', $attributes ) .
"\n" );
63 foreach ( $sites as $site ) {
64 $this->exportSite( $site );
67 fwrite( $this->sink, Xml::closeElement(
'sites' ) .
"\n" );
68 fflush( $this->sink );
76 private function exportSite(
Site $site ) {
78 $siteAttr = [
'type' => $site->
getType() ];
83 fwrite( $this->sink,
"\t" . Xml::openElement(
'site', $siteAttr ) .
"\n" );
85 fwrite( $this->sink,
"\t\t" . Xml::element(
'globalid',
null, $site->
getGlobalId() ) .
"\n" );
88 fwrite( $this->sink,
"\t\t" . Xml::element(
'group',
null, $site->
getGroup() ) .
"\n" );
92 fwrite( $this->sink,
"\t\t" . Xml::element(
'source',
null, $site->
getSource() ) .
"\n" );
96 fwrite( $this->sink,
"\t\t" . Xml::element(
'forward',
null,
'' ) .
"\n" );
100 fwrite( $this->sink,
"\t\t" . Xml::element(
'path', [
'type' =>
$type ],
$path ) .
"\n" );
104 foreach ( $ids as $id ) {
105 fwrite( $this->sink,
"\t\t" . Xml::element(
'localid', [
'type' =>
$type ], $id ) .
"\n" );
112 fwrite( $this->sink,
"\t" . Xml::closeElement(
'site' ) .
"\n" );
exportSites( $sites)
Writes a <site> tag for each Site object in $sites, and encloses the entire list between <sites> tags...
shouldForward()
Gets if site.tld/path/key:pageTitle should forward users to the page on the actual site,...
getSource()
Returns the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').
getType()
Returns the type of the site (ie mediawiki).
getGlobalId()
Returns the global site identifier (ie enwiktionary).
getAllPaths()
Returns the paths as associative array.
getLocalIds()
Returns all local ids.
getGroup()
Gets the group of the site (ie wikipedia).