ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilAdvancedMDParser Class Reference

Adv MD XML Parser. More...

+ Inheritance diagram for ilAdvancedMDParser:
+ Collaboration diagram for ilAdvancedMDParser:

Public Member Functions

 __construct ($a_obj_id, $a_mapping)
 
 setHandlers ($a_xml_parser)
 set event handlers More...
 
 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...
 
 getRecordIds ()
 
- Public Member Functions inherited from ilMDSaxParser
 ilMDSaxParser ($a_xml_file='')
 Constructor. More...
 
 enableMDParsing ($a_status)
 
 getMDParsingStatus ()
 
 setMDObject (&$md)
 
getMDObject ()
 
 inMetaData ()
 
 setHandlers ($a_xml_parser)
 set event handlers More...
 
 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...
 
 __getCharacterData ()
 
 __pushParent (&$md_obj)
 
__popParent ()
 
__getParent ()
 
 ilMDSaxParser ($a_xml_file='')
 Constructor. More...
 
 setMDObject (&$md)
 
 inMetaData ()
 
 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...
 
 __getCharacterData ()
 
 __pushParent (&$md_obj)
 
__popParent ()
 
__getParent ()
 
- 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...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 Start element handler. More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 End element handler. More...
 
 handlerCharacterData ($a_xml_parser, $a_name)
 

Protected Member Functions

 initValue ($a_import_id, $a_sub_type="", $a_sub_id=0)
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Protected Attributes

 $obj_id
 
 $rec_id
 
 $mapping
 
 $cdata
 
 $value_records = array()
 
 $current_record
 
 $current_value
 
 $has_values
 
 $record_ids = array()
 

Additional Inherited Members

- Data Fields inherited from ilMDSaxParser
 $md_in_md = false
 
 $md_chr_data = ''
 
 $md_cur_el = null
 
 $md_parsing_enabled = null
 
 $md = null
 
 $md_gen
 
- 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()
 

Detailed Description

Adv MD XML Parser.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilCourseXMLParser.php 53320 2014-09-12 11:33:49Z fwolf

Definition at line 18 of file class.ilAdvancedMDParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDParser::__construct (   $a_obj_id,
  $a_mapping 
)

Definition at line 30 of file class.ilAdvancedMDParser.php.

31 {
32 parent::__construct();
33
34 $parts = explode(":", $a_obj_id);
35 $this->obj_id = $parts[0];
36 $this->mapping = $a_mapping;
37 }

Member Function Documentation

◆ getRecordIds()

ilAdvancedMDParser::getRecordIds ( )

Definition at line 152 of file class.ilAdvancedMDParser.php.

References $record_ids.

◆ handlerBeginTag()

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

handler for begin of element

Reimplemented from ilMDSaxParser.

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

47 {
48 switch($a_name)
49 {
50 case 'AdvancedMetaData':
51
52
53 break;
54
55 case 'Value':
56 $this->initValue($a_attribs['id'], $a_attribs['sub_type'], $a_attribs['sub_id']);
57 break;
58 }
59 }
initValue($a_import_id, $a_sub_type="", $a_sub_id=0)

References initValue().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilAdvancedMDParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Reimplemented from ilMDSaxParser.

Definition at line 84 of file class.ilAdvancedMDParser.php.

85 {
86 if($a_data != "\n")
87 {
88 // Replace multiple tabs with one space
89 $a_data = preg_replace("/\t+/"," ",$a_data);
90
91 $this->cdata .= $a_data;
92 }
93 }

◆ handlerEndTag()

ilAdvancedMDParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Reimplemented from ilMDSaxParser.

Definition at line 61 of file class.ilAdvancedMDParser.php.

62 {
63 switch($a_name)
64 {
65 case 'AdvancedMetaData':
66 // we need to write all records that have been created (1 for each sub-item)
67 foreach($this->value_records as $record)
68 {
69 $record->write();
70 }
71 break;
72
73 case 'Value':
74 $value = trim($this->cdata);
75 if(is_object($this->current_value) && $value != "")
76 {
77 $this->current_value->importValueFromXML($value);
78 }
79 break;
80 }
81 $this->cdata = '';
82 }

◆ initValue()

ilAdvancedMDParser::initValue (   $a_import_id,
  $a_sub_type = "",
  $a_sub_id = 0 
)
protected

Definition at line 95 of file class.ilAdvancedMDParser.php.

96 {
97 $this->current_value = null;
98
100 {
101 $rec_id = $field->getRecordId();
102
103 $new_parent_id = $this->mapping->getMapping("Services/AdvancedMetaData", "parent", $this->obj_id);
104 if(!$new_parent_id)
105 {
106 return;
107 }
108
109 if($a_sub_type)
110 {
111 $new_sub_id = $this->mapping->getMapping("Services/AdvancedMetaData", "advmd_sub_item", "advmd:".$a_sub_type.":".$a_sub_id);
112 if(!$new_sub_id)
113 {
114 return;
115 }
116
117 $rec_idx = $rec_id.";".$a_sub_type.";".$new_sub_id;
118 if(!array_key_exists($rec_idx, $this->value_records))
119 {
120 $this->value_records[$rec_idx] = new ilAdvancedMDValues($rec_id, $new_parent_id, $a_sub_type, $new_sub_id);
121 }
122 }
123 else
124 {
125 $rec_idx = $rec_id.";;";
126 if(!array_key_exists($rec_idx, $this->value_records))
127 {
128 $this->value_records[$rec_idx] = new ilAdvancedMDValues($rec_id, $new_parent_id);
129 }
130 }
131
132 // init ADTGroup before definitions to bind definitions to group
133 $this->value_records[$rec_idx]->getADTGroup();
134
135 foreach($this->value_records[$rec_idx]->getDefinitions() as $def)
136 {
137 if($a_import_id == $def->getImportId())
138 {
139 $this->current_value = $def;
140 break;
141 }
142 }
143
144 // valid field found, record will be imported
145 if($this->current_value)
146 {
147 $this->record_ids[$new_parent_id][$a_sub_type][] = $rec_id;
148 }
149 }
150 }
static getInstanceByImportId($a_import_id)
Get definition instance by import id.

References $rec_id, and ilAdvancedMDFieldDefinition\getInstanceByImportId().

Referenced by handlerBeginTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilAdvancedMDParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser @access private

Reimplemented from ilMDSaxParser.

Definition at line 39 of file class.ilAdvancedMDParser.php.

40 {
41 $this->sax_controller = new ilSaxController();
42 $this->sax_controller->setHandlers($a_xml_parser);
43 $this->sax_controller->setDefaultElementHandler($this);
44 }
Controller class for sax element handlers.

Field Documentation

◆ $cdata

ilAdvancedMDParser::$cdata
protected

Definition at line 23 of file class.ilAdvancedMDParser.php.

◆ $current_record

ilAdvancedMDParser::$current_record
protected

Definition at line 25 of file class.ilAdvancedMDParser.php.

◆ $current_value

ilAdvancedMDParser::$current_value
protected

Definition at line 26 of file class.ilAdvancedMDParser.php.

◆ $has_values

ilAdvancedMDParser::$has_values
protected

Definition at line 27 of file class.ilAdvancedMDParser.php.

◆ $mapping

ilAdvancedMDParser::$mapping
protected

Definition at line 22 of file class.ilAdvancedMDParser.php.

◆ $obj_id

ilAdvancedMDParser::$obj_id
protected

Definition at line 20 of file class.ilAdvancedMDParser.php.

◆ $rec_id

ilAdvancedMDParser::$rec_id
protected

Definition at line 21 of file class.ilAdvancedMDParser.php.

Referenced by initValue().

◆ $record_ids

ilAdvancedMDParser::$record_ids = array()
protected

Definition at line 28 of file class.ilAdvancedMDParser.php.

Referenced by getRecordIds().

◆ $value_records

ilAdvancedMDParser::$value_records = array()
protected

Definition at line 24 of file class.ilAdvancedMDParser.php.


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