Public Member Functions | Data Fields

ilCourseXMLParser Class Reference

Inheritance diagram for ilCourseXMLParser:
Collaboration diagram for ilCourseXMLParser:

Public Member Functions

 ilCourseXMLParser (&$a_course_obj, $a_xml_file= '')
 Constructor.
 setHandlers ($a_xml_parser)
 set event handlers
 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
 __parseId ($a_id)

Data Fields

 $lng
 $md_obj = null

Detailed Description

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


Member Function Documentation

ilCourseXMLParser::__parseId ( a_id  ) 

Definition at line 447 of file class.ilCourseXMLParser.php.

References $fields, $id, ilSaxParser::$ilias, ilObjUser::_getImportedUserId(), and ilObjUser::_lookupLogin().

Referenced by handlerBeginTag().

        {
                global $ilias;

                $fields = explode('_',$a_id);

                if(!is_array($fields) or
                   $fields[0] != 'il' or
                   !is_numeric($fields[1]) or
                   $fields[2] != 'usr' or
                   !is_numeric($fields[3]))
                {
                        return false;
                }
                if($id = ilObjUser::_getImportedUserId($a_id))
                {
                        return array('imported' => true,
                                                 'local' => false,
                                                 'usr_id' => $id);
                }
                if(($fields[1] == $ilias->getSetting('inst_id',0)) and strlen(ilObjUser::_lookupLogin($fields[3])))
                {
                        return array('imported' => false,
                                                 'local' => true,
                                                 'usr_id' => $fields[3]);
                }
                return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseXMLParser::handlerBeginTag ( a_xml_parser,
a_name,
a_attribs 
)

handler for begin of element

Parameters:
resource $a_xml_parser xml parser
string $a_name element name
array $a_attribs element attributes array

Reimplemented from ilMDSaxParser.

Definition at line 98 of file class.ilCourseXMLParser.php.

References __parseId(), and ilObject::_writeImportId().

        {
                if($this->in_meta_data)
                {
                        parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);

                        return;
                }

                switch($a_name)
                {
                        case 'Course':

                                if(strlen($a_attribs['importId']))
                                {
                                        $this->log->write("CourseXMLParser: importId = ".$a_attribs['importId']);
                                        $this->course_obj->setImportId($a_attribs['importId']);
                                        ilObject::_writeImportId($this->course_obj->getId(),$a_attribs['importId']);
                                }
                                break;

                        case 'Admin':
                                if($id_data = $this->__parseId($a_attribs['id']))
                                {
                                        if($id_data['local'] or $id_data['imported'])
                                        {
                                                $this->course_members->add(new ilObjUser($id_data['usr_id']),
                                                                                                   $this->course_members->ROLE_ADMIN,
                                                                                                   $a_attribs['notification'] == 'Yes' ? 1 : 0,
                                                                                                   $a_attribs['passed'] == 'Yes' ? 1 : 0);
                                        }
                                }
                                break;

                        case 'Tutor':
                                if($id_data = $this->__parseId($a_attribs['id']))
                                {
                                        if($id_data['local'] or $id_data['imported'])
                                        {
                                                $this->course_members->add(new ilObjUser($id_data['usr_id']),
                                                                                                   $this->course_members->ROLE_TUTOR,
                                                                                                   $a_attribs['notification'] == 'Yes' ? 1 : 0,
                                                                                                   $a_attribs['passed'] == 'Yes' ? 1 : 0);
                                        }
                                }
                                break;

                        case 'Member':
                                if($id_data = $this->__parseId($a_attribs['id']))
                                {
                                        if($id_data['local'] or $id_data['imported'])
                                        {
                                                $this->course_members->add(new ilObjUser($id_data['usr_id']),
                                                                                                   $this->course_members->ROLE_MEMBER,
                                                                                                   $a_attribs['blocked'] == 'Yes' ? 
                                                                                                   $this->course_members->STATUS_BLOCKED : 
                                                                                                   $this->course_members->STATUS_UNBLOCKED,
                                                                                                   $a_attribs['passed'] == 'Yes' ? 1 : 0);
                                        }
                                }
                                break;

                        case 'Subscriber':
                                if($id_data = $this->__parseId($a_attribs['id']))
                                {
                                        if($id_data['local'] or $id_data['imported'])
                                        {
                                                $this->course_members->addSubscriber($id_data['usr_id']);
                                                $this->course_members->updateSubscriptionTime($id_data['usr_id'],$a_attribs['subscriptionTime']);
                                        }
                                }
                                break;

                        case 'WaitingList':
                                if($id_data = $this->__parseId($a_attribs['id']))
                                {
                                        if($id_data['local'] or $id_data['imported'])
                                        {
                                                $this->course_waiting_list->addToList($id_data['usr_id']);
                                                $this->course_waiting_list->updateSubscriptionTime($id_data['usr_id'],$a_attribs['subscriptionTime']);
                                        }
                                }
                                break;
                                

                        case 'Settings':
                                $this->in_settings = true;
                                break;
                        case 'Availability':
                                $this->in_availability = true;
                                break;

                        case 'NotAvailable':
                                if($this->in_availability)
                                {
                                        $this->course_obj->setActivationType(IL_CRS_ACTIVATION_OFFLINE);
                                }
                                elseif($this->in_registration)
                                {
                                        $this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
                                }
                                        
                                break;

                        case 'Unlimited':
                                if($this->in_availability)
                                {
                                        $this->course_obj->setActivationType(IL_CRS_ACTIVATION_UNLIMITED);
                                }
                                elseif($this->in_registration)
                                {
                                        $this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_UNLIMITED);
                                }
                                        
                                break;
                        case 'TemporarilyAvailable':
                                if($this->in_availability)
                                {
                                        $this->course_obj->setActivationType(IL_CRS_ACTIVATION_LIMITED);
                                }
                                elseif($this->in_registration)
                                {
                                        $this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_LIMITED);
                                }
                                break;

                        case 'Start':
                                break;
                                
                        case 'End':
                                break;

                        case 'Syllabus':
                                break;

                        case 'Contact':
                                break;

                        case 'Name':
                        case 'Responsibility':
                        case 'Phone':
                        case 'Email':
                        case 'Consultation':
                                break;

                        case 'Registration':
                                $this->in_registration = true;
                                
                                switch($a_attribs['registrationType'])
                                {
                                        case 'Confirmation':
                                                $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_CONFIRMATION);
                                                break;

                                        case 'Direct':
                                                $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_DIRECT);
                                                break;
                                                
                                        case 'Password':
                                                $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_PASSWORD);
                                                break;
                                }
                                $this->course_obj->setSubscriptionMaxMembers((int) $a_attribs['maxMembers']);
                                $this->course_obj->setSubscriptionNotify($a_attribs['notification'] == 'Yes' ? true : false);
                                $this->course_obj->enableWaitingList($a_attribs['waitingList'] == 'Yes' ? true : false);
                                break;

                        case 'Sort':
                                switch($a_attribs['type'])
                                {
                                        case 'Manual':
                                                $this->course_obj->setOrderType(IL_CRS_SORT_MANUAL);
                                                break;

                                        case 'Title':
                                                $this->course_obj->setOrderType(IL_CRS_SORT_TITLE);
                                                break;

                                        case 'Activation':
                                                $this->course_obj->setOrderType(IL_CRS_SORT_ACTIVATION);
                                                break;
                                }
                                break;


                        case 'Archive':
                                $this->in_archive = true;
                                switch($a_attribs['Access'])
                                {
                                        case 'Disabled':
                                                $this->course_obj->setArchiveType(IL_CRS_ARCHIVE_NONE);
                                                break;

                                        case 'Read':
                                                $this->course_obj->setArchiveType(IL_CRS_ARCHIVE_NONE);
                                                #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
                                                break;

                                        case 'Download':
                                                #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
                                                $this->course_obj->setArchiveType(IL_CRS_ARCHIVE_DOWNLOAD);
                                                break;
                                }
                                break;

                        case 'Disabled':
                                $this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
                                break;
                                
                        case "MetaData":
                                $this->in_meta_data = true;
                                parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
                                break;

                }
        }

Here is the call graph for this function:

ilCourseXMLParser::handlerCharacterData ( a_xml_parser,
a_data 
)

handler for character data

Parameters:
resource $a_xml_parser xml parser
string $a_data character data

Reimplemented from ilMDSaxParser.

Definition at line 428 of file class.ilCourseXMLParser.php.

        {
                // call meta data handler
                if($this->in_meta_data)
                {
                        parent::handlerCharacterData($a_xml_parser,$a_data);
                }
                if($a_data != "\n")
                {
                        // Replace multiple tabs with one space
                        $a_data = preg_replace("/\t+/"," ",$a_data);

                        $this->cdata .= $a_data;
                }


        }

ilCourseXMLParser::handlerEndTag ( a_xml_parser,
a_name 
)

handler for end of element

Parameters:
resource $a_xml_parser xml parser
string $a_name element name

Reimplemented from ilMDSaxParser.

Definition at line 323 of file class.ilCourseXMLParser.php.

        {
                if($this->in_meta_data)
                {
                        parent::handlerEndTag($a_xml_parser,$a_name);
                }

                switch($a_name)
                {
                        case 'Course':

                                $this->log->write('CourseXMLParser: import_id = '.$this->course_obj->getImportId());
                                $this->course_obj->updateSettings();
                                break;

                        case 'Settings':
                                $this->in_settings = false;
                                break;

                        case 'Availability':
                                $this->in_availability = false;
                                break;

                        case 'Registration':
                                $this->in_registration = false;
                                break;

                        case 'Archive':
                                $this->in_archive = false;
                                break;

                        case 'Start':
                                if($this->in_availability)
                                {
                                        $this->course_obj->setActivationStart(trim($this->cdata));
                                }
                                if($this->in_registration)
                                {
                                        $this->course_obj->setSubscriptionStart(trim($this->cdata));
                                }
                                if($this->in_archive)
                                {
                                        $this->course_obj->setArchiveStart(trim($this->cdata));
                                }
                                break;

                        case 'End':
                                if($this->in_availability)
                                {
                                        $this->course_obj->setActivationEnd(trim($this->cdata));
                                }
                                if($this->in_registration)
                                {
                                        $this->course_obj->setSubscriptionEnd(trim($this->cdata));
                                }
                                if($this->in_archive)
                                {
                                        $this->course_obj->setArchiveEnd(trim($this->cdata));
                                }
                                break;

                        case 'Syllabus':
                                $this->course_obj->setSyllabus(trim($this->cdata));
                                break;

                        case 'Name':
                                $this->course_obj->setContactName(trim($this->cdata));
                                break;

                        case 'Responsibility':
                                $this->course_obj->setContactResponsibility(trim($this->cdata));
                                break;

                        case 'Phone':
                                $this->course_obj->setContactPhone(trim($this->cdata));
                                break;

                        case 'Email':
                                $this->course_obj->setContactEmail(trim($this->cdata));
                                break;

                        case 'Consultation':
                                $this->course_obj->setContactConsultation(trim($this->cdata));
                                break;

                        case 'Password':
                                $this->course_obj->setSubscriptionPassword(trim($this->cdata));
                                break;

                        case 'MetaData':
                                $this->in_meta_data = false;
                                parent::handlerEndTag($a_xml_parser,$a_name);
                                break;
                }
                $this->cdata = '';

                return;
        }

ilCourseXMLParser::ilCourseXMLParser ( &$  a_course_obj,
a_xml_file = '' 
)

Constructor.

Parameters:
object $a_content_object must be of type ilObjContentObject ilObjTest or ilObjQuestionPool
string $a_xml_file xml file
string $a_subdir subdirectory in import directory public

Definition at line 56 of file class.ilCourseXMLParser.php.

References $ilLog, $lng, ilMDSaxParser::ilMDSaxParser(), and ilMDSaxParser::setMDObject().

        {
                global $lng,$ilLog;

                parent::ilMDSaxParser($a_xml_file);

                $this->log =& $ilLog;
                
                $this->course_obj =& $a_course_obj;
                $this->course_members = new ilCourseMembers($this->course_obj);
                $this->course_waiting_list = new ilCourseWaitingList($this->course_obj->getId());

                $this->md_obj = new ilMD($this->course_obj->getId(),0,'crs');
                
                $this->setMDObject($this->md_obj);

                $this->lng =& $lng;
        }

Here is the call graph for this function:

ilCourseXMLParser::setHandlers ( a_xml_parser  ) 

set event handlers

Parameters:
resource reference to the xml parser private

Reimplemented from ilMDSaxParser.

Definition at line 81 of file class.ilCourseXMLParser.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');
        }


Field Documentation

ilCourseXMLParser::$lng

Reimplemented from ilSaxParser.

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

Referenced by ilCourseXMLParser().

ilCourseXMLParser::$md_obj = null

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


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