[TASK] Make show_rechis.php mod.php dispatched
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / Classes / ViewHelpers / HistoryEntryViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Belog\ViewHelpers;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 use TYPO3\CMS\Core\Utility\GeneralUtility;
29
30 /**
31 * Get history entry from for log entry
32 *
33 * @author Christian Kuhn <lolli@schwarzbu.ch>
34 */
35 class HistoryEntryViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
36
37 /**
38 * @var \TYPO3\CMS\Belog\Domain\Repository\HistoryEntryRepository
39 * @inject
40 */
41 protected $historyEntryRepository;
42
43 /**
44 * Get system history record
45 *
46 * @param integer $uid Uid of the log entry
47 * @return string Formatted history entry if one exists, else empty string
48 */
49 public function render($uid) {
50 /** @var $historyEntry \TYPO3\CMS\Belog\Domain\Model\HistoryEntry */
51 $historyEntry = $this->historyEntryRepository->findOneBySysLogUid($uid);
52 if (!$historyEntry instanceof \TYPO3\CMS\Belog\Domain\Model\HistoryEntry) {
53 return '';
54 }
55 $historyLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
56 'changesInFields',
57 $this->controllerContext->getRequest()->getControllerExtensionName(),
58 array($historyEntry->getFieldlist())
59 );
60 $historyIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-history-open', array(
61 'title' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('showHistory', $this->controllerContext->getRequest()->getControllerExtensionName())
62 ));
63 $historyHref = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/' .
64 \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(
65 'record_history',
66 array(
67 'sh_uid' => $historyEntry->getUid(),
68 'returnUrl' => \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'),
69 )
70 );
71 $historyLink = '<a href="' . htmlspecialchars($historyHref) . '">' . $historyIcon . '</a>';
72 return $historyLabel . '&nbsp;' . $historyLink;
73 }
74
75 }