ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilForumExporter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
29  protected \ILIAS\Style\Content\DomainService $content_style_domain;
30 
31  public function init(): void
32  {
33  global $DIC;
34  $this->content_style_domain = $DIC
35  ->contentStyle()
36  ->domain();
37  }
38 
39 
40  public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
41  {
42  $xml = '';
43 
44  if (ilObject::_lookupType((int) $a_id) === 'frm') {
45  $writer = new ilForumXMLWriter();
46  $writer->setForumId((int) $a_id);
48  $writer->setFileTargetDirectories($this->getRelativeExportDirectory(), $this->getAbsoluteExportDirectory());
49  $writer->start();
50  $xml .= $writer->getXML();
51  }
52 
53  return $xml;
54  }
55 
56  public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
57  {
58  $deps = [];
59 
60  if ('frm' === $a_entity) {
61  $deps[] = [
62  'component' => 'Services/Object',
63  'entity' => 'common',
64  'ids' => $a_ids
65  ];
66 
67  $deps[] = [
68  "component" => "Services/News",
69  "entity" => "news_settings",
70  "ids" => $a_ids
71  ];
72  }
73 
74  $pageObjectIds = [];
75  $styleIds = [];
76 
77  foreach ($a_ids as $frmObjId) {
78  $frm = ilObjectFactory::getInstanceByObjId($frmObjId, false);
79  if (!$frm || !($frm instanceof ilObjForum)) {
80  continue;
81  }
82 
83  $frmPageObjIds = $frm->getPageObjIds();
84  foreach ($frmPageObjIds as $frmPageObjId) {
85  $pageObjectIds[] = self::OBJ_TYPE . ':' . $frmPageObjId;
86  }
87 
88  $style_id = $this->content_style_domain->styleForObjId((int) $frmObjId)->getStyleId();
89  if ($style_id > 0) {
90  $styleIds[$style_id] = $style_id;
91  }
92  }
93 
94  if (count($pageObjectIds) > 0) {
95  $deps[] = [
96  'component' => 'Services/COPage',
97  'entity' => 'pg',
98  'ids' => $pageObjectIds,
99  ];
100  }
101 
102  if (count($styleIds) > 0) {
103  $deps[] = [
104  'component' => 'Services/Style',
105  'entity' => 'sty',
106  'ids' => array_values($styleIds),
107  ];
108  }
109 
110  return $deps;
111  }
112 
118  public function getValidSchemaVersions(string $a_entity): array
119  {
120  return [
121  "4.1.0" => [
122  "namespace" => "http://www.ilias.de/Modules/Forum/frm/4_1",
123  "xsd_file" => "ilias_frm_4_1.xsd",
124  "uses_dataset" => false,
125  "min" => "4.1.0",
126  "max" => "4.4.999"
127  ],
128  "4.5.0" => [
129  "namespace" => "http://www.ilias.de/Modules/Forum/frm/4_5",
130  "xsd_file" => "ilias_frm_4_5.xsd",
131  "uses_dataset" => false,
132  "min" => "4.5.0",
133  "max" => "5.0.999"
134  ],
135  "5.1.0" => [
136  "namespace" => "http://www.ilias.de/Modules/Forum/frm/5_1",
137  "xsd_file" => "ilias_frm_5_1.xsd",
138  "uses_dataset" => false,
139  "min" => "5.1.0",
140  "max" => "7.999"
141  ],
142  "8.0" => [
143  "namespace" => "http://www.ilias.de/Modules/Forum/frm/8",
144  "xsd_file" => "ilias_frm_8.xsd",
145  "uses_dataset" => false,
146  "min" => "8.0",
147  "max" => ""
148  ]
149  ];
150  }
151 }
getValidSchemaVersions(string $a_entity)
Returns schema versions that the component can export to.
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
XML writer class Class to simplify manual writing of xml documents.
global $DIC
Definition: feed.php:28
Exporter class for sessions.
$xml
Definition: metadata.php:351
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
ILIAS Style Content DomainService $content_style_domain
Class ilObjForum.
static _lookupType(int $id, bool $reference=false)