/
controller.php
104 lines (93 loc) · 2.71 KB
/
controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
namespace Concrete\Block\Breadcrumbs;
use Concrete\Core\Block\BlockController;
use Concrete\Core\Feature\Features;
use Concrete\Core\Feature\UsesFeatureInterface;
use Concrete\Core\Navigation\Breadcrumb\PageBreadcrumbFactory;
use Concrete\Core\Page\Page;
defined('C5_EXECUTE') or die('Access Denied.');
class Controller extends BlockController implements UsesFeatureInterface
{
/** @var string[] */
protected $helpers = ['form'];
/** @var bool */
public $includeCurrent;
/** @var bool */
public $ignoreExcludeNav;
/** @var bool */
public $ignorePermission;
/** @var int */
protected $btInterfaceWidth = 500;
/** @var int */
protected $btInterfaceHeight = 300;
/** @var string */
protected $btTable = 'btBreadcrumbs';
/** @var bool */
protected $btCacheBlockRecord = true;
/** @var bool */
protected $btCacheBlockOutput = true;
/** @var bool */
protected $btCacheBlockOutputOnPost = true;
/** @var bool */
protected $btCacheBlockOutputForRegisteredUsers = true;
/** @var int */
protected $btCacheBlockOutputLifetime = 300;
/**
* {@inheritdoc}
*/
public function getBlockTypeName()
{
return t('Breadcrumbs');
}
/**
* {@inheritdoc}
*/
public function getBlockTypeDescription()
{
return t('Add a breadcrumbs navigation.');
}
/**
* {@inheritdoc}
*/
public function getRequiredFeatures(): array
{
return [
Features::NAVIGATION,
];
}
/**
* @return void
*/
public function add()
{
$this->set('includeCurrent', 1);
$this->set('ignoreExcludeNav', 1);
}
/**
* {@inheritdoc}
* @return void
*/
public function save($args)
{
$args['includeCurrent'] = isset($args['includeCurrent']) && $args['includeCurrent'] ? 1 : 0;
$args['ignoreExcludeNav'] = isset($args['ignoreExcludeNav']) && $args['ignoreExcludeNav'] ? 1 : 0;
$args['ignorePermission'] = isset($args['ignorePermission']) && $args['ignorePermission'] ? 1 : 0;
parent::save($args);
}
/**
* @return void
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function view()
{
$page = Page::getCurrentPage();
if ($page) {
/** @var PageBreadcrumbFactory $factory */
$factory = $this->app->make(PageBreadcrumbFactory::class);
$factory->setIncludeCurrent((bool) $this->includeCurrent);
$factory->setIgnoreExcludeNav((bool) $this->ignoreExcludeNav);
$breadcrumb = $factory->getBreadcrumb($page);
$this->set('breadcrumb', $breadcrumb);
}
}
}