ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSaxController Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilSaxController:

Public Member Functions

 setHandlers ($a_xml_parser)
 Set handlers. More...
 
 setDefaultElementHandler (ilSaxSubsetParser $a_default_parser)
 Set default element handler. More...
 
 setElementHandler (ilSaxSubsetParser $a_parser, string $a_element)
 
 handlerBeginTag ($a_xml_parser, string $a_name, array $a_attribs)
 default handlerBeginTag More...
 
 handlerEndTag ($a_xml_parser, string $a_name)
 handler for end of element More...
 
 handlerCharacterData ( $a_xml_parser, string $a_data)
 handler for character data More...
 

Protected Attributes

ilSaxSubsetParser $default_handler = null
 
array $element_handlers = []
 
array $handlers_in_use = []
 
 $handler_in_use = null
 
ilSaxSubsetParser $current_handler
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Controller class for sax element handlers. Could be used to split the xml handling in different responsible classes. Use the methods addElementHandler, addDefaultElementHandler

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 26 of file class.ilSaxController.php.

Member Function Documentation

◆ handlerBeginTag()

ilSaxController::handlerBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)

default handlerBeginTag

public

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

Definition at line 74 of file class.ilSaxController.php.

References $default_handler, $handler_in_use, and ilSaxSubsetParser\handlerBeginTag().

Referenced by setHandlers().

74  : void
75  {
76  if (isset($this->element_handlers[$a_name]) or $this->handler_in_use) {
77  if (!$this->handler_in_use) {
78  $this->handler_in_use = $this->element_handlers[$a_name];
79  }
80  // Forward to handler
81  $this->current_handler = $this->handler_in_use;
82  $this->current_handler->handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
83  return;
84  }
85  // Call default handler
86  $this->handler_in_use = false;
87  $this->current_handler = $this->default_handler;
88  $this->default_handler->handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
89  }
ilSaxSubsetParser $default_handler
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
Start element handler.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerCharacterData()

ilSaxController::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

Definition at line 120 of file class.ilSaxController.php.

Referenced by setHandlers().

123  : void {
124  $this->current_handler->handlerCharacterData(
125  $a_xml_parser,
126  $a_data
127  );
128  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

ilSaxController::handlerEndTag (   $a_xml_parser,
string  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

Definition at line 97 of file class.ilSaxController.php.

References $default_handler, $handler_in_use, and ilSaxSubsetParser\handlerEndTag().

Referenced by setHandlers().

97  : void
98  {
99  if (isset($this->element_handlers[$a_name])) {
100  $this->handler_in_use = false;
101  $this->current_handler = $this->element_handlers[$a_name];
102  $this->element_handlers[$a_name]->handlerEndTag($a_xml_parser, $a_name);
103  return;
104  } elseif ($this->handler_in_use) {
105  $this->current_handler = $this->handler_in_use;
106  $this->current_handler->handlerEndTag($a_xml_parser, $a_name);
107  return;
108  }
109  $this->handler_in_use = false;
110  $this->current_handler = $this->default_handler;
111  $this->default_handler->handlerEndTag($a_xml_parser, $a_name);
112  }
handlerEndTag($a_xml_parser, string $a_name)
End element handler.
ilSaxSubsetParser $default_handler
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDefaultElementHandler()

ilSaxController::setDefaultElementHandler ( ilSaxSubsetParser  $a_default_parser)

Set default element handler.

Definition at line 51 of file class.ilSaxController.php.

51  : void
52  {
53  $this->default_handler = $a_default_parser;
54  }

◆ setElementHandler()

ilSaxController::setElementHandler ( ilSaxSubsetParser  $a_parser,
string  $a_element 
)
Parameters
ilSaxSubsetParser$a_parserobject that parses the xmlsubset must implement interface ilSaxSubsetParser
string$a_elementelement name that triggers the handler

Definition at line 60 of file class.ilSaxController.php.

60  : void
61  {
62  $this->element_handlers[$a_element] = $a_parser;
63  $this->handlers_in_use[$a_element] = false;
64  }

◆ setHandlers()

ilSaxController::setHandlers (   $a_xml_parser)

Set handlers.

Parameters
resourcexml_parser instance

Definition at line 42 of file class.ilSaxController.php.

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

42  : void
43  {
44  xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
45  xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
46  }
handlerCharacterData( $a_xml_parser, string $a_data)
handler for character data
handlerEndTag($a_xml_parser, string $a_name)
handler for end of element
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
default handlerBeginTag
+ Here is the call graph for this function:

Field Documentation

◆ $current_handler

ilSaxSubsetParser ilSaxController::$current_handler
protected

Definition at line 35 of file class.ilSaxController.php.

◆ $default_handler

ilSaxSubsetParser ilSaxController::$default_handler = null
protected

Definition at line 28 of file class.ilSaxController.php.

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $element_handlers

array ilSaxController::$element_handlers = []
protected

Definition at line 29 of file class.ilSaxController.php.

◆ $handler_in_use

ilSaxController::$handler_in_use = null
protected

Definition at line 34 of file class.ilSaxController.php.

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $handlers_in_use

array ilSaxController::$handlers_in_use = []
protected

Definition at line 30 of file class.ilSaxController.php.


The documentation for this class was generated from the following file: