MediaWiki
REL1_24
|
Special page to direct the user to a random page. More...
Public Member Functions | |
__construct ($name= 'RandomInCategory') | |
getRandomTitle () | |
Choose a random title. | |
onSubmit (array $data) | |
Process the form on POST submission. | |
requiresUnblock () | |
Whether this action cannot be executed by a blocked user. | |
requiresWrite () | |
Whether this action requires the wiki not to be locked. | |
setCategory (Title $cat) | |
Set which category to use. | |
Protected Member Functions | |
getFormFields () | |
Get an HTMLForm descriptor array. | |
getGroupName () | |
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-group-*' for valid names This method defaults to group 'other'. | |
getMinAndMaxForCat (Title $category) | |
Get the lowest and highest timestamp for a category. | |
getQueryInfo ($rand, $offset, $up) | |
getTimestampOffset ($rand) | |
setParameter ($par) | |
Maybe do something interesting with the subpage parameter. | |
Protected Attributes | |
$category = false | |
$extra = array() | |
$maxOffset = 30 | |
Private Member Functions | |
selectRandomPageFromDB ($rand, $offset, $up, $fname=__METHOD__) | |
Private Attributes | |
$maxTimestamp = null | |
$minTimestamp = null |
Special page to direct the user to a random page.
A more unbiased method could be achieved by adding a cl_random field to the categorylinks table.
The method used here is as follows: * Find the smallest and largest timestamp in the category * Pick a random timestamp in between * Pick an offset between 0 and 30 * Get the offset'ed page that is newer than the timestamp selected The offset is meant to counter the fact the timestamps aren't usually uniformly distributed, so if things are very non-uniform at least we won't have the same page selected 99% of the time.
Definition at line 49 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::__construct | ( | $ | name = 'RandomInCategory' | ) |
Definition at line 56 of file SpecialRandomInCategory.php.
References $name.
SpecialRandomInCategory::getFormFields | ( | ) | [protected] |
Get an HTMLForm descriptor array.
Reimplemented from FormSpecialPage.
Definition at line 70 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::getGroupName | ( | ) | [protected] |
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-group-*' for valid names This method defaults to group 'other'.
Reimplemented from SpecialPage.
Definition at line 297 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::getMinAndMaxForCat | ( | Title $ | category | ) | [protected] |
Get the lowest and highest timestamp for a category.
Title | $category |
MWException | If category has no entries. |
Definition at line 251 of file SpecialRandomInCategory.php.
References $dbr, $res, array(), wfGetDB(), and wfTimestamp().
Referenced by getTimestampOffset().
SpecialRandomInCategory::getQueryInfo | ( | $ | rand, |
$ | offset, | ||
$ | up | ||
) | [protected] |
float | $rand | Random number between 0 and 1 |
int | $offset | Extra offset to fudge randomness |
bool | $up | True to get the result above the random number, false for below |
Definition at line 189 of file SpecialRandomInCategory.php.
References $dbr, $dir, array(), getTimestampOffset(), and wfGetDB().
Referenced by selectRandomPageFromDB().
Choose a random title.
Definition at line 139 of file SpecialRandomInCategory.php.
References $title, Title\makeTitle(), selectRandomPageFromDB(), and wfRandom().
Referenced by onSubmit().
SpecialRandomInCategory::getTimestampOffset | ( | $ | rand | ) | [protected] |
float | $rand | Random number between 0 and 1 |
Definition at line 226 of file SpecialRandomInCategory.php.
References $e, getMinAndMaxForCat(), and list.
Referenced by getQueryInfo().
SpecialRandomInCategory::onSubmit | ( | array $ | data | ) |
Process the form on POST submission.
array | $data | |
HTMLForm | $form |
Reimplemented from FormSpecialPage.
Definition at line 95 of file SpecialRandomInCategory.php.
References $title, SpecialPage\getOutput(), getRandomTitle(), Title\makeTitleSafe(), SpecialPage\msg(), Status\newFatal(), Title\newFromText(), setCategory(), and wfEscapeWikiText().
Referenced by setParameter().
Whether this action cannot be executed by a blocked user.
Reimplemented from FormSpecialPage.
Definition at line 86 of file SpecialRandomInCategory.php.
Whether this action requires the wiki not to be locked.
Reimplemented from FormSpecialPage.
Definition at line 82 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::selectRandomPageFromDB | ( | $ | rand, |
$ | offset, | ||
$ | up, | ||
$ | fname = __METHOD__ |
||
) | [private] |
float | $rand | A random number that is converted to a random timestamp |
int | $offset | A small offset to make the result seem more "random" |
bool | $up | Get the result above the random value |
string | $fname | The name of the calling method |
Definition at line 281 of file SpecialRandomInCategory.php.
References $dbr, $fname, $query, $res, getQueryInfo(), and wfGetDB().
Referenced by getRandomTitle().
Set which category to use.
Title | $cat |
Definition at line 64 of file SpecialRandomInCategory.php.
Referenced by onSubmit().
SpecialRandomInCategory::setParameter | ( | $ | par | ) | [protected] |
Maybe do something interesting with the subpage parameter.
string | $par |
Reimplemented from FormSpecialPage.
Definition at line 90 of file SpecialRandomInCategory.php.
References FormSpecialPage\$par, array(), and onSubmit().
SpecialRandomInCategory::$category = false [protected] |
Definition at line 51 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::$extra = array() [protected] |
Definition at line 50 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::$maxOffset = 30 [protected] |
Definition at line 52 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::$maxTimestamp = null [private] |
Definition at line 53 of file SpecialRandomInCategory.php.
SpecialRandomInCategory::$minTimestamp = null [private] |
Definition at line 54 of file SpecialRandomInCategory.php.