[TASK] Reports module based on extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / ViewHelpers / IconViewHelper.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Georg Ringer <typo3@ringerge.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Render the icon of a report
27 *
28 * @package TYPO3
29 * @subpackage tx_reports
30 */
31 class Tx_Reports_ViewHelpers_IconViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
32
33 /**
34 * Renders the icon
35 *
36 * @param string $icon Icon to be used
37 * @param string $title Optional title
38 * @return strin Content rendered image
39 */
40 public function render($icon, $title = '') {
41 if (!empty($icon)) {
42 $absIconPath = t3lib_div::getFileAbsFilename($icon);
43
44 if (file_exists($absIconPath)) {
45 $icon = $GLOBALS['BACK_PATH'] . '../' . str_replace(PATH_site, '', $absIconPath);
46 }
47 } else {
48 $icon = t3lib_extMgm::extRelPath('reports') . 'Resources/Public/moduleicon.gif';
49 }
50
51 $content = '<img' . t3lib_iconworks::skinImg($GLOBALS['BACK_PATH'], $icon, 'width="16" height="16"') .
52 ' title="' . htmlspecialchars($title) . '" alt="' . htmlspecialchars($title) . '" />';
53
54 return $content;
55 }
56
57 }
58 ?>