Newer
Older
<?php
require '../../vendor/autoload.php';
chdir('../..');
$nonReadableFiles = [];
$migrated = 0;
$customs = scandir('custom');
foreach ($customs as $custom) {

Florian Azizian
committed
if (in_array($custom, ['custom.json', 'custom.xml', '.', '..'])) {
continue;
}
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $custom]);
$path = "custom/{$custom}/apps/maarch_entreprise/xml/config.xml";
if (file_exists($path)) {
if (!is_readable($path) || !is_writable($path)) {
$nonReadableFiles[] = $path;
continue;
}
$loadedXml = simplexml_load_file($path);
if ($loadedXml) {
$loadedXml->CONFIG->CookieTime = 10080;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$i = 0;
foreach ($loadedXml->MODULES as $value) {
if (in_array($loadedXml->MODULES[$i]->moduleid, ['convert', 'reports', 'full_text', 'cases'])) {
unset($loadedXml->MODULES[$i]);
}
$i++;
}
$res = formatXml($loadedXml);
$fp = fopen($path, "w+");
if ($fp) {
fwrite($fp, $res);
}
$migrated++;
}
}
}
foreach ($nonReadableFiles as $file) {
printf("The file %s it is not readable or not writable.\n", $file);
}
printf($migrated . " custom(s) avec config.xml (modules) trouvé(s) et migré(s).\n");
function formatXml($simpleXMLElement)
{
$xmlDocument = new DOMDocument('1.0');
$xmlDocument->preserveWhiteSpace = false;
$xmlDocument->formatOutput = true;
$xmlDocument->loadXML($simpleXMLElement->asXML());
return $xmlDocument->saveXML();
}