MediaWiki REL1_28
AjaxResponse Class Reference

Handle responses for Ajax requests (send headers, print content, that sort of thing) More...

Collaboration diagram for AjaxResponse:

Public Member Functions

 __construct ( $text=null, Config $config=null)
 
 addText ( $text)
 Add content to the response.
 
 checkLastModified ( $timestamp)
 checkLastModified tells the client to use the client-cached response if possible.
 
 disable ()
 Disable output.
 
 loadFromMemcached ( $mckey, $touched)
 
 printText ()
 Output text.
 
 sendHeaders ()
 Construct the header and output it.
 
 setCacheDuration ( $duration)
 Set the number of seconds to get the response cached by a proxy.
 
 setContentType ( $type)
 Set the HTTP header Content-Type.
 
 setResponseCode ( $code)
 Set the HTTP response code.
 
 setVary ( $vary)
 Set the HTTP Vary header.
 
 storeInMemcached ( $mckey, $expiry=86400)
 

Private Attributes

 $mCacheDuration
 Number of seconds to get the response cached by a proxy.
 
Config $mConfig
 
 $mContentType
 HTTP header Content-Type.
 
 $mDisabled
 Disables output.
 
 $mLastModified
 Date for the HTTP header Last-modified.
 
 $mResponseCode
 HTTP response code.
 
 $mText
 Content of our HTTP response.
 
 $mVary
 HTTP Vary header.
 

Detailed Description

Handle responses for Ajax requests (send headers, print content, that sort of thing)

Definition at line 30 of file AjaxResponse.php.

Constructor & Destructor Documentation

◆ __construct()

AjaxResponse::__construct (   $text = null,
Config  $config = null 
)
Parameters
string | null$text
Config | null$config

Definition at line 82 of file AjaxResponse.php.

References addText().

Member Function Documentation

◆ addText()

AjaxResponse::addText (   $text)

Add content to the response.

Parameters
string$text

Definition at line 141 of file AjaxResponse.php.

Referenced by __construct().

◆ checkLastModified()

AjaxResponse::checkLastModified (   $timestamp)

checkLastModified tells the client to use the client-cached response if possible.

If successful, the AjaxResponse is disabled so that any future call to AjaxResponse::printText() have no effect.

Parameters
string$timestamp
Returns
bool Returns true if the response code was set to 304 Not Modified.

Definition at line 221 of file AjaxResponse.php.

References $fname, $timestamp, $wgCacheEpoch, $wgCachePages, $wgUser, disable(), global, setResponseCode(), TS_MW, TS_RFC2822, wfDebug(), and wfTimestamp().

◆ disable()

AjaxResponse::disable ( )

Disable output.

Definition at line 133 of file AjaxResponse.php.

Referenced by checkLastModified().

◆ loadFromMemcached()

AjaxResponse::loadFromMemcached (   $mckey,
  $touched 
)
Parameters
string$mckey
int$touched
Returns
bool

Definition at line 278 of file AjaxResponse.php.

References wfDebug().

◆ printText()

AjaxResponse::printText ( )

Output text.

Definition at line 150 of file AjaxResponse.php.

References $mText, and print.

◆ sendHeaders()

AjaxResponse::sendHeaders ( )

Construct the header and output it.

Definition at line 159 of file AjaxResponse.php.

References HttpStatus\header().

◆ setCacheDuration()

AjaxResponse::setCacheDuration (   $duration)

Set the number of seconds to get the response cached by a proxy.

Parameters
int$duration

Definition at line 102 of file AjaxResponse.php.

◆ setContentType()

AjaxResponse::setContentType (   $type)

Set the HTTP header Content-Type.

Parameters
string$type

Definition at line 126 of file AjaxResponse.php.

References $type.

◆ setResponseCode()

AjaxResponse::setResponseCode (   $code)

Set the HTTP response code.

Parameters
string$code

Definition at line 118 of file AjaxResponse.php.

References $code.

Referenced by checkLastModified().

◆ setVary()

AjaxResponse::setVary (   $vary)

Set the HTTP Vary header.

Parameters
string$vary

Definition at line 110 of file AjaxResponse.php.

◆ storeInMemcached()

AjaxResponse::storeInMemcached (   $mckey,
  $expiry = 86400 
)
Parameters
string$mckey
int$expiry
Returns
bool

Definition at line 304 of file AjaxResponse.php.

References wfTimestampNow().

Member Data Documentation

◆ $mCacheDuration

int AjaxResponse::$mCacheDuration
private

Number of seconds to get the response cached by a proxy.

Definition at line 35 of file AjaxResponse.php.

◆ $mConfig

Config AjaxResponse::$mConfig
private

Definition at line 76 of file AjaxResponse.php.

◆ $mContentType

string AjaxResponse::$mContentType
private

HTTP header Content-Type.

Definition at line 41 of file AjaxResponse.php.

◆ $mDisabled

bool AjaxResponse::$mDisabled
private

Disables output.

Can be set by calling $AjaxResponse->disable()

Definition at line 47 of file AjaxResponse.php.

◆ $mLastModified

string bool AjaxResponse::$mLastModified
private

Date for the HTTP header Last-modified.

Definition at line 53 of file AjaxResponse.php.

◆ $mResponseCode

string AjaxResponse::$mResponseCode
private

HTTP response code.

Definition at line 59 of file AjaxResponse.php.

◆ $mText

string AjaxResponse::$mText
private

Content of our HTTP response.

Definition at line 71 of file AjaxResponse.php.

Referenced by printText().

◆ $mVary

string AjaxResponse::$mVary
private

HTTP Vary header.

Definition at line 65 of file AjaxResponse.php.


The documentation for this class was generated from the following file: