+ /**
+ * Get an array of distant template insertions. Like getLinkInsertions()
+ * @private
+ */
+ function getDistantTemplateInsertions( $existing = array() ) {
+ $arr = array();
+ foreach( $this->mDistantTemplates as $prefix => $templatesToNS ) {
+ foreach( $templatesToNS as $ns => $dbkeys ) {
+ $diffs = isset( $existing[$prefix] ) && isset( $existing[$prefix][$ns] )
+ ? array_diff_key( $dbkeys, $existing[$prefix][$ns] )
+ : $dbkeys;
+ $interwiki = Interwiki::fetch( $prefix );
+ $wikiid = $interwiki->getWikiID();
+ foreach ( $diffs as $dbk => $id ) {
+ $arr['globaltemplatelinks'][] = array(
+ 'gtl_from_wiki' => wfWikiID(),
+ 'gtl_from_page' => $this->mId,
+ 'gtl_from_namespace' => $this->mTitle->getNamespace(),
+ 'gtl_from_title' => $this->mTitle->getText(),
+ 'gtl_to_wiki' => $wikiid,
+ 'gtl_to_namespace' => $ns,
+ 'gtl_to_title' => $dbk
+ );
+ $arr['globalinterwiki'][] = array(
+ 'giw_wikiid' => $wikiid,
+ 'giw_prefix' => $prefix,
+ );
+ $arr['globalnamespaces'][] = array(
+ 'gn_wiki' => wfWikiID( ),
+ 'gn_namespace' => $this->mTitle->getNamespace(),
+ 'gn_namespacetext' => $this->mTitle->getNsText(),
+ );
+ }
+ }
+ }
+ return $arr;
+ }
+