TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AvatarViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\ViewHelpers;
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  */
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
22 
27 {
28  use CompileWithRenderStatic;
29 
35  protected $escapeOutput = false;
36 
40  public function initializeArguments()
41  {
42  parent::initializeArguments();
43  $this->registerArgument('backendUser', 'int', 'Uid of the user', false, 0);
44  $this->registerArgument('size', 'int', 'width and height of the image', false, 32);
45  $this->registerArgument('showIcon', 'bool', 'show the record icon', false, false);
46  }
47 
56  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
57  {
58  if ($arguments['backendUser'] > 0) {
59  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
60  $queryBuilder->getRestrictions()->removeAll();
61  $backendUser = $queryBuilder
62  ->select('*')
63  ->from('be_users')
64  ->where(
65  $queryBuilder->expr()->eq(
66  'uid',
67  $queryBuilder->createNamedParameter($arguments['backendUser'], \PDO::PARAM_INT)
68  )
69  )
70  ->execute()
71  ->fetch();
72  } else {
73  $backendUser = $GLOBALS['BE_USER']->user;
74  }
76  $avatar = GeneralUtility::makeInstance(Avatar::class);
77  return $avatar->render($backendUser, $arguments['size'], $arguments['showIcon']);
78  }
79 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)