2 namespace TYPO3\CMS\Fluid\ViewHelpers\Be\Menus
;
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
12 * This script is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15 * General Public License for more details. *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with the script. *
19 * If not, see http://www.gnu.org/licenses/lgpl.html *
21 * The TYPO3 project - inspiring people to share! *
24 * View helper which returns a select box, that can be used to switch between
25 * multiple actions and controllers and looks similar to TYPO3s funcMenu.
26 * Note: This view helper is experimental!
30 * <code title="Simple">
31 * <f:be.menus.actionMenu>
32 * <f:be.menus.actionMenuItem label="Overview" controller="Blog" action="index" />
33 * <f:be.menus.actionMenuItem label="Create new Blog" controller="Blog" action="new" />
34 * <f:be.menus.actionMenuItem label="List Posts" controller="Post" action="index" arguments="{blog: blog}" />
35 * </f:be.menus.actionMenu>
38 * Selectbox with the options "Overview", "Create new Blog" and "List Posts"
41 * <code title="Localized">
42 * <f:be.menus.actionMenu>
43 * <f:be.menus.actionMenuItem label="{f:translate(key:'overview')}" controller="Blog" action="index" />
44 * <f:be.menus.actionMenuItem label="{f:translate(key:'create_blog')}" controller="Blog" action="new" />
45 * </f:be.menus.actionMenu>
51 class ActionMenuViewHelper
extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper
implements \TYPO3\CMS\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface
{
56 protected $tagName = 'select';
59 * An array of Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode
63 protected $childNodes = array();
66 * Setter for ChildNodes - as defined in ChildNodeAccessInterface
68 * @param array $childNodes Child nodes of this syntax tree node
72 public function setChildNodes(array $childNodes) {
73 $this->childNodes
= $childNodes;
79 * @param string $defaultController
82 public function render($defaultController = NULL) {
83 $this->tag
->addAttribute('onchange', 'jumpToUrl(this.options[this.selectedIndex].value, this);');
85 foreach ($this->childNodes
as $childNode) {
86 if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode
) {
87 $options .= $childNode->evaluate($this->renderingContext
);
90 $this->tag
->setContent($options);
91 return '<div class="docheader-funcmenu">' . $this->tag
->render() . '</div>';