/** * @param string $interwiki * @param string $page * @param bool $history * @param bool $templates * @param int $pageLinkDepth * @return Status */ public static function newFromInterwiki($interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0) { if ($page == '') { return Status::newFatal('import-noarticle'); } $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (is_null($link) || !$link->isExternal()) { return Status::newFatal('importbadinterwiki'); } else { $params = array(); if ($history) { $params['history'] = 1; } if ($templates) { $params['templates'] = 1; } if ($pageLinkDepth) { $params['pagelink-depth'] = $pageLinkDepth; } $url = $link->getFullURL($params); # For interwikis, use POST to avoid redirects. return ImportStreamSource::newFromURL($url, "POST"); } }
function newFromInterwiki($interwiki, $page, $history = false) { $base = Title::getInterwikiLink($interwiki); $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (empty($base) || empty($link)) { return new WikiErrorMsg('importbadinterwiki'); } else { $params = $history ? 'history=1' : ''; $url = $link->getFullUrl($params); return ImportStreamSource::newFromURL($url); } }
function newFromInterwiki($interwiki, $page) { $base = Title::getInterwikiLink($interwiki); if (empty($base)) { return new WikiError('Bad interwiki link'); } else { $import = wfUrlencode("Special:Export/{$page}"); $url = str_replace("\$1", $import, $base); return ImportStreamSource::newFromURL($url); } }
/** * @param string $interwiki * @param string $page * @param bool $history * @param bool $templates * @param int $pageLinkDepth * @return Status */ public static function newFromInterwiki($interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0) { if ($page == '') { return Status::newFatal('import-noarticle'); } # Look up the first interwiki prefix, and let the foreign site handle # subsequent interwiki prefixes $firstIwPrefix = strtok($interwiki, ':'); $firstIw = Interwiki::fetch($firstIwPrefix); if (!$firstIw) { return Status::newFatal('importbadinterwiki'); } $additionalIwPrefixes = strtok(''); if ($additionalIwPrefixes) { $additionalIwPrefixes .= ':'; } # Have to do a DB-key replacement ourselves; otherwise spaces get # URL-encoded to +, which is wrong in this case. Similar to logic in # Title::getLocalURL $link = $firstIw->getURL(strtr("{$additionalIwPrefixes}Special:Export/{$page}", ' ', '_')); $params = array(); if ($history) { $params['history'] = 1; } if ($templates) { $params['templates'] = 1; } if ($pageLinkDepth) { $params['pagelink-depth'] = $pageLinkDepth; } $url = wfAppendQuery($link, $params); # For interwikis, use POST to avoid redirects. return ImportStreamSource::newFromURL($url, "POST"); }
public static function newFromInterwiki($interwiki, $page, $history = false) { if ($page == '') { return new WikiErrorMsg('import-noarticle'); } $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (is_null($link) || $link->getInterwiki() == '') { return new WikiErrorMsg('importbadinterwiki'); } else { $params = $history ? 'history=1' : ''; $url = $link->getFullUrl($params); # For interwikis, use POST to avoid redirects. return ImportStreamSource::newFromURL($url, "POST"); } }
public static function newFromInterwiki($interwiki, $page, $history = false) { $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (is_null($link) || $link->getInterwiki() == '') { return new WikiErrorMsg('importbadinterwiki'); } else { $params = $history ? 'history=1' : ''; $url = $link->getFullUrl($params); return ImportStreamSource::newFromURL($url); } }