[TASK] Reports module based on extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / ViewHelpers / ActionMenuItemViewHelper.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Georg Ringer <typo3@ringerge.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Render an item of the menu
27 *
28 * @package TYPO3
29 * @subpackage tx_reports
30 */
31 class Tx_Reports_ViewHelpers_ActionMenuItemViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper {
32
33 /**
34 * @var string
35 */
36 protected $tagName = 'option';
37
38 /**
39 * Renders an ActionMenu option tag
40 *
41 * @param string $label label of the option tag
42 * @param string $controller controller to be associated with this ActionMenuItem
43 * @param string $action the action to be associated with this ActionMenuItem
44 * @param array $arguments additional controller arguments to be passed to the action when this ActionMenuItem is selected
45 * @return string the rendered option tag
46 * @see Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper
47 */
48 public function render($label, $controller, $action, array $arguments = array()) {
49 $uriBuilder = $this->controllerContext->getUriBuilder();
50 $uri = $uriBuilder
51 ->reset()
52 ->uriFor($action, $arguments, $controller);
53 $this->tag->addAttribute('value', $uri);
54
55 $currentRequest = $this->controllerContext->getRequest();
56 $currentController = $currentRequest->getControllerName();
57 $currentAction = $currentRequest->getControllerActionName();
58 $currentArguments = $currentRequest->getArguments();
59
60 unset($currentArguments['action']);
61 unset($currentArguments['controller']);
62 if ($action === $currentAction && $controller === $currentController && $currentArguments === $arguments) {
63 $this->tag->addAttribute('selected', 'selected');
64 }
65
66 $this->tag->setContent($label);
67
68 return $this->tag->render();
69 }
70 }
71 ?>