/** * 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()); }
function __construct( $name = 'RandomExcludeBlank' ){ global $wgContentNamespaces; $this->namespaces = $wgContentNamespaces; parent::__construct( $name ); SpecialPageFactory::setGroup( 'RandomExcludeBlank','redirects' ); }
protected function getQueryInfo($randstr) { $query = parent::getQueryInfo($randstr); $query['tables'][] = 'categorylinks'; unset($query['conds']['page_namespace']); array_merge($query['conds'], array('page_namespace != ' . NS_CATEGORY)); $query['conds']['cl_to'] = $this->category; // FIXME: FORCE INDEX gets added in wrong place, goes after table join, should be before // bug 27081 unset($query['options']['USE INDEX']); $query['options']['USE INDEX'] = array('page' => 'page_random'); $query['join_conds'] = array('categorylinks' => array('JOIN', array('page_id=cl_from'))); return $query; }
public function __construct() { global $wgUser, $wgRequest, $wmincPref, $wmincProjectSite; $target = $wgRequest->getVal( 'testwiki' ); $target = IncubatorTest::analyzePrefix( $target ); $project = isset( $target['project'] ) ? $target['project'] : ''; $lang = isset( $target['lang'] ) ? $target['lang'] : ''; if( IncubatorTest::isContentProject() || ( $project && $lang ) ) { $dbr = wfGetDB( DB_SLAVE ); $this->extra[] = 'page_title' . $dbr->buildLike( IncubatorTest::displayPrefix( $project, $lang ) . '/', $dbr->anyString() ); } elseif( $wgUser->getOption($wmincPref . '-project') == $wmincProjectSite['short'] ) { # project or help namespace $this->extra['page_namespace'] = array( 4, 12 ); } parent::__construct( 'RandomByTest' ); }
function __construct() { parent::__construct('Randomredirect'); $this->isRedir = true; }
function __construct() { parent::__construct('Randomredirect'); }
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>"); }
public function __construct() { parent::__construct( 'Randomrootpage' ); $this->extra[] = "page_title NOT LIKE '%/%'"; }
/** * 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); }
public function __construct() { parent::__construct('Randomrootpage'); $dbr = wfGetDB(DB_REPLICA); $this->extra[] = 'page_title NOT ' . $dbr->buildLike($dbr->anyString(), '/', $dbr->anyString()); }
} 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"; }