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

Services/Utilities/classes/class.ilSaxController.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 
00035 class ilSaxController
00036 {
00037         protected $default_handler = null;
00038         protected $element_handlers = array();
00039         protected $handlers_in_use = array();
00040                 
00048         public function __construct()
00049         {
00050                 
00051         }
00052         
00060         public function setHandlers($a_xml_parser)
00061         {
00062                 xml_set_object($a_xml_parser,$this);
00063                 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00064                 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00065                 return;
00066         }
00067         
00075         public function setDefaultElementHandler(ilSaxSubsetParser $a_default_parser)
00076         {
00077                 $this->default_handler = $a_default_parser;
00078         }
00079         
00088         public function setElementHandler(ilSaxSubsetParser $a_parser,$a_element)
00089         {
00090                 $this->element_handlers[$a_element] = $a_parser;
00091                 $this->handlers_in_use[$a_element] = false;
00092         }
00093         
00112         public function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
00113         {
00114                 if(isset($this->element_handlers[$a_name]) or $this->handler_in_use)
00115                 {
00116                         if(!$this->handler_in_use)
00117                         {
00118                                 $this->handler_in_use = $this->element_handlers[$a_name];
00119                         }
00120                         // Forward to handler
00121                         $this->current_handler = $this->handler_in_use;
00122                         return $this->current_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
00123                 }
00124                 // Call default handler
00125                 $this->handler_in_use = false;
00126                 $this->current_handler = $this->default_handler;
00127                 return $this->default_handler->handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
00128         }
00129         
00136         function handlerEndTag($a_xml_parser,$a_name)
00137         {
00138                 if(isset($this->element_handlers[$a_name]))
00139                 {
00140                         $this->handler_in_use = false;
00141                         $this->current_handler = $this->element_handlers[$a_name];
00142                         return $this->element_handlers[$a_name]->handlerEndTag($a_xml_parser,$a_name);
00143                 }
00144                 elseif($this->handler_in_use)
00145                 {
00146                         $this->current_handler = $this->handler_in_use;
00147                         return $this->current_handler->handlerEndTag($a_xml_parser,$a_name);
00148                 }
00149                 $this->handler_in_use = false;
00150                 $this->current_handler = $this->default_handler;
00151                 return $this->default_handler->handlerEndTag($a_xml_parser,$a_name);
00152         }
00153 
00160         function handlerCharacterData($a_xml_parser,$a_data)
00161         {
00162                 return $this->current_handler->handlerCharacterData(a_xml_parser,$a_data);
00163         }
00164         
00165 }
00166 ?>

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