TYPO3 CMS  TYPO3_7-6
PermissionsViewHelper.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 
29 {
33  protected static $permissionLabels = [];
34 
43  public function render($permission, $scope, $pageId)
44  {
45  return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
46  }
47 
58  {
59  $masks = [1, 16, 2, 4, 8];
60 
61  if (empty(static::$permissionLabels)) {
62  foreach ($masks as $mask) {
63  static::$permissionLabels[$mask] = LocalizationUtility::translate(
64  'LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:' . $mask,
65  'be_user'
66  );
67  }
68  }
69 
70  $icon = '';
71  foreach ($masks as $mask) {
72  if ($arguments['permission'] & $mask) {
73  $permissionClass = 'fa-check text-success';
74  $mode = 'delete';
75  } else {
76  $permissionClass = 'fa-times text-danger';
77  $mode = 'add';
78  }
79 
80  $label = htmlspecialchars(static::$permissionLabels[$mask]);
81  $icon .= '<span style="cursor:pointer"'
82  . ' title="' . $label . '"'
83  . ' data-toggle="tooltip"'
84  . ' data-page="' . $arguments['pageId'] . '"'
85  . ' data-permissions="' . $arguments['permission'] . '"'
86  . ' data-who="' . $arguments['scope'] . '"'
87  . ' data-bits="' . $mask . '"'
88  . ' data-mode="' . $mode . '"'
89  . ' class="t3-icon change-permission fa ' . $permissionClass . '"></span>';
90  }
91 
92  return '<span id="' . $arguments['pageId'] . '_' . $arguments['scope'] . '">' . $icon . '</span>';
93  }
94 }
static translate($key, $extensionName, $arguments=null)
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)