Go to the documentation of this file.
62 parent::__construct( $name );
70 $this->category = $cat;
71 $this->maxTimestamp =
null;
72 $this->minTimestamp =
null;
83 'label-message' =>
'randomincategory-category',
113 $categoryStr = $data[
'category'];
115 if ( $categoryStr ) {
119 if ( $cat && $cat->getNamespace() !==
NS_CATEGORY ) {
128 if ( !$this->category && $categoryStr ) {
129 $msg = $this->
msg(
'randomincategory-invalidcategory',
134 } elseif ( !$this->category ) {
140 if ( is_null(
$title ) ) {
141 $msg = $this->
msg(
'randomincategory-nopages',
142 $this->category->getText() );
161 $offset = mt_rand( 0, $this->maxOffset );
163 if ( mt_rand( 0, 1 ) ) {
205 $op = $up ?
'>=' :
'<=';
206 $dir = $up ?
'ASC' :
'DESC';
207 if ( !$this->category instanceof
Title ) {
211 'tables' => [
'categorylinks',
'page' ],
212 'fields' => [
'page_title',
'page_namespace' ],
213 'conds' => array_merge( [
214 'cl_to' => $this->category->getDBkey(),
217 'ORDER BY' =>
'cl_timestamp ' . $dir,
222 'page' => [
'JOIN',
'cl_from = page_id' ]
229 $qi[
'conds'][] =
'cl_timestamp ' . $op .
' ' .
230 $dbr->addQuotes(
$dbr->timestamp( $minClTime ) );
242 if ( $rand ===
false ) {
245 if ( !$this->minTimestamp || !$this->maxTimestamp ) {
247 list( $this->minTimestamp, $this->maxTimestamp ) = $this->
getMinAndMaxForCat( $this->category );
248 }
catch ( Exception $e ) {
256 return intval( $ts );
271 'low' =>
'MIN( cl_timestamp )',
272 'high' =>
'MAX( cl_timestamp )'
275 'cl_to' => $this->category->getDBkey(),
309 return $res->fetchObject();
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
requiresUnblock()
Whether this action cannot be executed by a blocked user.
getRandomTitle()
Choose a random title.
getOutput()
Get the OutputPage being used for this instance.
getTimestampOffset( $rand)
getMinAndMaxForCat(Title $category)
Get the lowest and highest timestamp for a category.
requiresWrite()
Whether this action requires the wiki not to be locked.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
__construct( $name='RandomInCategory')
Special page which uses an HTMLForm to handle processing.
onSubmit(array $data)
Process the form on POST submission.
setParameter( $par)
Maybe do something interesting with the subpage parameter.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
setCategory(Title $cat)
Set which category to use.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
string null $par
The sub-page of the special page.
getDisplayFormat()
Get display format for the form.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getFormFields()
Get an HTMLForm descriptor array.
Special page to direct the user to a random page.
Represents a title within MediaWiki.
wfRandom()
Get a random decimal value in the domain of [0, 1), in a way not likely to give duplicate values for ...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getQueryInfo( $rand, $offset, $up)
selectRandomPageFromDB( $rand, $offset, $up, $fname=__METHOD__)