mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
WIP
This commit is contained in:
parent
18188f7185
commit
b1c48a9069
@ -6,7 +6,8 @@
|
||||
<?= $this->translate('There is no such module installed.') ?>
|
||||
<?php return; endif ?>
|
||||
<?php
|
||||
$requiredMods = $module->getRequiredModules();
|
||||
$requiredMods = array_diff_key($module->getRequiredModules(), $module->getOptionalModules());
|
||||
$optionalMods = $module->getOptionalModules();
|
||||
$requiredLibs = $module->getRequiredLibraries();
|
||||
$restrictions = $module->getProvidedRestrictions();
|
||||
$permissions = $module->getProvidedPermissions();
|
||||
@ -50,7 +51,7 @@
|
||||
<tr>
|
||||
<th><?= $this->escape($this->translate('Dependencies')) ?></th>
|
||||
<td class="module-dependencies">
|
||||
<?php if (empty($requiredLibs) && empty($requiredMods)): ?>
|
||||
<?php if (empty($requiredLibs) && empty($requiredMods) && empty($optionalMods)): ?>
|
||||
<?= $this->translate('This module has no dependencies') ?>
|
||||
<?php else: ?>
|
||||
<?php if ($unmetDependencies): ?>
|
||||
@ -78,28 +79,63 @@
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
<?php if (! empty($requiredMods)): ?>
|
||||
<?php if (! empty($requiredMods) || ! empty($optionalMods)): ?>
|
||||
<table class="name-value-table">
|
||||
<caption><?= $this->translate('Modules') ?></caption>
|
||||
<?php foreach ($requiredMods as $moduleName => $versionString): ?>
|
||||
<tr>
|
||||
<th><?= $this->escape($moduleName) ?></th>
|
||||
<td>
|
||||
<?php if ($moduleManager->has($moduleName, $versionString === true ? null : $versionString)): ?>
|
||||
<?= $versionString === true ? '*' : $this->escape($versionString) ?>
|
||||
<?php else: ?>
|
||||
<span class="missing"><?= $versionString === true ? '*' : $this->escape($versionString) ?></span>
|
||||
<?php if (! $moduleManager->hasInstalled($moduleName)): ?>
|
||||
(<?= $this->translate('not installed') ?>)
|
||||
<?php else: ?>
|
||||
(<?= $moduleManager->getModule($moduleName, false)->getVersion() ?><?= $moduleManager->hasEnabled($moduleName) ? '' : ', ' . $this->translate('disabled') ?>)
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
<?php if (! empty($requiredMods)): ?>
|
||||
<?php foreach ($requiredMods as $moduleName => $versionString): ?>
|
||||
<tr>
|
||||
<th><?= $this->escape($moduleName) ?></th>
|
||||
<td>
|
||||
<?php if ($moduleManager->has($moduleName, $versionString === true ? null : $versionString)): ?>
|
||||
<?= $versionString === true ? '*' : $this->escape($versionString) ?>
|
||||
<?php else: ?>
|
||||
<span class="missing"><?= $versionString === true ? '*' : $this->escape($versionString) ?></span>
|
||||
<?php if (! $moduleManager->hasInstalled($moduleName)): ?>
|
||||
(<?= $this->translate('not installed') ?>)
|
||||
<?php else: ?>
|
||||
(<?= $moduleManager->getModule($moduleName, false)->getVersion() ?><?= $moduleManager->hasEnabled($moduleName) ? '' : ', ' . $this->translate('disabled') ?>)
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
<?php if (! empty($optionalMods)): ?>
|
||||
<?php foreach ($optionalMods as $modules): ?>
|
||||
<?php
|
||||
$i = 0;
|
||||
$has = $moduleManager->hasAny($modules);
|
||||
?>
|
||||
<tbody class="optional-module-group">
|
||||
<?php foreach ($modules as $moduleName => $versionString): ?>
|
||||
<?php if ($i > 0): ?>
|
||||
<tr><th class="or-separator"><?= $this->translate('or') ?></th></tr>
|
||||
<?php endif ?>
|
||||
<tr>
|
||||
<th><?=$this->escape($moduleName) ?></th>
|
||||
<td>
|
||||
<?php if ($moduleManager->has($moduleName, $versionString === true ? null : $versionString)): ?>
|
||||
<?= $versionString === true ? '*' : $this->escape($versionString) ?>
|
||||
<?php else: ?>
|
||||
<span class=<?= ! $has ? 'missing' : null ?>>
|
||||
<?= $versionString === true ? '*' : $this->escape($versionString) ?>
|
||||
</span>
|
||||
<?php if (! $moduleManager->hasInstalled($moduleName)): ?>
|
||||
(<?= $this->translate('not installed') ?>)
|
||||
<?php else: ?>
|
||||
(<?= $moduleManager->getModule($moduleName, false)->getVersion() ?><?= $moduleManager->hasEnabled($moduleName) ? '' : ', ' . $this->translate('disabled') ?>)
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $i++ ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -474,6 +474,24 @@ class Manager
|
||||
return version_compare($modVersion, $version, $operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any module in the given array is enabled
|
||||
*
|
||||
* @param array $modules
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAny($modules)
|
||||
{
|
||||
foreach ($modules as $name => $version) {
|
||||
if ($this->has($name, $version)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently loaded modules
|
||||
*
|
||||
@ -558,7 +576,14 @@ class Manager
|
||||
{
|
||||
$module = $this->getModule($name, false);
|
||||
|
||||
$requiredMods = $module->getRequiredModules();
|
||||
$optionalMods = $module->getOptionalModules();
|
||||
foreach ($optionalMods as $modules) {
|
||||
if (! $this->hasAny($modules)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$requiredMods = array_diff_key($module->getRequiredModules(), $optionalMods);
|
||||
foreach ($requiredMods as $moduleName => $moduleVersion) {
|
||||
if (! $this->has($moduleName, $moduleVersion)) {
|
||||
return true;
|
||||
|
@ -897,6 +897,25 @@ class Module
|
||||
return $requiredModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get optional modules
|
||||
*
|
||||
* Modules that have an or operator
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionalModules()
|
||||
{
|
||||
$modulesWithOrOperator = [];
|
||||
foreach ($this->getRequiredModules() as $key => $val) {
|
||||
if (strpos($key, '|') !== false) {
|
||||
$modulesWithOrOperator[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $modulesWithOrOperator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch module metadata
|
||||
*
|
||||
@ -983,8 +1002,15 @@ class Module
|
||||
}
|
||||
|
||||
$parts = preg_split('/,\s+/', $val);
|
||||
foreach ($parts as $part) {
|
||||
if (preg_match('/^([\w\-\/]+)\s+\((.+)\)$/', $part, $m)) {
|
||||
foreach ($parts as $i => $part) {
|
||||
if (strpos($part, '|') !== false) {
|
||||
$orParts = array_map('trim', explode('|', $part));
|
||||
foreach ($orParts as $orPart) {
|
||||
if (preg_match('/^([\w\-\/]+)\s+\((.+)\)$/', $orPart, $m)) {
|
||||
$metadata->{$key}['|' . $i][$m[1]] = $m[2];
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('/^([\w\-\/]+)\s+\((.+)\)$/', $part, $m)) {
|
||||
$metadata->{$key}[$m[1]] = $m[2];
|
||||
} else {
|
||||
// TODO: FAIL?
|
||||
|
@ -440,5 +440,10 @@ a:hover > .icon-cancel {
|
||||
.var(color, color-critical);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.or-separator {
|
||||
position: relative;
|
||||
transform: translate(70%, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user