Go to the documentation of this file.
67 $this->
data = $_POST + $_GET;
85 public static function getPathInfo( $want =
'all' ) {
91 if ( !empty( $_SERVER[
'REQUEST_URI'] ) ) {
93 $url = $_SERVER[
'REQUEST_URI'];
94 if ( !preg_match(
'!^https?://!', $url ) ) {
95 $url =
'http://unused' . $url;
98 $a = parse_url( $url );
101 $path = isset( $a[
'path'] ) ? $a[
'path'] :
'';
104 if (
$path == $wgScript && $want !==
'all' ) {
113 $router->
add(
"$wgScript/$1" );
115 if ( isset( $_SERVER[
'SCRIPT_NAME'] )
116 && preg_match(
'/\.php5?/', $_SERVER[
'SCRIPT_NAME'] )
118 # Check for SCRIPT_NAME, we handle index.php explicitly
119 # But we do have some other .php files such as img_auth.php
120 # Don't let root article paths clober the parsing for them
121 $router->add( $_SERVER[
'SCRIPT_NAME'] .
"/$1" );
135 if ( $wgVariantArticlePath ) {
136 $router->add( $wgVariantArticlePath,
137 array(
'variant' =>
'$2' ),
146 } elseif ( $wgUsePathInfo ) {
147 if ( isset( $_SERVER[
'ORIG_PATH_INFO'] ) && $_SERVER[
'ORIG_PATH_INFO'] !=
'' ) {
151 $matches[
'title'] = substr( $_SERVER[
'ORIG_PATH_INFO'], 1 );
153 } elseif ( isset( $_SERVER[
'PATH_INFO'] ) && $_SERVER[
'PATH_INFO'] !=
'' ) {
155 $matches[
'title'] = substr( $_SERVER[
'PATH_INFO'], 1 );
170 $stdPort = $proto ===
'https' ? 443 : 80;
172 $varNames =
array(
'HTTP_HOST',
'SERVER_NAME',
'HOSTNAME',
'SERVER_ADDR' );
175 foreach ( $varNames
as $varName ) {
176 if ( !isset( $_SERVER[$varName] ) ) {
185 if ( $parts[1] ===
false ) {
186 if ( isset( $_SERVER[
'SERVER_PORT'] ) ) {
187 $port = $_SERVER[
'SERVER_PORT'];
206 if ( ( isset( $_SERVER[
'HTTPS'] ) && $_SERVER[
'HTTPS'] ==
'on' ) ||
207 ( isset( $_SERVER[
'HTTP_X_FORWARDED_PROTO'] ) &&
208 $_SERVER[
'HTTP_X_FORWARDED_PROTO'] ==
'https' ) ) {
220 if ( $this->protocol ===
null ) {
235 if ( defined(
'MW_API' ) ) {
241 $this->
data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
256 foreach ( (
array)$bases
as $keyValue => $base ) {
258 $base = str_replace(
'$1',
'', $base );
259 $baseLen = strlen( $base );
260 if ( substr(
$path, 0, $baseLen ) == $base ) {
261 $raw = substr(
$path, $baseLen );
287 foreach ( $arr
as $key => $val ) {
288 if ( is_array( $val ) ) {
289 $cleanKey = $topLevel ? stripslashes( $key ) : $key;
292 $cleanKey = stripslashes( $key );
293 $clean[$cleanKey] = stripslashes( $val );
307 $mustFixQuotes = function_exists(
'get_magic_quotes_gpc' )
308 && get_magic_quotes_gpc();
309 if ( $mustFixQuotes ) {
327 if ( is_array(
$data ) ) {
328 foreach (
$data as $key => $val ) {
347 # PHP is so nice to not touch input data, except sometimes:
348 # http://us2.php.net/variables.external#language.variables.external.dot-in-names
349 # Work around PHP *feature* to avoid *bugs* elsewhere.
351 if ( isset( $arr[
$name] ) ) {
354 if ( isset( $_GET[
$name] ) && !is_array(
$data ) ) {
355 # Check for alternate/legacy character encoding.
379 if ( is_array( $val ) ) {
382 if ( is_null( $val ) ) {
397 $ret = isset( $this->
data[$key] ) ? $this->
data[$key] :
null;
409 if ( !isset( $this->
data[$key] ) ) {
413 unset( $this->
data[$key] );
429 if ( is_null( $val ) ) {
447 $val = $this->
getArray( $name, $default );
448 if ( is_array( $val ) ) {
449 $val = array_map(
'intval', $val );
464 return intval( $this->
getVal( $name, $default ) );
476 $val = $this->
getVal( $name );
477 return is_numeric( $val )
493 return floatval( $this->
getVal( $name, $default ) );
506 return (
bool)$this->
getVal( $name, $default );
519 return $this->
getBool( $name, $default ) && strcasecmp( $this->
getVal( $name ),
'false' ) !== 0;
531 # Checkboxes and buttons are only present when clicked
532 # Presence connotes truth, absence false
533 return $this->
getVal( $name,
null ) !==
null;
550 $val = $this->
getVal( $name, $default );
551 return str_replace(
"\r\n",
"\n",
563 $names = func_get_args();
564 if ( count( $names ) == 0 ) {
565 $names = array_keys( $this->
data );
571 if ( !is_null(
$value ) ) {
605 return $_SERVER[
'QUERY_STRING'];
629 static $input =
false;
630 if ( $input ===
false ) {
631 $input = file_get_contents(
'php://input' );
642 return isset( $_SERVER[
'REQUEST_METHOD'] ) ? $_SERVER[
'REQUEST_METHOD'] :
'GET';
670 return isset( $_COOKIE[session_name()] );
681 public function getCookie( $key, $prefix =
null, $default =
null ) {
682 if ( $prefix ===
null ) {
686 return $this->
getGPCVal( $_COOKIE, $prefix . $key, $default );
697 if ( isset( $_SERVER[
'REQUEST_URI'] ) && strlen( $_SERVER[
'REQUEST_URI'] ) ) {
698 $base = $_SERVER[
'REQUEST_URI'];
699 } elseif ( isset( $_SERVER[
'HTTP_X_ORIGINAL_URL'] ) && strlen( $_SERVER[
'HTTP_X_ORIGINAL_URL'] ) ) {
701 $base = $_SERVER[
'HTTP_X_ORIGINAL_URL'];
702 } elseif ( isset( $_SERVER[
'SCRIPT_NAME'] ) ) {
703 $base = $_SERVER[
'SCRIPT_NAME'];
704 if ( isset( $_SERVER[
'QUERY_STRING'] ) && $_SERVER[
'QUERY_STRING'] !=
'' ) {
705 $base .=
'?' . $_SERVER[
'QUERY_STRING'];
709 throw new MWException(
"Web server doesn't provide either " .
710 "REQUEST_URI, HTTP_X_ORIGINAL_URL or SCRIPT_NAME. Report details " .
711 "of your web server configuration to http://bugzilla.wikimedia.org/" );
717 $hash = strpos( $base,
'#' );
718 if (
$hash !==
false ) {
719 $base = substr( $base, 0,
$hash );
722 if ( $base[0] ==
'/' ) {
724 return preg_replace(
'!^/+!',
'/', $base );
727 return preg_replace(
'!^[^:]+://[^/]+/+!',
'/', $base );
787 unset( $newquery[
'title'] );
788 $newquery = array_merge( $newquery, $array );
802 public function getLimitOffset( $deflimit = 50, $optionname =
'rclimit' ) {
809 if ( (
$limit == 0 ) && ( $optionname !=
'' ) ) {
819 $offset = $this->
getInt(
'offset', 0 );
835 return $file->getTempName();
846 return $file->getError();
862 return $file->getName();
883 if ( !is_object( $this->
response ) ) {
884 $class = ( $this instanceof
FauxRequest ) ?
'FauxResponse' :
'WebResponse';
894 if ( count( $this->
headers ) ) {
898 $apacheHeaders = function_exists(
'apache_request_headers' ) ? apache_request_headers() :
false;
899 if ( $apacheHeaders ) {
900 foreach ( $apacheHeaders
as $tempName => $tempValue ) {
901 $this->
headers[strtoupper( $tempName )] = $tempValue;
905 if ( substr(
$name, 0, 5 ) ===
'HTTP_' ) {
906 $name = str_replace(
'_',
'-', substr(
$name, 5 ) );
908 } elseif (
$name ===
'CONTENT_LENGTH' ) {
933 $name = strtoupper(
$name );
934 if ( isset( $this->
headers[$name] ) ) {
948 if ( !isset( $_SESSION[$key] ) ) {
951 return $_SESSION[$key];
961 $_SESSION[$key] =
$data;
975 global $wgScriptExtension;
976 $extWhitelist[] = ltrim( $wgScriptExtension,
'.' );
981 if ( $newUrl !==
false ) {
987 'Invalid file extension found in the path info or query string.' );
1000 header(
'Location: ' . $url );
1001 header(
'Content-Type: text/html' );
1002 $encUrl = htmlspecialchars( $url );
1011 We can
't serve non-HTML content from the URL you have requested, because
1012 Internet Explorer would interpret it as an incorrect and potentially dangerous
1014 <p>Instead, please use <a href="$encUrl">this URL</a>, which is the same as the URL you have requested, except that
1015 "&*" is appended. This prevents Internet Explorer from seeing a bogus file
1033 public function getAcceptLang() {
1034 // Modified version of code found at http://www.thefutureoftheweb.com/blog/use-accept-language-header
1035 $acceptLang = $this->getHeader( 'Accept-
Language' );
1036 if ( !$acceptLang ) {
1040 // Return the language codes in lower case
1041 $acceptLang = strtolower( $acceptLang );
1043 // Break up string into pieces (languages and q factors)
1045 preg_match_all( '/([a-z]{1,8}(-[a-z]{1,8})*|\*)\s*(;\s*q\s*=\s*(1(\.0{0,3})?|0(\.[0-9]{0,3})?)?)?/
',
1046 $acceptLang, $lang_parse );
1048 if ( !count( $lang_parse[1] ) ) {
1052 $langcodes = $lang_parse[1];
1053 $qvalues = $lang_parse[4];
1054 $indices = range( 0, count( $lang_parse[1] ) - 1 );
1056 // Set default q factor to 1
1057 foreach ( $indices as $index ) {
1058 if ( $qvalues[$index] === '' ) {
1059 $qvalues[$index] = 1;
1060 } elseif ( $qvalues[$index] == 0 ) {
1061 unset( $langcodes[$index], $qvalues[$index], $indices[$index] );
1065 // Sort list. First by $qvalues, then by order. Reorder $langcodes the same way
1066 array_multisort( $qvalues, SORT_DESC, SORT_NUMERIC, $indices, $langcodes );
1068 // Create a list like "en" => 0.8
1069 $langs = array_combine( $langcodes, $qvalues );
1082 protected function getRawIP() {
1083 if ( !isset( $_SERVER['REMOTE_ADDR
'] ) ) {
1087 if ( is_array( $_SERVER['REMOTE_ADDR
'] ) || strpos( $_SERVER['REMOTE_ADDR
'], ',
' ) !== false ) {
1088 throw new MWException( __METHOD__ . " : Could not determine the remote IP address due to multiple values." );
1090 $ipchain = $_SERVER['REMOTE_ADDR
'];
1093 return IP::canonicalize( $ipchain );
1105 public function getIP() {
1106 global $wgUsePrivateIPs;
1108 # Return cached result
1109 if ( $this->ip !== null ) {
1113 # collect the originating ips
1114 $ip = $this->getRawIP();
1117 $forwardedFor = $this->getHeader( 'X-Forwarded-For
' );
1118 if ( $forwardedFor !== false ) {
1119 $ipchain = array_map( 'trim
', explode( ',
', $forwardedFor ) );
1120 $ipchain = array_reverse( $ipchain );
1122 array_unshift( $ipchain, $ip );
1125 # Step through XFF list and find the last address in the list which is a
1126 # trusted server. Set $ip to the IP address given by that trusted server,
1127 # unless the address is not sensible (e.g. private). However, prefer private
1128 # IP addresses over proxy servers controlled by this site (more sensible).
1129 foreach ( $ipchain as $i => $curIP ) {
1130 // ignore 'unknown
' value from Squid when 'forwarded_for
off' and try next
1131 if ( $curIP === 'unknown
' ) {
1134 $curIP = IP::sanitizeIP( IP::canonicalize( $curIP ) );
1135 if ( wfIsTrustedProxy( $curIP ) && isset( $ipchain[$i + 1] ) ) {
1136 if ( wfIsConfiguredProxy( $curIP ) || // bug 48919; treat IP as sane
1137 IP::isPublic( $ipchain[$i + 1] ) ||
1140 $nextIP = IP::canonicalize( $ipchain[$i + 1] );
1141 if ( !$nextIP && wfIsConfiguredProxy( $ip ) ) {
1142 // We have not yet made it past CDN/proxy servers of this site,
1143 // so either they are misconfigured or there is some IP spoofing.
1144 throw new MWException( "Invalid IP given in XFF '$forwardedFor
'." );
1154 # Allow extensions to improve our guess
1155 wfRunHooks( 'GetIP
', array( &$ip ) );
1158 throw new MWException( "Unable to determine IP." );
1161 wfDebug( "IP: $ip\n" );
1171 public function setIP( $ip ) {
1179 class WebRequestUpload {
1181 protected $doesExist;
1182 protected $fileInfo;
1190 public function __construct( $request, $key ) {
1191 $this->request = $request;
1192 $this->doesExist = isset( $_FILES[$key] );
1193 if ( $this->doesExist ) {
1194 $this->fileInfo = $_FILES[$key];
1203 public function exists() {
1204 return $this->doesExist;
1212 public function getName() {
1213 if ( !$this->exists() ) {
1218 $name = $this->fileInfo['name'];
1220 # Safari sends filenames in HTML-encoded Unicode form D...
1221 # Horrid and evil! Let's
try to make
some kind
of sense
of it.
1224 wfDebug( __METHOD__ .
": {$this->fileInfo['name']} normalized to '$name'\n" );
1233 public function getSize() {
1234 if ( !$this->exists() ) {
1238 return $this->fileInfo[
'size'];
1246 public function getTempName() {
1247 if ( !$this->exists() ) {
1251 return $this->fileInfo[
'tmp_name'];
1260 public function getError() {
1261 if ( !$this->exists() ) {
1262 return 0; # UPLOAD_ERR_OK
1265 return $this->fileInfo[
'error'];
1274 public function isIniSizeOverflow() {
1275 if ( $this->getError() == UPLOAD_ERR_INI_SIZE ) {
1276 # PHP indicated that upload_max_filesize is exceeded
1280 $contentLength = $this->
request->getHeader(
'CONTENT_LENGTH' );
1282 # post_max_size is exceeded
1308 if ( is_array(
$data ) ) {
1311 throw new MWException(
"FauxRequest() got bogus data" );
1325 throw new MWException(
"{$method}() not implemented" );
1334 # Override; don't recode since we're using internal data
1335 return (
string)$this->
getVal( $name, $default );
1357 return $this->
wasPosted ?
'POST' :
'GET';
1367 public function getCookie( $key, $prefix =
null, $default =
null ) {
1406 if ( isset( $this->session[$key] ) ) {
1407 return $this->session[$key];
1417 $this->session[$key] =
$data;
1489 public function getCookie( $key, $prefix =
null, $default =
null ) {
1490 return $this->base->getCookie( $key, $prefix, $default );
1494 return $this->base->checkSessionCookie();
1498 return $this->base->getHeader(
$name );
1502 return $this->base->getAllHeaders();
1506 return $this->base->getSessionData( $key );
1510 $this->base->setSessionData( $key,
$data );
1514 return $this->base->getAcceptLang();
1517 public function getIP() {
1518 return $this->base->getIP();
1522 return $this->base->getProtocol();
checkSessionCookie()
Returns true if there is a session cookie set.
initHeaders()
Initialise the header list.
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
add( $path, $params=array(), $options=array())
Add a new path pattern to the path router.
WebRequest clone which takes values from a provided array.
getSessionData( $key)
Get data from $_SESSION.
& fix_magic_quotes(&$arr, $topLevel=true)
Recursively strips slashes from the given array; used for undoing the evil that is magic_quotes_gpc.
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getAllHeaders()
Get an array containing all request headers.
escapeAppendQuery( $query)
HTML-safe version of appendQuery().
getRawQueryString()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
static combineHostAndPort( $host, $port, $defaultPort=false)
Given a host name and a port, combine them into host/port string like you might find in a URL.
getRawPostString()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
setSessionData( $key, $data)
interpolateTitle()
Check for title, action, and/or variant data in the URL and interpolate it into the GET variables.
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C,...
checkMagicQuotes()
If magic_quotes_gpc option is on, run the global arrays through fix_magic_quotes to strip out the stu...
getIP()
Work out the IP address based on various globals For trusted proxies, use the XFF client IP (first of...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
if( $wgRCFilterByAge) if( $wgSkipSkin) if( $wgLocalInterwiki) if( $wgSharedPrefix===false) if(! $wgCookiePrefix) $wgCookiePrefix
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
getRawInput()
FauxRequests shouldn't depend on raw request data (but that could be implemented here)
getIntOrNull( $name)
Fetch an integer value from the input or return null if empty.
getRawPostString()
Return the contents of the POST with no decoding.
static detectProtocol()
Detect the protocol from $_SERVER.
getGPCVal( $arr, $name, $default)
Fetch a value from the given array or return $default if it's not set.
getAcceptLang()
Parse the Accept-Language header sent by the client into an array.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
checkSessionCookie()
Returns true if there is a session cookie set.
static areServerVarsBad( $vars, $extWhitelist=array())
Check a subset of $_SERVER (or the whole of $_SERVER if you like) to see if it indicates that the req...
checkSessionCookie()
Returns true if there is a session cookie set.
Show an error that looks like an HTTP server error.
getRawQueryString()
Return the contents of the Query with no decoding.
getFileTempname( $key)
Return the path to the temporary file where PHP has stored the upload.
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
getText( $name, $default='')
Fetch a text string from the given array or return $default if it's not set.
string $protocol
Cached URL protocol.
getProtocol()
Get the current URL protocol (http or https)
getMethod()
Get the HTTP method used for this request.
getFileName( $key)
Return the original filename of the uploaded file, as reported by the submitting user agent.
appendQuery( $query)
Take an arbitrary query and rewrite the present URL to include it.
wfRestoreWarnings()
Restore error level to previous value.
setVal( $key, $value)
Set an arbitrary value into our get/post data.
getRawInput()
Return the raw request body, with no processing.
getUpload( $key)
Return a WebRequestUpload object corresponding to the key.
getValues()
Extracts the given named values into an array.
static getPathInfo( $want='all')
Extract relevant query arguments from the http request uri's path to be merged with the normal php pr...
getProtocol()
Get the current URL protocol (http or https)
getFullRequestURL()
Return the request URI with the canonical service and hostname, path, and query string.
getArray( $name, $default=null)
Fetch an array from the input or return $default if it's not set.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
WebResponse $response
Lazy-init response object.
wfShorthandToInteger( $string='')
Converts shorthand byte notation to integer form.
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
getFloat( $name, $default=0)
Fetch a floating point value from the input or return $default if not set.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
getAllHeaders()
Get an array containing all request headers.
when a variable name is used in a it is silently declared as a new masking the global
getValueNames( $exclude=array())
Returns the names of all input values excluding those in $exclude.
Object to access the $_FILES array.
getText( $name, $default='')
appendQueryValue( $key, $value, $onlyquery=false)
processing should stop and the error should be shown to the user * false
normalizeUnicode( $data)
Recursively normalizes UTF-8 strings in the given array.
checkUrlExtension( $extWhitelist=array())
getCheck( $name)
Return true if the named value is set in the input, whatever that value is (even "0").
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
getProtocol()
Get the current URL protocol (http or https)
Allows to change the fields on the form that will be generated $name
response()
Return a handle to WebResponse style object, for setting cookies, headers and other stuff,...
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
checkUrlExtension( $extWhitelist=array())
Check if Internet Explorer will detect an incorrect cache extension in PATH_INFO or QUERY_STRING.
static splitHostAndPort( $both)
Given a host/port string, like one might find in the host part of a URL per RFC 2732,...
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for some
getLimitOffset( $deflimit=50, $optionname='rclimit')
Check for limit and offset parameters on the input, and return sensible defaults if not given.
getIntArray( $name, $default=null)
Fetch an array of integers, or return $default if it's not set.
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
getRequestURL()
Return the path and query string portion of the request URI.
Use of locking define a new flag for $wgAntiLockFlags which allows them to be turned off
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.
String $ip
Cached client IP address.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
if(PHP_SAPI !='cli') $file
getMethod()
Get the HTTP method used for this request.
getUploadError( $key)
Return the upload error or 0.
setSessionData( $key, $data)
Set session data.
=Architecture==Two class hierarchies are used to provide the functionality associated with the different content models:*Content interface(and AbstractContent base class) define functionality that acts on the concrete content of a page, and *ContentHandler base class provides functionality specific to a content model, but not acting on concrete content. The most important function of ContentHandler is to act as a factory for the appropriate implementation of Content. These Content objects are to be used by MediaWiki everywhere, instead of passing page content around as text. All manipulation and analysis of page content must be done via the appropriate methods of the Content object. For each content model, a subclass of ContentHandler has to be registered with $wgContentHandlers. The ContentHandler object for a given content model can be obtained using ContentHandler::getForModelID($id). Also Title, WikiPage and Revision now have getContentHandler() methods for convenience. ContentHandler objects are singletons that provide functionality specific to the content type, but not directly acting on the content of some page. ContentHandler::makeEmptyContent() and ContentHandler::unserializeContent() can be used to create a Content object of the appropriate type. However, it is recommended to instead use WikiPage::getContent() resp. Revision::getContent() to get a page 's content as a Content object. These two methods should be the ONLY way in which page content is accessed. Another important function of ContentHandler objects is to define custom action handlers for a content model, see ContentHandler::getActionOverrides(). This is similar to what WikiPage::getActionOverrides() was already doing.==Serialization==With the ContentHandler facility, page content no longer has to be text based. Objects implementing the Content interface are used to represent and handle the content internally. For storage and data exchange, each content model supports at least one serialization format via ContentHandler::serializeContent($content). The list of supported formats for a given content model can be accessed using ContentHandler::getSupportedFormats(). Content serialization formats are identified using MIME type like strings. The following formats are built in:*text/x-wiki - wikitext *text/javascript - for js pages *text/css - for css pages *text/plain - for future use, e.g. with plain text messages. *text/html - for future use, e.g. with plain html messages. *application/vnd.php.serialized - for future use with the api and for extensions *application/json - for future use with the api, and for use by extensions *application/xml - for future use with the api, and for use by extensions In PHP, use the corresponding CONTENT_FORMAT_XXX constant. Note that when using the API to access page content, especially action=edit, action=parse and action=query &prop=revisions, the model and format of the content should always be handled explicitly. Without that information, interpretation of the provided content is not reliable. The same applies to XML dumps generated via maintenance/dumpBackup.php or Special:Export. Also note that the API will provide encapsulated, serialized content - so if the API was called with format=json, and contentformat is also json(or rather, application/json), the page content is represented as a string containing an escaped json structure. Extensions that use JSON to serialize some types of page content may provide specialized API modules that allow access to that content in a more natural form.==Compatibility==The ContentHandler facility is introduced in a way that should allow all existing code to keep functioning at least for pages that contain wikitext or other text based content. However, a number of functions and hooks have been deprecated in favor of new versions that are aware of the page 's content model, and will now generate warnings when used. Most importantly, the following functions have been deprecated:*Revisions::getText() and Revisions::getRawText() is deprecated in favor Revisions::getContent() *WikiPage::getText() is deprecated in favor WikiPage::getContent() Also, the old Article::getContent()(which returns text) is superceded by Article::getContentObject(). However, both methods should be avoided since they do not provide clean access to the page 's actual content. For instance, they may return a system message for non-existing pages. Use WikiPage::getContent() instead. Code that relies on a textual representation of the page content should eventually be rewritten. However, ContentHandler::getContentText() provides a stop-gap that can be used to get text for a page. Its behavior is controlled by $wgContentHandlerTextFallback it
static fixUrlForIE6( $url, $extWhitelist=array())
Returns a variant of $url which will pass isUrlExtensionBad() but has the same GET parameters,...
doSecurityRedirect( $url)
Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in IE 6.
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it's not set.
getInt( $name, $default=0)
Fetch an integer value from the input or return $default if not set.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static detectServer()
Work out an appropriate URL prefix containing scheme and host, based on information detected from $_S...
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
static decodeCharReferences( $text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string.
getHeader( $name)
Get a request header, or false if it isn't set.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
wasPosted()
Returns true if the present request was reached by a POST operation, false otherwise (GET,...
unsetVal( $key)
Unset an arbitrary value from our get/post data.
getRequestURL()
Return the path and query string portion of the request URI.
static extractTitle( $path, $bases, $key=false)
URL rewriting function; tries to extract page title and, optionally, one other fixed parameter value ...
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...
getQueryValues()
Get the values passed in the query string.
getFuzzyBool( $name, $default=false)
Fetch a boolean value from the input or return $default if not set.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LoginAuthenticateAudit' this hook is for auditing only etc create2 Corresponds to logging log_action database field and which is displayed in the UI similar to $comment this hook should only be used to add variables that depend on the current page request
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add headers
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second redirect
Internationalisation code.
setSessionData( $key, $data)
getBool( $name, $default=false)
Fetch a boolean value from the input or return $default if not set.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
if(! $wgRequest->checkUrlExtension()) if(! $wgEnableAPI) $wgTitle
appendQueryArray( $array, $onlyquery=false)
Appends or replaces value of query variables.
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes two arrays as input, and returns a CGI-style string, e.g.
getCookie( $key, $prefix=null, $default=null)
Get a cookie from the $_COOKIE jar.