2 namespace TYPO3\CMS\Workspaces\Backend\ToolbarItems;
42 public function __construct()
46 $this->availableWorkspaces = $wsService->getAvailableWorkspaces();
51 $pageRenderer->loadRequireJsModule(
'TYPO3/CMS/Workspaces/Toolbar/WorkspacesMenu');
61 return count($this->availableWorkspaces) > 1;
71 if (empty($this->availableWorkspaces)) {
75 return '<span title="' . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:toolbarItems.workspace',
true) .
'">'
76 . $this->iconFactory->getIcon(
'apps-toolbar-menu-workspace',
Icon::SIZE_SMALL)->render(
'inline') .
'</span>';
90 $activeWorkspace = (int)$backendUser->workspace;
91 $stateCheckedIcon = $this->iconFactory->getIcon(
'status-status-checked',
Icon::SIZE_SMALL)->render();
92 $stateUncheckedIcon =
'<span title="' . $languageService->getLL(
'bookmark_inactive',
true) .
'">' . $this->iconFactory->getIcon(
'empty-empty',
Icon::SIZE_SMALL)->render() .
'</span>';
93 $workspaceSections = array(
98 foreach ($this->availableWorkspaces as $workspaceId => $label) {
99 $workspaceId = (int)$workspaceId;
100 $iconState = ($workspaceId === $activeWorkspace ? $stateCheckedIcon : $stateUncheckedIcon);
101 $classValue = ($workspaceId === $activeWorkspace ?
' class="selected"' :
'');
102 $sectionName = ($index++ === 0 ?
'top' :
'items');
103 $workspaceSections[$sectionName][] =
'<li' . $classValue .
'>'
104 .
'<a href="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(
'main', array(
'changeWorkspace' => $workspaceId))) .
'" data-workspaceid="' . $workspaceId .
'" class="dropdown-list-link tx-workspaces-switchlink">'
105 . $iconState .
' ' . htmlspecialchars($label)
109 if (!empty($workspaceSections[
'top'])) {
112 if ($backendUser->check(
'modules',
'web_WorkspacesWorkspaces')) {
113 $workspaceSections[
'top'][] =
'<li><a target="content" data-module="web_WorkspacesWorkspaces" class="dropdown-list-link tx-workspaces-modulelink">'
114 . $stateUncheckedIcon .
' ' . $languageService->getLL(
'bookmark_workspace',
true)
119 $workspaceSections[
'top'][] =
'<li>' . $stateUncheckedIcon .
' ' . $languageService->getLL(
'bookmark_noWSfound',
true) .
'</li>';
122 $workspaceMenu = array(
123 '<ul class="dropdown-list">' ,
124 implode(LF, $workspaceSections[
'top']),
125 (!empty($workspaceSections[
'items']) ?
'<li class="divider"></li>' :
''),
126 implode(LF, $workspaceSections[
'items']),
130 return implode(LF, $workspaceMenu);
150 return !empty($this->availableWorkspaces);