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/',
63 foreach ( $sites as $site ) {
68 fflush( $this->sink );
78 $siteAttr = [
'type' => $site->
getType() ];
96 fwrite( $this->sink,
"\t\t" .
Xml::element(
'forward',
null,
'' ) .
"\n" );
104 foreach ( $ids as $id ) {
105 fwrite( $this->sink,
"\t\t" .
Xml::element(
'localid', [
'type' =>
$type ], $id ) .
"\n" );
exportSites( $sites)
Writes a <site> tag for each Site object in $sites, and encloses the entire list between <sites> tags...
exportSite(Site $site)
Writes a <site> tag representing the given Site object.
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).
static closeElement( $element)
Shortcut to close an XML element.
static openElement( $element, $attribs=null)
This opens an XML element.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.