Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once("./classes/class.ilSaxParser.php");
00026
00036 class ilnetucateResponse extends ilSaxParser
00037 {
00042 function ilnetucateResponse($a_xml_str)
00043 {
00044 parent::ilSaxParser($a_xml_str);
00045
00046 $this->startParsing();
00047 }
00048
00049 function isError()
00050 {
00051 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
00052 {
00053 return true;
00054 }
00055
00056 return false;
00057 }
00058
00059 function getErrorMsg()
00060 {
00061 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
00062 {
00063 return $this->data['result']['cdata'];
00064 }
00065 }
00066
00067 function getResultMsg()
00068 {
00069 return $this->data['result']['cdata'];
00070 }
00071
00072 function getFirstID()
00073 {
00074 reset($this->data['id']);
00075 return current($this->data['id']);
00076 }
00077
00078
00084 function setHandlers($a_xml_parser)
00085 {
00086 xml_set_object($a_xml_parser,$this);
00087 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00088 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00089 }
00090
00094 function startParsing()
00095 {
00096 $xml_parser = $this->createParser();
00097 $this->setOptions($xml_parser);
00098 $this->setHandlers($xml_parser);
00099 $this->parse($xml_parser,$this->xml_file);
00100 $this->freeParser($xml_parser);
00101 return true;
00102 }
00103
00109 function parse($a_xml_parser,$a_xml_str)
00110 {
00111 $parseOk = xml_parse($a_xml_parser,$a_xml_str,true);
00112
00113 if (!$parseOk && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
00114 {
00115 $this->ilias->raiseError("XML Parse Error: ",$this->ilias->error_obj->FATAL);
00116 }
00117 }
00118
00119
00123 function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
00124 {
00125 global $ilErr;
00126
00127 switch($a_name)
00128 {
00129 case "netucate.API.Response":
00130 $this->data['response']['failureCount'] = $a_attribs['failureCount'];
00131 $this->data['response']['operationTotal'] = $a_attribs['operationTotal'];
00132 $this->data['response']['status'] = $a_attribs['status'];
00133 $this->data['response']['successCount'] = $a_attribs['successCount'];
00134 break;
00135
00136 case "netucate.Result":
00137 $this->data['result']['code'] = $a_attribs['code'];
00138 $this->data['result']['id'] = $a_attribs['id'];
00139 $this->data['result']['name'] = $a_attribs['name'];
00140 $this->data['result']['request'] = $a_attribs['request'];
00141 break;
00142
00143 case "netucate.ElementID":
00144 $this->data['element']['type'] = $a_attribs['type'];
00145 break;
00146
00147 case "netucate.URL":
00148 break;
00149
00150 case "netucate.ID":
00151 break;
00152 }
00153 }
00154
00155
00156 function handlerEndTag($a_xml_parser, $a_name)
00157 {
00158 switch($a_name)
00159 {
00160 case "netucate.API.Response":
00161 $this->data['response']['cdata'] = $this->cdata;
00162 break;
00163
00164 case "netucate.Result":
00165 $this->data['result']['cdata'] = $this->cdata;
00166 break;
00167
00168 case "netucate.ElementID":
00169
00170 break;
00171
00172 case "netucate.URL":
00173 $this->data['url']['cdata'] = $this->cdata;
00174 break;
00175
00176 case "netucate.ID":
00177 $this->data['id'][$this->cdata] = $this->cdata;
00178 break;
00179 }
00180
00181 $this->cdata = '';
00182 }
00183
00187 function handlerCharacterData($a_xml_parser, $a_data)
00188 {
00189 if(!empty($a_data))
00190 {
00191 $this->cdata .= $a_data;
00192 }
00193 }
00194
00195 }
00196 ?>