4 include_once(
"Services/Xml/classes/class.ilSaxParser.php");
5 include_once(
"Services/Utilities/classes/class.ilSaxController.php");
6 include_once(
"Services/Utilities/interfaces/interface.ilSaxSubsetParser.php");
7 include_once(
"Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php");
8 include_once(
"Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php");
42 parent::__construct();
46 $parts = explode(
":", $a_obj_id);
47 $this->obj_id = $parts[0];
48 $this->mapping = $a_mapping;
54 $this->sax_controller->setHandlers($a_xml_parser);
55 $this->sax_controller->setDefaultElementHandler($this);
61 file_put_contents($tmp_file, $a_xml);
67 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
75 catch(ilSAXParserException $exc)
83 foreach($map as $record_id => $fields)
85 $this->local_rec_fields_map[$record_id] = $fields;
88 foreach($fields as $import_id => $new_id)
90 $old_id = array_pop(explode(
"_", $import_id));
91 $this->mapping->addMapping(
"Services/AdvancedMetaData",
"lfld", $old_id, $new_id);
95 $new_id = array_shift(array_keys($map));
96 $this->local_rec_map[$a_old_id] = $new_id;
103 case 'AdvancedMetaData':
107 $this->local_record =
array(
'id'=>$a_attribs[
'local_id']);
111 $this->
initValue($a_attribs[
'id'], $a_attribs[
'sub_type'], $a_attribs[
'sub_id'], $a_attribs[
'local_rec_id']);
120 case 'AdvancedMetaData':
122 foreach($this->value_records as $record)
129 $this->local_record[
'xml'] = base64_decode(trim($this->cdata));
130 $this->log->debug(
"Local Record XML: ".$this->local_record[
'xml']);
134 $value = trim($this->cdata);
135 $this->log->debug(
"End Tag Value: -".is_object($this->current_value).
"-".$value);
136 if(is_object($this->current_value) && $value !=
"")
138 $this->current_value->importValueFromXML($value);
150 $a_data = preg_replace(
"/\t+/",
" ",$a_data);
152 $this->cdata .= $a_data;
156 protected function initValue($a_import_id, $a_sub_type =
"", $a_sub_id = 0, $a_local_rec_id = null)
158 $this->current_value = null;
161 $new_parent_id = $this->mapping->getMapping(
"Services/AdvancedMetaData",
"parent", $this->obj_id);
168 $new_sub_id = $this->mapping->getMapping(
"Services/AdvancedMetaData",
"advmd_sub_item",
"advmd:".$a_sub_type.
":".$a_sub_id);
177 if(is_array($this->local_record))
179 $this->
createLocalRecord($this->local_record[
'id'], $this->local_record[
'xml'], $new_parent_id, $a_sub_type);
180 $this->local_record = null;
190 $rec_id = $field->getRecordId();
196 $rec_id = $this->local_rec_map[$a_local_rec_id];
207 $rec_idx =
$rec_id.
";".$a_sub_type.
";".$new_sub_id;
208 if(!array_key_exists($rec_idx, $this->value_records))
216 if(!array_key_exists($rec_idx, $this->value_records))
223 $this->value_records[$rec_idx]->getADTGroup();
226 $this->log->debug(
"Find element: ".$a_import_id.
", local rec_id: ".$a_local_rec_id);
229 foreach($this->value_records[$rec_idx]->getDefinitions() as $def)
231 if($a_import_id == $def->getImportId())
233 $this->current_value = $def;
241 $field_id = $this->local_rec_fields_map[
$rec_id][$a_import_id];
244 $this->log->debug(
"- Field id: ".$field_id);
245 foreach($this->value_records[$rec_idx]->getDefinitions() as $def)
247 $this->log->debug(
"- Def field id: ".$def->getFieldId());
248 if($field_id == $def->getFieldId())
250 $this->current_value = $def;
257 $this->log->debug(
"- No Field id. local rec: ".$a_local_rec_id.
258 ", rec id:".$rec_id.
", import id: ".$a_import_id.
", map: ".print_r($this->local_rec_fields_map,
true));
264 if($this->current_value &&
267 $this->record_ids[$new_parent_id][$a_sub_type][] =
$rec_id;
createLocalRecord($a_old_id, $a_xml, $a_obj_id, $a_sub_type=null)
initValue($a_import_id, $a_sub_type="", $a_sub_id=0, $a_local_rec_id=null)
static getInstanceByImportId($a_import_id)
Get definition instance by import id.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
setHandlers($a_xml_parser)
handlerEndTag($a_xml_parser, $a_name)
End element handler.
__construct($a_obj_id, $a_mapping)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
Interface definition for sax subset parsers.
Controller class for sax element handlers.
handlerCharacterData($a_xml_parser, $a_data)
Character data handler.
static getLogger($a_component_id)
Get component logger.
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
Start element handler.
SAX based XML parser for record import files.
const MODE_INSERT_VALIDATION