ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilContainerReferenceXmlWriter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 public const MODE_SOAP = 1;
29 public const MODE_EXPORT = 2;
30
32
33 private int $mode = self::MODE_SOAP;
35
36 public function __construct(?ilContainerReference $ref = null)
37 {
38 global $DIC;
39
40 $this->settings = $DIC->settings();
42 $this->ref = $ref;
43 }
44
45 public function setMode(int $a_mode): void
46 {
47 $this->mode = $a_mode;
48 }
49
50 public function getMode(): int
51 {
52 return $this->mode;
53 }
54
56 {
57 return $this->ref;
58 }
59
60 public function export(bool $a_with_header = true): void
61 {
62 if ($this->getMode() === self::MODE_EXPORT) {
63 if ($a_with_header) {
64 $this->buildHeader();
65 }
66 $this->buildReference();
67 $this->buildTarget();
68 $this->buildTitle();
69 $this->buildFooter();
70 }
71 }
72
73 public function getXml(): string
74 {
75 return $this->xmlDumpMem(false);
76 }
77
78 protected function buildHeader(): void
79 {
80 $this->xmlSetGenCmt("Export of ILIAS container reference " . $this->getReference()->getId() . " of installation " . $this->settings->get('inst_id') . ".");
81 $this->xmlHeader();
82 }
83
84 protected function buildTarget(): void
85 {
86 $this->xmlElement('Target', ['id' => $this->getReference()->getTargetId()]);
87 }
88
89 protected function buildTitle(): void
90 {
91 $title = '';
92 if ($this->getReference()->getTitleType() === ilContainerReference::TITLE_TYPE_CUSTOM) {
93 $title = $this->getReference()->getTitle();
94 }
95
96 $this->xmlElement(
97 'Title',
98 [
99 'type' => $this->getReference()->getTitleType()
100 ],
101 $title
102 );
103 }
104
105 protected function buildReference(): void
106 {
107 $this->xmlStartTag('ContainerReference');
108 }
109
110 protected function buildFooter(): void
111 {
112 $this->xmlEndTag('ContainerReference');
113 }
114}
Class for container reference export.
__construct(?ilContainerReference $ref=null)
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlDumpMem(bool $format=true)
Returns xml document from memory.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26