• 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_str)
00043         {
00044                 $xml_str = $this->validateInput($a_str);
00045 
00046                 parent::ilSaxParser($xml_str);
00047                                 
00048                 $this->startParsing();
00049         }
00050         
00051         function validateInput($a_str)
00052         {
00053                 $response = split("\r\n\r\n",$a_str);
00054         
00055                 $header = $response[0];
00056                 $response_data = $response[1];
00057                 
00058                 if (strpos($response_data,"<?xml") === false)
00059                 {
00060                         echo "netucateResponse::validateInput() : No valid response data!<br/>";
00061                         var_dump($header,$response_data);
00062                         exit;
00063                 }
00064         
00065         return chop($response_data);
00066         }
00067         
00068         function isError()
00069         {
00070                 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
00071                 {
00072                         return true;
00073                 }
00074                 
00075                 return false;
00076         }
00077         
00078         function getErrorMsg()
00079         {
00080                 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
00081                 {
00082                         return trim($this->data['result']['cdata']);
00083                 }
00084         }
00085         
00086         function getResultMsg()
00087         {
00088                 return trim($this->data['result']['cdata']);
00089         }
00090         
00091         function getFirstID()
00092         {
00093                 reset($this->data['id']);
00094                 return current($this->data['id']);
00095         }
00096                 
00097 
00103         function setHandlers($a_xml_parser)
00104         {
00105                 xml_set_object($a_xml_parser,$this);
00106                 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00107                 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00108         }
00109 
00113         function startParsing()
00114         {
00115                 $xml_parser = $this->createParser();
00116                 $this->setOptions($xml_parser);
00117                 $this->setHandlers($xml_parser);
00118                 $this->parse($xml_parser,$this->xml_file);
00119                 $this->freeParser($xml_parser);
00120                 return true;
00121         }
00122         
00128         function parse($a_xml_parser,$a_xml_str)
00129         {
00130                 $parseOk = xml_parse($a_xml_parser,$a_xml_str,true);
00131 
00132                 if (!$parseOk && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
00133                 {
00134                                 $this->ilias->raiseError("XML Parse Error: ".xml_error_string(xml_get_error_code($a_xml_parser)),$this->ilias->error_obj->FATAL);
00135                 }
00136         }
00137 
00138 
00142         function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
00143         {
00144                 global $ilErr;
00145 
00146                 switch($a_name)
00147                 {
00148                         case "netucate.API.Response":
00149                                 $this->data['response']['failureCount'] = $a_attribs['failureCount'];
00150                                 $this->data['response']['operationTotal'] = $a_attribs['operationTotal'];
00151                                 $this->data['response']['status'] = $a_attribs['status'];
00152                                 $this->data['response']['successCount'] = $a_attribs['successCount'];
00153                                 break;
00154 
00155                         case "netucate.Result":
00156                                 $this->data['result']['code'] = $a_attribs['code'];
00157                                 $this->data['result']['id'] = $a_attribs['id'];
00158                                 $this->data['result']['name'] = $a_attribs['name'];
00159                                 $this->data['result']['request'] = $a_attribs['request'];
00160                                 break;
00161 
00162                         case "netucate.ElementID":
00163                                 $this->data['element']['type'] = $a_attribs['type'];
00164                                 break;
00165 
00166                         case "netucate.URL":
00167                                 break;
00168 
00169                         case "netucate.ID":
00170                                 break;
00171                                 
00172                         case "netucate.Class.List":
00173                         case "netucate.User.List":
00174                                 break;
00175                                 
00176                         case "netucate.Class":
00177                                 $this->data['classes'][$a_attribs['classid']] = array (
00178                                                                                                                                                 'name' => $a_attribs['name'],
00179                                                                                                                                                 'instructoruserid' => $a_attribs['instructoruserid'],
00180                                                                                                                                                 'bandwidth' => $a_attribs['bandwidth'],
00181                                                                                                                                                 'appsharebandwidth' => $a_attribs['appsharebandwidth'],
00182                                                                                                                                                 'description' => $a_attribs['description'],
00183                                                                                                                                                 'password' => $a_attribs['password'],
00184                                                                                                                                                 'message' => $a_attribs['message'],
00185                                                                                                                                                 'floorpolicy' => $a_attribs['floorpolicy'],
00186                                                                                                                                                 'conferencetypeid' => $a_attribs['conferencetypeid'],
00187                                                                                                                                                 'videobandwidth' => $a_attribs['videobandwidth'],
00188                                                                                                                                                 'videoframerate' => $a_attribs['videoframerate'],
00189                                                                                                                                                 'enablepush' => $a_attribs['enablepush'],
00190                                                                                                                                                 'issecure' => $a_attribs['issecure'],
00191                                                                                                                                                 'alwaysopen' => $a_attribs['alwaysopen'],
00192                                                                                                                                                 'akclassvalue1' => $a_attribs['akclassvalue1'],
00193                                                                                                                                                 'akclassvalue1' => $a_attribs['akclassvalue1']
00194                                                                                                                                                 );
00195                                 break;
00196                                 
00197                         case "netucate.User":
00198                                 $this->data['users'][$a_attribs['userid']] = array (
00199                                                                                                                                                 'fullname' => $a_attribs['fullname']
00200                                                                                                                                                 );
00201                                 break;
00202                 }
00203         }
00204 
00205 
00206         function handlerEndTag($a_xml_parser, $a_name)
00207         {
00208                 switch($a_name)
00209                 {
00210                         case "netucate.API.Response":
00211                                 $this->data['response']['cdata'] = $this->cdata;
00212                                 break;
00213 
00214                         case "netucate.Result":
00215                                 $this->data['result']['cdata'] = $this->cdata;
00216                                 break;
00217 
00218                         case "netucate.ElementID":
00219                                 //$this->data['element']['cdata'] = $this->cdata;
00220                                 break;
00221 
00222                         case "netucate.URL":
00223                                 $this->data['url']['cdata'] = trim($this->cdata);
00224                                 break;
00225 
00226                         case "netucate.ID":
00227                                 $this->data['id'][trim($this->cdata)] = trim($this->cdata);
00228                                 break;
00229                                 
00230                         case "netucate.Class.List":
00231                         case "netucate.Class":
00232                         case "netucate.User.List":
00233                         case "netucate.User":
00234                                 break;
00235                 }
00236                 
00237                 $this->cdata = '';
00238         }
00239         
00243         function handlerCharacterData($a_xml_parser, $a_data)
00244         {
00245                 if(!empty($a_data))
00246                 {
00247                         $this->cdata .= $a_data;
00248                 }
00249         }
00250         
00251 }
00252 ?>

Generated on Fri Dec 13 2013 11:57:58 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1