Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
306
Merge Requests
306
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
035713ea
Commit
035713ea
authored
May 23, 2008
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#239071
by flobruit and Moshe: add support for colgroup tag to theme_table().
parent
d9546f6d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
1 deletion
+66
-1
includes/theme.inc
includes/theme.inc
+66
-1
No files found.
includes/theme.inc
View file @
035713ea
...
...
@@ -1234,10 +1234,40 @@ function theme_submenu($links) {
* An array of HTML attributes to apply to the table tag.
* @param $caption
* A localized string to use for the <caption> tag.
* @param $colgroups
* An array of column groups. Each element of the array can be either:
* - An array of columns, each of which is an associative array of HTML attributes
* applied to the COL element.
* - An array of attributes applied to the COLGROUP element, which must include a
* "data" attribute. To add attributes to COL elements, set the "data" attribute
* with an array of columns, each of which is an associative array of HTML attributes.
* Here's an example for $colgroup:
* @verbatim
* $colgroup = array(
* // COLGROUP with one COL element.
* array(
* array(
* 'class' => 'funky', // Attribute for the COL element.
* ),
* ),
* // Colgroup with attributes and inner COL elements.
* array(
* 'data' => array(
* array(
* 'class' => 'funky', // Attribute for the COL element.
* ),
* ),
* 'class' => 'jazzy', // Attribute for the COLGROUP element.
* ),
* );
* @endverbatim
* These optional tags are used to group and set properties on columns
* within a table. For example, one may easily group three columns and
* apply same background style to all.
* @return
* An HTML string representing the table.
*/
function
theme_table
(
$header
,
$rows
,
$attributes
=
array
(),
$caption
=
NULL
)
{
function
theme_table
(
$header
,
$rows
,
$attributes
=
array
(),
$caption
=
NULL
,
$colgroups
=
array
()
)
{
// Add sticky headers, if applicable.
if
(
count
(
$header
))
{
...
...
@@ -1253,6 +1283,41 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
$output
.
=
'<caption>'
.
$caption
.
"</caption>
\n
"
;
}
// Format the table columns:
if
(
count
(
$colgroups
))
{
foreach
(
$colgroups
as
$number
=>
$colgroup
)
{
$attributes
=
array
();
// Check if we're dealing with a simple or complex column
if
(
isset
(
$colgroup
[
'data'
]))
{
foreach
(
$colgroup
as
$key
=>
$value
)
{
if
(
$key
==
'data'
)
{
$cols
=
$value
;
}
else
{
$attributes
[
$key
]
=
$value
;
}
}
}
else
{
$cols
=
$colgroup
;
}
// Build colgroup
if
(
is_array
(
$cols
)
&&
count
(
$cols
))
{
$output
.
=
' <colgroup'
.
drupal_attributes
(
$attributes
)
.
'>'
;
$i
=
0
;
foreach
(
$cols
as
$col
)
{
$output
.
=
' <col'
.
drupal_attributes
(
$col
)
.
' />'
;
}
$output
.
=
" </colgroup>
\n
"
;
}
else
{
$output
.
=
' <colgroup'
.
drupal_attributes
(
$attributes
)
.
" />
\n
"
;
}
}
}
// Format the table header:
if
(
count
(
$header
))
{
$ts
=
tablesort_init
(
$header
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment