|
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 save button with icon 00024 * Note: This view helper is experimental! 00025 * 00026 * = Examples = 00027 * 00028 * <code title="Default"> 00029 * <f:be.buttons.icon uri="{f:uri.action()}" /> 00030 * </code> 00031 * <output> 00032 * An icon button as known from the TYPO3 backend, skinned and linked with the default action of the current controller. 00033 * Note: By default the "close" icon is used as image 00034 * </output> 00035 * 00036 * <code title="Default"> 00037 * <f:be.buttons.icon uri="{f:uri.action(action='new')}" icon="new_el" title="Create new Foo" /> 00038 * </code> 00039 * <output> 00040 * This time the "new_el" icon is returned, the button has the title attribute set and links to the "new" action of the current controller. 00041 * </output> 00042 * 00043 * @author Steffen Kamper <info@sk-typo3.de> 00044 * @author Bastian Waidelich <bastian@typo3.org> 00045 * @license http://www.gnu.org/copyleft/gpl.html 00046 */ 00047 class Tx_Fluid_ViewHelpers_Be_Buttons_IconViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper { 00048 00049 /** 00050 * @var array allowed icons to be used with this view helper 00051 */ 00052 protected $allowedIcons = array('add', 'add_workspace', 'button_down', 'button_hide', 'button_left', 'button_unhide', 'button_right', 'button_up', 'clear_cache', 'clip_copy', 'clip_cut', 'clip_pasteafter', 'closedok', 'datepicker', 'deletedok', 'edit2', 'helpbubble', 'icon_fatalerror', 'icon_note', 'icon_ok', 'icon_warning', 'new_el', 'options', 'perm', 'refresh_n', 'saveandclosedok', 'savedok', 'savedoknew', 'savedokshow', 'viewdok', 'zoom'); 00053 00054 /** 00055 * Renders an icon link as known from the TYPO3 backend 00056 * 00057 * @param string $uri the target URI for the link. If you want to execute JavaScript here, prefix the URI with "javascript:" 00058 * @param string $icon Icon to be used. See self::allowedIcons for a list of allowed icon names 00059 * @param string $title Title attribte of the resulting link 00060 * @return string the rendered icon link 00061 */ 00062 public function render($uri, $icon = 'closedok', $title = '') { 00063 if (!in_array($icon, $this->allowedIcons)) { 00064 throw new Tx_Fluid_Core_ViewHelper_Exception('"' . $icon . '" is no valid icon. Allowed are "' . implode('", "', $this->allowedIcons) .'".', 1253208523); 00065 } 00066 00067 $skinnedIcon = t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/' . $icon . '.gif', ''); 00068 return '<a href="' . $uri . '"><img' . $skinnedIcon . '" title="' . htmlspecialchars($title) . '" alt="" /></a>'; 00069 } 00070 } 00071 ?>
1.8.0