public static function getHtmlTab($tab, $url_params = array())
{
// default values
$defaults = array('text' => '', 'class' => '', 'active' => null, 'link' => '', 'sep' => '?', 'attr' => '', 'args' => '', 'warning' => '', 'fragment' => '', 'id' => '');
$tab = array_merge($defaults, $tab);
// determine additional style-class
if (empty($tab['class'])) {
if (!empty($tab['active']) || PMA_isValid($GLOBALS['active_page'], 'identical', $tab['link'])) {
$tab['class'] = 'active';
} elseif (is_null($tab['active']) && empty($GLOBALS['active_page']) && basename($GLOBALS['PMA_PHP_SELF']) == $tab['link']) {
$tab['class'] = 'active';
}
}
// If there are any tab specific URL parameters, merge those with
// the general URL parameters
if (!empty($tab['url_params']) && is_array($tab['url_params'])) {
$url_params = array_merge($url_params, $tab['url_params']);
}
// build the link
if (!empty($tab['link'])) {
$tab['link'] = htmlentities($tab['link']);
$tab['link'] = $tab['link'] . URL::getCommon($url_params);
if (!empty($tab['args'])) {
foreach ($tab['args'] as $param => $value) {
$tab['link'] .= URL::getArgSeparator('html') . urlencode($param) . '=' . urlencode($value);
}
}
}
if (!empty($tab['fragment'])) {
$tab['link'] .= $tab['fragment'];
}
// display icon
if (isset($tab['icon'])) {
// avoid generating an alt tag, because it only illustrates
// the text that follows and if browser does not display
// images, the text is duplicated
$tab['text'] = self::getIcon($tab['icon'], $tab['text'], false, true, 'TabsMode');
} elseif (empty($tab['text'])) {
// check to not display an empty link-text
$tab['text'] = '?';
trigger_error('empty linktext in function ' . __FUNCTION__ . '()', E_USER_NOTICE);
}
//Set the id for the tab, if set in the params
$tabId = empty($tab['id']) ? null : $tab['id'];
$item = array();
if (!empty($tab['link'])) {
$item = array('content' => $tab['text'], 'url' => array('href' => empty($tab['link']) ? null : $tab['link'], 'id' => $tabId, 'class' => 'tab' . htmlentities($tab['class'])));
} else {
$item['content'] = '<span class="tab' . htmlentities($tab['class']) . '"' . $tabId . '>' . $tab['text'] . '</span>';
}
$item['class'] = $tab['class'] == 'active' ? 'active' : '';
return Template::get('list/item')->render($item);
}