Class SloodleLSLResponse

Description

A helper class to validate and structure data for output according to the Sloodle communications specification.

  • usedby: SloodleLSLRequest - Outputs error messages in appropriate format if an error occurs.

Located in /lib/sl_iolib.php (line 41)


	
			
Variable Summary
Method Summary
 void SloodleLSLResponse ([int $status_code = NULL], [string $status_descriptor = NULL], [mixed $data = NULL])
 void add_data_line (mixed $par)
 void add_side_effect (integer $par)
 void add_side_effects (mixed $par)
 void clear_data ()
 void quick_output (int $status_code, [string $status_descriptor = NULL], [mixed $data = NULL], [bool $static = TRUE])
 void render_to_string (string &$str)
 void set_data (mixed $par)
 void set_page_number (mixed $par)
 void set_page_total (mixed $par)
 void set_request_descriptor (mixed $par)
 void set_request_timestamp (mixed $par)
 void set_response_timestamp (mixed $par)
 void set_side_effects (mixed $par)
 void set_status_code (integer $par)
 void set_status_descriptor (mixed $par)
 void set_tracking_code (mixed $par)
 void set_user_key (mixed $par)
 void _internal_validation_error (string $msg)
Variables
mixed $data = NULL (line 156)

Data to render following the status line in the response.

This value can either be a scalar (single value, e.g. int, string, float), or an array. If it is a single scalar, it is rendered as a single line. If it is an array, then each element becomes one line. If an element is a scalar, then it is directly output onto the line. If an element is an array, then each child element is output as a separate field on the same line. Optional. Ignored if NULL.

integer $page_number = NULL (line 138)

Current page number.

If a response requires multiple pages, this value indicates which page is being returned in this response. Optional, unless $page_total is specified. Ignored if NULL. Not yet supported.

  • access: private
integer $page_total = NULL (line 129)

Total number of pages.

If a response requires multiple pages, this value indicates how many pages there are. Optional, unless $page_number is specified. Ignored if NULL. Not yet supported.

  • access: private
string $request_descriptor = NULL (line 81)

Request descriptor.

A brief string passed into the request by an LSL script (via HTTP parameter 'sloodlerequestdesc'), which is returned so that it can correctly distinguish one request from anotehr. Optional. Ignored if NULL.

  • access: private
integer $request_timestamp = NULL (line 90)

Timestamp when the request was originally made by the LSL script.

This is not filled-in automatically. You must do it manually if you need it. Optional. Ignored if NULL.

  • access: private
integer $response_timestamp = NULL (line 99)

Timestamp when the response was generated on the Moodle site.

This is not filled-in automatically. You must do it manually if you need it. Optional. Ignored if NULL.

  • access: private
mixed $side_effects = NULL (line 71)

Integer side effect(s) codes.

Status code(s) of side effect(s) incurred during the operation. Can be a single integer, or an array of integers. Optional. Ignored if NULL.

  • access: private
int $status_code = NULL (line 52)

Integer status code of the response.

Refer to the status codes page on the Sloodle wiki for a reference. Required.

  • access: private
string $status_descriptor = NULL (line 61)

Status descriptor string.

Should contain a generalised description/category of the status code. Optional but recommended. Ignored if NULL.

  • access: private
mixed $tracking_code = NULL (line 120)

Tracking code of the request.

Use of this value is undefined. Please do not use it. Optional. Ignored if NULL.

  • access: private
string $user_key = NULL (line 111)

SL agent key.

Should be a string specifying the UUID key of the agent in-world being handled. (Typically of the user who initiated the request). Optional. Ignored if NULL.

  • access: private
Methods
Constructor SloodleLSLResponse (line 463)

Constructor

  • can intialise some variables

  • access: public
void SloodleLSLResponse ([int $status_code = NULL], [string $status_descriptor = NULL], [mixed $data = NULL])
  • int $status_code: The initial status code for the response (optional - ignore if NULL)
  • string $status_descriptor: The initial status descriptor for the response (optional - ignore if NULL)
  • mixed $data: The initial data for the response, which can be a scalar, or a mixed array of scalars/scalar-arrays (see SloodleLSLResponse::$data) (optional - ignore if NULL)
add_data_line (line 421)

Adds one line of data to the $data member

void add_data_line (mixed $par)
  • mixed $par: A scalar, or an array of scalars
add_side_effect (line 269)

Adds a single side effect code to member $status_code

void add_side_effect (integer $par)
  • integer $par: An integer side-effect code.
add_side_effects (line 228)

Adds one or more integer side effect codes to member $status_code.

void add_side_effects (mixed $par)
  • mixed $par: An integer side effect code, or an array of them.
clear_data (line 447)

Clears all data from member $data

void clear_data ()
quick_output (line 640)

Quick output of data to avoid several accessor calls if the response is very basic.

Can be called statically to allow simple output of basic data. The status code is required, but the other parameters are optional If an error occurs, the LSL-friendly error message is output to the HTTP response, and the script terminated

  • access: public
void quick_output (int $status_code, [string $status_descriptor = NULL], [mixed $data = NULL], [bool $static = TRUE])
  • int $status_code: The status code for the response (required)
  • string $status_descriptor: The status descriptor for the response (optional - ignored if NULL)
  • mixed $data: The data for the response, which can be a scalar, or a mixed array of scalars/scalar-arrays (see SloodleLSLResponse::$data) (optional - ignored if NULL)
  • bool $static: If TRUE (default), then this function will assume it is being call statically, and construct its own response object. Otherwise, it will all the existing member data to render the output.
render_to_output (line 612)

Outputs the response directly to the HTTP response.

void render_to_output ()
render_to_string (line 480)

Renders the response to a string.

Prior to rendering, this function will perform final validation on all the data. If anything fails, then the script will terminate with an LSL-friendly error message.

void render_to_string (string &$str)
  • string &$str: Reference to a string object which the response should be rendered to.
set_data (line 382)

Accessor function to set member value $data. Note: it is recommended that you use the add_data_line() and clear_data() functions instead of this.

void set_data (mixed $par)
  • mixed $par: Any scalar value, or a mixed array of scalars or scalar arrays, or NULL to clear it
set_page_number (line 367)

Accessor function to set member value $page_number

void set_page_number (mixed $par)
  • mixed $par: A positive page number, or NULL to clear it
set_page_total (line 352)

Accessor function to set member value $page_total

void set_page_total (mixed $par)
  • mixed $par: A positive page total count, or NULL to clear it
set_request_descriptor (line 282)

Accessor function to set member value $request_descriptor

void set_request_descriptor (mixed $par)
  • mixed $par: A string request descriptor, or NULL to clear it
set_request_timestamp (line 297)

Accessor function to set member value $request_timestamp

void set_request_timestamp (mixed $par)
  • mixed $par: An integer timestamp, or NULL to clear it
set_response_timestamp (line 312)

Accessor function to set member value $response_timestamp

void set_response_timestamp (mixed $par)
  • mixed $par: An integer timestamp, or NULL to clear it
set_side_effects (line 198)

Accessor function to set member value $side_effects. Note: it is recommended that you use add_side_effect() or add_side_effects() instead.

void set_side_effects (mixed $par)
  • mixed $par: An integer side effect code, an array of integer side effect codes, or null to clear it
set_status_code (line 168)

Accessor function to set member value $status_code

void set_status_code (integer $par)
  • integer $par: A non-zero status code
set_status_descriptor (line 183)

Accessor function to set member value $status_descriptor

void set_status_descriptor (mixed $par)
  • mixed $par: A status descriptor string, or NULL to clear it
set_tracking_code (line 342)

Accessor function to set member value $tracking_code

void set_tracking_code (mixed $par)
  • mixed $par: Any scalar value
set_user_key (line 327)

Accessor function to set member value $user_key

void set_user_key (mixed $par)
  • mixed $par: A string containing a UUID, or NULL to clear it
_internal_validation_error (line 666)

Internal function to report a data validation error.

Outputs an LSL-friendly error message, and terminates the script

  • access: private
void _internal_validation_error (string $msg)
  • string $msg: The error message to output.

Documentation generated on Tue, 04 Mar 2008 15:08:46 +0000 by phpDocumentor 1.4.0