From 1a2576036b3377ec83a08b7238f59dc474053543 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 12 Jun 2003 17:24:06 +0000 Subject: - Bugfix: charset fixes/clean-up. Patch #52 by Al. - Improvement: renamed some theme functions of the forum module for sake of consistency/readability. Patch #2 by Kristjan. - Improvement: usability improvements to the Xtemplate theme. Patch #3 by Kristjan. - Improvement: CSS'ified the book module pages. Patch #3 by Al. (I simplified the "l ocation" part. Al's approach gave you a bit more power but I'm not sure anyone wants to change that. Besides, this will change as soon we integrate the menu system so I kept it easy for now.) --- modules/book.module | 86 ++++++++++++++++++++++++++++---------------- modules/book/book.module | 86 ++++++++++++++++++++++++++++---------------- modules/forum.module | 18 +++++----- modules/forum/forum.module | 18 +++++----- modules/locale.module | 2 +- modules/locale/locale.module | 2 +- 6 files changed, 130 insertions(+), 82 deletions(-) (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index e2e81fae6..2f4c0ec6a 100644 --- a/modules/book.module +++ b/modules/book.module @@ -410,40 +410,55 @@ function book_view($node, $main = 0) { $next = book_next($node); } - $output .= ""; - - if ($node->title) { - // build the tree from bottom to top to have the book index in $level for navigation later - $path = array_reverse(book_location($node)); - $i = count($path); - foreach ($path as $level) { - $indent = str_repeat("-", --$i); - $location = "$indent ". l($level->title, "node/view/$level->nid") ."
". $location; - } - - $output .= " "; - $output .= " "; - $output .= " "; + // build the tree from bottom to top to have the book index in $level for navigation later + $path = book_location($node); + foreach ($path as $level) { + $trail[] = l($level->title, "node/view/$level->nid"); } - if ($node->body) { - $output .= " "; + $output .= "
"; + if ($trail) { + $output .= "
". implode($trail, " » ") ."

"; } + $output .= "
$node->title
"; + $output .= "
". t("Last updated by %u on %d", array("%u" => format_name($node), "%d" => format_date($node->changed))) ."
"; + + $output .= "
$node->body
"; if ($node->moderate) { - $output .= "
"; + $output .= "
". t("Log") .":
$node->log
"; } if ($node->nid) { - $output .= " "; + $output .= "
". book_tree($node->nid) ."
"; + if ($prev) { + $links .= "
"; + $links .= l(t("previous"), "node/view/$prev->nid", array("title" => t("View the previous page in this book."))); + $links .= "
"; + $titles .= "
$prev->title
"; + } + if ($next) { + $links .= "
"; + $links .= l(t("next"), "node/view/$next->nid", array("title" => t("View the next page in this book."))); + $links .= "
"; + $titles .= "
$next->title
"; + } + if ($node->parent) { + $links .= "
"; + $links .= l(t("up"), "node/view/$node->parent", array("title" => t("View this page's parent section."))); + if ($node->parent != $level->nid) { + $links .= " | "; + $links .= l(t("index"), "node/view/$level->nid", array("title" => t("View this book's table of contents."))); + } + $links .= "
"; + } + $output .= "
"; + $output .= "
$links
"; + $output .= "
$titles
"; + $output .= "
"; } - - $output .= " "; - $output .= " "; - $output .= " "; - $output .= " "; - $output .= " "; - $output .= "
$location

$node->title". ($node->body ? "
". t("Last updated by %u on %d", array("%u" => format_name($node), "%d" => format_date($node->created))) ." " : "") ."

$node->body

". t("Log") .":
$node->log

". book_tree($node->nid) ."

". ($prev ? l(t("previous"), "node/view/$prev->nid", array("title" => t("View the previous page in this book."))) : " ") ."". ($node->parent ? l(t("up"), "node/view/$node->parent", array("title" => t("View this page's parent section."))) : " ") ."". ($next ? l(t("next"), "node/view/$next->nid", array("title" => t("View the next page in this book."))) : " ") ."
". ($prev ? "$prev->title" : " ") ."". ($node->parent && $node->parent != $level->nid ? l(t("index"), "node/view/$level->nid", array("title" => t("View this book's table of contents."))) : " ") ."". ($next ? "$next->title" : " ") ."

". theme("links", link_node($node, $main)) ."
"; + $output .= "
". theme("links", link_node($node, $main)) ."
"; + $output .= ""; theme("box", t("Handbook"), $output); } @@ -541,12 +556,15 @@ function book_render() { if ($node) { // output the content: - $output .= "
". l($node->title, "node/view/$node->nid") ."
". book_body($node) ."

"; + $output .= "
"; + $output .= "
". l($node->title, "node/view/$node->nid") ."
"; + $output .= "
". book_body($node) ."
"; + $output .= "
"; } } theme("header"); - theme("box", t("Handbook"), "
$output
"); + theme("box", t("Handbook"), "$output"); theme("footer"); } @@ -570,6 +588,7 @@ function book_page() { } function book_print($id = "", $depth = 1) { + global $base_url; $result = db_query("SELECT n.nid FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id); while ($page = db_fetch_object($result)) { @@ -583,17 +602,22 @@ function book_print($id = "", $depth = 1) { if ($node) { // output the content: - $output .= "$node->title"; + $output .= "

nid\" name=\"$node->nid\" class=\"book-h$depth\">$node->title

"; if ($node->body) { - $output .= ""; + $output .= book_body($node); } } } $output .= book_print_recurse($id, $depth); - return $output; + $html = "$node->title"; + $html .= ""; + $html .= ""; + $html .= "". $output .""; + + return $html; } function book_print_recurse($parent = "", $depth = 1) { @@ -610,7 +634,7 @@ function book_print_recurse($parent = "", $depth = 1) { if ($node) { // output the content: - $output .= "$node->title"; + $output .= "

nid\" name=\"$node->nid\" class=\"book-h$depth\">$node->title

"; if ($node->body) { $output .= ""; diff --git a/modules/book/book.module b/modules/book/book.module index e2e81fae6..2f4c0ec6a 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -410,40 +410,55 @@ function book_view($node, $main = 0) { $next = book_next($node); } - $output .= ""; - - if ($node->title) { - // build the tree from bottom to top to have the book index in $level for navigation later - $path = array_reverse(book_location($node)); - $i = count($path); - foreach ($path as $level) { - $indent = str_repeat("-", --$i); - $location = "$indent ". l($level->title, "node/view/$level->nid") ."
". $location; - } - - $output .= " "; - $output .= " "; - $output .= " "; + // build the tree from bottom to top to have the book index in $level for navigation later + $path = book_location($node); + foreach ($path as $level) { + $trail[] = l($level->title, "node/view/$level->nid"); } - if ($node->body) { - $output .= " "; + $output .= "
"; + if ($trail) { + $output .= "
". implode($trail, " » ") ."

"; } + $output .= "
$node->title
"; + $output .= "
". t("Last updated by %u on %d", array("%u" => format_name($node), "%d" => format_date($node->changed))) ."
"; + + $output .= "
$node->body
"; if ($node->moderate) { - $output .= "
"; + $output .= "
". t("Log") .":
$node->log
"; } if ($node->nid) { - $output .= " "; + $output .= "
". book_tree($node->nid) ."
"; + if ($prev) { + $links .= "
"; + $links .= l(t("previous"), "node/view/$prev->nid", array("title" => t("View the previous page in this book."))); + $links .= "
"; + $titles .= "
$prev->title
"; + } + if ($next) { + $links .= "
"; + $links .= l(t("next"), "node/view/$next->nid", array("title" => t("View the next page in this book."))); + $links .= "
"; + $titles .= "
$next->title
"; + } + if ($node->parent) { + $links .= "
"; + $links .= l(t("up"), "node/view/$node->parent", array("title" => t("View this page's parent section."))); + if ($node->parent != $level->nid) { + $links .= " | "; + $links .= l(t("index"), "node/view/$level->nid", array("title" => t("View this book's table of contents."))); + } + $links .= "
"; + } + $output .= "
"; + $output .= "
$links
"; + $output .= "
$titles
"; + $output .= "
"; } - - $output .= " "; - $output .= " "; - $output .= " "; - $output .= " "; - $output .= " "; - $output .= "
$location

$node->title". ($node->body ? "
". t("Last updated by %u on %d", array("%u" => format_name($node), "%d" => format_date($node->created))) ." " : "") ."

$node->body

". t("Log") .":
$node->log

". book_tree($node->nid) ."

". ($prev ? l(t("previous"), "node/view/$prev->nid", array("title" => t("View the previous page in this book."))) : " ") ."". ($node->parent ? l(t("up"), "node/view/$node->parent", array("title" => t("View this page's parent section."))) : " ") ."". ($next ? l(t("next"), "node/view/$next->nid", array("title" => t("View the next page in this book."))) : " ") ."
". ($prev ? "$prev->title" : " ") ."". ($node->parent && $node->parent != $level->nid ? l(t("index"), "node/view/$level->nid", array("title" => t("View this book's table of contents."))) : " ") ."". ($next ? "$next->title" : " ") ."

". theme("links", link_node($node, $main)) ."
"; + $output .= "
". theme("links", link_node($node, $main)) ."
"; + $output .= ""; theme("box", t("Handbook"), $output); } @@ -541,12 +556,15 @@ function book_render() { if ($node) { // output the content: - $output .= "
". l($node->title, "node/view/$node->nid") ."
". book_body($node) ."

"; + $output .= "
"; + $output .= "
". l($node->title, "node/view/$node->nid") ."
"; + $output .= "
". book_body($node) ."
"; + $output .= "
"; } } theme("header"); - theme("box", t("Handbook"), "
$output
"); + theme("box", t("Handbook"), "$output"); theme("footer"); } @@ -570,6 +588,7 @@ function book_page() { } function book_print($id = "", $depth = 1) { + global $base_url; $result = db_query("SELECT n.nid FROM node n INNER JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id); while ($page = db_fetch_object($result)) { @@ -583,17 +602,22 @@ function book_print($id = "", $depth = 1) { if ($node) { // output the content: - $output .= "$node->title"; + $output .= "

nid\" name=\"$node->nid\" class=\"book-h$depth\">$node->title

"; if ($node->body) { - $output .= ""; + $output .= book_body($node); } } } $output .= book_print_recurse($id, $depth); - return $output; + $html = "$node->title"; + $html .= ""; + $html .= ""; + $html .= "". $output .""; + + return $html; } function book_print_recurse($parent = "", $depth = 1) { @@ -610,7 +634,7 @@ function book_print_recurse($parent = "", $depth = 1) { if ($node) { // output the content: - $output .= "$node->title"; + $output .= "

nid\" name=\"$node->nid\" class=\"book-h$depth\">$node->title

"; if ($node->body) { $output .= ""; diff --git a/modules/forum.module b/modules/forum.module index 23232b85d..268746f30 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -484,7 +484,7 @@ function forum_page() { $topics = forum_get_topics($tid, $sortby, $forum_per_page); } - theme("forum_render", $forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset); + theme("forum_theme_display", $forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset); } else { theme("header"); @@ -500,27 +500,27 @@ function forum_page() { } /* -** Render functions. +** Theme functions */ -function forum_render($forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset) { +function forum_theme_display($forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset) { // forum list, topics list, topic browser and "add new topic" link - $output .= theme("forum_forum_list", $forums, $parents, $tid); + $output .= theme("forum_theme_list", $forums, $parents, $tid); if ($tid && !in_array($tid, variable_get("forum_containers", array()))) { - $output .= theme("forum_topic_list", $tid, $topics, $sortby, $forum_per_page, $offset); + $output .= theme("forum_theme_topic_list", $tid, $topics, $sortby, $forum_per_page, $offset); } theme("header"); theme("box", t("Discussion forum"), $output); if ($tid && !in_array($tid, variable_get("forum_containers", array()))) { - theme("box", t("Control panel"), theme("forum_topic_browser", $sortby, $forum_per_page, $offset)); + theme("box", t("Control panel"), theme("forum_theme_topic_browser", $sortby, $forum_per_page, $offset)); } theme("footer"); } -function forum_forum_list($forums, $parents, $tid) { +function forum_theme_list($forums, $parents, $tid) { global $user; if ($parents) { foreach($parents as $p) { @@ -572,7 +572,7 @@ function forum_forum_list($forums, $parents, $tid) { return $output; } -function forum_topic_browser() { +function forum_theme_topic_browser() { global $tid, $sortby, $forum_per_page, $offset; if (empty($sortby)) { @@ -601,7 +601,7 @@ function forum_topic_browser() { return form(form_item(t("Topic viewing options"), $output, t("Select your preferred way to display the topics and click 'Update settings'."))); } -function forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset) { +function forum_theme_topic_list($tid, $topics, $sortby, $forum_per_page, $offset) { global $id, $status, $user, $pager_total; if ($topics) { diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 23232b85d..268746f30 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -484,7 +484,7 @@ function forum_page() { $topics = forum_get_topics($tid, $sortby, $forum_per_page); } - theme("forum_render", $forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset); + theme("forum_theme_display", $forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset); } else { theme("header"); @@ -500,27 +500,27 @@ function forum_page() { } /* -** Render functions. +** Theme functions */ -function forum_render($forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset) { +function forum_theme_display($forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset) { // forum list, topics list, topic browser and "add new topic" link - $output .= theme("forum_forum_list", $forums, $parents, $tid); + $output .= theme("forum_theme_list", $forums, $parents, $tid); if ($tid && !in_array($tid, variable_get("forum_containers", array()))) { - $output .= theme("forum_topic_list", $tid, $topics, $sortby, $forum_per_page, $offset); + $output .= theme("forum_theme_topic_list", $tid, $topics, $sortby, $forum_per_page, $offset); } theme("header"); theme("box", t("Discussion forum"), $output); if ($tid && !in_array($tid, variable_get("forum_containers", array()))) { - theme("box", t("Control panel"), theme("forum_topic_browser", $sortby, $forum_per_page, $offset)); + theme("box", t("Control panel"), theme("forum_theme_topic_browser", $sortby, $forum_per_page, $offset)); } theme("footer"); } -function forum_forum_list($forums, $parents, $tid) { +function forum_theme_list($forums, $parents, $tid) { global $user; if ($parents) { foreach($parents as $p) { @@ -572,7 +572,7 @@ function forum_forum_list($forums, $parents, $tid) { return $output; } -function forum_topic_browser() { +function forum_theme_topic_browser() { global $tid, $sortby, $forum_per_page, $offset; if (empty($sortby)) { @@ -601,7 +601,7 @@ function forum_topic_browser() { return form(form_item(t("Topic viewing options"), $output, t("Select your preferred way to display the topics and click 'Update settings'."))); } -function forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset) { +function forum_theme_topic_list($tid, $topics, $sortby, $forum_per_page, $offset) { global $id, $status, $user, $pager_total; if ($topics) { diff --git a/modules/locale.module b/modules/locale.module index 99f374d36..5a60c6162 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -103,7 +103,7 @@ function locale_edit($lid) { $result = db_query("SELECT * FROM locales WHERE lid = '$lid'"); if ($translation = db_fetch_object($result)) { - $form .= form_item(t("Original text"), wordwrap(htmlspecialchars($translation->string))); + $form .= form_item(t("Original text"), wordwrap(drupal_specialchars($translation->string, 0))); foreach ($languages as $code=>$language) { $form .= (strlen($translation->string) > 30) ? form_textarea($language, $code, $translation->$code, 50, 10) : form_textfield($language, $code, $translation->$code, 50, 128); diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 99f374d36..5a60c6162 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -103,7 +103,7 @@ function locale_edit($lid) { $result = db_query("SELECT * FROM locales WHERE lid = '$lid'"); if ($translation = db_fetch_object($result)) { - $form .= form_item(t("Original text"), wordwrap(htmlspecialchars($translation->string))); + $form .= form_item(t("Original text"), wordwrap(drupal_specialchars($translation->string, 0))); foreach ($languages as $code=>$language) { $form .= (strlen($translation->string) > 30) ? form_textarea($language, $code, $translation->$code, 50, 10) : form_textfield($language, $code, $translation->$code, 50, 128); -- cgit v1.2.3