34 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
35 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
69 parent::__construct($a_file,
true);
82 $this->mode = $a_mode;
106 parent::startParsing();
107 if ($this->is_error) {
108 include_once(
'./Services/Xml/exceptions/class.ilSaxParserException.php');
121 xml_set_object($a_xml_parser, $this);
122 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
123 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
134 case 'AdvancedMetaDataRecords':
135 $this->is_error =
false;
136 $this->error_msg =
array();
147 $parsed_id[
'inst_id'] == IL_INST_ID &&
151 $scope->setRefId($parsed_id[
'id']);
152 $this->scopes[] = $scope;
159 $this->current_field = null;
160 $this->current_record = null;
161 if (!strlen($a_attribs[
'id']) or !isset($a_attribs[
'active'])) {
176 if (!strlen($a_attribs[
'id']) or !isset($a_attribs[
'searchable']) or !isset($a_attribs[
'fieldType'])) {
179 if (!$this->
initFieldObject($a_attribs[
'id'], $a_attribs[
'fieldType'])) {
183 $this->
getCurrentField()->setSearchable($a_attribs[
'searchable'] ==
'Yes' ?
true :
false);
187 case 'FieldDescription':
188 case 'FieldPosition':
190 $this->field_value_id = $a_attribs[
'id'];
203 case 'AdvancedMetaDataRecords':
224 $parts = explode(
":", trim($this->cdata));
236 case 'FieldDescription':
240 case 'FieldPosition':
245 $this->
getCurrentField()->importXMLProperty($this->field_value_id, trim($this->cdata));
259 if ($a_data !=
"\n") {
261 $a_data = preg_replace(
"/\t+/",
" ", $a_data);
263 $this->cdata .= $a_data;
277 case self::MODE_INSERT:
278 case self::MODE_INSERT_VALIDATION:
299 case self::MODE_INSERT:
300 case self::MODE_INSERT_VALIDATION:
302 $this->
fields[] = $this->current_field;
307 $this->current_field = ilAdvancedMDRecord::_getInstanceByFieldId($this->extractFieldId($a_id));
323 return $this->current_record;
333 return $this->current_field;
347 $this->record_exists =
true;
364 $this->is_error =
true;
365 $this->error_msg[] = $a_msg;
378 case self::MODE_INSERT_VALIDATION:
379 case self::MODE_UPDATE_VALIDATION:
382 case self::MODE_INSERT:
384 if (is_array($this->context)) {
388 "obj_type" => $this->context[
"obj_type"],
389 "sub_type" => $this->context[
"sub_type"],
397 foreach ($this->
fields as $field) {
400 case self::MODE_INSERT:
404 $this->log->debug(
"add to record map, rec id: " . $this->
getCurrentRecord()->getRecordId() .
405 ", import id: " . $field->getImportId() .
", field id:" . $field->getFieldId());
406 $this->rec_map[$this->
getCurrentRecord()->getRecordId()][$field->getImportId()] = $field->getFieldId();
412 public function setContext($a_obj_id, $a_obj_type, $a_sub_type = null)
418 $this->context =
array(
419 "obj_id" => $a_obj_id,
420 "obj_type" => $a_obj_type,
421 "sub_type" => $a_sub_type
427 return $this->rec_map;
Scope restrictions for advanced md records.
setHandlers($a_xml_parser)
set event handlers
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
initFieldObject($a_id, $a_type)
Init field definition object.
appendErrorMessage($a_msg)
private
setMode($a_mode)
set parsing mode
storeRecords()
Store Record.
static parseImportId($a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
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.