34 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
35 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
67 parent::__construct($a_file,
true);
80 $this->mode = $a_mode;
104 parent::startParsing();
107 include_once(
'./Services/Xml/exceptions/class.ilSaxParserException.php');
120 xml_set_object($a_xml_parser,$this);
121 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
122 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
134 case 'AdvancedMetaDataRecords':
135 $this->is_error =
false;
136 $this->error_msg =
array();
142 $this->current_field = null;
143 $this->current_record = null;
144 if(!strlen($a_attribs[
'id'])
or !isset($a_attribs[
'active']))
161 if(!strlen($a_attribs[
'id'])
or !isset($a_attribs[
'searchable'])
or !isset($a_attribs[
'fieldType']))
170 $this->
getCurrentField()->setSearchable($a_attribs[
'searchable'] ==
'Yes' ?
true :
false);
174 case 'FieldDescription':
175 case 'FieldPosition':
177 $this->field_value_id = $a_attribs[
'id'];
191 case 'AdvancedMetaDataRecords':
208 $parts = explode(
":", trim($this->cdata));
220 case 'FieldDescription':
224 case 'FieldPosition':
229 $this->
getCurrentField()->importXMLProperty($this->field_value_id, trim($this->cdata));
246 $a_data = preg_replace(
"/\t+/",
" ",$a_data);
248 $this->cdata .= $a_data;
263 case self::MODE_INSERT:
264 case self::MODE_INSERT_VALIDATION:
286 case self::MODE_INSERT:
287 case self::MODE_INSERT_VALIDATION:
289 $this->
fields[] = $this->current_field;
294 $this->current_field = ilAdvancedMDRecord::_getInstanceByFieldId($this->extractFieldId($a_id));
310 return $this->current_record;
320 return $this->current_field;
335 $this->record_exists =
true;
352 $this->is_error =
true;
353 $this->error_msg[] = $a_msg;
367 case self::MODE_INSERT_VALIDATION:
368 case self::MODE_UPDATE_VALIDATION:
371 case self::MODE_INSERT:
373 if(is_array($this->context))
378 "obj_type" => $this->context[
"obj_type"],
379 "sub_type" => $this->context[
"sub_type"],
387 foreach($this->
fields as $field)
392 case self::MODE_INSERT:
396 $this->log->debug(
"add to record map, rec id: ".$this->
getCurrentRecord()->getRecordId().
397 ", import id: ".$field->getImportId().
", field id:".$field->getFieldId());
398 $this->rec_map[$this->
getCurrentRecord()->getRecordId()][$field->getImportId()] = $field->getFieldId();
404 public function setContext($a_obj_id, $a_obj_type, $a_sub_type = null)
411 $this->context =
array(
412 "obj_id" => $a_obj_id,
413 "obj_type" => $a_obj_type,
414 "sub_type" => $a_sub_type
420 return $this->rec_map;
setHandlers($a_xml_parser)
set event handlers
initFieldObject($a_id, $a_type)
Init field definition object.
appendErrorMessage($a_msg)
private
setMode($a_mode)
set parsing mode
storeRecords()
Store Record.
SaxParserException thrown by ilSaxParser if property throwException is set.
handlerEndTag($a_xml_parser, $a_name)
Handler for end tags.
__construct($a_file)
Constructor.
startParsing()
stores xml data in array
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
Handler for start tags.
extractRecordId($a_id_string)
Extract id.
getCurrentRecord()
get current record
Create styles array
The data for the language used.
initRecordObject($a_id)
Init record object.
setContext($a_obj_id, $a_obj_type, $a_sub_type=null)
getCurrentField()
get current field definition private
static getLogger($a_component_id)
Get component logger.
SAX based XML parser for record import files.
const MODE_UPDATE_VALIDATION
static getInstanceByTypeString($a_type)
Get instance by type string (used by import)
const MODE_INSERT_VALIDATION
static _lookupRecordIdByImportId($a_ilias_id)
Lookup record Id by import id.