ILIAS  release_8 Revision v8.23
class.ilWikiExporter.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  private ilWikiDataSet $ds;
27  protected \ILIAS\Style\Content\DomainService $content_style_domain;
28  protected ilLogger $wiki_log;
29 
30  public function init(): void
31  {
32  global $DIC;
33 
34  $this->ds = new ilWikiDataSet();
35  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
36  $this->ds->setDSPrefix("ds");
37  $this->wiki_log = ilLoggerFactory::getLogger('wiki');
38  $this->content_style_domain = $DIC->contentStyle()
39  ->domain();
40  }
41 
43  string $a_entity,
44  string $a_target_release,
45  array $a_ids
46  ): array {
47  $pg_ids = array();
48  foreach ($a_ids as $id) {
49  $pages = ilWikiPage::getAllWikiPages($id);
50  foreach ($pages as $p) {
51  if (ilWikiPage::_exists("wpg", $p["id"])) {
52  $pg_ids[] = "wpg:" . $p["id"];
53  }
54  }
55  }
56 
57  $deps = array(
58  array(
59  "component" => "Services/COPage",
60  "entity" => "pg",
61  "ids" => $pg_ids),
62  array(
63  "component" => "Services/Rating",
64  "entity" => "rating_category",
65  "ids" => $a_ids
66  )
67  );
68 
69  $advmd_ids = array();
70  foreach ($a_ids as $id) {
71  $rec_ids = $this->getActiveAdvMDRecords($id);
72  $this->wiki_log->debug("advmd rec ids: wiki id:" . $id . ", adv rec ids" . print_r($rec_ids, true));
73  if (count($rec_ids)) {
74  foreach ($rec_ids as $rec_id) {
75  $advmd_ids[] = $id . ":" . $rec_id;
76  }
77  }
78  }
79 
80  $this->wiki_log->debug("advmd ids: " . print_r($advmd_ids, true));
81 
82  if (count($advmd_ids)) {
83  $deps[] = array(
84  "component" => "Services/AdvancedMetaData",
85  "entity" => "advmd",
86  "ids" => $advmd_ids
87  );
88  }
89 
90  // style
91  /*
92  $obj_ids = (is_array($a_ids))
93  ? $a_ids
94  : array($a_ids);
95  $deps[] = array(
96  "component" => "Services/Style",
97  "entity" => "object_style",
98  "ids" => $obj_ids
99  );*/
100 
101  // style
102  foreach ($a_ids as $id) {
103  $style_id = $this->content_style_domain->styleForObjId($id)->getStyleId();
104  if ($style_id > 0) {
105  $deps[] = array(
106  "component" => "Services/Style",
107  "entity" => "sty",
108  "ids" => $style_id
109  );
110  }
111  }
112 
113  // service settings
114  $deps[] = array(
115  "component" => "Services/Object",
116  "entity" => "common",
117  "ids" => $a_ids);
118 
119  return $deps;
120  }
121 
122  protected function getActiveAdvMDRecords(int $a_id): array
123  {
124  $active = array();
125  // selected globals
126  $sel_globals = ilAdvancedMDRecord::getObjRecSelection($a_id, "wpg");
127 
128  foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType("wiki", "wpg") as $record_obj) {
129  // local ones and globally activated for the object
130  if ($record_obj->getParentObject() === $a_id || in_array($record_obj->getRecordId(), $sel_globals)) {
131  $active[] = $record_obj->getRecordId();
132  }
133  }
134 
135  $this->wiki_log->debug("active md rec: " . print_r($active, true));
136 
137  return $active;
138  }
139 
140  public function getXmlRepresentation(
141  string $a_entity,
142  string $a_schema_version,
143  string $a_id
144  ): string {
145  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], "", true, true);
146  }
147 
148  public function getValidSchemaVersions(string $a_entity): array
149  {
150  return array(
151  "5.4.0" => array(
152  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/5_4",
153  "xsd_file" => "ilias_wiki_5_4.xsd",
154  "uses_dataset" => true,
155  "min" => "5.4.0",
156  "max" => ""),
157  "4.1.0" => array(
158  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/4_1",
159  "xsd_file" => "ilias_wiki_4_1.xsd",
160  "uses_dataset" => true,
161  "min" => "4.1.0",
162  "max" => "4.2.99"),
163  "4.3.0" => array(
164  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/4_3",
165  "xsd_file" => "ilias_wiki_4_3.xsd",
166  "uses_dataset" => true,
167  "min" => "4.3.0",
168  "max" => "4.3.99"),
169  "4.4.0" => array(
170  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/4_4",
171  "xsd_file" => "ilias_wiki_4_4.xsd",
172  "uses_dataset" => true,
173  "min" => "4.4.0",
174  "max" => "5.0.99"),
175  "5.1.0" => array(
176  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/5_1",
177  "xsd_file" => "ilias_wiki_5_1.xsd",
178  "uses_dataset" => true,
179  "min" => "5.1.0",
180  "max" => "5.3.99")
181  );
182  }
183 }
getValidSchemaVersions(string $a_entity)
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
static getLogger(string $a_component_id)
Get component logger.
static _getActivatedRecordsByObjectType(string $a_obj_type, string $a_sub_type="", bool $a_only_optional=false)
Get activated records by object type.
static getAllWikiPages(int $a_wiki_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
getActiveAdvMDRecords(int $a_id)
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Style Content DomainService $content_style_domain
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23