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

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