|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /* * 00003 * This script belongs to the FLOW3 package "Fluid". * 00004 * * 00005 * It is free software; you can redistribute it and/or modify it under * 00006 * the terms of the GNU Lesser General Public License as published by the * 00007 * Free Software Foundation, either version 3 of the License, or (at your * 00008 * option) any later version. * 00009 * * 00010 * This script is distributed in the hope that it will be useful, but * 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * 00012 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * 00013 * General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Lesser General Public * 00016 * License along with the script. * 00017 * If not, see http://www.gnu.org/licenses/lgpl.html * 00018 * * 00019 * The TYPO3 project - inspiring people to share! * 00020 * */ 00021 00022 /** 00023 * View helper which returns a select box, that can be used to switch between 00024 * multiple actions and controllers and looks similar to TYPO3s funcMenu. 00025 * Note: This view helper is experimental! 00026 * 00027 * = Examples = 00028 * 00029 * <code title="Simple"> 00030 * <f:be.menus.actionMenu> 00031 * <f:be.menus.actionMenuItem label="Overview" controller="Blog" action="index" /> 00032 * <f:be.menus.actionMenuItem label="Create new Blog" controller="Blog" action="new" /> 00033 * <f:be.menus.actionMenuItem label="List Posts" controller="Post" action="index" arguments="{blog: blog}" /> 00034 * </f:be.menus.actionMenu> 00035 * </code> 00036 * <output> 00037 * Selectbox with the options "Overview", "Create new Blog" and "List Posts" 00038 * </output> 00039 * 00040 * <code title="Localized"> 00041 * <f:be.menus.actionMenu> 00042 * <f:be.menus.actionMenuItem label="{f:translate(key='overview')}" controller="Blog" action="index" /> 00043 * <f:be.menus.actionMenuItem label="{f:translate(key='create_blog')}" controller="Blog" action="new" /> 00044 * </f:be.menus.actionMenu> 00045 * </code> 00046 * <output> 00047 * localized selectbox 00048 * <output> 00049 * 00050 * @author Steffen Kamper <info@sk-typo3.de> 00051 * @author Bastian Waidelich <bastian@typo3.org> 00052 * @license http://www.gnu.org/copyleft/gpl.html 00053 */ 00054 class Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper implements Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface { 00055 00056 /** 00057 * @var string 00058 */ 00059 protected $tagName = 'select'; 00060 00061 /** 00062 * An array of Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode 00063 * @var array 00064 */ 00065 protected $childNodes = array(); 00066 00067 /** 00068 * Setter for ChildNodes - as defined in ChildNodeAccessInterface 00069 * 00070 * @param array $childNodes Child nodes of this syntax tree node 00071 * @return void 00072 * @author Sebastian Kurfürst <sebastian@typo3.org> 00073 * @api 00074 */ 00075 public function setChildNodes(array $childNodes) { 00076 $this->childNodes = $childNodes; 00077 } 00078 00079 /** 00080 * Render FunctionMenu 00081 * 00082 * @param string $defaultController 00083 * @return string 00084 */ 00085 public function render($defaultController = NULL) { 00086 $this->tag->addAttribute('onchange', 'jumpToUrl(this.options[this.selectedIndex].value, this);'); 00087 $options = ''; 00088 foreach ($this->childNodes as $childNode) { 00089 if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode) { 00090 $options .= $childNode->evaluate($this->getRenderingContext()); 00091 } 00092 } 00093 $this->tag->setContent($options); 00094 return '<div class="docheader-funcmenu">' . $this->tag->render() . '</div>'; 00095 } 00096 } 00097 ?>
1.8.0