Public Member Functions | Data Fields

ilSCORMPackageParser Class Reference

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

Data Fields

 $cnt
 $current_element
 $slm_object
 $parent_stack
 $tree_created
 $scorm_tree
 $current_organization
 $current_resource
 $item_stack
 $package_title = ""

Detailed Description

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


Member Function Documentation

ilSCORMPackageParser::beginElement ( a_name  ) 

Definition at line 100 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
string element/tag name
array array of attributes

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

References $type.

        {
                $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 116 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 133 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 125 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 181 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 141 of file class.ilSCORMPackageParser.php.

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

        }

ilSCORMPackageParser::getPackageTitle (  ) 

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

        {
                return $this->package_title;
        }

ilSCORMPackageParser::handlerBeginTag ( a_xml_parser,
a_name,
a_attribs 
)

handler for begin of element

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

References $file, 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 =& new ilSCORMResourceFile();
                                $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 335 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 299 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_object must be of type ilObjLearningModule
string $a_xml_file xml file public

Definition at line 64 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 80 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

Reimplemented from ilSaxParser.

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


Field Documentation

ilSCORMPackageParser::$cnt

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

ilSCORMPackageParser::$current_element

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

ilSCORMPackageParser::$current_organization

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

ilSCORMPackageParser::$current_resource

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

ilSCORMPackageParser::$item_stack

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

ilSCORMPackageParser::$package_title = ""

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

ilSCORMPackageParser::$parent_stack

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

ilSCORMPackageParser::$scorm_tree

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

ilSCORMPackageParser::$slm_object

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

ilSCORMPackageParser::$tree_created

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


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