ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSoapInstallationInfoXMLWriter.php
Go to the documentation of this file.
1<?php
2
20{
21 protected array $settings = [];
22
23 public function setSettings(array $settings): void
24 {
25 $this->settings = $settings;
26 }
27
28 public function start(): void
29 {
30 $this->buildHeader();
31 $this->buildInstallationInfo();
32 $this->xmlStartTag("Clients");
33 }
34
35 public function addClient(string $client_directory): bool
36 {
37 return $this->buildClient($client_directory);
38 }
39
40 public function end(): void
41 {
42 $this->xmlEndTag("Clients");
43 $this->buildFooter();
44 }
45
46 public function getXML(): string
47 {
48 return $this->xmlDumpMem(false);
49 }
50
51 private function buildHeader(): void
52 {
53 // we have to build the http path here since this request is client independent!
55 $this->xmlSetDtdDef("<!DOCTYPE Installation PUBLIC \"-//ILIAS//DTD InstallationInfo//EN\" \"" . $httpPath . "/components/ILIAS/Export/xml/ilias_installation_info_5_3.dtd\">");
56 $this->xmlSetGenCmt("Export of ILIAS clients.");
57 $this->xmlHeader();
58 $this->xmlStartTag(
59 "Installation",
60 array(
61 "version" => ILIAS_VERSION,
62 "path" => $httpPath,
63 )
64 );
65 }
66
67 private function buildFooter(): void
68 {
69 $this->xmlEndTag('Installation');
70 }
71
72 private function buildClient(string $client_directory): bool
73 {
74 global $DIC;
75
76 $ini_file = "./" . $client_directory . "/client.ini.php";
77
78 // get settings from ini file
79
80 $ilClientIniFile = new ilIniFile($ini_file);
81 $ilClientIniFile->read();
82 if ($ilClientIniFile->ERROR !== "") {
83 return false;
84 }
85 $client_id = $ilClientIniFile->readVariable('client', 'name');
86 if ($ilClientIniFile->variableExists('client', 'expose')) {
87 $client_expose = $ilClientIniFile->readVariable('client', 'expose');
88 if ($client_expose === "0") {
89 return false;
90 }
91 }
92
93 // build dsn of database connection and connect
95 $ilClientIniFile->readVariable("db", "type")
96 );
97 $ilDB->initFromIniFile($ilClientIniFile);
98 if ($ilDB->connect(true)) {
99 unset($DIC['ilDB']);
100 $DIC['ilDB'] = $ilDB;
101
102
103 $settings = new ilSetting();
104 unset($DIC["ilSetting"]);
105 $DIC["ilSetting"] = $settings;
106
107 // workaround to determine http path of client
108 define("IL_INST_ID", (int) $settings->get("inst_id", '0'));
109
110 $this->xmlStartTag(
111 "Client",
112 [
113 "inst_id" => $settings->get("inst_id"),
114 "id" => basename($client_directory),
115 'enabled' => $ilClientIniFile->readVariable("client", "access") ? "TRUE" : "FALSE",
116 "default_lang" => $ilClientIniFile->readVariable("language", "default")
117 ]
118 );
119 $this->xmlEndTag("Client");
120 }
121 return true;
122 }
123
124 private function buildInstallationInfo(): void
125 {
126 $this->xmlStartTag("Settings");
127 $this->xmlElement(
128 "Setting",
129 array("key" => "default_client"),
130 $GLOBALS['DIC']['ilIliasIniFile']->readVariable("clients", "default")
131 );
132 $this->xmlEndTag("Settings");
133 }
134}
readVariable(string $a_group, string $a_var_name)
reads a single variable from a group
static getWrapper(string $a_type)
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
ILIAS Setting Class.
static buildHTTPPath(bool $use_module_depending_path=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
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.
const ILIAS_VERSION
$client_id
Definition: ltiauth.php:67
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54