ILIAS  release_8 Revision v8.24
class.ilContentPageDataSet.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
27 protected array $newMobIds = [];
28
29 public function getSupportedVersions(): array
30 {
31 return [
32 '5.4.0',
33 ];
34 }
35
36 protected function getXmlNamespace(string $a_entity, string $a_schema_version): string
37 {
38 return 'http://www.ilias.de/xml/Modules/ContentPage/' . $a_entity;
39 }
40
41 protected function getTypes(string $a_entity, string $a_version): array
42 {
43 switch ($a_entity) {
44 case self::OBJ_TYPE:
45 return [
46 'id' => 'integer',
47 'title' => 'text',
48 'description' => 'text',
49 'info-tab' => 'integer'
50 ];
51
52 default:
53 return [];
54 }
55 }
56
57 public function readData(string $a_entity, string $a_version, array $a_ids): void
58 {
59 $this->data = [];
60
61 if (!is_array($a_ids)) {
62 $a_ids = [$a_ids];
63 }
64
65 $this->readEntityData($a_entity, $a_ids);
66 }
67
68
73 protected function readEntityData(string $entity, array $ids): void
74 {
75 switch ($entity) {
76 case self::OBJ_TYPE:
77 foreach ($ids as $objId) {
78 if (ilObject::_lookupType((int) $objId) === self::OBJ_TYPE) {
81
82 $this->data[] = [
83 'id' => $obj->getId(),
84 'title' => $obj->getTitle(),
85 'description' => $obj->getDescription(),
86 'info-tab' => (string) ((bool) ilContainer::_lookupContainerSetting(
87 $obj->getId(),
89 '1'
90 ))
91 ];
92 }
93 }
94 break;
95
96 default:
97 break;
98 }
99 }
100
101 public function importRecord(
102 string $a_entity,
103 array $a_types,
104 array $a_rec,
105 ilImportMapping $a_mapping,
106 string $a_schema_version
107 ): void {
108 switch ($a_entity) {
109 case self::OBJ_TYPE:
110 if ($newObjId = $a_mapping->getMapping('Services/Container', 'objs', (string) $a_rec['id'])) {
111 $newObject = ilObjectFactory::getInstanceByObjId((int) $newObjId, false);
112 } else {
113 $newObject = new ilObjContentPage();
114 }
115
116 $newObject->setTitle(ilUtil::stripSlashes($a_rec['title']));
117 $newObject->setDescription(ilUtil::stripSlashes($a_rec['description']));
118
119 if (!$newObject->getId()) {
120 $newObject->create();
121 }
122
124 $newObject->getId(),
126 (string) ((bool) $a_rec['info-tab'])
127 );
128
129 $a_mapping->addMapping(
130 'Modules/ContentPage',
131 self::OBJ_TYPE,
132 (string) $a_rec['id'],
133 (string) $newObject->getId()
134 );
135 $a_mapping->addMapping(
136 'Services/COPage',
137 'pg',
138 self::OBJ_TYPE . ':' . $a_rec['id'],
139 self::OBJ_TYPE . ':' . $newObject->getId()
140 );
141 break;
142 }
143 }
144}
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
Class ilContentPageDataSet.
getXmlNamespace(string $a_entity, string $a_schema_version)
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Needs to be overwritten for import use case.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $entity
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType(int $id, bool $reference=false)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
Interface ilContentPageObjectConstants.
$objId
Definition: xapitoken.php:57