34dc03f5d8488a896768fab12a4aa6cbd87b72dd
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / ViewHelpers / IconViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Reports\ViewHelpers;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Georg Ringer <typo3@ringerge.org>
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 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Render the icon of a report
28 *
29 */
30 class IconViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper {
31
32 /**
33 * Renders the icon
34 *
35 * @param string $icon Icon to be used
36 * @param string $title Optional title
37 * @return string Content rendered image
38 */
39 public function render($icon, $title = '') {
40 if (!empty($icon)) {
41 $absIconPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFilename($icon);
42 if (file_exists($absIconPath)) {
43 $icon = $GLOBALS['BACK_PATH'] . '../' . str_replace(PATH_site, '', $absIconPath);
44 }
45 } else {
46 $icon = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('reports') . 'ext_icon.png';
47 }
48 $content = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], $icon, 'width="16" height="16"') . ' title="' . htmlspecialchars($title) . '" alt="' . htmlspecialchars($title) . '" />';
49 return $content;
50 }
51
52 }