[TASK] Set TYPO3 version to 7.3-dev
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / Classes / ViewHelpers / HistoryEntryViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Belog\ViewHelpers;
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
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * Get history entry from for log entry
21 *
22 * @author Christian Kuhn <lolli@schwarzbu.ch>
23 * @internal
24 */
25 class HistoryEntryViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
26
27 /**
28 * @var \TYPO3\CMS\Belog\Domain\Repository\HistoryEntryRepository
29 * @inject
30 */
31 protected $historyEntryRepository;
32
33 /**
34 * Get system history record
35 *
36 * @param int $uid Uid of the log entry
37 * @return string Formatted history entry if one exists, else empty string
38 */
39 public function render($uid) {
40 /** @var $historyEntry \TYPO3\CMS\Belog\Domain\Model\HistoryEntry */
41 $historyEntry = $this->historyEntryRepository->findOneBySysLogUid($uid);
42 if (!$historyEntry instanceof \TYPO3\CMS\Belog\Domain\Model\HistoryEntry) {
43 return '';
44 }
45 $historyLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
46 'changesInFields',
47 $this->controllerContext->getRequest()->getControllerExtensionName(),
48 array($historyEntry->getFieldlist())
49 );
50 $historyIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-history-open', array(
51 'title' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('showHistory', $this->controllerContext->getRequest()->getControllerExtensionName())
52 ));
53 $historyHref = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/' .
54 \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(
55 'record_history',
56 array(
57 'sh_uid' => $historyEntry->getUid(),
58 'returnUrl' => \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'),
59 )
60 );
61 $historyLink = '<a href="' . htmlspecialchars($historyHref) . '">' . $historyIcon . '</a>';
62 return $historyLabel . '&nbsp;' . $historyLink;
63 }
64
65 }