/**
 * 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());
}
Пример #2
0
 /**
  * Special:Randomizer redirects to a random URL in the set of URLs
  * we've defined.
  */
 public function execute()
 {
     global $wgOut, $wgLanguageCode, $wgRequest;
     $fname = 'Randomizer::execute';
     wfProfileIn($fname);
     if ($wgLanguageCode != 'en') {
         $rp = new RandomPage();
         $title = $rp->getRandomTitle();
     } else {
         $title = self::getRandomTitle();
     }
     if (!$title) {
         // try to recover from error
         $title = Title::newFromText(wfMsg('mainpage'));
     }
     $url = $title->getFullUrl();
     $wgOut->redirect($url);
     wfProfileOut($fname);
 }
Пример #3
0
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     if (!in_array('sysop', $wgUser->getGroups())) {
         $wgOut->setArticleRelated(false);
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     if ($target) {
         if (preg_match("@[^0-9]@", $target)) {
             $t = Title::newFromURL($target);
         } else {
             $r = Revision::newFromID($target);
             if ($wgRequest->getVal('popup')) {
                 $wgOut->setArticleBodyOnly(true);
                 $wgOut->addHTML("<style type='text/css'>\n\t\t\t\t\t\ttable.diff  {\n\t\t\t\t\t\t\tmargin-left: auto; margin-right: auto;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttable.diff td {\n\t\t\t\t\t\t\tmax-width: 400px;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>");
             }
             $wgOut->addHTML("Revid: {$r->mId}\n");
             $d = self::getDiffToMeasure($r);
             $de = new DifferenceEngine($r->mTitle, $d['revlo']->mId, $d['revhi']->mId);
             self::getPoints($r, $d, $de, true);
             if (!$d['revlo']) {
                 $de->mOldRev = null;
                 $de->mOldid = null;
             }
             $de->showDiffPage();
             return;
         }
     } else {
         $rp = new RandomPage();
         $t = $rp->getRandomTitle();
     }
     $wgOut->addHTML("<script type='text/javascript'>\nfunction getPoints(rev) {\n\t\$('#img-box').load('/Special:Points/' + rev + '?popup=true', function() {\n\t\t\t\$('#img-box').dialog({\n\t\t\t   width: 750,\n\t\t\t   modal: true,\n\t\t\t\ttitle: 'Points', \n\t\t\t   show: 'slide',\n\t\t\t\tcloseOnEscape: true,\n\t\t\t\tposition: 'center'\n\t\t\t});\n\t});\n\treturn false;\n}\n</script>\n");
     // get the groups of edits
     $group = self::getEditGroups($t);
     $wgOut->addHTML("Title: <a href='{$t->getFullURL()}?action=history' target='new'>{$t->getFullText()}</a><br/><br/>");
     $wgOut->addHTML("<table width='100%'><tr><td><u>User</u></td><td><u># Edits</u></td>");
     $wgOut->addHTML("<td><u>Date</u></td><td><u>Points</u></td></tr>");
     foreach ($group as $g) {
         $r = Revision::newFromID($g['max_revid']);
         $d = self::getDiffToMeasure($r);
         $de = new DifferenceEngine($r->mTitle, $d['revlo']->mId, $d['revhi']->mId);
         $points = self::getPoints($r, $d, $de);
         $date = date("Y-m-d", wfTimestamp(TS_UNIX, $g['max_revtimestamp']));
         $wgOut->addHTML("<tr><td>{$g['user_text']}</td><td>{$g['edits']}</td><td>{$date}</td>");
         $wgOut->addHTML("<td><a href='#' onclick='return getPoints({$g['max_revid']});'>{$points}</a></td></tr>");
     }
     $wgOut->addHTML("</table>");
 }
Пример #4
0
        } else {
            echo implode(",", $suggestions) . "\n";
        }
    } else {
        echo "no suggestions\n";
    }
}
function spellCheck($string)
{
    return preg_replace_callback('/\\b(\\w|\')+\\b/', 'spellCheckWord', $string);
}
$t = null;
if (isset($argv[0])) {
    $t = Title::newFromURL(urldecode($argv[0]));
} else {
    $rp = new RandomPage();
    $t = $rp->getRandomTitle();
}
echo "Doing {$t->getFullURL()}\n";
$r = Revision::newFromTitle($t);
if (!$r) {
    echo "can't get revision for this bad boy\n";
}
$text = $r->getText();
$newtext = WikihowArticleEditor::textify($text, array('remove_ext_links' => 1));
echo "text ...{$newtext}\n\n";
$pspell = pspell_new('en', 'american', '', 'utf-8', PSPELL_FAST);
spellCheck($newtext);
if ($bad == 0) {
    echo "No misspellings\n";
}