ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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) @access 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.

@access public

Parameters
stringresult_string
intresult type
Exceptions
ilECSConnectorException

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

64 {
65 global $DIC;
66
67 $ilLog = $DIC['ilLog'];
68
69 $this->log = $ilLog;
70
71 $this->result_string = $a_res;
72 $this->result_type = $a_type;
73
74 if ($with_headers) {
75 $this->header_parsing = true;
76 }
77
78 $this->init();
79 }
init()
init result (json_decode) @access private
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92

References $a_type, $DIC, $ilLog, and init().

+ Here is the call graph for this function:

Member Function Documentation

◆ getHeaders()

ilECSResult::getHeaders ( )

get headers

@access public

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

141 {
142 return $this->headers ? $this->headers : array();
143 }

◆ getHTTPCode()

ilECSResult::getHTTPCode ( )

get HTTP code

@access public

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

99 {
100 return $this->http_code;
101 }

References $http_code.

◆ getPlainResultString()

ilECSResult::getPlainResultString ( )

get unformated result string

@access public

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

110 {
112 }

References $result_string.

Referenced by parseUriList().

+ Here is the caller graph for this function:

◆ getResult()

ilECSResult::getResult ( )

get result

@access public

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

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

122 {
123 return $this->result;
124 }

References $result.

◆ init()

ilECSResult::init ( )
private

init result (json_decode) @access private

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

151 {
152 if ($this->header_parsing and $this->result_string) {
153 $this->splitHeader();
154 $this->parseHeader();
155 }
156
157
158 switch ($this->result_type) {
160 if ($this->result_string) {
161 $this->result = json_decode($this->result_string);
162 } else {
163 $this->result = array();
164 }
165 break;
166
168 $this->result = $this->parseUriList($this->result_string);
169 break;
170 }
171 return true;
172 }
const RESULT_TYPE_URL_LIST
parseUriList($a_content)
splitHeader()
Split header and content.
parseHeader()
Parse header.

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseHeader()

ilECSResult::parseHeader ( )
private

Parse header.

@access private

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

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

References $location, and HEADER_ECS_SENDER.

Referenced by init().

+ Here is the caller graph for this function:

◆ parseUriList()

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

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

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

References $list, and getPlainResultString().

Referenced by init().

+ 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 130 of file class.ilECSResult.php.

131 {
132 $this->headers = $a_headers;
133 }

◆ setHTTPCode()

ilECSResult::setHTTPCode (   $a_code)

set HTTP return code

@access public

Parameters
stringhttp code

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

89 {
90 $this->http_code = $a_code;
91 }

◆ splitHeader()

ilECSResult::splitHeader ( )
private

Split header and content.

@access private

Exceptions
ilECSConnectorException

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

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

Referenced by init().

+ 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.

Referenced by parseHeader().

◆ RESULT_TYPE_JSON

const ilECSResult::RESULT_TYPE_JSON = 1

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

Referenced by init().

◆ RESULT_TYPE_URL_LIST

const ilECSResult::RESULT_TYPE_URL_LIST = 2

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