2021-09-08 10:57:22 +02:00
|
|
|
<?php
|
2021-09-09 11:05:00 +02:00
|
|
|
use Cake\Core\Configure;
|
2021-09-09 13:11:45 +02:00
|
|
|
use Cake\Routing\Router;
|
2021-09-09 11:05:00 +02:00
|
|
|
|
|
|
|
$controller = $this->request->getParam('controller');
|
|
|
|
$action = $this->request->getParam('action');
|
|
|
|
$curentPath = "{$controller}{$action}";
|
|
|
|
|
|
|
|
$breadcrumbLinks = '';
|
|
|
|
$breadcrumbAction = '';
|
2021-09-08 10:57:22 +02:00
|
|
|
$this->Breadcrumbs->setTemplates([
|
|
|
|
'wrapper' => sprintf(
|
2021-09-09 17:16:37 +02:00
|
|
|
'<nav class="header-breadcrumb d-xl-block d-none"{{attrs}}><ol class="">{{content}}</ol></nav>'
|
2021-09-08 10:57:22 +02:00
|
|
|
),
|
2021-09-16 15:50:55 +02:00
|
|
|
'item' => '<li class="header-breadcrumb-item"{{attrs}}><i class="{{icon}} mr-1"></i><a class="{{linkClass}}" href="{{url}}"{{innerAttrs}}>{{title}}</a></li>{{separator}}',
|
2021-09-08 10:57:22 +02:00
|
|
|
'itemWithoutLink' => '<li class="header-breadcrumb-item"{{attrs}}><span{{innerAttrs}}>{{title}}</span></li>{{separator}}',
|
|
|
|
'separator' => '<li class="header-breadcrumb-separator"{{attrs}}><span{{innerAttrs}}><i class="fa fa-sm fa-angle-right"></i></span></li>'
|
|
|
|
]);
|
2021-09-09 11:05:00 +02:00
|
|
|
|
|
|
|
if (!empty($breadcrumb)) {
|
2021-09-13 13:04:54 +02:00
|
|
|
foreach ($breadcrumb as $i => $entry) {
|
2021-09-09 11:05:00 +02:00
|
|
|
if (!empty($entry['textGetter'])) {
|
|
|
|
$entry['label'] = Cake\Utility\Hash::get($entity, $entry['textGetter']);
|
|
|
|
}
|
|
|
|
if (!empty($entry['url_vars'])) {
|
|
|
|
$entry['url'] = $this->DataFromPath->buildStringFromDataPath($entry['url'], $entity, $entry['url_vars']);
|
|
|
|
}
|
2021-09-10 15:58:41 +02:00
|
|
|
$this->Breadcrumbs->add(h($entry['label']), Router::url($entry['url']), [
|
|
|
|
'title' => h($entry['label']),
|
|
|
|
'templateVars' => [
|
2021-09-13 13:04:54 +02:00
|
|
|
'linkClass' => $i == 0 ? 'font-weight-light' : '',
|
2021-09-10 15:58:41 +02:00
|
|
|
'icon' => !empty($entry['icon']) ? $this->FontAwesome->getClass(h($entry['icon'])) : ''
|
|
|
|
]
|
|
|
|
]);
|
2021-09-09 11:05:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$lastCrumb = $breadcrumb[count($breadcrumb)-1];
|
|
|
|
if (!empty($lastCrumb['links']) || !empty($lastCrumb['actions'])) {
|
|
|
|
$this->Breadcrumbs->add([[]]); // add last separetor
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($lastCrumb['links'])) {
|
|
|
|
foreach ($lastCrumb['links'] as $i => $linkEntry) {
|
|
|
|
$active = $linkEntry['route_path'] == $lastCrumb['route_path'];
|
|
|
|
if (!empty($linkEntry['url_vars'])) {
|
|
|
|
$linkEntry['url'] = $this->DataFromPath->buildStringFromDataPath($linkEntry['url'], $entity, $linkEntry['url_vars']);
|
|
|
|
}
|
|
|
|
$breadcrumbLinks .= sprintf('<a class="btn btn-%s btn-sm text-nowrap" role="button" href="%s">%s</a>',
|
2021-09-16 15:50:55 +02:00
|
|
|
$active ? 'secondary' : 'dark',
|
2021-09-09 13:11:45 +02:00
|
|
|
Router::url($linkEntry['url']),
|
2021-09-10 09:22:08 +02:00
|
|
|
h($linkEntry['label'])
|
2021-09-09 11:05:00 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!empty($lastCrumb['actions'])) {
|
|
|
|
foreach ($lastCrumb['actions'] as $i => $actionEntry) {
|
|
|
|
if (!empty($actionEntry['url_vars'])) {
|
|
|
|
$actionEntry['url'] = $this->DataFromPath->buildStringFromDataPath($actionEntry['url'], $entity, $actionEntry['url_vars']);
|
|
|
|
}
|
2021-09-10 09:22:08 +02:00
|
|
|
$breadcrumbAction .= sprintf('<a class="dropdown-item" href="%s">%s</a>', Router::url($actionEntry['url']), h($actionEntry['label']));
|
2021-09-09 11:05:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
2021-09-08 10:57:22 +02:00
|
|
|
echo $this->Breadcrumbs->render(
|
|
|
|
[],
|
|
|
|
['separator' => '']
|
|
|
|
);
|
|
|
|
?>
|
2021-09-09 11:05:00 +02:00
|
|
|
<?php if (!empty($breadcrumbLinks)): ?>
|
2021-09-09 17:16:37 +02:00
|
|
|
<div class="header-breadcrumb-children d-none d-md-flex">
|
2021-09-09 11:05:00 +02:00
|
|
|
<?= $breadcrumbLinks ?>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php if (!empty($breadcrumbAction)): ?>
|
2021-09-10 09:22:08 +02:00
|
|
|
<div class="header-breadcrumb-actions dropdown d-flex align-items-center">
|
2021-09-09 11:05:00 +02:00
|
|
|
<a class="btn btn-primary dropdown-toggle" href="#" role="button" id="dropdownMenuBreadcrumbAction" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
|
|
<?= __('Actions') ?>
|
|
|
|
</a>
|
|
|
|
<div class="dropdown-menu" aria-labelledby="dropdownMenuBreadcrumbAction">
|
|
|
|
<?= $breadcrumbAction ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|