コード例 #1
0
/**
 * Main execution point
 * @param $par Namespace to select the page from
 */
function wfSpecialRandompage($par = null)
{
    global $wgOut, $wgContLang;
    $rnd = new RandomPage();
    $rnd->setNamespace($wgContLang->getNsIndex($par));
    $rnd->setRedirect(false);
    $title = $rnd->getRandomTitle();
    if (is_null($title)) {
        $wgOut->addWikiText(wfMsg('randompage-nopages'));
        return;
    }
    $wgOut->reportTime();
    $wgOut->redirect($title->getFullUrl());
}