ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilECSResult Class Reference
+ Collaboration diagram for ilECSResult:

Public Member Functions

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

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 More...
 
 splitHeader ()
 Split header and content. More...
 
 parseHeader ()
 Parse header. More...
 
 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

◆ __construct()

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 $a_type, $ilLog, and init().

64  {
65  global $ilLog;
66 
67  $this->log = $ilLog;
68 
69  $this->result_string = $a_res;
70  $this->result_type = $a_type;
71 
72  if ($with_headers) {
73  $this->header_parsing = true;
74  }
75 
76  $this->init();
77  }
$a_type
Definition: workflow.php:92
init()
init result (json_decode) private
+ Here is the call graph for this function:

Member Function Documentation

◆ getHeaders()

ilECSResult::getHeaders ( )

get headers

public

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

References array.

139  {
140  return $this->headers ? $this->headers : array();
141  }
Create styles array
The data for the language used.

◆ getHTTPCode()

ilECSResult::getHTTPCode ( )

get HTTP code

public

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

References $http_code.

97  {
98  return $this->http_code;
99  }

◆ getPlainResultString()

ilECSResult::getPlainResultString ( )

get unformated result string

public

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

References $result_string.

Referenced by parseUriList().

108  {
109  return $this->result_string;
110  }
+ Here is the caller graph for this function:

◆ getResult()

ilECSResult::getResult ( )

get result

public

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

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

References $result.

120  {
121  return $this->result;
122  }

◆ init()

ilECSResult::init ( )
private

init result (json_decode) private

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

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

Referenced by __construct().

149  {
150  if ($this->header_parsing and $this->result_string) {
151  $this->splitHeader();
152  $this->parseHeader();
153  }
154 
155 
156  switch ($this->result_type) {
157  case self::RESULT_TYPE_JSON:
158  if ($this->result_string) {
159  $this->result = json_decode($this->result_string);
160  } else {
161  $this->result = array();
162  }
163  break;
164 
165  case self::RESULT_TYPE_URL_LIST:
166  $this->result = $this->parseUriList($this->result_string);
167  break;
168  }
169  return true;
170  }
parseHeader()
Parse header.
parseUriList($a_content)
Create styles array
The data for the language used.
splitHeader()
Split header and content.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseHeader()

ilECSResult::parseHeader ( )
private

Parse header.

private

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

References $location.

Referenced by init().

199  {
200  // In the moment only look for "Location:" value
201  $location_start = strpos($this->result_header, "Location:");
202  if ($location_start !== false) {
203  $location_start += 10;
204  $location_end = strpos($this->result_header, "\r\n", $location_start);
205 
206  $location = substr($this->result_header, $location_start, $location_end - $location_start);
207  $this->headers['Location'] = $location;
208  }
209 
210  $ecs_sender = strpos($this->result_header, self::HEADER_ECS_SENDER);
211  if ($ecs_sender !== false) {
212  $sender_start =+13;
213  $sender_end = strpos($this->result_header, "\r\n", $sender_start);
214  $sender = substr($this->result_header, $sender_start, $sender_end - $sender_start);
215 
216  $senders_arr = explode(',', $sender);
217  $this->header_map[self::HEADER_ECS_SENDER] = $senders_arr;
218  }
219  return true;
220  }
$location
Definition: buildRTE.php:44
+ Here is the caller graph for this function:

◆ parseUriList()

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

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

References $list, and getPlainResultString().

Referenced by init().

228  {
229  include_once 'Services/WebServices/ECS/classes/class.ilECSUriList.php';
230  $list = new ilECSUriList();
231  $lines = explode("\n", $this->getPlainResultString());
232  foreach ($lines as $line) {
233  $line = trim($line);
234  if (!strlen($line)) {
235  continue;
236  }
237  $uri_parts = explode("/", $line);
238  $list->add($line, array_pop($uri_parts));
239  }
240 
241  return $list;
242  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
Presentation of ecs uril (http://...campusconnect/courselinks)
getPlainResultString()
get unformated result string
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHeaders()

ilECSResult::setHeaders (   $a_headers)

Set header.

Parameters
array$a_headers

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

129  {
130  $this->headers = $a_headers;
131  }

◆ setHTTPCode()

ilECSResult::setHTTPCode (   $a_code)

set HTTP return code

public

Parameters
stringhttp code

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

87  {
88  $this->http_code = $a_code;
89  }

◆ splitHeader()

ilECSResult::splitHeader ( )
private

Split header and content.

private

Exceptions
ilECSConnectorException

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

Referenced by init().

180  {
181  $pos = strpos($this->result_string, "\r\n\r\n");
182  if ($pos !== false) {
183  $this->result_header = substr($this->result_string, 0, $pos + 2);
184  $this->result_string = substr($this->result_string, $pos + 2, -1);
185  return true;
186  } else {
187  $this->log->write(__METHOD__ . ': Cannot find header entry');
188  throw new ilECSConnectorException('Cannot find header part.');
189  }
190  }
+ Here is the caller graph for this function:

Field Documentation

◆ $header_map

ilECSResult::$header_map = array()
protected

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

◆ $header_parsing

ilECSResult::$header_parsing = false
protected

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

◆ $headers

ilECSResult::$headers = array()
protected

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

◆ $http_code

ilECSResult::$http_code = ''
protected

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

Referenced by getHTTPCode().

◆ $log

ilECSResult::$log
protected

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

◆ $result

ilECSResult::$result
protected

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

Referenced by getResult().

◆ $result_header

ilECSResult::$result_header = ''
protected

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

◆ $result_string

ilECSResult::$result_string = ''
protected

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

Referenced by getPlainResultString().

◆ $result_type

ilECSResult::$result_type
protected

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

◆ HEADER_ECS_SENDER

const ilECSResult::HEADER_ECS_SENDER = 'X-EcsSender'

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

◆ RESULT_TYPE_JSON

const ilECSResult::RESULT_TYPE_JSON = 1

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

◆ RESULT_TYPE_URL_LIST

const ilECSResult::RESULT_TYPE_URL_LIST = 2

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