TYPO3 CMS  TYPO3_7-6
HistoryEntryViewHelper.php
Go to the documentation of this file.
1 <?php
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 
28 
34 {
41  public function render($uid)
42  {
43  return static::renderStatic(
44  [
45  'uid' => $uid
46  ],
48  $this->renderingContext
49  );
50  }
51 
60  {
62  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
64  $historyEntryRepository = $objectManager->get(HistoryEntryRepository::class);
66  $historyEntry = $historyEntryRepository->findOneBySysLogUid($arguments['uid']);
68  $controllerContext = $renderingContext->getControllerContext();
70  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
71 
72  if (!$historyEntry instanceof HistoryEntry) {
73  return '';
74  }
75  $historyLabel = LocalizationUtility::translate(
76  'changesInFields',
77  $controllerContext->getRequest()->getControllerExtensionName(),
78  [$historyEntry->getFieldlist()]
79  );
80  $titleLable = LocalizationUtility::translate(
81  'showHistory',
82  $controllerContext->getRequest()->getControllerExtensionName()
83  );
84  $historyIcon = $iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render();
85  $historyHref = BackendUtility::getModuleUrl(
86  'record_history',
87  [
88  'sh_uid' => $historyEntry->getUid(),
89  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
90  ]
91  );
92  $historyLink = '<a href="' . htmlspecialchars($historyHref) . '" title="' . htmlspecialchars($titleLable) . '">' . $historyIcon . '</a>';
93  return $historyLabel . '&nbsp;' . $historyLink;
94  }
95 }
static translate($key, $extensionName, $arguments=null)
render($uid)
$uid
Definition: server.php:38
static renderStatic(array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)