3 declare(strict_types=1);
36 private int $mode = self::MODE_UNDEFINED;
66 public function setMode(
int $a_mode): void
68 $this->mode = $a_mode;
78 parent::startParsing();
79 if ($this->is_error) {
91 xml_set_object($a_xml_parser, $this);
92 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
93 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
103 case 'AdvancedMetaDataRecords':
104 $this->is_error =
false;
105 $this->error_msg = array();
120 $scope->setRefId((
int) $parsed_id[
'id']);
127 $this->current_field = null;
128 $this->current_record = null;
129 if (!strlen($a_attribs[
'id']) or !isset($a_attribs[
'active'])) {
139 if (isset($a_attribs[
'defaultLanguage'])) {
140 $language = (string) $a_attribs[
'defaultLanguage'];
149 case 'RecordTranslations':
150 $this->translations = [];
151 $this->field_translations = [];
153 $a_attribs[
'defaultLanguage'] ?? $this->
getCurrentRecord()->getDefaultLanguage()
157 case 'RecordTranslation':
158 $this->translation_language = $a_attribs[
'language'] ?? $this->
lng->getDefaultLanguage();
161 case 'FieldTranslations':
162 $this->field_translations[$this->
getCurrentField()->getImportId()] = [];
165 case 'FieldTranslation':
166 $this->field_translation_language = $a_attribs[
'language'] ?? $this->
lng->getDefaultLanguage();
173 if (!strlen($a_attribs[
'id']) or !isset($a_attribs[
'searchable']) or !isset($a_attribs[
'fieldType'])) {
176 if (!$this->
initFieldObject((
int) $a_attribs[
'id'], (
string) $a_attribs[
'fieldType'])) {
180 $this->
getCurrentField()->setSearchable($a_attribs[
'searchable'] ==
'Yes');
184 case 'FieldDescription':
185 case 'FieldPosition':
187 $this->field_value_id = (string) ($a_attribs[
'id'] ??
"");
199 case 'AdvancedMetaDataRecords':
220 $parts = explode(
":", trim($this->cdata));
227 case 'RecordTranslationTitle':
231 case 'RecordTranslationDescription':
235 case 'FieldTranslationTitle':
239 case 'FieldTranslationDescription':
247 case 'FieldDescription':
251 case 'FieldPosition':
256 $this->
getCurrentField()->importXMLProperty($this->field_value_id, trim($this->cdata));
269 if ($a_data !=
"\n") {
271 $a_data = preg_replace(
"/\t+/",
" ", $a_data);
273 $this->cdata .= $a_data;
280 case self::MODE_INSERT:
281 case self::MODE_INSERT_VALIDATION:
297 case self::MODE_INSERT:
298 case self::MODE_INSERT_VALIDATION:
305 'Current parsing mode is not supported. Mode: ' . $this->
getMode()
331 $this->is_error =
true;
332 $this->error_msg[] = $a_msg;
338 case self::MODE_INSERT_VALIDATION:
339 case self::MODE_UPDATE_VALIDATION:
342 case self::MODE_INSERT:
344 if (isset($this->context) && is_array($this->context)) {
348 "obj_type" => $this->context[
"obj_type"],
349 "sub_type" => $this->context[
"sub_type"],
358 foreach ($this->
fields as $field) {
361 case self::MODE_INSERT:
363 foreach ($this->field_translations as $field_id => $field_info) {
364 if (strcmp($field_id, $field->getImportId()) !== 0) {
367 foreach ((array) $field_info as $language => $field_translation) {
369 (
int) $field->getFieldId(),
370 (string) $field_translation[
'title'],
371 (
string) $field_translation[
'description'],
374 $translation->insert();
380 ", import id: " . $field->getImportId() .
", field id:" . $field->getFieldId());
381 $this->rec_map[$this->
getCurrentRecord()->getRecordId()][$field->getImportId()] = $field->getFieldId();
386 $translations->addTranslationEntry($this->
getCurrentRecord()->getDefaultLanguage(),
true);
387 $translations->updateTranslations(
393 foreach ($this->translations as $lang_key => $translation_info) {
394 if (!$translations->isConfigured($lang_key)) {
395 $translations->addTranslationEntry($lang_key);
397 $translations->updateTranslations(
399 (
string) $translation_info[
'title'],
400 (
string) $translation_info[
'description']
405 public function setContext(
int $a_obj_id,
string $a_obj_type, ?
string $a_sub_type = null): void
411 $this->context = array(
412 "obj_id" => $a_obj_id,
413 "obj_type" => $a_obj_type,
414 "sub_type" => $a_sub_type
Scope restrictions for advanced md records.
initFieldObject(int $a_id, string $a_type)
Init field definition object.
setHandlers($a_xml_parser)
set event handlers
initRecordObject(string $a_id)
ilAdvancedMDFieldDefinition $current_field
static getLogger(string $a_component_id)
Get component logger.
string $field_translation_language
ilAdvancedMDRecord $current_record
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
AMD field abstract base class.
__construct(string $a_file)
setContext(int $a_obj_id, string $a_obj_type, ?string $a_sub_type=null)
SaxParserException thrown by ilSaxParser if property throwException is set.
handlerEndTag($a_xml_parser, $a_name)
Handler for end tags protected.
handlerCharacterData($a_xml_parser, string $a_data)
handler for character data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstanceByRecordId(int $a_record_id)
static _lookupRecordIdByImportId(string $a_ilias_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
array $field_translations
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
Handler for start tags protected.
static lookupId(string $a_lang_key)
Lookup obj_id of language.
static parseImportId(string $a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
appendErrorMessage(string $a_msg)
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const MODE_UPDATE_VALIDATION
string $translation_language
const MODE_INSERT_VALIDATION
extractRecordId(string $a_id_string)
static getInstanceByTypeString(string $a_type)
Get instance by type string (used by import)
Class ilAdvancedMDFieldTranslation.
static getInstanceByRecordId(int $record_id)