ILIAS  release_8 Revision v8.24
class.ilSoapInstallationInfoXMLWriter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once "./Services/Xml/classes/class.ilXmlWriter.php";
6
8{
9 protected array $settings = [];
10
11 public function setSettings(array $settings) : void
12 {
13 $this->settings = $settings;
14 }
15
16 public function start() : void
17 {
18 $this->buildHeader();
19 $this->buildInstallationInfo();
20 $this->xmlStartTag("Clients");
21 }
22
23 public function addClient(string $client_directory) : bool
24 {
25 return $this->buildClient($client_directory);
26 }
27
28 public function end() : void
29 {
30 $this->xmlEndTag("Clients");
31 $this->buildFooter();
32 }
33
34 public function getXML() : string
35 {
36 return $this->xmlDumpMem(false);
37 }
38
39 private function buildHeader() : void
40 {
41 // we have to build the http path here since this request is client independent!
43 $this->xmlSetDtdDef("<!DOCTYPE Installation PUBLIC \"-//ILIAS//DTD InstallationInfo//EN\" \"" . $httpPath . "/xml/ilias_installation_info_5_3.dtd\">");
44 $this->xmlSetGenCmt("Export of ILIAS clients.");
45 $this->xmlHeader();
46 $this->xmlStartTag(
47 "Installation",
48 array(
49 "version" => ILIAS_VERSION,
50 "path" => $httpPath,
51 )
52 );
53 }
54
55 private function buildFooter() : void
56 {
57 $this->xmlEndTag('Installation');
58 }
59
60 private function buildClient(string $client_directory) : bool
61 {
62 global $DIC;
63
64 $ini_file = "./" . $client_directory . "/client.ini.php";
65
66 // get settings from ini file
67 require_once("./Services/Init/classes/class.ilIniFile.php");
68
69 $ilClientIniFile = new ilIniFile($ini_file);
70 $ilClientIniFile->read();
71 if ($ilClientIniFile->ERROR !== "") {
72 return false;
73 }
74 $client_id = $ilClientIniFile->readVariable('client', 'name');
75 if ($ilClientIniFile->variableExists('client', 'expose')) {
76 $client_expose = $ilClientIniFile->readVariable('client', 'expose');
77 if ($client_expose === "0") {
78 return false;
79 }
80 }
81
82 // build dsn of database connection and connect
84 $ilClientIniFile->readVariable("db", "type")
85 );
86 $ilDB->initFromIniFile($ilClientIniFile);
87 if ($ilDB->connect(true)) {
88 unset($DIC['ilDB']);
89 $DIC['ilDB'] = $ilDB;
90
91 require_once("Services/Administration/classes/class.ilSetting.php");
92
93 $settings = new ilSetting();
94 unset($DIC["ilSetting"]);
95 $DIC["ilSetting"] = $settings;
96
97 // workaround to determine http path of client
98 if (!defined("IL_INST_ID")) {
99 define("IL_INST_ID", (int)$settings->get("inst_id", '0'));
100 }
101
102 $this->xmlStartTag(
103 "Client",
104 [
105 "inst_id" => $settings->get("inst_id"),
106 "id" => basename($client_directory),
107 'enabled' => $ilClientIniFile->readVariable("client", "access") ? "TRUE" : "FALSE",
108 "default_lang" => $ilClientIniFile->readVariable("language", "default")
109 ]
110 );
111 $this->xmlEndTag("Client");
112 }
113 return true;
114
115 }
116
117 private function buildInstallationInfo() : void
118 {
119 $this->xmlStartTag("Settings");
120 $this->xmlElement(
121 "Setting",
122 array("key" => "default_client"),
123 $GLOBALS['DIC']['ilIliasIniFile']->readVariable("clients", "default")
124 );
125 $this->xmlEndTag("Settings");
126 }
127}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
readVariable(string $a_group, string $a_var_name)
reads a single variable from a group
static getWrapper(string $a_type)
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...
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.
global $DIC
Definition: feed.php:28
const ILIAS_VERSION
$client_id
Definition: ltiauth.php:68