ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSCORMPackageParser Class Reference

SCORM Package Parser. More...

+ Inheritance diagram for ilSCORMPackageParser:
+ Collaboration diagram for ilSCORMPackageParser:

Public Member Functions

 ilSCORMPackageParser (&$a_slm_object, $a_xml_file)
 Constructor. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 startParsing ()
 stores xml data in array More...
 
 getPackageTitle ()
 
 beginElement ($a_name)
 
 endElement ($a_name)
 
 getCurrentElement ()
 
 getAncestorElement ($nr=1)
 
 getOpenCount ($a_name)
 
 buildTag ($type, $name, $attr="")
 generate a tag with given name and attributes More...
 
 getCurrentParent ()
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object @access public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $cnt
 
 $current_element
 
 $slm_object
 
 $parent_stack
 
 $tree_created
 
 $scorm_tree
 
 $current_organization
 
 $current_resource
 
 $item_stack
 
 $package_title = ""
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

SCORM Package Parser.

Author
Version
$Id$

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

Member Function Documentation

◆ beginElement()

ilSCORMPackageParser::beginElement (   $a_name)

Definition at line 99 of file class.ilSCORMPackageParser.php.

100 {
101 if(!isset($this->status["$a_name"]))
102 {
103 $this->cnt[$a_name] = 1;
104 }
105 else
106 {
107 $this->cnt[$a_name]++;
108 }
109 $this->current_element[count($this->current_element)] = $a_name;
110 }

Referenced by handlerBeginTag().

+ Here is the caller graph for this function:

◆ buildTag()

ilSCORMPackageParser::buildTag (   $type,
  $name,
  $attr = "" 
)

generate a tag with given name and attributes

Parameters
string"start" | "end" for starting or ending tag
stringelement/tag name
arrayarray of attributes

Definition at line 160 of file class.ilSCORMPackageParser.php.

161 {
162 $tag = "<";
163
164 if ($type == "end")
165 $tag.= "/";
166
167 $tag.= $name;
168
169 if (is_array($attr))
170 {
171 while (list($k,$v) = each($attr))
172 $tag.= " ".$k."=\"$v\"";
173 }
174
175 $tag.= ">";
176
177 return $tag;
178 }

◆ endElement()

ilSCORMPackageParser::endElement (   $a_name)

Definition at line 115 of file class.ilSCORMPackageParser.php.

116 {
117 $this->cnt[$a_name]--;
118 unset ($this->current_element[count($this->current_element) - 1]);
119 }

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getAncestorElement()

ilSCORMPackageParser::getAncestorElement (   $nr = 1)

Definition at line 132 of file class.ilSCORMPackageParser.php.

133 {
134 return ($this->current_element[count($this->current_element) - 1 - $nr]);
135 }

Referenced by handlerCharacterData().

+ Here is the caller graph for this function:

◆ getCurrentElement()

ilSCORMPackageParser::getCurrentElement ( )

Definition at line 124 of file class.ilSCORMPackageParser.php.

125 {
126 return ($this->current_element[count($this->current_element) - 1]);
127 }

Referenced by handlerCharacterData().

+ Here is the caller graph for this function:

◆ getCurrentParent()

ilSCORMPackageParser::getCurrentParent ( )

Definition at line 180 of file class.ilSCORMPackageParser.php.

181 {
182 return $this->parent_stack[count($this->parent_stack) - 1];
183 }

◆ getOpenCount()

ilSCORMPackageParser::getOpenCount (   $a_name)

Definition at line 140 of file class.ilSCORMPackageParser.php.

141 {
142 if (isset($this->cnt[$a_name]))
143 {
144 return $this->cnt[$a_name];
145 }
146 else
147 {
148 return 0;
149 }
150
151 }

◆ getPackageTitle()

ilSCORMPackageParser::getPackageTitle ( )

Definition at line 91 of file class.ilSCORMPackageParser.php.

References $package_title.

◆ handlerBeginTag()

ilSCORMPackageParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Definition at line 188 of file class.ilSCORMPackageParser.php.

189 {
190//echo "<br>handlerBeginTag:".$a_name;
191 switch($a_name)
192 {
193 case "manifest":
194 $manifest =& new ilSCORMManifest();
195 $manifest->setSLMId($this->slm_object->getId());
196 $manifest->setImportId($a_attribs["identifier"]);
197 $manifest->setVersion($a_attribs["version"]);
198 $manifest->setXmlBase($a_attribs["xml:base"]);
199 $manifest->create();
200 if (!$this->tree_created)
201 {
202 $this->sc_tree =& new ilSCORMTree($this->slm_object->getId());
203 $this->sc_tree->addTree($this->slm_object->getId(), $manifest->getId());
204 }
205 else
206 {
207 $this->sc_tree->insertNode($manifest->getId(), $this->getCurrentParent());
208 }
209 array_push($this->parent_stack, $manifest->getId());
210 break;
211
212 case "organizations":
213 $organizations =& new ilSCORMOrganizations();
214 $organizations->setSLMId($this->slm_object->getId());
215 $organizations->setDefaultOrganization($a_attribs["default"]);
216 $organizations->create();
217 $this->sc_tree->insertNode($organizations->getId(), $this->getCurrentParent());
218 array_push($this->parent_stack, $organizations->getId());
219 break;
220
221 case "organization":
222 $organization =& new ilSCORMOrganization();
223 $organization->setSLMId($this->slm_object->getId());
224 $organization->setImportId($a_attribs["identifier"]);
225 $organization->setStructure($a_attribs["structure"]);
226 $organization->create();
227 $this->current_organization =& $organization;
228 $this->sc_tree->insertNode($organization->getId(), $this->getCurrentParent());
229 array_push($this->parent_stack, $organization->getId());
230 break;
231
232 case "item":
233 $item =& new ilSCORMItem();
234 $item->setSLMId($this->slm_object->getId());
235 $item->setImportId($a_attribs["identifier"]);
236 $item->setIdentifierRef($a_attribs["identifierref"]);
237 if (strtolower($a_attribs["isvisible"]) != "false")
238 {
239 $item->setVisible(true);
240 }
241 else
242 {
243 $item->setVisible(false);
244 }
245 $item->setParameters($a_attribs["parameters"]);
246 $item->create();
247 $this->sc_tree->insertNode($item->getId(), $this->getCurrentParent());
248 array_push($this->parent_stack, $item->getId());
249 $this->item_stack[count($this->item_stack)] =& $item;
250 break;
251
252 case "adlcp:prerequisites":
253 $this->item_stack[count($this->item_stack) - 1]->setPrereqType($a_attribs["type"]);
254 break;
255
256 case "resources":
257 $resources =& new ilSCORMResources();
258 $resources->setSLMId($this->slm_object->getId());
259 $resources->setXmlBase($a_attribs["xml:base"]);
260 $resources->create();
261 $this->sc_tree->insertNode($resources->getId(), $this->getCurrentParent());
262 array_push($this->parent_stack, $resources->getId());
263 break;
264
265 case "resource":
266 $resource =& new ilSCORMResource();
267 $resource->setSLMId($this->slm_object->getId());
268 $resource->setImportId($a_attribs["identifier"]);
269 $resource->setResourceType($a_attribs["type"]);
270 $resource->setScormType($a_attribs["adlcp:scormtype"]);
271 $resource->setXmlBase($a_attribs["xml:base"]);
272 $resource->setHRef($a_attribs["href"]);
273 $resource->create();
274 $this->current_resource =& $resource;
275 $this->sc_tree->insertNode($resource->getId(), $this->getCurrentParent());
276 array_push($this->parent_stack, $resource->getId());
277 break;
278
279 case "file":
280 $file =& new ilSCORMResourceFile();
281 $file->setHRef($a_attribs["href"]);
282 $this->current_resource->addFile($file);
283 break;
284
285 case "dependency":
286 $dependency =& new ilSCORMResourceDependency();
287 $dependency->setIdentifierRef($a_attribs["identifierref"]);
288 $this->current_resource->addDependency($dependency);
289 break;
290
291 }
292 $this->beginElement($a_name);
293 }
print $file
SCORM Resource Dependency, DB accesses are done in ilSCORMResource.
SCORM Resource File, DB accesses are done in ilSCORMResource.
SCORM Resources Element.
SCORM Object Tree.

References $file, and beginElement().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilSCORMPackageParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 334 of file class.ilSCORMPackageParser.php.

335 {
336//echo "<br>handlerCharacterData:".$this->getCurrentElement().":".$a_data;
337 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
338 $a_data = preg_replace("/\n/","",$a_data);
339 $a_data = preg_replace("/\t+/","",$a_data);
340 if(!empty($a_data))
341 {
342 switch($this->getCurrentElement())
343 {
344 case "title":
345 switch ($this->getAncestorElement(1))
346 {
347 case "organization":
348 $this->current_organization->setTitle(
349 $this->current_organization->getTitle() . $a_data
350 );
351 $this->package_title = $this->current_organization->getTitle();
352 break;
353
354 case "item":
355 $this->item_stack[count($this->item_stack) - 1]->setTitle(
356 $this->item_stack[count($this->item_stack) - 1]->getTitle() . $a_data
357 );
358 break;
359 }
360 break;
361
362 case "adlcp:prerequisites":
363 $this->item_stack[count($this->item_stack) - 1]->setPrerequisites($a_data);
364 break;
365
366 case "adlcp:maxtimeallowed":
367 $this->item_stack[count($this->item_stack) - 1]->setMaxTimeAllowed($a_data);
368 break;
369
370 case "adlcp:timelimitaction":
371 $this->item_stack[count($this->item_stack) - 1]->setTimeLimitAction($a_data);
372 break;
373
374 case "adlcp:datafromlms":
375 $this->item_stack[count($this->item_stack) - 1]->setDataFromLms($a_data);
376 break;
377
378 case "adlcp:masteryscore":
379 $this->item_stack[count($this->item_stack) - 1]->setMasteryScore($a_data);
380 break;
381
382 }
383 }
384 }

References getAncestorElement(), and getCurrentElement().

+ Here is the call graph for this function:

◆ handlerEndTag()

ilSCORMPackageParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 298 of file class.ilSCORMPackageParser.php.

299 {
300//echo "<br>handlerEndTag:".$a_name;
301
302 switch($a_name)
303 {
304 case "manifest":
305 case "organizations":
306 case "resources":
307 array_pop($this->parent_stack);
308 break;
309
310 case "organization":
311 $this->current_organization->update();
312 array_pop($this->parent_stack);
313 break;
314
315 case "item":
316 $this->item_stack[count($this->item_stack) - 1]->update();
317 unset($this->item_stack[count($this->item_stack) - 1]);
318 array_pop($this->parent_stack);
319 break;
320
321 case "resource":
322 $this->current_resource->update();
323 array_pop($this->parent_stack);
324 break;
325
326 }
327 $this->endElement($a_name);
328
329 }

References endElement().

+ Here is the call graph for this function:

◆ ilSCORMPackageParser()

ilSCORMPackageParser::ilSCORMPackageParser ( $a_slm_object,
  $a_xml_file 
)

Constructor.

Parameters
object$a_lm_objectmust be of type ilObjLearningModule
string$a_xml_filexml file @access public

Definition at line 63 of file class.ilSCORMPackageParser.php.

64 {
65 parent::ilSaxParser($a_xml_file);
66 $this->cnt = array();
67 $this->current_element = array();
68 $this->slm_object =& $a_slm_object;
69 $this->tree_created = false;
70 $this->parent_stack = array();
71 $this->item_stack = array();
72 }

◆ setHandlers()

ilSCORMPackageParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class @access private

Reimplemented from ilSaxParser.

Definition at line 79 of file class.ilSCORMPackageParser.php.

80 {
81 xml_set_object($a_xml_parser,$this);
82 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
83 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
84 }

◆ startParsing()

ilSCORMPackageParser::startParsing ( )

stores xml data in array

@access private

Exceptions
ilSaxParserExceptionor ILIAS Error

Reimplemented from ilSaxParser.

Definition at line 86 of file class.ilSCORMPackageParser.php.

87 {
88 parent::startParsing();
89 }

Field Documentation

◆ $cnt

ilSCORMPackageParser::$cnt

Definition at line 44 of file class.ilSCORMPackageParser.php.

◆ $current_element

ilSCORMPackageParser::$current_element

Definition at line 45 of file class.ilSCORMPackageParser.php.

◆ $current_organization

ilSCORMPackageParser::$current_organization

Definition at line 50 of file class.ilSCORMPackageParser.php.

◆ $current_resource

ilSCORMPackageParser::$current_resource

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

◆ $item_stack

ilSCORMPackageParser::$item_stack

Definition at line 52 of file class.ilSCORMPackageParser.php.

◆ $package_title

ilSCORMPackageParser::$package_title = ""

Definition at line 53 of file class.ilSCORMPackageParser.php.

Referenced by getPackageTitle().

◆ $parent_stack

ilSCORMPackageParser::$parent_stack

Definition at line 47 of file class.ilSCORMPackageParser.php.

◆ $scorm_tree

ilSCORMPackageParser::$scorm_tree

Definition at line 49 of file class.ilSCORMPackageParser.php.

◆ $slm_object

ilSCORMPackageParser::$slm_object

Definition at line 46 of file class.ilSCORMPackageParser.php.

◆ $tree_created

ilSCORMPackageParser::$tree_created

Definition at line 48 of file class.ilSCORMPackageParser.php.


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