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

webservice/soap/classes/class.ilObjectXMLParser.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 
00034 include_once 'classes/class.ilSaxParser.php';
00035 
00036 class ilObjectXMLParser extends ilSaxParser
00037 {
00038         var $object_data = array();
00039 
00049         function ilObjectXMLParser($a_xml_data = '', $throwException = false)
00050         {
00051                 parent::ilSaxParser('', $throwException);
00052                 $this->setXMLContent($a_xml_data);
00053         }
00054 
00055         function getObjectData()
00056         {
00057                 return $this->object_data ? $this->object_data : array();
00058         }
00059 
00066         function setHandlers($a_xml_parser)
00067         {
00068                 xml_set_object($a_xml_parser,$this);
00069                 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00070                 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00071         }
00072 
00073         
00074 
00075 
00083         function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00084         {
00085                 switch($a_name)
00086                 {
00087                         case 'Objects':
00088                                 $this->curr_obj = -1;
00089                                 break;
00090 
00091                         case 'Object':
00092                                 ++$this->curr_obj;
00093                                 
00094                                 $this->__addProperty('type',$a_attribs['type']);
00095                                 $this->__addProperty('obj_id',is_numeric($a_attribs['obj_id'])?(int) $a_attribs["obj_id"] :  ilUtil::__extractId($a_attribs["obj_id"], IL_INST_ID));
00096                                 break;
00097 
00098                         case 'Title':
00099                                 break;
00100 
00101                         case 'Description':
00102                                 break;
00103 
00104                         case 'Owner':
00105                                 break;
00106 
00107                         case 'CreateDate':
00108                                 break;
00109 
00110                         case 'LastUpdate':
00111                                 break;
00112                                 
00113                         case 'ImportId':
00114                                 break;
00115 
00116                         case 'References':
00117                                 $this->ref_id = $a_attribs["ref_id"];
00118                                 break;
00119                 }
00120         }
00121 
00128         function handlerEndTag($a_xml_parser,$a_name)
00129         {
00130                 switch($a_name)
00131                 {
00132                         case 'Objects':
00133                                 break;
00134 
00135                         case 'Object':
00136                                 break;
00137 
00138                         case 'Title':
00139                                 $this->__addProperty('title',trim($this->cdata));
00140                                 break;
00141 
00142                         case 'Description':
00143                                 $this->__addProperty('description',trim($this->cdata));
00144                                 break;
00145 
00146                         case 'Owner':
00147                                 $this->__addProperty('owner',trim($this->cdata));
00148                                 break;
00149 
00150                         case 'CreateDate':
00151                                 $this->__addProperty('create_date',trim($this->cdata));
00152                                 break;
00153 
00154                         case 'LastUpdate':
00155                                 $this->__addProperty('last_update',trim($this->cdata));
00156                                 break;
00157                                 
00158                         case 'ImportId':
00159                                 $this->__addProperty('import_id',trim($this->cdata));
00160                                 break;
00161 
00162                         case 'References':
00163                                 $this->__addReference($this->ref_id);
00164                                 break;
00165                 }
00166 
00167                 $this->cdata = '';
00168 
00169                 return;
00170         }
00171 
00178         function handlerCharacterData($a_xml_parser,$a_data)
00179         {
00180                 if($a_data != "\n")
00181                 {
00182                         // Replace multiple tabs with one space
00183                         $a_data = preg_replace("/\t+/"," ",$a_data);
00184 
00185                         $this->cdata .= $a_data;
00186                 }
00187 
00188 
00189         }
00190 
00191         // PRIVATE
00192         function __addProperty($a_name,$a_value)
00193         {
00194                 $this->object_data[$this->curr_obj][$a_name] = $a_value;
00195         }
00196 
00197         function __addReference($a_value)
00198         {
00199                 if($a_value)
00200                 {
00201                         $this->object_data[$this->curr_obj]['references'][] = $a_value;
00202                 }
00203         }
00204 
00205 }
00206 ?>

Generated on Fri Dec 13 2013 17:57:03 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1