TYPO3 CMS  TYPO3_8-7
IconViewHelper.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 
22 
29 {
35  protected $escapeOutput = false;
36 
40  public function initializeArguments()
41  {
42  parent::initializeArguments();
43  $this->registerArgument('icon', 'string', 'Icon to be used', true);
44  $this->registerArgument('title', 'string', 'Optional title', false, '');
45  }
46 
52  public function render()
53  {
54  return static::renderStatic(
55  $this->arguments,
56  $this->buildRenderChildrenClosure(),
57  $this->renderingContext
58  );
59  }
60 
68  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
69  {
70  $icon = $arguments['icon'];
71  $title = $arguments['title'];
72 
74 
75  // use the extension icon from EXT:reports as fallback
76  if (!$icon) {
77  $fallbackIconPath = ExtensionManagementUtility::extPath('reports');
78  $icon = ExtensionManagementUtility::getExtensionIcon($fallbackIconPath, true);
79  }
80 
81  return '<img src="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($icon))
82  . '" width="16" height="16" title="' . htmlspecialchars($title)
83  . '" alt="' . htmlspecialchars($title) . '" />';
84  }
85 }
static getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:40
static getFileAbsFileName($filename, $_=null, $_2=null)
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
static getExtensionIcon($extensionPath, $returnFullPath=false)