/
RelationListController.php
82 lines (64 loc) · 2.63 KB
/
RelationListController.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
<?php
namespace Concrete\Core\Page\Relation\Menu\Item;
use Concrete\Controller\Panel\PageRelations;
use Concrete\Core\Application\Service\Dashboard;
use Concrete\Core\Application\UserInterface\Menu\Item\Controller;
use Concrete\Core\Multilingual\Service\UserInterface\Flag;
use Concrete\Core\Page\Page;
use HtmlObject\Element;
use HtmlObject\Link;
class RelationListController extends Controller
{
protected $dashboard;
protected $page;
protected $flagService;
protected $multilingualSection;
public function __construct(Page $page, Dashboard $dashboard, Flag $flagService)
{
$this->page = $page;
$this->dashboard = $dashboard;
$this->flagService = $flagService;
$this->multilingualSection = \Concrete\Core\Multilingual\Page\Section\Section::getBySectionOfSite($page);
}
/**
* Determine whether item should be displayed
*
* @return bool
*/
public function displayItem()
{
$controller = new PageRelations();
$controller->setPageObject($this->page);
return $controller->canAccessPanel();
}
public function getMenuItemLinkElement()
{
$link = new Link('#', '');
$link->setAttribute('data-panel-url', \URL::to('/ccm/system/panels/page/relations'));
$link->setAttribute('title', t('View related pages'));
$link->setAttribute('data-launch-panel', 'page_relations');
$show_tooltips = (bool) \Config::get('concrete.accessibility.toolbar_tooltips');
if ($show_tooltips) {
$link->setAttribute('class', 'launch-tooltip');
$link->setAttribute('data-bs-toggle', 'tooltip');
$link->setAttribute('data-bs-placement', 'bottom');
// data-bs-delay will throw a TypeError with current BS version
//$link->setAttribute('data-bs-delay', '{ "show": 500, "hide": 0 }');
}
if (is_object($this->multilingualSection)) {
$icon = $this->flagService->getFlagIcon($this->multilingualSection->getIcon());
$accessibility = new Element('span', $this->multilingualSection->getLanguageText());
$accessibility->addClass('ccm-toolbar-accessibility-title');
$link->appendChild($icon);
$link->appendChild($accessibility);
} else {
$icon = new Element('i', '');
$icon->addClass('fas fa-sitemap');
$accessibility = new Element('span', t('Related Pages'));
$accessibility->addClass('ccm-toolbar-accessibility-title');
$link->appendChild($icon);
$link->appendChild($accessibility);
}
return $link;
}
}