2 namespace TYPO3\CMS\Opendocs\Backend\ToolbarItems;
51 $this->
getLanguageService()->includeLLFile(
'EXT:opendocs/Resources/Private/Language/locallang.xlf');
54 $pageRenderer->loadRequireJsModule(
'TYPO3/CMS/Opendocs/Toolbar/OpendocsMenu');
64 $conf = $this->
getBackendUser()->getTSConfig(
'backendToolbarItem.tx_opendocs.disabled');
65 return $conf[
'value'] != 1;
76 list($this->openDocs, ) = $backendUser->getModuleData(
'FormEngine',
'ses');
77 $this->recentDocs = $backendUser->getModuleData(
'opendocs::recent');
87 $numDocs = count($this->openDocs);
90 $opendocsMenu = array();
91 $opendocsMenu[] =
'<span title="' . $title .
'">' . $this->iconFactory->getIcon(
'apps-toolbar-menu-opendocs',
Icon::SIZE_SMALL)->render(
'inline') .
'</span>';
92 $opendocsMenu[] =
'<span class="badge" id="tx-opendocs-counter">' . $numDocs .
'</span>';
94 return implode(LF, $opendocsMenu);
108 if (!empty($openDocuments)) {
109 $entries[] =
'<li class="dropdown-header">' . $languageService->getLL(
'open_docs',
true) .
'</li>';
111 foreach ($openDocuments as $md5sum => $openDocument) {
113 $entries[] = $this->
renderMenuEntry($openDocument, $md5sum,
false, $i == 1);
115 $entries[] =
'<li class="divider"></li>';
118 if (!empty($recentDocuments)) {
119 $entries[] =
'<li class="dropdown-header">' . $languageService->getLL(
'recent_docs',
true) .
'</li>';
121 foreach ($recentDocuments as $md5sum => $recentDocument) {
123 $entries[] = $this->
renderMenuEntry($recentDocument, $md5sum,
true, $i == 1);
126 if (!empty($entries)) {
127 $content =
'<ul class="dropdown-list">' . implode(
'', $entries) .
'</ul>';
129 $content =
'<p>' . $languageService->getLL(
'no_docs',
true) .
'</p>';
143 protected function renderMenuEntry($document, $md5sum, $isRecentDoc =
false, $isFirstDoc =
false)
145 $table = $document[3][
'table'];
146 $uid = $document[3][
'uid'];
147 $record = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($table, $uid);
148 if (!is_array($record)) {
152 $label = htmlspecialchars(strip_tags(htmlspecialchars_decode($document[0])));
153 $icon = $this->iconFactory->getIconForRecord($table, $record,
Icon::SIZE_SMALL)->render();
154 $link = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(
'record_edit') .
'&' . $document[2];
155 $pageId = (int)$document[3][
'uid'];
156 if ($document[3][
'table'] !==
'pages') {
157 $pageId = (int)$document[3][
'pid'];
159 $onClickCode =
'jump(' .
GeneralUtility::quoteJSvalue($link) .
', \'web_list\', \'web\', ' . $pageId .
'); TYPO3.OpendocsMenu.toggleMenu(); return false;';
161 $title = $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:rm.closeDoc',
true);
163 $closeIcon = $this->iconFactory->getIcon(
'actions-close',
Icon::SIZE_SMALL)->render(
'inline');
166 <a href="#" class="dropdown-list-link dropdown-link-list-add-close" onclick="' . htmlspecialchars($onClickCode) .
'" target="content">' . $icon .
' ' . $label .
'</a>
167 <a href="#" class="dropdown-list-link-close" data-opendocsidentifier="' . $md5sum .
'" title="' . $title .
'">' . $closeIcon .
'</a>
173 <a href="#" class="dropdown-list-link" onclick="' . htmlspecialchars($onClickCode) .
'" target="content">' . $icon .
' ' . $label .
'</a>
213 $params[
'JScode'] =
'
214 if (top && top.TYPO3.OpendocsMenu) {
215 top.TYPO3.OpendocsMenu.updateMenu();
234 if ($md5sum && isset($this->openDocs[$md5sum])) {
236 $this->recentDocs = array_merge(array($md5sum => $this->openDocs[$md5sum]), $this->recentDocs);
238 if (count($this->recentDocs) > 8) {
239 $this->recentDocs = array_slice($this->recentDocs, 0, 8);
242 unset($this->openDocs[$md5sum]);
243 list(, $docDat) = $backendUser->getModuleData(
'FormEngine',
'ses');
244 $backendUser->pushModuleData(
'FormEngine', array($this->openDocs, $docDat));
245 $backendUser->pushModuleData(
'opendocs::recent', $this->recentDocs);
247 return $this->
renderMenu($request, $response);
260 $response = $response->
withHeader(
'Content-Type',
'html');