ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSCORMPackageParser Class Reference

SCORM Package Parser. More...

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

Public Member Functions

 __construct (&$a_slm_object, $a_xml_file)
 Constructor. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 startParsing ()
 
 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
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object 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 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
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). 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...
 
 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

- Static Public Member Functions inherited from PEAR
static & 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...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
- 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.

Constructor & Destructor Documentation

◆ __construct()

ilSCORMPackageParser::__construct ( $a_slm_object,
  $a_xml_file 
)

Constructor.

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

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

References array.

64  {
65  parent::__construct($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  }
Create styles array
The data for the language used.

Member Function Documentation

◆ beginElement()

ilSCORMPackageParser::beginElement (   $a_name)

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

Referenced by handlerBeginTag().

100  {
101  if (!isset($this->status["$a_name"])) {
102  $this->cnt[$a_name] == 1;
103  } else {
104  $this->cnt[$a_name]++;
105  }
106  $this->current_element[count($this->current_element)] = $a_name;
107  }
+ 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 153 of file class.ilSCORMPackageParser.php.

References $name, $tag, and $type.

154  {
155  $tag = "<";
156 
157  if ($type == "end") {
158  $tag.= "/";
159  }
160 
161  $tag.= $name;
162 
163  if (is_array($attr)) {
164  while (list($k, $v) = each($attr)) {
165  $tag.= " " . $k . "=\"$v\"";
166  }
167  }
168 
169  $tag.= ">";
170 
171  return $tag;
172  }
$type
if($format !==null) $name
Definition: metadata.php:146
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ endElement()

ilSCORMPackageParser::endElement (   $a_name)

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

Referenced by handlerEndTag().

113  {
114  $this->cnt[$a_name]--;
115  unset($this->current_element[count($this->current_element) - 1]);
116  }
+ Here is the caller graph for this function:

◆ getAncestorElement()

ilSCORMPackageParser::getAncestorElement (   $nr = 1)

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

Referenced by handlerCharacterData().

130  {
131  return ($this->current_element[count($this->current_element) - 1 - $nr]);
132  }
+ Here is the caller graph for this function:

◆ getCurrentElement()

ilSCORMPackageParser::getCurrentElement ( )

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

Referenced by handlerCharacterData().

122  {
123  return ($this->current_element[count($this->current_element) - 1]);
124  }
+ Here is the caller graph for this function:

◆ getCurrentParent()

ilSCORMPackageParser::getCurrentParent ( )

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

Referenced by handlerBeginTag().

175  {
176  return $this->parent_stack[count($this->parent_stack) - 1];
177  }
+ Here is the caller graph for this function:

◆ getOpenCount()

ilSCORMPackageParser::getOpenCount (   $a_name)

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

138  {
139  if (isset($this->cnt[$a_name])) {
140  return $this->cnt[$a_name];
141  } else {
142  return 0;
143  }
144  }

◆ 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 182 of file class.ilSCORMPackageParser.php.

References $file, $organizations, ilTree\addTree(), beginElement(), and getCurrentParent().

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

◆ handlerCharacterData()

ilSCORMPackageParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

References getAncestorElement(), and getCurrentElement().

320  {
321  //echo "<br>handlerCharacterData:".$this->getCurrentElement().":".$a_data;
322  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
323  $a_data = preg_replace("/\n/", "", $a_data);
324  $a_data = preg_replace("/\t+/", "", $a_data);
325  if (!empty($a_data)) {
326  switch ($this->getCurrentElement()) {
327  case "title":
328  switch ($this->getAncestorElement(1)) {
329  case "organization":
330  $this->current_organization->setTitle(
331  $this->current_organization->getTitle() . $a_data
332  );
333  $this->package_title = $this->current_organization->getTitle();
334  break;
335 
336  case "item":
337  $this->item_stack[count($this->item_stack) - 1]->setTitle(
338  $this->item_stack[count($this->item_stack) - 1]->getTitle() . $a_data
339  );
340  break;
341  }
342  break;
343 
344  case "adlcp:prerequisites":
345  $this->item_stack[count($this->item_stack) - 1]->setPrerequisites($a_data);
346  break;
347 
348  case "adlcp:maxtimeallowed":
349  $this->item_stack[count($this->item_stack) - 1]->setMaxTimeAllowed($a_data);
350  break;
351 
352  case "adlcp:timelimitaction":
353  $this->item_stack[count($this->item_stack) - 1]->setTimeLimitAction($a_data);
354  break;
355 
356  case "adlcp:datafromlms":
357  $this->item_stack[count($this->item_stack) - 1]->setDataFromLms($a_data);
358  break;
359 
360  case "adlcp:masteryscore":
361  $this->item_stack[count($this->item_stack) - 1]->setMasteryScore($a_data);
362  break;
363 
364  }
365  }
366  }
+ Here is the call graph for this function:

◆ handlerEndTag()

ilSCORMPackageParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

References endElement().

286  {
287  //echo "<br>handlerEndTag:".$a_name;
288 
289  switch ($a_name) {
290  case "manifest":
291  case "organizations":
292  case "resources":
293  array_pop($this->parent_stack);
294  break;
295 
296  case "organization":
297  $this->current_organization->update();
298  array_pop($this->parent_stack);
299  break;
300 
301  case "item":
302  $this->item_stack[count($this->item_stack) - 1]->update();
303  unset($this->item_stack[count($this->item_stack) - 1]);
304  array_pop($this->parent_stack);
305  break;
306 
307  case "resource":
308  $this->current_resource->update();
309  array_pop($this->parent_stack);
310  break;
311 
312  }
313  $this->endElement($a_name);
314  }
+ Here is the call graph for this function:

◆ setHandlers()

ilSCORMPackageParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

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 ( )

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: