• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

ilinc/classes/class.ilnetucateResponse.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                                 //$this->data['element']['cdata'] = $this->cdata;
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 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1