ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjQuestionPoolXMLParser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Xml/classes/class.ilSaxParser.php';
5
13{
17 private $poolOBJ;
18
20
23
28 public function __construct(ilObjQuestionPool $poolOBJ, $xmlFile)
29 {
30 $this->poolOBJ = $poolOBJ;
31
32 $this->inSettingsTag = false;
33 $this->inMetaDataTag = false;
34 $this->inMdGeneralTag = false;
35
36 return parent::ilSaxParser($xmlFile);
37 }
38
39 public function setHandlers($xmlParser)
40 {
41 xml_set_object($xmlParser,$this);
42 xml_set_element_handler($xmlParser,'handlerBeginTag','handlerEndTag');
43 xml_set_character_data_handler($xmlParser,'handlerCharacterData');
44 }
45
46 public function handlerBeginTag($xmlParser, $tagName, $tagAttributes)
47 {
48 switch($tagName)
49 {
50 case 'MetaData':
51 $this->inMetaDataTag = true;
52 break;
53
54 case 'General':
55 if($this->inMetaDataTag)
56 {
57 $this->inMdGeneralTag = true;
58 }
59 break;
60
61 case 'Description':
62 if($this->inMetaDataTag && $this->inMdGeneralTag)
63 {
64 $this->cdata = '';
65 }
66 break;
67
68 case 'Settings':
69 $this->inSettingsTag = true;
70 break;
71
72 case 'ShowTaxonomies':
73 case 'NavTaxonomy':
74 case 'SkillService':
75 if($this->inSettingsTag)
76 {
77 $this->cdata = '';
78 }
79 break;
80 }
81 }
82
83 public function handlerEndTag($xmlParser, $tagName)
84 {
85 switch($tagName)
86 {
87 case 'MetaData':
88 $this->inMetaDataTag = false;
89 break;
90
91 case 'General':
92 if($this->inMetaDataTag)
93 {
94 $this->inMdGeneralTag = false;
95 }
96 break;
97
98 case 'Description':
99 if($this->inMetaDataTag && $this->inMdGeneralTag)
100 {
101 $this->poolOBJ->setDescription($this->cdata);
102 $this->cdata = '';
103 }
104 break;
105
106 case 'Settings':
107 $this->inSettingsTag = false;
108 break;
109
110 case 'ShowTaxonomies':
111 $this->poolOBJ->setShowTaxonomies((bool)$this->cdata);
112 $this->cdata = '';
113 break;
114
115 case 'NavTaxonomy':
116 $this->poolOBJ->setNavTaxonomyId((int)$this->cdata);
117 $this->cdata = '';
118 break;
119
120 case 'SkillService':
121 $this->poolOBJ->setSkillServiceEnabled((bool)$this->cdata);
122 $this->cdata = '';
123 break;
124 }
125 }
126
127 public function handlerCharacterData($xmlParser, $charData)
128 {
129 if( $charData != "\n" )
130 {
131 // Replace multiple tabs with one space
132 $charData = preg_replace("/\t+/"," ",$charData);
133
134 $this->cdata .= $charData;
135 }
136 }
137}
setHandlers($xmlParser)
set event handler should be overwritten by inherited class @access private
__construct(ilObjQuestionPool $poolOBJ, $xmlFile)
handlerBeginTag($xmlParser, $tagName, $tagAttributes)
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...