4include_once(
"Services/Xml/classes/class.ilSaxParser.php");
 
    5include_once(
"Services/Utilities/classes/class.ilSaxController.php");
 
    6include_once(
"Services/Utilities/interfaces/interface.ilSaxSubsetParser.php");
 
    7include_once(
"Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php");
 
    8include_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);
 
   66            include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
 
   73        } 
catch (ilSAXParserException $exc) {
 
   79        foreach (
$map as $record_id => $fields) {
 
   80            $this->local_rec_fields_map[$record_id] = $fields;
 
   83            foreach ($fields as $import_id => $new_id) {
 
   84                $old_id = array_pop(explode(
"_", $import_id));
 
   85                $this->mapping->addMapping(
"Services/AdvancedMetaData", 
"lfld", $old_id, $new_id);
 
   89        $new_id = array_shift(array_keys(
$map));
 
   90        $this->local_rec_map[$a_old_id] = $new_id;
 
   96            case 'AdvancedMetaData':
 
  100                $this->local_record = array(
'id' => $a_attribs[
'local_id']);
 
  104                $this->
initValue($a_attribs[
'id'], $a_attribs[
'sub_type'], $a_attribs[
'sub_id'], $a_attribs[
'local_rec_id']);
 
  112            case 'AdvancedMetaData':
 
  114                foreach ($this->value_records as $record) {
 
  120                $this->local_record[
'xml'] = base64_decode(trim($this->cdata));
 
  121                $this->log->debug(
"Local Record XML: " . $this->local_record[
'xml']);
 
  125                $value = trim($this->cdata);
 
  126                $this->log->debug(
"End Tag Value: -" . is_object($this->current_value) . 
"-" . $value);
 
  127                if (is_object($this->current_value) && $value != 
"") {
 
  128                    $this->current_value->importValueFromXML($value);
 
  137        if ($a_data != 
"\n") {
 
  139            $a_data = preg_replace(
"/\t+/", 
" ", $a_data);
 
  141            $this->cdata .= $a_data;
 
  145    protected function initValue($a_import_id, $a_sub_type = 
"", $a_sub_id = 0, $a_local_rec_id = 
null)
 
  147        $this->current_value = 
null;
 
  150        $new_parent_id = $this->mapping->getMapping(
"Services/AdvancedMetaData", 
"parent", $this->obj_id);
 
  151        $this->log->notice(
'Found new parent id:' . $new_parent_id);
 
  152        if (!$new_parent_id) {
 
  157            strcmp($a_sub_type, 
'-') !== 0
 
  159            $new_sub_id = $this->mapping->getMapping(
"Services/AdvancedMetaData", 
"advmd_sub_item", 
"advmd:" . $a_sub_type . 
":" . $a_sub_id);
 
  167        if (is_array($this->local_record)) {
 
  168            $this->
createLocalRecord($this->local_record[
'id'], $this->local_record[
'xml'], $new_parent_id, $a_sub_type);
 
  169            $this->local_record = 
null;
 
  175        if (!$a_local_rec_id) {
 
  177                $rec_id = $field->getRecordId();
 
  182            $rec_id = $this->local_rec_map[$a_local_rec_id];
 
  191            $rec_idx = 
$rec_id . 
";" . $a_sub_type . 
";" . $new_sub_id;
 
  192            if (!array_key_exists($rec_idx, $this->value_records)) {
 
  197            if (!array_key_exists($rec_idx, $this->value_records)) {
 
  203        $this->value_records[$rec_idx]->getADTGroup();
 
  206        $this->log->debug(
"Find element: " . $a_import_id . 
", local rec_id: " . $a_local_rec_id);
 
  207        if (!$a_local_rec_id) {
 
  208            foreach ($this->value_records[$rec_idx]->getDefinitions() as 
$def) {
 
  209                if ($a_import_id == 
$def->getImportId()) {
 
  210                    $this->current_value = 
$def;
 
  216            $field_id = $this->local_rec_fields_map[
$rec_id][$a_import_id];
 
  218                $this->log->debug(
"- Field id: " . $field_id);
 
  219                foreach ($this->value_records[$rec_idx]->getDefinitions() as 
$def) {
 
  220                    $this->log->debug(
"- Def field id: " . 
$def->getFieldId());
 
  221                    if ($field_id == 
$def->getFieldId()) {
 
  222                        $this->current_value = 
$def;
 
  227                $this->log->debug(
"- No Field id. local rec: " . $a_local_rec_id .
 
  228                    ", rec id:" . 
$rec_id . 
", import id: " . $a_import_id . 
", map: " . print_r($this->local_rec_fields_map, 
true));
 
  234        if ($this->current_value &&
 
  236            $this->record_ids[$new_parent_id][$a_sub_type][] = 
$rec_id;
 
An exception for terminatinating execution or to throw for unit testing.
static getInstanceByImportId($a_import_id)
Get definition instance by import id.
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
setHandlers($a_xml_parser)
set event handlers
__construct($a_obj_id, $a_mapping)
Constructor setup ILIAS global object @access public.
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
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)
SAX based XML parser for record import files.
const MODE_INSERT_VALIDATION
static getLogger($a_component_id)
Get component logger.
static _lookupType($a_id, $a_reference=false)
lookup object type
Controller class for sax element handlers.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
Interface definition for sax subset parsers.