forked from fneumann/TestPageComponent
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclass.ilTestPageComponentImporter.php
More file actions
71 lines (61 loc) · 2.16 KB
/
class.ilTestPageComponentImporter.php
File metadata and controls
71 lines (61 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/
/**
* Exporter class for the TestPageComponent Plugin
* @author Fred Neumann <fred.neumann@gmx.de>
*/
class ilTestPageComponentImporter extends ilPageComponentPluginImporter
{
public function init() : void
{
}
/**
* Import xml representation
* @param string $a_entity
* @param string $a_id
* @param string $a_xml
* @param ilImportMapping $a_mapping
*/
public function importXmlRepresentation(
string $a_entity,
string $a_id,
string $a_xml,
ilImportMapping $a_mapping
) : void {
global $DIC;
/** @var ilComponentFactory $component_factory */
$component_factory = $DIC["component.factory"];
/** @var ilTestPageComponentPlugin $plugin */
$plugin = $component_factory->getPlugin("pctpc");
$new_id = self::getPCMapping($a_id, $a_mapping);
$properties = self::getPCProperties($new_id);
$version = self::getPCVersion($new_id);
// write the mapped file id to the properties
if ($old_file_id = $properties['page_file']) {
$new_file_id = $a_mapping->getMapping("components/ILIAS/File", 'file', $old_file_id);
$properties['page_file'] = $new_file_id;
}
// save the data from the imported xml and write its id to the properties
if ($additional_data_id = $properties['additional_data_id']) {
$data = html_entity_decode(substr($a_xml, 6, -7));
$id = $plugin->saveData($data);
$properties['additional_data_id'] = $id;
}
self::setPCProperties($new_id, $properties);
self::setPCVersion($new_id, $version);
}
}