[BUGFIX] Reports status listing table
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / ViewHelpers / ActionMenuItemViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Reports\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 */
16
17 /**
18 * Render an item of the menu
19 */
20 class ActionMenuItemViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper {
21
22 /**
23 * @var string
24 */
25 protected $tagName = 'option';
26
27 /**
28 * Renders an ActionMenu option tag
29 *
30 * @param string $label label of the option tag
31 * @param string $controller controller to be associated with this ActionMenuItem
32 * @param string $action the action to be associated with this ActionMenuItem
33 * @param array $arguments additional controller arguments to be passed to the action when this ActionMenuItem is selected
34 * @return string the rendered option tag
35 * @see Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper
36 */
37 public function render($label, $controller, $action, array $arguments = array()) {
38 $uriBuilder = $this->controllerContext->getUriBuilder();
39 $uri = $uriBuilder->reset()->uriFor($action, $arguments, $controller);
40 $this->tag->addAttribute('value', $uri);
41 $currentRequest = $this->controllerContext->getRequest();
42 $currentController = $currentRequest->getControllerName();
43 $currentAction = $currentRequest->getControllerActionName();
44 $currentArguments = $currentRequest->getArguments();
45 unset($currentArguments['action']);
46 unset($currentArguments['controller']);
47 unset($currentArguments['redirect']);
48
49 if ($action === $currentAction && $controller === $currentController && $currentArguments === $arguments) {
50 $this->tag->addAttribute('selected', 'selected');
51 }
52 $this->tag->setContent($label);
53 return $this->tag->render();
54 }
55
56 }