41 if ( !is_resource(
$sink ) || get_resource_type(
$sink ) !==
'stream' ) {
42 throw new InvalidArgumentException(
'$sink must be a file handle' );
57 'xmlns' =>
'http://www.mediawiki.org/xml/sitelist-1.0/',
60 fwrite( $this->sink, Xml::openElement(
'sites', $attributes ) .
"\n" );
62 foreach ( $sites as $site ) {
66 fwrite( $this->sink, Xml::closeElement(
'sites' ) .
"\n" );
67 fflush( $this->sink );
77 $siteAttr = [
'type' => $site->
getType() ];
82 fwrite( $this->sink,
"\t" . Xml::openElement(
'site', $siteAttr ) .
"\n" );
84 fwrite( $this->sink,
"\t\t" . Xml::element(
'globalid',
null, $site->
getGlobalId() ) .
"\n" );
87 fwrite( $this->sink,
"\t\t" . Xml::element(
'group',
null, $site->
getGroup() ) .
"\n" );
91 fwrite( $this->sink,
"\t\t" . Xml::element(
'source',
null, $site->
getSource() ) .
"\n" );
95 fwrite( $this->sink,
"\t\t" . Xml::element(
'forward',
null,
'' ) .
"\n" );
99 fwrite( $this->sink,
"\t\t" . Xml::element(
'path', [
'type' =>
$type ],
$path ) .
"\n" );
103 foreach ( $ids as $id ) {
104 fwrite( $this->sink,
"\t\t" . Xml::element(
'localid', [
'type' =>
$type ], $id ) .
"\n" );
111 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...
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).