Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
c47d2fcb
Commit
c47d2fcb
authored
Oct 23, 2005
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#33220
by Tobias: improved themeability of book module.
parent
5a90aa11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
46 deletions
+60
-46
modules/book.module
modules/book.module
+30
-23
modules/book/book.module
modules/book/book.module
+30
-23
No files found.
modules/book.module
View file @
c47d2fcb
...
@@ -444,7 +444,17 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
...
@@ -444,7 +444,17 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
foreach
(
$book
as
$key
=>
$value
)
{
foreach
(
$book
as
$key
=>
$value
)
{
$node
->
$key
=
$value
;
$node
->
$key
=
$value
;
}
}
$node
=
theme
(
'book_navigation'
,
$node
);
$path
=
book_location
(
$node
);
// Construct the breadcrumb:
$node
->
breadcrumb
=
array
();
// Overwrite the trail with a book trail.
foreach
(
$path
as
$level
)
{
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$level
->
nid
,
'title'
=>
$level
->
title
);
}
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$node
->
nid
);
$node
->
body
.
=
theme
(
'book_navigation'
,
$node
);
if
(
$page
)
{
if
(
$page
)
{
menu_set_location
(
$node
->
breadcrumb
);
menu_set_location
(
$node
->
breadcrumb
);
}
}
...
@@ -461,16 +471,6 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
...
@@ -461,16 +471,6 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
* @ingroup themeable
* @ingroup themeable
*/
*/
function
theme_book_navigation
(
$node
)
{
function
theme_book_navigation
(
$node
)
{
$path
=
book_location
(
$node
);
// Construct the breadcrumb:
$node
->
breadcrumb
=
array
();
// Overwrite the trail with a book trail.
foreach
(
$path
as
$level
)
{
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$level
->
nid
,
'title'
=>
$level
->
title
);
}
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$node
->
nid
);
if
(
$node
->
nid
)
{
if
(
$node
->
nid
)
{
$output
.
=
'<div class="book">'
;
$output
.
=
'<div class="book">'
;
...
@@ -509,9 +509,7 @@ function theme_book_navigation($node) {
...
@@ -509,9 +509,7 @@ function theme_book_navigation($node) {
$output
.
=
'</div>'
;
$output
.
=
'</div>'
;
}
}
$node
->
body
=
$node
->
body
.
$output
;
return
$output
;
return
$node
;
}
}
/**
/**
...
@@ -657,7 +655,6 @@ function book_render() {
...
@@ -657,7 +655,6 @@ function book_render() {
*
*
*/
*/
function
book_export
(
$type
=
'html'
,
$nid
=
FALSE
)
{
function
book_export
(
$type
=
'html'
,
$nid
=
FALSE
)
{
global
$base_url
;
$type
=
drupal_strtolower
(
$type
);
$type
=
drupal_strtolower
(
$type
);
$node
=
node_load
(
$nid
);
$node
=
node_load
(
$nid
);
if
(
$node
)
{
if
(
$node
)
{
...
@@ -684,14 +681,7 @@ function book_export($type = 'html', $nid = FALSE) {
...
@@ -684,14 +681,7 @@ function book_export($type = 'html', $nid = FALSE) {
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$output
.
=
"</div>
\n
"
;
$output
.
=
"</div>
\n
"
;
}
}
$html
=
"<!DOCTYPE html PUBLIC
\"
-//W3C//DTD XHTML 1.0 Transitional//EN
\"
\"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
\"
>
\n
"
;
print
theme
(
'book_export_html'
,
check_plain
(
$node
->
title
),
$output
);
$html
.
=
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'
;
$html
.
=
"<head>
\n
<title>"
.
check_plain
(
$node
->
title
)
.
"</title>
\n
"
;
$html
.
=
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'
;
$html
.
=
'<base href="'
.
$base_url
.
'/" />'
.
"
\n
"
;
$html
.
=
"<style type=
\"
text/css
\"
>
\n
@import url(misc/print.css);
\n
</style>
\n
"
;
$html
.
=
"</head>
\n
<body>
\n
"
.
$output
.
"
\n
</body>
\n
</html>
\n
"
;
print
$html
;
}
}
else
{
else
{
drupal_access_denied
();
drupal_access_denied
();
...
@@ -720,6 +710,23 @@ function book_export($type = 'html', $nid = FALSE) {
...
@@ -720,6 +710,23 @@ function book_export($type = 'html', $nid = FALSE) {
}
}
}
}
/**
* How the book's HTML export should be themed
*
* @ingroup themeable
*/
function
theme_book_export_html
(
$title
,
$content
)
{
global
$base_url
;
$html
=
"<!DOCTYPE html PUBLIC
\"
-//W3C//DTD XHTML 1.0 Transitional//EN
\"
\"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
\"
>
\n
"
;
$html
.
=
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'
;
$html
.
=
"<head>
\n
<title>"
.
$title
.
"</title>
\n
"
;
$html
.
=
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'
;
$html
.
=
'<base href="'
.
$base_url
.
'/" />'
.
"
\n
"
;
$html
.
=
"<style type=
\"
text/css
\"
>
\n
@import url(misc/print.css);
\n
</style>
\n
"
;
$html
.
=
"</head>
\n
<body>
\n
"
.
$content
.
"
\n
</body>
\n
</html>
\n
"
;
return
$html
;
}
/**
/**
* Given a node, this function returns the depth of the node in its hierarchy.
* Given a node, this function returns the depth of the node in its hierarchy.
* A root node has depth 1, and children of a node of depth n have depth (n+1).
* A root node has depth 1, and children of a node of depth n have depth (n+1).
...
...
modules/book/book.module
View file @
c47d2fcb
...
@@ -444,7 +444,17 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
...
@@ -444,7 +444,17 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
foreach
(
$book
as
$key
=>
$value
)
{
foreach
(
$book
as
$key
=>
$value
)
{
$node
->
$key
=
$value
;
$node
->
$key
=
$value
;
}
}
$node
=
theme
(
'book_navigation'
,
$node
);
$path
=
book_location
(
$node
);
// Construct the breadcrumb:
$node
->
breadcrumb
=
array
();
// Overwrite the trail with a book trail.
foreach
(
$path
as
$level
)
{
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$level
->
nid
,
'title'
=>
$level
->
title
);
}
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$node
->
nid
);
$node
->
body
.
=
theme
(
'book_navigation'
,
$node
);
if
(
$page
)
{
if
(
$page
)
{
menu_set_location
(
$node
->
breadcrumb
);
menu_set_location
(
$node
->
breadcrumb
);
}
}
...
@@ -461,16 +471,6 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
...
@@ -461,16 +471,6 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
* @ingroup themeable
* @ingroup themeable
*/
*/
function
theme_book_navigation
(
$node
)
{
function
theme_book_navigation
(
$node
)
{
$path
=
book_location
(
$node
);
// Construct the breadcrumb:
$node
->
breadcrumb
=
array
();
// Overwrite the trail with a book trail.
foreach
(
$path
as
$level
)
{
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$level
->
nid
,
'title'
=>
$level
->
title
);
}
$node
->
breadcrumb
[]
=
array
(
'path'
=>
'node/'
.
$node
->
nid
);
if
(
$node
->
nid
)
{
if
(
$node
->
nid
)
{
$output
.
=
'<div class="book">'
;
$output
.
=
'<div class="book">'
;
...
@@ -509,9 +509,7 @@ function theme_book_navigation($node) {
...
@@ -509,9 +509,7 @@ function theme_book_navigation($node) {
$output
.
=
'</div>'
;
$output
.
=
'</div>'
;
}
}
$node
->
body
=
$node
->
body
.
$output
;
return
$output
;
return
$node
;
}
}
/**
/**
...
@@ -657,7 +655,6 @@ function book_render() {
...
@@ -657,7 +655,6 @@ function book_render() {
*
*
*/
*/
function
book_export
(
$type
=
'html'
,
$nid
=
FALSE
)
{
function
book_export
(
$type
=
'html'
,
$nid
=
FALSE
)
{
global
$base_url
;
$type
=
drupal_strtolower
(
$type
);
$type
=
drupal_strtolower
(
$type
);
$node
=
node_load
(
$nid
);
$node
=
node_load
(
$nid
);
if
(
$node
)
{
if
(
$node
)
{
...
@@ -684,14 +681,7 @@ function book_export($type = 'html', $nid = FALSE) {
...
@@ -684,14 +681,7 @@ function book_export($type = 'html', $nid = FALSE) {
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$output
.
=
"</div>
\n
"
;
$output
.
=
"</div>
\n
"
;
}
}
$html
=
"<!DOCTYPE html PUBLIC
\"
-//W3C//DTD XHTML 1.0 Transitional//EN
\"
\"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
\"
>
\n
"
;
print
theme
(
'book_export_html'
,
check_plain
(
$node
->
title
),
$output
);
$html
.
=
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'
;
$html
.
=
"<head>
\n
<title>"
.
check_plain
(
$node
->
title
)
.
"</title>
\n
"
;
$html
.
=
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'
;
$html
.
=
'<base href="'
.
$base_url
.
'/" />'
.
"
\n
"
;
$html
.
=
"<style type=
\"
text/css
\"
>
\n
@import url(misc/print.css);
\n
</style>
\n
"
;
$html
.
=
"</head>
\n
<body>
\n
"
.
$output
.
"
\n
</body>
\n
</html>
\n
"
;
print
$html
;
}
}
else
{
else
{
drupal_access_denied
();
drupal_access_denied
();
...
@@ -720,6 +710,23 @@ function book_export($type = 'html', $nid = FALSE) {
...
@@ -720,6 +710,23 @@ function book_export($type = 'html', $nid = FALSE) {
}
}
}
}
/**
* How the book's HTML export should be themed
*
* @ingroup themeable
*/
function
theme_book_export_html
(
$title
,
$content
)
{
global
$base_url
;
$html
=
"<!DOCTYPE html PUBLIC
\"
-//W3C//DTD XHTML 1.0 Transitional//EN
\"
\"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
\"
>
\n
"
;
$html
.
=
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'
;
$html
.
=
"<head>
\n
<title>"
.
$title
.
"</title>
\n
"
;
$html
.
=
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'
;
$html
.
=
'<base href="'
.
$base_url
.
'/" />'
.
"
\n
"
;
$html
.
=
"<style type=
\"
text/css
\"
>
\n
@import url(misc/print.css);
\n
</style>
\n
"
;
$html
.
=
"</head>
\n
<body>
\n
"
.
$content
.
"
\n
</body>
\n
</html>
\n
"
;
return
$html
;
}
/**
/**
* Given a node, this function returns the depth of the node in its hierarchy.
* Given a node, this function returns the depth of the node in its hierarchy.
* A root node has depth 1, and children of a node of depth n have depth (n+1).
* A root node has depth 1, and children of a node of depth n have depth (n+1).
...
...
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