‪TYPO3CMS  10.4
IconViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
23 
30 {
36  protected ‪$escapeOutput = false;
37 
41  public function ‪initializeArguments()
42  {
43  parent::initializeArguments();
44  $this->registerArgument('icon', 'string', 'Icon to be used', true);
45  $this->registerArgument('title', 'string', 'Optional title', false, '');
46  }
47 
53  public function ‪render()
54  {
55  return static::renderStatic(
56  $this->arguments,
57  $this->buildRenderChildrenClosure(),
58  $this->renderingContext
59  );
60  }
61 
69  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
70  {
71  $icon = $arguments['icon'];
72  $title = $arguments['title'];
73 
74  $icon = GeneralUtility::getFileAbsFileName($icon);
75 
76  // use the extension icon from EXT:reports as fallback
77  if (!$icon) {
78  $fallbackIconPath = ‪ExtensionManagementUtility::extPath('reports');
79  $icon = ‪ExtensionManagementUtility::getExtensionIcon($fallbackIconPath, true);
80  }
81 
82  return '<img src="' . htmlspecialchars(‪PathUtility::getAbsoluteWebPath($icon))
83  . '" width="16" height="16" title="' . htmlspecialchars($title)
84  . '" alt="' . htmlspecialchars($title) . '" />';
85  }
86 }
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:24
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: IconViewHelper.php:35
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: IconViewHelper.php:68
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper
Definition: IconViewHelper.php:30
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\render
‪string render()
Definition: IconViewHelper.php:52
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\initializeArguments
‪initializeArguments()
Definition: IconViewHelper.php:40
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:28
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:43
‪TYPO3\CMS\Reports\ViewHelpers
Definition: IconViewHelper.php:16
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\extPath
‪static string extPath($key, $script='')
Definition: ExtensionManagementUtility.php:127
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\getExtensionIcon
‪static string getExtensionIcon($extensionPath, $returnFullPath=false)
Definition: ExtensionManagementUtility.php:1518
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:43