ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilWikiExporter.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  private ilWikiDataSet $ds;
27  protected \ILIAS\Wiki\InternalRepoService $page_repo;
28  protected \ILIAS\Style\Content\DomainService $content_style_domain;
29  protected ilLogger $wiki_log;
30 
31  public function init(): void
32  {
33  global $DIC;
34 
35  $repo = $DIC->wiki()->internal()->repo();
36  $this->ds = new ilWikiDataSet();
37  $this->ds->initByExporter($this);
38  $this->ds->setDSPrefix("ds");
39  $this->wiki_log = ilLoggerFactory::getLogger('wiki');
40  $this->content_style_domain = $DIC->contentStyle()
41  ->domain();
42  $this->page_repo = $repo;
43  }
44 
46  string $a_entity,
47  string $a_target_release,
48  array $a_ids
49  ): array {
50  $pg_ids = array();
51  foreach ($a_ids as $id) {
52  foreach ($this->page_repo->page()->getWikiPages($id) as $page) {
53  if ($this->page_repo->page()->exists($page->getId())) {
54  $pg_ids[] = "wpg:" . $page->getId();
55  }
56  }
57  }
58 
59  $deps = array(
60  array(
61  "component" => "components/ILIAS/COPage",
62  "entity" => "pg",
63  "ids" => $pg_ids),
64  array(
65  "component" => "components/ILIAS/Rating",
66  "entity" => "rating_category",
67  "ids" => $a_ids
68  )
69  );
70 
71  $advmd_ids = array();
72  foreach ($a_ids as $id) {
73  $rec_ids = $this->getActiveAdvMDRecords($id);
74  $this->wiki_log->debug("advmd rec ids: wiki id:" . $id . ", adv rec ids" . print_r($rec_ids, true));
75  if (count($rec_ids)) {
76  foreach ($rec_ids as $rec_id) {
77  $advmd_ids[] = $id . ":" . $rec_id;
78  }
79  }
80  }
81 
82  $this->wiki_log->debug("advmd ids: " . print_r($advmd_ids, true));
83 
84  if (count($advmd_ids)) {
85  $deps[] = array(
86  "component" => "components/ILIAS/AdvancedMetaData",
87  "entity" => "advmd",
88  "ids" => $advmd_ids
89  );
90  }
91 
92  // style
93  /*
94  $obj_ids = (is_array($a_ids))
95  ? $a_ids
96  : array($a_ids);
97  $deps[] = array(
98  "component" => "components/ILIAS/Style",
99  "entity" => "object_style",
100  "ids" => $obj_ids
101  );*/
102 
103  // style
104  foreach ($a_ids as $id) {
105  $style_id = $this->content_style_domain->styleForObjId($id)->getExportStyleId();
106  if ($style_id > 0) {
107  $deps[] = array(
108  "component" => "components/ILIAS/Style",
109  "entity" => "sty",
110  "ids" => $style_id
111  );
112  }
113  }
114 
115  // service settings
116  $deps[] = array(
117  "component" => "components/ILIAS/ILIASObject",
118  "entity" => "common",
119  "ids" => $a_ids);
120 
121  return $deps;
122  }
123 
124  protected function getActiveAdvMDRecords(int $a_id): array
125  {
126  $active = array();
127  // selected globals
128  $sel_globals = ilAdvancedMDRecord::getObjRecSelection($a_id, "wpg");
129 
130  foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType("wiki", "wpg") as $record_obj) {
131  // local ones and globally activated for the object
132  if ($record_obj->getParentObject() === $a_id || in_array($record_obj->getRecordId(), $sel_globals)) {
133  $active[] = $record_obj->getRecordId();
134  }
135  }
136 
137  $this->wiki_log->debug("active md rec: " . print_r($active, true));
138 
139  return $active;
140  }
141 
142  public function getXmlRepresentation(
143  string $a_entity,
144  string $a_schema_version,
145  string $a_id
146  ): string {
147  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], "", true, true);
148  }
149 
150  public function getValidSchemaVersions(string $a_entity): array
151  {
152  return array(
153  "5.4.0" => array(
154  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/5_4",
155  "xsd_file" => "ilias_wiki_5_4.xsd",
156  "uses_dataset" => true,
157  "min" => "5.4.0",
158  "max" => ""),
159  "4.1.0" => array(
160  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/4_1",
161  "xsd_file" => "ilias_wiki_4_1.xsd",
162  "uses_dataset" => true,
163  "min" => "4.1.0",
164  "max" => "4.2.99"),
165  "4.3.0" => array(
166  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/4_3",
167  "xsd_file" => "ilias_wiki_4_3.xsd",
168  "uses_dataset" => true,
169  "min" => "4.3.0",
170  "max" => "4.3.99"),
171  "4.4.0" => array(
172  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/4_4",
173  "xsd_file" => "ilias_wiki_4_4.xsd",
174  "uses_dataset" => true,
175  "min" => "4.4.0",
176  "max" => "5.0.99"),
177  "5.1.0" => array(
178  "namespace" => "https://www.ilias.de/Modules/Wiki/wiki/5_1",
179  "xsd_file" => "ilias_wiki_5_1.xsd",
180  "uses_dataset" => true,
181  "min" => "5.1.0",
182  "max" => "5.3.99")
183  );
184  }
185 }
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.
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...
global $DIC
Definition: shib_login.php:22
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
ILIAS Wiki InternalRepoService $page_repo