[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/api/ -> ApiResult.php (summary)

Created on Sep 4, 2006 Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"

File Size: 631 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ApiResult:: (26 methods):
  __construct()
  reset()
  setRawMode()
  getIsRawMode()
  getData()
  size()
  getSize()
  disableSizeCheck()
  enableSizeCheck()
  setElement()
  setContent()
  setSubelements()
  setIndexedTagName()
  setIndexedTagName_recursive()
  setIndexedTagName_internal()
  addValue()
  setParsedLimit()
  unsetValue()
  cleanUpUTF8()
  cleanUp_helper()
  convertStatusToArray()
  execute()
  beginContinuation()
  setContinueParam()
  setGeneratorContinueParam()
  endContinuation()


Class: ApiResult  - X-Ref

This class represents the result of the API operations.
It simply wraps a nested array() structure, adding some functions to simplify
array's modifications. As various modules execute, they add different pieces
of information to this result, structuring it as it will be given to the client.

Each subarray may either be a dictionary - key-value pairs with unique keys,
or lists, where the items are added using $data[] = $value notation.

There are three special key values that change how XML output is generated:
'_element'     This key sets the tag name for the rest of the elements in the current array.
It is only inserted if the formatter returned true for getNeedsRawData()
'_subelements' This key causes the specified elements to be returned as subelements rather than attributes.
It is only inserted if the formatter returned true for getNeedsRawData()
'*'            This key has special meaning only to the XML formatter, and is outputted as is
for all others. In XML it becomes the content of the current element.

__construct( ApiMain $main )   X-Ref

param: ApiMain $main

reset()   X-Ref
Clear the current result data.


setRawMode( $flag = true )   X-Ref
Call this function when special elements such as '_element'
are needed by the formatter, for example in XML printing.

param: bool $flag Set the raw mode flag to this state

getIsRawMode()   X-Ref
Returns true whether the formatter requested raw data.

return: bool

getData()   X-Ref
Get the result's internal data array (read-only)

return: array

size( $value )   X-Ref
Get the 'real' size of a result item. This means the strlen() of the item,
or the sum of the strlen()s of the elements if the item is an array.

param: mixed $value
return: int

getSize()   X-Ref
Get the size of the result, i.e. the amount of bytes in it

return: int

disableSizeCheck()   X-Ref
Disable size checking in addValue(). Don't use this unless you
REALLY know what you're doing. Values added while size checking
was disabled will not be counted (ever)


enableSizeCheck()   X-Ref
Re-enable size checking in addValue()


setElement( &$arr, $name, $value, $flags = 0 )   X-Ref
Add an output value to the array by name.
Verifies that value with the same name has not been added before.

param: array $arr To add $value to
param: string $name Index of $arr to add $value at
param: mixed $value
param: int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP.

setContent( &$arr, $value, $subElemName = null )   X-Ref
Adds a content element to an array.
Use this function instead of hardcoding the '*' element.

param: array $arr To add the content element to
param: mixed $value
param: string $subElemName When present, content element is created

setSubelements( &$arr, $names )   X-Ref
Causes the elements with the specified names to be output as
subelements rather than attributes.

param: array $arr
param: array|string $names The element name(s) to be output as subelements

setIndexedTagName( &$arr, $tag )   X-Ref
In case the array contains indexed values (in addition to named),
give all indexed values the given tag name. This function MUST be
called on every array that has numerical indexes.

param: array $arr
param: string $tag Tag name

setIndexedTagName_recursive( &$arr, $tag )   X-Ref
Calls setIndexedTagName() on each sub-array of $arr

param: array $arr
param: string $tag Tag name

setIndexedTagName_internal( $path, $tag )   X-Ref
Calls setIndexedTagName() on an array already in the result.
Don't specify a path to a value that's not in the result, or
you'll get nasty errors.

param: array $path Path to the array, like addValue()'s $path
param: string $tag

addValue( $path, $name, $value, $flags = 0 )   X-Ref
Add value to the output data at the given path.
Path can be an indexed array, each element specifying the branch at which to add the new
value. Setting $path to array('a','b','c') is equivalent to data['a']['b']['c'] = $value.
If $path is null, the value will be inserted at the data root.
If $name is empty, the $value is added as a next list element data[] = $value.

param: array|string|null $path
param: string $name
param: mixed $value
param: int $flags Zero or more OR-ed flags like OVERRIDE | ADD_ON_TOP.
return: bool True if $value fits in the result, false if not

setParsedLimit( $moduleName, $limit )   X-Ref
Add a parsed limit=max to the result.

param: string $moduleName
param: int $limit

unsetValue( $path, $name )   X-Ref
Unset a value previously added to the result set.
Fails silently if the value isn't found.
For parameters, see addValue()

param: array|null $path
param: string $name

cleanUpUTF8()   X-Ref
Ensure all values in this result are valid UTF-8.


cleanUp_helper( &$s )   X-Ref
Callback function for cleanUpUTF8()

param: string $s

convertStatusToArray( $status, $errorType = 'error' )   X-Ref
Converts a Status object to an array suitable for addValue

param: Status $status
param: string $errorType
return: array

execute()   X-Ref
No description

beginContinuation($continue, array $allModules = array()   X-Ref
Parse a 'continue' parameter and return status information.

This must be balanced by a call to endContinuation().

param: string|null $continue The "continue" parameter, if any
param: ApiBase[] $allModules Contains ApiBase instances that will be executed
param: array $generatedModules Names of modules that depend on the generator
return: array Two elements: a boolean indicating if the generator is done,

setContinueParam( ApiBase $module, $paramName, $paramValue )   X-Ref
Set the continuation parameter for a module

param: ApiBase $module
param: string $paramName
param: string|array $paramValue

setGeneratorContinueParam( ApiBase $module, $paramName, $paramValue )   X-Ref
Set the continuation parameter for the generator module

param: ApiBase $module
param: string $paramName
param: string|array $paramValue

endContinuation( $style = 'standard' )   X-Ref
Close continuation, writing the data into the result

param: string $style 'standard' for the new style since 1.21, 'raw' for



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1