ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 
5 
7 {
8  protected array $settings = [];
9 
10  public function setSettings(array $settings): void
11  {
12  $this->settings = $settings;
13  }
14 
15  public function start(): void
16  {
17  $this->buildHeader();
18  $this->buildInstallationInfo();
19  $this->xmlStartTag("Clients");
20  }
21 
22  public function addClient(string $client_directory): bool
23  {
24  return $this->buildClient($client_directory);
25  }
26 
27  public function end(): void
28  {
29  $this->xmlEndTag("Clients");
30  $this->buildFooter();
31  }
32 
33  public function getXML(): string
34  {
35  return $this->xmlDumpMem(false);
36  }
37 
38  private function buildHeader(): void
39  {
40  // we have to build the http path here since this request is client independent!
41  $httpPath = ilSoapFunctions::buildHTTPPath();
42  $this->xmlSetDtdDef("<!DOCTYPE Installation PUBLIC \"-//ILIAS//DTD InstallationInfo//EN\" \"" . $httpPath . "/components/ILIAS/Export/xml/ilias_installation_info_5_3.dtd\">");
43  $this->xmlSetGenCmt("Export of ILIAS clients.");
44  $this->xmlHeader();
45  $this->xmlStartTag(
46  "Installation",
47  array(
48  "version" => ILIAS_VERSION,
49  "path" => $httpPath,
50  )
51  );
52  }
53 
54  private function buildFooter(): void
55  {
56  $this->xmlEndTag('Installation');
57  }
58 
59  private function buildClient(string $client_directory): bool
60  {
61  global $DIC;
62 
63  $ini_file = "./" . $client_directory . "/client.ini.php";
64 
65  // get settings from ini file
66 
67  $ilClientIniFile = new ilIniFile($ini_file);
68  $ilClientIniFile->read();
69  if ($ilClientIniFile->ERROR !== "") {
70  return false;
71  }
72  $client_id = $ilClientIniFile->readVariable('client', 'name');
73  if ($ilClientIniFile->variableExists('client', 'expose')) {
74  $client_expose = $ilClientIniFile->readVariable('client', 'expose');
75  if ($client_expose === "0") {
76  return false;
77  }
78  }
79 
80  // build dsn of database connection and connect
82  $ilClientIniFile->readVariable("db", "type")
83  );
84  $ilDB->initFromIniFile($ilClientIniFile);
85  if ($ilDB->connect(true)) {
86  unset($DIC['ilDB']);
87  $DIC['ilDB'] = $ilDB;
88 
89 
90  $settings = new ilSetting();
91  unset($DIC["ilSetting"]);
92  $DIC["ilSetting"] = $settings;
93 
94  // workaround to determine http path of client
95  define("IL_INST_ID", (int) $settings->get("inst_id", '0'));
96 
97  $this->xmlStartTag(
98  "Client",
99  [
100  "inst_id" => $settings->get("inst_id"),
101  "id" => basename($client_directory),
102  'enabled' => $ilClientIniFile->readVariable("client", "access") ? "TRUE" : "FALSE",
103  "default_lang" => $ilClientIniFile->readVariable("language", "default")
104  ]
105  );
106  $this->xmlEndTag("Client");
107  }
108  return true;
109  }
110 
111  private function buildInstallationInfo(): void
112  {
113  $this->xmlStartTag("Settings");
114  $this->xmlElement(
115  "Setting",
116  array("key" => "default_client"),
117  $GLOBALS['DIC']['ilIliasIniFile']->readVariable("clients", "default")
118  );
119  $this->xmlEndTag("Settings");
120  }
121 }
xmlSetGenCmt(string $genCmt)
Sets generated comment.
static getWrapper(string $a_type)
xmlEndTag(string $tag)
Writes an endtag.
const ILIAS_VERSION
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
$GLOBALS["DIC"]
Definition: wac.php:30
global $DIC
Definition: shib_login.php:25
xmlHeader()
Writes xml header.
static buildHTTPPath(bool $use_module_depending_path=true)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
$client_id
Definition: ltiauth.php:67
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlDumpMem(bool $format=true)
Returns xml document from memory.