TYPO3  7.6
HelpToolbarItem.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
23 
28 {
32  protected $helpModuleMenu = null;
33 
37  protected $iconFactory;
38 
42  public function __construct()
43  {
45  $backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
47  $helpModuleMenu = $backendModuleRepository->findByModuleName('help');
48  if ($helpModuleMenu && $helpModuleMenu->getChildren()->count() > 0) {
49  $this->helpModuleMenu = $helpModuleMenu;
50  }
51  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
52  }
53 
59  public function checkAccess()
60  {
61  $result = (bool)$this->helpModuleMenu;
62  return $result;
63  }
64 
70  public function getItem()
71  {
72  return $this->iconFactory->getIcon('apps-toolbar-menu-help', Icon::SIZE_SMALL)->render('inline');
73  }
74 
80  public function getDropDown()
81  {
82  $dropdown = array();
83  $dropdown[] = '<ul class="dropdown-list">';
84  foreach ($this->helpModuleMenu->getChildren() as $module) {
86  $moduleIcon = $module->getIcon();
87  $dropdown[] ='<li'
88  . ' id="' . htmlspecialchars($module->getName()) . '"'
89  . ' class="typo3-module-menu-item submodule mod-' . htmlspecialchars($module->getName()) . '" '
90  . ' data-modulename="' . htmlspecialchars($module->getName()) . '"'
91  . ' data-navigationcomponentid="' . htmlspecialchars($module->getNavigationComponentId()) . '"'
92  . ' data-navigationframescript="' . htmlspecialchars($module->getNavigationFrameScript()) . '"'
93  . ' data-navigationframescriptparameters="' . htmlspecialchars($module->getNavigationFrameScriptParameters()) . '"'
94  . '>';
95  $dropdown[] = '<a title="' . htmlspecialchars($module->getDescription()) . '" href="' . htmlspecialchars($module->getLink()) . '" class="dropdown-list-link modlink">';
96  $dropdown[] = '<span class="submodule-icon typo3-app-icon"><span><span>' . $moduleIcon . '</span></span></span>';
97  $dropdown[] = '<span class="submodule-label">' . htmlspecialchars($module->getTitle()) . '</span>';
98  $dropdown[] = '</a>';
99  $dropdown[] = '</li>';
100  }
101  $dropdown[] = '</ul>';
102  return implode(LF, $dropdown);
103  }
104 
110  public function getAdditionalAttributes()
111  {
112  return array('class' => 'typo3-module-menu-group');
113  }
114 
120  public function hasDropDown()
121  {
122  return true;
123  }
124 
130  public function getIndex()
131  {
132  return 70;
133  }
134 }