ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilECSResult.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
25
36{
39
40 protected $log;
41
42 protected $result_string = '';
43 protected $http_code = '';
44 protected $result;
45 protected $result_type;
46
47 protected $headers = array();
48
58 public function __construct($a_res, $a_type = self::RESULT_TYPE_JSON)
59 {
60 global $DIC;
61
62 $ilLog = $DIC['ilLog'];
63
64 $this->log = $ilLog;
65
66 $this->result_string = $a_res;
67 $this->result_type = $a_type;
68
69 $this->init();
70 }
71
79 public function setHTTPCode($a_code)
80 {
81 $this->http_code = $a_code;
82 }
83
89 public function getHTTPCode()
90 {
91 return $this->http_code;
92 }
93
100 public function getPlainResultString()
101 {
103 }
104
112 public function getResult()
113 {
114 return $this->result;
115 }
116
121 public function setHeaders($a_headers)
122 {
123 $this->headers = $a_headers;
124 }
125
131 public function getHeaders()
132 {
133 return $this->headers ?: [];
134 }
135
141 private function init()
142 {
143 switch ($this->result_type) {
145 if ($this->result_string) {
146 $this->result = json_decode($this->result_string);
147 } else {
148 $this->result = array();
149 }
150 break;
151
153 $this->result = $this->parseUriList($this->result_string);
154 break;
155 }
156 return true;
157 }
158
164 private function parseUriList($a_content)
165 {
166 include_once 'Services/WebServices/ECS/classes/class.ilECSUriList.php';
167 $list = new ilECSUriList();
168 $lines = explode("\n", $this->getPlainResultString());
169 foreach ($lines as $line) {
170 $line = trim($line);
171 if (!strlen($line)) {
172 continue;
173 }
174 $uri_parts = explode("/", $line);
175 $list->add($line, array_pop($uri_parts));
176 }
177
178 return $list;
179 }
180}
An exception for terminatinating execution or to throw for unit testing.
setHeaders($a_headers)
Set header.
getHeaders()
get headers
getResult()
get result
const RESULT_TYPE_URL_LIST
parseUriList($a_content)
setHTTPCode($a_code)
set HTTP return code
getHTTPCode()
get HTTP code
init()
init result (json_decode) @access private
getPlainResultString()
get unformated result string
__construct($a_res, $a_type=self::RESULT_TYPE_JSON)
Constructor.
Presentation of ecs uril (http://...campusconnect/courselinks)
global $DIC
Definition: goto.php:24