[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 3 require_once dirname(__FILE__) . '/Widget.php'; 4 5 /** 6 * The Horde_UI_Tabs:: class manages and renders a tab-like interface. 7 * 8 * $Horde: framework/UI/UI/Tabs.php,v 1.27.6.10 2006/06/20 09:08:45 jan Exp $ 9 * 10 * Copyright 2001-2003 Robert E. Coyle <robertecoyle@hotmail.com> 11 * Copyright 2003-2006 Jason M. Felice <jfelice@cronosys.com> 12 * 13 * See the enclosed file COPYING for license information (LGPL). If you 14 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 15 * 16 * @since Horde_UI 0.0.1 17 * @package Horde_UI 18 */ 19 class Horde_UI_Tabs extends Horde_UI_Widget { 20 21 /** 22 * The array of tabs. 23 * 24 * @var array 25 */ 26 var $_tabs = array(); 27 28 /** 29 * Add a tab to the interface. 30 * 31 * @param string $title The text which appears on the tab. 32 * @param string $link The target page. 33 * @param mixed $params Either a string value to set the tab variable to, 34 * or a hash of parameters. If an array, the tab variable 35 * can be set by the 'tabname' key. 36 */ 37 function addTab($title, $link, $params = array()) 38 { 39 if (!is_array($params)) { 40 $params = array('tabname' => $params); 41 } 42 $this->_tabs[] = array_merge(array('title' => $title, 43 'link' => $link, 44 'tabname' => null), 45 $params); 46 } 47 48 /** 49 * Retrieve the title of the tab with the specified name. 50 * 51 * @param string $tabname The name of the tab. 52 * 53 * @return string The tab's title. 54 */ 55 function getTitleFromAction($tabname) 56 { 57 foreach ($this->_tabs as $tab) { 58 if ($tab['tabname'] == $tabname) { 59 return $tab['title']; 60 } 61 } 62 63 return null; 64 } 65 66 /** 67 * Renders the tabs. 68 * 69 * @param string $active_tab If specified, the name of the active tab. If 70 * not, the active tab is determined 71 * automatically. 72 */ 73 function render($active_tab = null) 74 { 75 $html = "<div class=\"tabset\"><ul>\n"; 76 77 $first = true; 78 $active = $_SERVER['PHP_SELF'] . $this->_vars->get($this->_name); 79 80 foreach ($this->_tabs as $tab) { 81 $link = $this->_addPreserved($tab['link']); 82 if (!is_null($this->_name) && !is_null($tab['tabname'])) { 83 $link = Util::addParameter($link, $this->_name, 84 $tab['tabname']); 85 } 86 87 $class = ''; 88 if ((!is_null($active_tab) && $active_tab == $tab['tabname']) || 89 ($active == $tab['link'] . $tab['tabname'])) { 90 $class = ' class="activeTab"'; 91 } 92 93 if (!isset($tab['target'])) { 94 $tab['target'] = ''; 95 } 96 97 if (!isset($tab['onclick'])) { 98 $tab['onclick'] = ''; 99 } 100 101 $accesskey = Horde::getAccessKey($tab['title']); 102 103 $html .= '<li' . $class . '>' . 104 Horde::link($link, '', '', $tab['target'], $tab['onclick'], null, $accesskey) . 105 Horde::highlightAccessKey(str_replace(' ', ' ', $tab['title']), $accesskey) . 106 "</a> </li>\n"; 107 } 108 109 return $html . "</ul></div><br class=\"clear\" />\n"; 110 } 111 112 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |