|
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 option tag. 00024 * This view helper only works in conjunction with Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper 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_ActionMenuItemViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper { 00055 00056 /** 00057 * @var string 00058 */ 00059 protected $tagName = 'option'; 00060 00061 /** 00062 * Renders an ActionMenu option tag 00063 * 00064 * @param string $label label of the option tag 00065 * @param string $controller controller to be associated with this ActionMenuItem 00066 * @param string $action the action to be associated with this ActionMenuItem 00067 * @param array $arguments additional controller arguments to be passed to the action when this ActionMenuItem is selected 00068 * @return string the rendered option tag 00069 * @see Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper 00070 */ 00071 public function render($label, $controller, $action, array $arguments = array()) { 00072 $uriBuilder = $this->controllerContext->getUriBuilder(); 00073 $uri = $uriBuilder 00074 ->reset() 00075 ->uriFor($action, $arguments, $controller); 00076 $this->tag->addAttribute('value', $uri); 00077 00078 $currentRequest = $this->controllerContext->getRequest(); 00079 $currentController = $currentRequest->getControllerName(); 00080 $currentAction = $currentRequest->getControllerActionName(); 00081 if ($action === $currentAction && $controller === $currentController) { 00082 $this->tag->addAttribute('selected', TRUE); 00083 } 00084 00085 $this->tag->setContent($label); 00086 00087 return $this->tag->render(); 00088 } 00089 } 00090 ?>
1.8.0