[TASK] Re-work/simplify copyright header in PHP files - Part 2
[Packages/TYPO3.CMS.git] / typo3 / sysext / documentation / Classes / ViewHelpers / Be / Security / IfAdminViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Documentation\ViewHelpers\Be\Security;
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
17 /**
18 * This view helper checks whether a given BE user is admin or not.
19 *
20 * = Examples =
21 *
22 * <code title="Basic usage">
23 * <doc:be.security.ifAdmin>
24 * You see this is you're an admin.
25 * </doc:be.security.ifAdmin>
26 * </code>
27 * <output>
28 * You see this is you're an admin. (if an admin user, of course)
29 * </output>
30 *
31 * <code title="Usage with then / else">
32 * <doc:be.security.ifAdmin>
33 * <f:then>
34 * You see this is you're an admin.
35 * </f:then>
36 * <f:else>
37 * You see this is you're not an admin.
38 * </f:else>
39 * </doc:be.security.ifAdmin>
40 * </code>
41 * <output>
42 * Content of the "then" tag if an admin, content of the "else" tag otherwise.
43 * </output>
44 *
45 * @api
46 */
47 class IfAdminViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper {
48
49 /**
50 * Renders <f:then> child if the current logged in BE user is an admin,
51 * otherwise renders <f:else> child.
52 *
53 * @return string the rendered string
54 * @api
55 */
56 public function render() {
57 if ($GLOBALS['BE_USER']->isAdmin()) {
58 return $this->renderThenChild();
59 } else {
60 return $this->renderElseChild();
61 }
62 }
63 }