ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSResult Class Reference
+ Collaboration diagram for ilECSResult:

Public Member Functions

 __construct ($a_res, $with_headers=false, $a_type=self::RESULT_TYPE_JSON)
 Constructor.
 setHTTPCode ($a_code)
 set HTTP return code
 getHTTPCode ()
 get HTTP code
 getPlainResultString ()
 get unformated result string
 getResult ()
 get result
 setHeaders ($a_headers)
 Set header.
 getHeaders ()
 get headers

Data Fields

const RESULT_TYPE_JSON = 1
const RESULT_TYPE_URL_LIST = 2
const HEADER_ECS_SENDER = 'X-EcsSender'

Protected Attributes

 $log
 $result_string = ''
 $result_header = ''
 $http_code = ''
 $result
 $result_type
 $header_parsing = false
 $headers = array()
 $header_map = array()

Private Member Functions

 init ()
 init result (json_decode) private
 splitHeader ()
 Split header and content.
 parseHeader ()
 Parse header.
 parseUriList ($a_content)

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 35 of file class.ilECSResult.php.

Constructor & Destructor Documentation

ilECSResult::__construct (   $a_res,
  $with_headers = false,
  $a_type = self::RESULT_TYPE_JSON 
)

Constructor.

public

Parameters
stringresult_string
intresult type
Exceptions
ilECSConnectorException

Definition at line 63 of file class.ilECSResult.php.

References $ilLog, and init().

{
global $ilLog;
$this->log = $ilLog;
$this->result_string = $a_res;
$this->result_type = $a_type;
if($with_headers)
{
$this->header_parsing = true;
}
$this->init();
}

+ Here is the call graph for this function:

Member Function Documentation

ilECSResult::getHeaders ( )

get headers

public

Definition at line 139 of file class.ilECSResult.php.

{
return $this->headers ? $this->headers : array();
}
ilECSResult::getHTTPCode ( )

get HTTP code

public

Definition at line 97 of file class.ilECSResult.php.

References $http_code.

{
}
ilECSResult::getPlainResultString ( )

get unformated result string

public

Definition at line 108 of file class.ilECSResult.php.

References $result_string.

Referenced by parseUriList().

{
}

+ Here is the caller graph for this function:

ilECSResult::getResult ( )

get result

public

Returns
mixed JSON object, array of objects or false in case of errors.

Definition at line 120 of file class.ilECSResult.php.

References $result.

{
return $this->result;
}
ilECSResult::init ( )
private

init result (json_decode) private

Definition at line 149 of file class.ilECSResult.php.

References parseHeader(), parseUriList(), and splitHeader().

Referenced by __construct().

{
if($this->header_parsing and $this->result_string)
{
$this->splitHeader();
$this->parseHeader();
}
switch($this->result_type)
{
case self::RESULT_TYPE_JSON:
if($this->result_string)
{
$this->result = json_decode($this->result_string);
}
else
{
$this->result = array();
}
break;
case self::RESULT_TYPE_URL_LIST:
$this->result = $this->parseUriList($this->result_string);
break;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSResult::parseHeader ( )
private

Parse header.

private

Definition at line 207 of file class.ilECSResult.php.

References $location, and HEADER_ECS_SENDER.

Referenced by init().

{
// In the moment only look for "Location:" value
$location_start = strpos($this->result_header,"Location:");
if($location_start !== false)
{
$location_start += 10;
$location_end = strpos($this->result_header,"\r\n",$location_start);
$location = substr($this->result_header,$location_start,$location_end - $location_start);
$this->headers['Location'] = $location;
}
$ecs_sender = strpos($this->result_header,self::HEADER_ECS_SENDER);
if($ecs_sender !== false)
{
$sender_start =+ 13;
$sender_end = strpos($this->result_header,"\r\n",$sender_start);
$sender = substr($this->result_header,$sender_start,$sender_end - $sender_start);
$senders_arr = explode(',',$sender);
$this->header_map[self::HEADER_ECS_SENDER] = $senders_arr;
}
return true;
}

+ Here is the caller graph for this function:

ilECSResult::parseUriList (   $a_content)
private
Parameters
<type>$a_content
Returns
ilECSUriList

Definition at line 238 of file class.ilECSResult.php.

References getPlainResultString().

Referenced by init().

{
include_once 'Services/WebServices/ECS/classes/class.ilECSUriList.php';
$list = new ilECSUriList();
$lines = explode("\n", $this->getPlainResultString());
foreach($lines as $line)
{
$line = trim($line);
if(!strlen($line))
{
continue;
}
$uri_parts = explode("/", $line);
$list->add($line, array_pop($uri_parts));
}
return $list;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSResult::setHeaders (   $a_headers)

Set header.

Parameters
array$a_headers

Definition at line 129 of file class.ilECSResult.php.

{
$this->headers = $a_headers;
}
ilECSResult::setHTTPCode (   $a_code)

set HTTP return code

public

Parameters
stringhttp code

Definition at line 87 of file class.ilECSResult.php.

{
$this->http_code = $a_code;
}
ilECSResult::splitHeader ( )
private

Split header and content.

private

Exceptions
ilECSConnectorException

Definition at line 185 of file class.ilECSResult.php.

Referenced by init().

{
$pos = strpos($this->result_string,"\r\n\r\n");
if($pos !== false)
{
$this->result_header = substr($this->result_string,0,$pos + 2);
$this->result_string = substr($this->result_string,$pos + 2,-1);
return true;
}
else
{
$this->log->write(__METHOD__.': Cannot find header entry');
throw new ilECSConnectorException('Cannot find header part.');
}
}

+ Here is the caller graph for this function:

Field Documentation

ilECSResult::$header_map = array()
protected

Definition at line 52 of file class.ilECSResult.php.

ilECSResult::$header_parsing = false
protected

Definition at line 49 of file class.ilECSResult.php.

ilECSResult::$headers = array()
protected

Definition at line 51 of file class.ilECSResult.php.

ilECSResult::$http_code = ''
protected

Definition at line 46 of file class.ilECSResult.php.

Referenced by getHTTPCode().

ilECSResult::$log
protected

Definition at line 42 of file class.ilECSResult.php.

ilECSResult::$result
protected

Definition at line 47 of file class.ilECSResult.php.

Referenced by getResult().

ilECSResult::$result_header = ''
protected

Definition at line 45 of file class.ilECSResult.php.

ilECSResult::$result_string = ''
protected

Definition at line 44 of file class.ilECSResult.php.

Referenced by getPlainResultString().

ilECSResult::$result_type
protected

Definition at line 48 of file class.ilECSResult.php.

const ilECSResult::HEADER_ECS_SENDER = 'X-EcsSender'

Definition at line 40 of file class.ilECSResult.php.

Referenced by parseHeader().

const ilECSResult::RESULT_TYPE_JSON = 1

Definition at line 37 of file class.ilECSResult.php.

const ilECSResult::RESULT_TYPE_URL_LIST = 2

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