MediaWiki
REL1_22
|
Special page to direct the user to a random page. More...
Public Member Functions | |
__construct ($name= 'RandomInCategory') | |
execute ($par) | |
Default execute method Checks user permissions, calls the function given in mFunction. | |
getRandomTitle () | |
Choose a random title. | |
setCategory (Title $cat) | |
Set which category to use. | |
Protected Member Functions | |
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) | |
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::execute | ( | $ | subPage | ) |
Default execute method Checks user permissions, calls the function given in mFunction.
This must be overridden by subclasses; it will be made abstract in a future version
$subPage | string|null |
Reimplemented from SpecialPage.
Definition at line 70 of file SpecialRandomInCategory.php.
References $form, $query, $title, array(), SpecialPage\getOutput(), getRandomTitle(), SpecialPage\getRequest(), SpecialPage\getTitle(), global, Html\hidden(), Html\input(), Title\makeTitleSafe(), SpecialPage\msg(), Title\newFromText(), Html\rawElement(), setCategory(), SpecialPage\setHeaders(), and wfEscapeWikiText().
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 288 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 243 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 183 of file SpecialRandomInCategory.php.
References $dbr, $dir, array(), getTimestampOffset(), and wfGetDB().
Referenced by selectRandomPageFromDB().
Choose a random title.
Definition at line 133 of file SpecialRandomInCategory.php.
References $title, Title\makeTitle(), selectRandomPageFromDB(), and wfRandom().
Referenced by execute().
SpecialRandomInCategory::getTimestampOffset | ( | $ | rand | ) | [protected] |
float | $rand | Random number between 0 and 1 |
Definition at line 219 of file SpecialRandomInCategory.php.
References getMinAndMaxForCat(), and list.
Referenced by getQueryInfo().
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 272 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 execute().
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.