2020-06-08 14:11:20 +02:00
|
|
|
<?php
|
|
|
|
$children = '';
|
2020-06-23 14:14:20 +02:00
|
|
|
$backgroundColour = $darkMode ? 'bg-dark' : 'bg-light';
|
2020-06-08 14:11:20 +02:00
|
|
|
if (isset($menu[$metaGroup])) {
|
|
|
|
foreach ($menu[$metaGroup] as $scope => $scopeData) {
|
|
|
|
$children .= sprintf(
|
2020-06-23 14:14:20 +02:00
|
|
|
'<a href="%s" class="font-weight-bold list-group-item list-group-item-action %s %s pl-1 border-0">%s</a>',
|
2021-02-09 22:10:26 +01:00
|
|
|
empty($scopeData['url']) ? '#' : $baseurl . '/' . h($scopeData['url']),
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($scopeData['class']) ? '' : h($scopeData['class']),
|
2020-06-23 14:14:20 +02:00
|
|
|
$backgroundColour,
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($scopeData['label']) ? h($scope) : $scopeData['label']
|
|
|
|
);
|
|
|
|
foreach ($scopeData['children'] as $action => $data) {
|
|
|
|
if (
|
|
|
|
(!empty($data['requirements']) && !$data['requirements']) ||
|
|
|
|
(
|
|
|
|
!empty($data['actions']) &&
|
|
|
|
!in_array($this->request->getParam('action'), $data['actions'])
|
|
|
|
) ||
|
|
|
|
!empty($data['actions']) && $scope !== $this->request->getParam('controller')
|
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$matches = [];
|
|
|
|
preg_match_all('/\{\{.*?\}\}/', $data['url'], $matches);
|
|
|
|
if (!empty($matches[0])) {
|
|
|
|
$mainEntity = \Cake\Utility\Inflector::underscore(\Cake\Utility\Inflector::singularize($scope));
|
|
|
|
foreach ($matches as $match) {
|
2020-06-19 00:43:11 +02:00
|
|
|
$data['url'] = str_replace(
|
|
|
|
$match[0],
|
|
|
|
Cake\Utility\Hash::extract($entity, trim($match[0], '{}'))[0],
|
|
|
|
$data['url']
|
|
|
|
);
|
2020-06-08 14:11:20 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-23 14:14:20 +02:00
|
|
|
$active = ($scope === $this->request->getParam('controller') && $action === $this->request->getParam('action'));
|
2020-11-06 13:21:45 +01:00
|
|
|
if (!empty($data['popup'])) {
|
2021-03-15 22:47:13 +01:00
|
|
|
$link_template = '<a href="#" onClick="UI.submissionModalAutoGuess(\'%s\')" class="list-group-item list-group-item-action %s %s pl-3 border-0 %s">%s</a>';
|
2020-11-06 13:21:45 +01:00
|
|
|
} else {
|
|
|
|
$link_template = '<a href="%s" class="list-group-item list-group-item-action %s %s pl-3 border-0 %s">%s</a>';
|
|
|
|
}
|
2020-06-08 14:11:20 +02:00
|
|
|
$children .= sprintf(
|
2020-11-06 13:21:45 +01:00
|
|
|
$link_template,
|
2021-02-09 22:10:26 +01:00
|
|
|
empty($data['url']) ? '#' : $baseurl . h($data['url']),
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($data['class']) ? '' : h($data['class']),
|
2020-06-23 14:14:20 +02:00
|
|
|
$active ? 'active' : '',
|
|
|
|
$active ? '' : $backgroundColour,
|
2020-06-08 14:11:20 +02:00
|
|
|
empty($data['label']) ? h($action) : $data['label']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo sprintf(
|
2020-06-23 14:14:20 +02:00
|
|
|
'<div class="list-group %s h-100" id="side-menu-div">%s</div>',
|
|
|
|
$backgroundColour,
|
2020-06-08 14:11:20 +02:00
|
|
|
$children
|
|
|
|
);
|