/usr/share/drupal6/modules/views/includes/tabs.inc is in drupal6-mod-views 2.16-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | <?php
/**
* @file
*
* Classes and theme functions for rendering javascript UI tabs.
*/
/**
* Contain a set of tabs as well as the ability to render them.
*
* There are three 'areas' of a tabset.
* - title: The clickable link to display the tab area. These are always visible.
* - body: The actual HTML body of the tab. Only one body is visible at a time.
* - extra: An optional decorative area around the tabs.
*/
class views_tabset {
var $tabs = array();
var $extra = '';
var $selected = NULL;
/**
* Add a tab to the tabset.
*
* @param $name
* The name of the tab; this is the internal identifier and must be
* unique within the tabset.
* @param $title
* If given, this will be the visible title of the tab. This can also
* be set via $tabset->set(). This will be the link to click on to
* view the tab.
* @param $body
* If given, this is the body of the tab itself. It will display
* when the tab title is clicked on.
*/
function add($name, $title = '', $body = '') {
if (is_object($name) && is_subclass_of($name, 'views_tab')) {
$this->add_tab($name);
}
elseif (is_array($name)) {
foreach ($name as $real_tab) {
$this->add($real_tab);
}
}
else {
$this->add_tab(new views_tab($name, $title, $body));
}
}
/**
* Add a fully realized tab object to the tabset.
*
* @param $tab
* A fully populated views_tab object.
*/
function add_tab($tab) {
$this->tabs[$tab->name] = $tab;
}
/**
* Set the values of a tab.
*
* @param $name
* The unique identifier of the tab to set.
* @param $title
* The title of the tab; this will be clickable.
* @param $body
* The HTML body of the tab.
*/
function set($name, $title, $body = NULL) {
if (empty($this->tabs[$name])) {
return $this->add($name, $title, $body);
}
$this->tabs[$name]->title = $title;
if (isset($body)) {
$this->tabs[$name]->body = $body;
}
}
/**
* Set the body of a tab.
*/
function set_body($name, $body) {
if (empty($this->tabs[$name])) {
return $this->add($name, '', $body);
}
$this->tabs[$name]->body = $body;
}
/**
* Add text to the 'extra' region of the tabset.
*/
function add_extra($text) {
$this->extra .= $text;
}
/**
* Remove a tab.
*
* @param $tab
* May be the name of the tab or a views_tab object.
*/
function remove($tab) {
if (is_string($tab)) {
unset($this->tabs[$tab]);
}
else {
unset($this->tabs[$tab->name]);
}
}
/**
* Control which tab will be selected when it is rendered.
*/
function set_selected($name) {
$this->selected = $name;
}
/**
* Output the HTML for the tabs.
*
* @return
* HTML representation of the tabs.
*/
function render() {
views_add_js('tabs');
views_add_css('views-tabs');
if (empty($this->selected)) {
$keys = array_keys($this->tabs);
$this->selected = array_shift($keys);
}
drupal_alter('views_tabset', $this);
return theme('views_tabset', $this->tabs, $this->extra, $this->selected);
}
}
/**
* An object to represent an individual tab within a tabset.
*/
class views_tab {
var $title;
var $body;
var $name;
/**
* Construct a new tab.
*/
function views_tab($name, $title, $body = NULL) {
$this->name = $name;
$this->title = $title;
$this->body = $body;
}
/**
* Generate HTML output for a tab.
*/
function render() {
return theme('views_tab', $this->body);
}
}
/**
* Render a tabset.
*
* @todo Turn this into a template.
*/
function theme_views_tabset($tabs, $extra = NULL, $selected = NULL) {
$link_output = "<div class=\"views-tabs\"><ul id=\"views-tabset\">\n";
$tab_output = "<div class=\"views-tab-area\">\n";
foreach ($tabs as $name => $tab) {
$link_output .= '<li' . ($name == $selected ? ' class="active"': '') . '><a href="#views-tab-' . $tab->name . '" id="views-tab-title-' . $tab->name . '">' . check_plain($tab->title) . '</a></li>' . "\n";
$tab_output .= '<div id="views-tab-' . $tab->name . '" class="views-tab">' . $tab->render() . "</div>\n";
}
$link_output .= "</ul>\n";
if ($extra) {
$link_output .= "<div class=\"extra\">$extra</div>\n";
}
$link_output .= "</div>\n";
$tab_output .= "</div>\n";
return '<div class="views-tabset clear-block">' . $link_output . $tab_output . '</div>';
}
/**
* Theme a simple tab.
*/
function theme_views_tab($body) {
return $body;
}
|