ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private
 startParsing ()
 stores xml data in array
 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
 getCurrentParent ()
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 createParser ()
 create parser
 setOptions ($a_xml_parser)
 set parser options
 openXMLFile ()
 open xml file
 parse ($a_xml_parser, $a_fp=null)
 parse xml file
 freeParser ($a_xml_parser)
 free xml parser handle
 setThrowException ($throwException)
 set error handling
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
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.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
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.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

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

Detailed Description

SCORM Package Parser.

Author
Version
$Id$

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

Member Function Documentation

ilSCORMPackageParser::beginElement (   $a_name)

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

Referenced by handlerBeginTag().

{
if(!isset($this->status["$a_name"]))
{
$this->cnt[$a_name] == 1;
}
else
{
$this->cnt[$a_name]++;
}
$this->current_element[count($this->current_element)] = $a_name;
}

+ Here is the caller graph for this function:

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.

{
$tag = "<";
if ($type == "end")
$tag.= "/";
$tag.= $name;
if (is_array($attr))
{
while (list($k,$v) = each($attr))
$tag.= " ".$k."=\"$v\"";
}
$tag.= ">";
return $tag;
}
ilSCORMPackageParser::endElement (   $a_name)

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

Referenced by handlerEndTag().

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

+ Here is the caller graph for this function:

ilSCORMPackageParser::getAncestorElement (   $nr = 1)

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

Referenced by handlerCharacterData().

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

+ Here is the caller graph for this function:

ilSCORMPackageParser::getCurrentElement ( )

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

Referenced by handlerCharacterData().

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

+ Here is the caller graph for this function:

ilSCORMPackageParser::getCurrentParent ( )

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

Referenced by handlerBeginTag().

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

+ Here is the caller graph for this function:

ilSCORMPackageParser::getOpenCount (   $a_name)

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

{
if (isset($this->cnt[$a_name]))
{
return $this->cnt[$a_name];
}
else
{
return 0;
}
}
ilSCORMPackageParser::getPackageTitle ( )

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

References $package_title.

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

handler for begin of element

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

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

{
//echo "<br>handlerBeginTag:".$a_name;
switch($a_name)
{
case "manifest":
$manifest =& new ilSCORMManifest();
$manifest->setSLMId($this->slm_object->getId());
$manifest->setImportId($a_attribs["identifier"]);
$manifest->setVersion($a_attribs["version"]);
$manifest->setXmlBase($a_attribs["xml:base"]);
$manifest->create();
if (!$this->tree_created)
{
$this->sc_tree =& new ilSCORMTree($this->slm_object->getId());
$this->sc_tree->addTree($this->slm_object->getId(), $manifest->getId());
}
else
{
$this->sc_tree->insertNode($manifest->getId(), $this->getCurrentParent());
}
array_push($this->parent_stack, $manifest->getId());
break;
case "organizations":
$organizations =& new ilSCORMOrganizations();
$organizations->setSLMId($this->slm_object->getId());
$organizations->setDefaultOrganization($a_attribs["default"]);
$organizations->create();
$this->sc_tree->insertNode($organizations->getId(), $this->getCurrentParent());
array_push($this->parent_stack, $organizations->getId());
break;
case "organization":
$organization =& new ilSCORMOrganization();
$organization->setSLMId($this->slm_object->getId());
$organization->setImportId($a_attribs["identifier"]);
$organization->setStructure($a_attribs["structure"]);
$organization->create();
$this->current_organization =& $organization;
$this->sc_tree->insertNode($organization->getId(), $this->getCurrentParent());
array_push($this->parent_stack, $organization->getId());
break;
case "item":
$item =& new ilSCORMItem();
$item->setSLMId($this->slm_object->getId());
$item->setImportId($a_attribs["identifier"]);
$item->setIdentifierRef($a_attribs["identifierref"]);
if (strtolower($a_attribs["isvisible"]) != "false")
{
$item->setVisible(true);
}
else
{
$item->setVisible(false);
}
$item->setParameters($a_attribs["parameters"]);
$item->create();
$this->sc_tree->insertNode($item->getId(), $this->getCurrentParent());
array_push($this->parent_stack, $item->getId());
$this->item_stack[count($this->item_stack)] =& $item;
break;
case "adlcp:prerequisites":
$this->item_stack[count($this->item_stack) - 1]->setPrereqType($a_attribs["type"]);
break;
case "resources":
$resources =& new ilSCORMResources();
$resources->setSLMId($this->slm_object->getId());
$resources->setXmlBase($a_attribs["xml:base"]);
$resources->create();
$this->sc_tree->insertNode($resources->getId(), $this->getCurrentParent());
array_push($this->parent_stack, $resources->getId());
break;
case "resource":
$resource =& new ilSCORMResource();
$resource->setSLMId($this->slm_object->getId());
$resource->setImportId($a_attribs["identifier"]);
$resource->setResourceType($a_attribs["type"]);
$resource->setScormType($a_attribs["adlcp:scormtype"]);
$resource->setXmlBase($a_attribs["xml:base"]);
$resource->setHRef($a_attribs["href"]);
$resource->create();
$this->current_resource =& $resource;
$this->sc_tree->insertNode($resource->getId(), $this->getCurrentParent());
array_push($this->parent_stack, $resource->getId());
break;
case "file":
$file->setHRef($a_attribs["href"]);
$this->current_resource->addFile($file);
break;
case "dependency":
$dependency =& new ilSCORMResourceDependency();
$dependency->setIdentifierRef($a_attribs["identifierref"]);
$this->current_resource->addDependency($dependency);
break;
}
$this->beginElement($a_name);
}

+ Here is the call graph for this function:

ilSCORMPackageParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

References getAncestorElement(), and getCurrentElement().

{
//echo "<br>handlerCharacterData:".$this->getCurrentElement().":".$a_data;
// DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
$a_data = preg_replace("/\n/","",$a_data);
$a_data = preg_replace("/\t+/","",$a_data);
if(!empty($a_data))
{
switch($this->getCurrentElement())
{
case "title":
switch ($this->getAncestorElement(1))
{
case "organization":
$this->current_organization->setTitle(
$this->current_organization->getTitle() . $a_data
);
$this->package_title = $this->current_organization->getTitle();
break;
case "item":
$this->item_stack[count($this->item_stack) - 1]->setTitle(
$this->item_stack[count($this->item_stack) - 1]->getTitle() . $a_data
);
break;
}
break;
case "adlcp:prerequisites":
$this->item_stack[count($this->item_stack) - 1]->setPrerequisites($a_data);
break;
case "adlcp:maxtimeallowed":
$this->item_stack[count($this->item_stack) - 1]->setMaxTimeAllowed($a_data);
break;
case "adlcp:timelimitaction":
$this->item_stack[count($this->item_stack) - 1]->setTimeLimitAction($a_data);
break;
case "adlcp:datafromlms":
$this->item_stack[count($this->item_stack) - 1]->setDataFromLms($a_data);
break;
case "adlcp:masteryscore":
$this->item_stack[count($this->item_stack) - 1]->setMasteryScore($a_data);
break;
}
}
}

+ Here is the call graph for this function:

ilSCORMPackageParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

References endElement().

{
//echo "<br>handlerEndTag:".$a_name;
switch($a_name)
{
case "manifest":
case "organizations":
case "resources":
array_pop($this->parent_stack);
break;
case "organization":
$this->current_organization->update();
array_pop($this->parent_stack);
break;
case "item":
$this->item_stack[count($this->item_stack) - 1]->update();
unset($this->item_stack[count($this->item_stack) - 1]);
array_pop($this->parent_stack);
break;
case "resource":
$this->current_resource->update();
array_pop($this->parent_stack);
break;
}
$this->endElement($a_name);
}

+ Here is the call graph for this function:

ilSCORMPackageParser::ilSCORMPackageParser ( $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 ilSaxParser\ilSaxParser().

{
parent::ilSaxParser($a_xml_file);
$this->cnt = array();
$this->current_element = array();
$this->slm_object =& $a_slm_object;
$this->tree_created = false;
$this->parent_stack = array();
$this->item_stack = array();
}

+ Here is the call graph for this function:

ilSCORMPackageParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Reimplemented from ilSaxParser.

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

{
xml_set_object($a_xml_parser,$this);
xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
}
ilSCORMPackageParser::startParsing ( )

stores xml data in array

private

Exceptions
ilSaxParserExceptionor ILIAS Error

Reimplemented from ilSaxParser.

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

Field Documentation

ilSCORMPackageParser::$cnt

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

ilSCORMPackageParser::$current_element

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

ilSCORMPackageParser::$current_organization

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

ilSCORMPackageParser::$current_resource

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

ilSCORMPackageParser::$item_stack

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

ilSCORMPackageParser::$package_title = ""

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

Referenced by getPackageTitle().

ilSCORMPackageParser::$parent_stack

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

ilSCORMPackageParser::$scorm_tree

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

ilSCORMPackageParser::$slm_object

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

ilSCORMPackageParser::$tree_created

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


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