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
f8e2be5f
Commit
f8e2be5f
authored
Sep 29, 2005
by
Dries
Browse files
- Patch
#32584
by Gerhard: removed reference to node_revision_load() and fixed
input validation error..
parent
c4757dd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/book.module
View file @
f8e2be5f
...
...
@@ -310,34 +310,6 @@ function book_outline() {
}
}
/**
* Return the most recent revision that matches the specified conditions.
*/
function
book_revision_load
(
$page
,
$conditions
=
array
())
{
$revisions
=
array_reverse
(
node_revision_list
(
$page
));
foreach
(
$revisions
as
$revision
)
{
// Extract the specified revision:
$node
=
node_revision_load
(
$page
,
$revision
);
// Check to see if the conditions are met:
$status
=
TRUE
;
foreach
(
$conditions
as
$key
=>
$value
)
{
if
(
$node
->
$key
!=
$value
)
{
$status
=
FALSE
;
}
}
if
(
$status
)
{
return
$node
;
}
}
}
/**
* Return the path (call stack) to a certain book page.
*/
...
...
@@ -416,17 +388,6 @@ function book_next($node) {
function
book_content
(
$node
,
$teaser
=
FALSE
)
{
$op
=
$_POST
[
'op'
];
// Always display the most recently approved revision of a node
// (if any) unless we have to display this page in the context of
// the moderation queue.
if
(
$op
!=
t
(
'Preview'
)
&&
$node
->
moderate
&&
arg
(
0
)
!=
'queue'
)
{
$revision
=
book_revision_load
(
$node
,
array
(
'moderate'
=>
0
,
'status'
=>
1
));
if
(
$revision
)
{
$node
=
$revision
;
}
}
// Extract the page body.
$node
=
node_prepare
(
$node
,
$teaser
);
...
...
@@ -676,42 +637,49 @@ function book_render() {
function
book_export
(
$type
=
'html'
,
$nid
=
0
)
{
global
$base_url
;
$type
=
drupal_strtolower
(
$type
);
$depth
=
_book_get_depth
(
$nid
);
$node
=
node_load
(
$nid
);
switch
(
$type
)
{
case
'docbook'
:
$xml
=
"<?xml version='1.0'?>
\n
"
;
$xml
.
=
"<!DOCTYPE book PUBLIC
\"
-//OASIS//DTD Docbook XML V4.1.2//EN
\"
\"
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
\"
>
\n
"
;
$xml
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_xml_pre'
,
'book_node_visitor_xml_post'
);
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$xml
;
break
;
case
'html'
:
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$output
.
=
"<div class=
\"
section-
$i
\"
>
\n
"
;
}
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_html_pre'
,
'book_node_visitor_html_post'
);
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$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
"
;
$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
;
break
;
case
'opml'
:
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_opml_pre'
,
'book_node_visitor_opml_post'
);
$ompl
=
"<?xml version='1.0'?>
\n
"
;
$opml
.
=
"<opml version='1.0'>
\n
"
;
$opml
.
=
"<head>
\n
<title>"
.
check_plain
(
$node
->
title
)
.
"</title>
\n
"
;
$opml
.
=
"</head>
\n
<body>
\n
"
.
$output
.
"
\n
</body>
\n
</opml>
\n
"
;
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$opml
;
break
;
if
(
$nid
)
{
$depth
=
_book_get_depth
(
$nid
);
$node
=
node_load
(
$nid
);
switch
(
$type
)
{
case
'docbook'
:
$xml
=
"<?xml version='1.0'?>
\n
"
;
$xml
.
=
"<!DOCTYPE book PUBLIC
\"
-//OASIS//DTD Docbook XML V4.1.2//EN
\"
\"
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
\"
>
\n
"
;
$xml
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_xml_pre'
,
'book_node_visitor_xml_post'
);
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$xml
;
break
;
case
'html'
:
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$output
.
=
"<div class=
\"
section-
$i
\"
>
\n
"
;
}
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_html_pre'
,
'book_node_visitor_html_post'
);
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$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
"
;
$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
;
break
;
case
'opml'
:
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_opml_pre'
,
'book_node_visitor_opml_post'
);
$ompl
=
"<?xml version='1.0'?>
\n
"
;
$opml
.
=
"<opml version='1.0'>
\n
"
;
$opml
.
=
"<head>
\n
<title>"
.
check_plain
(
$node
->
title
)
.
"</title>
\n
"
;
$opml
.
=
"</head>
\n
<body>
\n
"
.
$output
.
"
\n
</body>
\n
</opml>
\n
"
;
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$opml
;
break
;
default
:
drupal_not_found
();
}
}
else
{
drupal_not_found
();
}
}
...
...
@@ -771,11 +739,6 @@ function book_recurse($nid = 0, $depth = 1, $visit_pre, $visit_post) {
// Load the node:
$node
=
node_load
(
$page
->
nid
);
// Take the most recent approved revision:
if
(
$node
->
moderate
)
{
$node
=
book_revision_load
(
$node
,
array
(
'moderate'
=>
0
,
'status'
=>
1
));
}
if
(
$node
)
{
if
(
function_exists
(
$visit_pre
))
{
$output
.
=
call_user_func
(
$visit_pre
,
$node
,
$depth
,
$nid
);
...
...
modules/book/book.module
View file @
f8e2be5f
...
...
@@ -310,34 +310,6 @@ function book_outline() {
}
}
/**
* Return the most recent revision that matches the specified conditions.
*/
function
book_revision_load
(
$page
,
$conditions
=
array
())
{
$revisions
=
array_reverse
(
node_revision_list
(
$page
));
foreach
(
$revisions
as
$revision
)
{
// Extract the specified revision:
$node
=
node_revision_load
(
$page
,
$revision
);
// Check to see if the conditions are met:
$status
=
TRUE
;
foreach
(
$conditions
as
$key
=>
$value
)
{
if
(
$node
->
$key
!=
$value
)
{
$status
=
FALSE
;
}
}
if
(
$status
)
{
return
$node
;
}
}
}
/**
* Return the path (call stack) to a certain book page.
*/
...
...
@@ -416,17 +388,6 @@ function book_next($node) {
function
book_content
(
$node
,
$teaser
=
FALSE
)
{
$op
=
$_POST
[
'op'
];
// Always display the most recently approved revision of a node
// (if any) unless we have to display this page in the context of
// the moderation queue.
if
(
$op
!=
t
(
'Preview'
)
&&
$node
->
moderate
&&
arg
(
0
)
!=
'queue'
)
{
$revision
=
book_revision_load
(
$node
,
array
(
'moderate'
=>
0
,
'status'
=>
1
));
if
(
$revision
)
{
$node
=
$revision
;
}
}
// Extract the page body.
$node
=
node_prepare
(
$node
,
$teaser
);
...
...
@@ -676,42 +637,49 @@ function book_render() {
function
book_export
(
$type
=
'html'
,
$nid
=
0
)
{
global
$base_url
;
$type
=
drupal_strtolower
(
$type
);
$depth
=
_book_get_depth
(
$nid
);
$node
=
node_load
(
$nid
);
switch
(
$type
)
{
case
'docbook'
:
$xml
=
"<?xml version='1.0'?>
\n
"
;
$xml
.
=
"<!DOCTYPE book PUBLIC
\"
-//OASIS//DTD Docbook XML V4.1.2//EN
\"
\"
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
\"
>
\n
"
;
$xml
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_xml_pre'
,
'book_node_visitor_xml_post'
);
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$xml
;
break
;
case
'html'
:
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$output
.
=
"<div class=
\"
section-
$i
\"
>
\n
"
;
}
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_html_pre'
,
'book_node_visitor_html_post'
);
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$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
"
;
$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
;
break
;
case
'opml'
:
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_opml_pre'
,
'book_node_visitor_opml_post'
);
$ompl
=
"<?xml version='1.0'?>
\n
"
;
$opml
.
=
"<opml version='1.0'>
\n
"
;
$opml
.
=
"<head>
\n
<title>"
.
check_plain
(
$node
->
title
)
.
"</title>
\n
"
;
$opml
.
=
"</head>
\n
<body>
\n
"
.
$output
.
"
\n
</body>
\n
</opml>
\n
"
;
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$opml
;
break
;
if
(
$nid
)
{
$depth
=
_book_get_depth
(
$nid
);
$node
=
node_load
(
$nid
);
switch
(
$type
)
{
case
'docbook'
:
$xml
=
"<?xml version='1.0'?>
\n
"
;
$xml
.
=
"<!DOCTYPE book PUBLIC
\"
-//OASIS//DTD Docbook XML V4.1.2//EN
\"
\"
http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd
\"
>
\n
"
;
$xml
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_xml_pre'
,
'book_node_visitor_xml_post'
);
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$xml
;
break
;
case
'html'
:
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$output
.
=
"<div class=
\"
section-
$i
\"
>
\n
"
;
}
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_html_pre'
,
'book_node_visitor_html_post'
);
for
(
$i
=
1
;
$i
<
$depth
;
$i
++
)
{
$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
"
;
$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
;
break
;
case
'opml'
:
$output
.
=
book_recurse
(
$nid
,
$depth
,
'book_node_visitor_opml_pre'
,
'book_node_visitor_opml_post'
);
$ompl
=
"<?xml version='1.0'?>
\n
"
;
$opml
.
=
"<opml version='1.0'>
\n
"
;
$opml
.
=
"<head>
\n
<title>"
.
check_plain
(
$node
->
title
)
.
"</title>
\n
"
;
$opml
.
=
"</head>
\n
<body>
\n
"
.
$output
.
"
\n
</body>
\n
</opml>
\n
"
;
drupal_set_header
(
'Content-Type: text/xml; charset=utf-8'
);
print
$opml
;
break
;
default
:
drupal_not_found
();
}
}
else
{
drupal_not_found
();
}
}
...
...
@@ -771,11 +739,6 @@ function book_recurse($nid = 0, $depth = 1, $visit_pre, $visit_post) {
// Load the node:
$node
=
node_load
(
$page
->
nid
);
// Take the most recent approved revision:
if
(
$node
->
moderate
)
{
$node
=
book_revision_load
(
$node
,
array
(
'moderate'
=>
0
,
'status'
=>
1
));
}
if
(
$node
)
{
if
(
function_exists
(
$visit_pre
))
{
$output
.
=
call_user_func
(
$visit_pre
,
$node
,
$depth
,
$nid
);
...
...
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