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' => [
'INNER 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 ) {
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();
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
msg( $key)
Wrapper around wfMessage that sets the current context.
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.
static newFatal( $message)
Factory function for fatal errors.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
__construct( $name='RandomInCategory')
Special page which uses an HTMLForm to handle processing.
Allows to change the fields on the form that will be generated $name
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
onSubmit(array $data)
Process the form on POST submission.
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
setParameter( $par)
Maybe do something interesting with the subpage parameter.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
namespace and then decline to actually register it file or subcat img or subcat $title
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.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
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.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
string $par
The sub-page of the special page.
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 between 0 and 1, in a way not likely to give duplicate values for any real...
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__)
the array() calling protocol came about after MediaWiki 1.4rc1.