Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
14158fbc
Commit
14158fbc
authored
Dec 29, 2002
by
Dries
Browse files
- Added table rendering functions. As an example, I changed the node module to take advantage of it.
parent
be431bd9
Changes
4
Hide whitespace changes
Inline
Side-by-side
includes/common.inc
View file @
14158fbc
...
...
@@ -182,6 +182,66 @@ function variable_del($name) {
unset
(
$conf
[
$name
]);
}
function
table_cell
(
$cell
,
$header
=
0
)
{
if
(
is_array
(
$cell
))
{
$data
=
$cell
[
"data"
];
foreach
(
$cell
as
$key
=>
$value
)
{
if
(
$key
!=
"data"
)
{
$attributes
.
=
"
$key
=
\"
$value
\"
"
;
}
}
}
else
{
$data
=
$cell
;
}
if
(
$header
)
{
$output
=
"<th
$attributes
>
$data
</th>"
;
}
else
{
$output
=
"<td
$attributes
>
$data
</td>"
;
}
return
$output
;
}
function
table
(
$header
,
$rows
)
{
$output
.
=
"<table>"
;
/*
** Emit the table header:
*/
$output
.
=
" <tr>"
;
foreach
(
$header
as
$cell
)
{
$output
.
=
table_cell
(
$cell
,
1
);
}
$output
.
=
" </tr>"
;
/*
** Emit the table rows:
*/
foreach
(
$rows
as
$number
=>
$row
)
{
if
(
$number
%
2
==
1
)
{
$output
.
=
" <tr class=
\"
light
\"
>"
;
}
else
{
$output
.
=
" <tr class=
\"
dark
\"
>"
;
}
foreach
(
$row
as
$cell
)
{
$output
.
=
table_cell
(
$cell
,
0
);
}
$output
.
=
" </tr>"
;
}
$output
.
=
"</table>"
;
return
$output
;
}
/**
* Format a single result entry of a search query:
*
...
...
misc/admin.css
View file @
14158fbc
...
...
@@ -3,7 +3,6 @@ body {
margin
:
0
;
background-color
:
#fff
;
}
/* text */
body
,
th
,
td
,
h1
,
h2
,
h3
,
h4
,
#menu
,
#main
{
font-family
:
helvetica
,
arial
;
}
...
...
@@ -35,16 +34,20 @@ h3 {
padding
:
0
0
.5em
0
;
}
th
{
font-size
:
90%
;
text-align
:
left
;
vertical-align
:
top
;
background-color
:
#CCCCCC
;
color
:
#995555
;
text-align
:
center
;
color
:
#994444
;
border-bottom
:
1px
solid
#000
;
}
tr
.dark
{
background-color
:
#ccc
;
}
tr
.light
{
background-color
:
#ddd
;
}
td
{
font-size
:
90%
;
padding
:
5px
;
}
/* layout */
#menu
{
position
:
absolute
;
left
:
0px
;
...
...
modules/node.module
View file @
14158fbc
...
...
@@ -493,15 +493,14 @@ function node_admin_nodes() {
$result
=
pager_query
(
"SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid "
.
$queries
[
$query
?
$query
:
0
],
50
);
$
output
.
=
"<table border=
\"
1
\"
cellpadding=
\"
2
\"
cellspacing=
\"
2
\"
>
\n
"
;
$output
.
=
" <tr><th>"
.
t
(
"title"
)
.
"</th><th>"
.
t
(
"type"
)
.
"</th><th>"
.
t
(
"author"
)
.
"</th><th>"
.
t
(
"status"
)
.
"</th><th colspan=
\"
2
\"
>"
.
t
(
"operations"
)
.
"</th></tr>
\n
"
;
$
header
=
array
(
t
(
"title"
),
t
(
"type"
),
t
(
"author"
),
t
(
"status"
),
array
(
"data"
=>
t
(
"operations"
),
"colspan"
=>
2
))
;
while
(
$node
=
db_fetch_object
(
$result
))
{
$
output
.
=
"<tr><td>"
.
l
(
check_output
(
$node
->
title
),
array
(
"id"
=>
$node
->
nid
))
.
"</td><td>"
.
module_invoke
(
$node
->
type
,
"node"
,
"name"
)
.
"</td><td nowrap=
\"
nowrap
\"
>"
.
format_name
(
$node
)
.
"</td><td>"
.
(
$node
->
status
?
t
(
"published"
)
:
t
(
"not published"
))
.
"</td><td nowrap=
\"
nowrap
\"
>"
.
la
(
t
(
"edit node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"edit"
,
"id"
=>
$node
->
nid
))
.
"</td><td nowrap=
\"
nowrap
\"
>"
.
la
(
t
(
"delete node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"delete"
,
"id"
=>
$node
->
nid
))
.
"</td></tr>"
;
$
rows
[]
=
array
(
l
(
check_output
(
$node
->
title
),
array
(
"id"
=>
$node
->
nid
))
,
module_invoke
(
$node
->
type
,
"node"
,
"name"
)
,
format_name
(
$node
)
,
(
$node
->
status
?
t
(
"published"
)
:
t
(
"not published"
))
,
la
(
t
(
"edit node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"edit"
,
"id"
=>
$node
->
nid
))
,
la
(
t
(
"delete node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"delete"
,
"id"
=>
$node
->
nid
))
)
;
}
$output
.
=
"<tr><td colspan=
\"
6
\"
>"
.
pager_display
(
NULL
,
50
,
0
,
"admin"
)
.
"</td></tr></table>"
;
// $output .= "<tr><td colspan=\"6\">". pager_display(NULL, 50, 0, "admin") ."</td></tr></table>";
return
$output
;
return
table
(
$header
,
$rows
)
;
}
/*
...
...
modules/node/node.module
View file @
14158fbc
...
...
@@ -493,15 +493,14 @@ function node_admin_nodes() {
$result
=
pager_query
(
"SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid "
.
$queries
[
$query
?
$query
:
0
],
50
);
$
output
.
=
"<table border=
\"
1
\"
cellpadding=
\"
2
\"
cellspacing=
\"
2
\"
>
\n
"
;
$output
.
=
" <tr><th>"
.
t
(
"title"
)
.
"</th><th>"
.
t
(
"type"
)
.
"</th><th>"
.
t
(
"author"
)
.
"</th><th>"
.
t
(
"status"
)
.
"</th><th colspan=
\"
2
\"
>"
.
t
(
"operations"
)
.
"</th></tr>
\n
"
;
$
header
=
array
(
t
(
"title"
),
t
(
"type"
),
t
(
"author"
),
t
(
"status"
),
array
(
"data"
=>
t
(
"operations"
),
"colspan"
=>
2
))
;
while
(
$node
=
db_fetch_object
(
$result
))
{
$
output
.
=
"<tr><td>"
.
l
(
check_output
(
$node
->
title
),
array
(
"id"
=>
$node
->
nid
))
.
"</td><td>"
.
module_invoke
(
$node
->
type
,
"node"
,
"name"
)
.
"</td><td nowrap=
\"
nowrap
\"
>"
.
format_name
(
$node
)
.
"</td><td>"
.
(
$node
->
status
?
t
(
"published"
)
:
t
(
"not published"
))
.
"</td><td nowrap=
\"
nowrap
\"
>"
.
la
(
t
(
"edit node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"edit"
,
"id"
=>
$node
->
nid
))
.
"</td><td nowrap=
\"
nowrap
\"
>"
.
la
(
t
(
"delete node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"delete"
,
"id"
=>
$node
->
nid
))
.
"</td></tr>"
;
$
rows
[]
=
array
(
l
(
check_output
(
$node
->
title
),
array
(
"id"
=>
$node
->
nid
))
,
module_invoke
(
$node
->
type
,
"node"
,
"name"
)
,
format_name
(
$node
)
,
(
$node
->
status
?
t
(
"published"
)
:
t
(
"not published"
))
,
la
(
t
(
"edit node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"edit"
,
"id"
=>
$node
->
nid
))
,
la
(
t
(
"delete node"
),
array
(
"mod"
=>
"node"
,
"op"
=>
"delete"
,
"id"
=>
$node
->
nid
))
)
;
}
$output
.
=
"<tr><td colspan=
\"
6
\"
>"
.
pager_display
(
NULL
,
50
,
0
,
"admin"
)
.
"</td></tr></table>"
;
// $output .= "<tr><td colspan=\"6\">". pager_display(NULL, 50, 0, "admin") ."</td></tr></table>";
return
$output
;
return
table
(
$header
,
$rows
)
;
}
/*
...
...
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