‪TYPO3CMS  9.5
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 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
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 
73  $icon = GeneralUtility::getFileAbsFileName($icon);
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 }
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:23
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: IconViewHelper.php:34
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: IconViewHelper.php:67
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper
Definition: IconViewHelper.php:29
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\render
‪string render()
Definition: IconViewHelper.php:51
‪TYPO3\CMS\Reports\ViewHelpers\IconViewHelper\initializeArguments
‪initializeArguments()
Definition: IconViewHelper.php:39
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:27
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Reports\ViewHelpers
Definition: IconViewHelper.php:2
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\extPath
‪static string extPath($key, $script='')
Definition: ExtensionManagementUtility.php:149
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\getExtensionIcon
‪static string getExtensionIcon($extensionPath, $returnFullPath=false)
Definition: ExtensionManagementUtility.php:1511
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:42