Commit 7cd8427f authored by Dries's avatar Dries

- Patch #257730 by Senpai: code clean-up for book module.

parent a7d345d7
......@@ -2,7 +2,7 @@
// $Id$
/**
* @file book-export-html.tpl.php
* @file
* Default theme implementation for printed version of book outline.
*
* Available variables:
......@@ -45,9 +45,7 @@
<div class="section-<?php print $i; ?>">
<?php $div_close .= '</div>'; ?>
<?php endfor; ?>
<?php print $contents; ?>
<?php print $div_close; ?>
</body>
</html>
......@@ -2,7 +2,7 @@
// $Id$
/**
* @file book-navigation.tpl.php
* @file
* Default theme implementation to navigate books. Presented under nodes that
* are a part of book outlines.
*
......
......@@ -2,7 +2,7 @@
// $Id$
/**
* @file book-node-export-html.tpl.php
* @file
* Default theme implementation for rendering a single node in a printer
* friendly outline.
*
......
......@@ -46,6 +46,7 @@ function book_admin_settings() {
);
$form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
$form['#validate'][] = 'book_admin_settings_validate';
return system_settings_form($form);
}
......@@ -77,6 +78,7 @@ function book_admin_edit($form_state, $node) {
'#type' => 'submit',
'#value' => t('Save book pages'),
);
return $form;
}
......@@ -139,6 +141,7 @@ function _book_admin_table($node) {
if ($tree['below']) {
_book_admin_table_tree($tree['below'], $form);
}
return $form;
}
......@@ -246,5 +249,6 @@ function _book_admin_compare($a, $b) {
if ($weight) {
return $weight;
}
return strncmp($a['link']['title'], $b['link']['title']);
}
......@@ -49,4 +49,4 @@
}
#book-admin-edit .form-item {
float: left;
}
\ No newline at end of file
}
; $Id$
name = Book
description = Allows users to structure site pages in a hierarchy or outline.
package = Core - optional
......
......@@ -23,7 +23,7 @@ function book_uninstall() {
}
function _book_install_type_create() {
// Create an additional node type
// Create an additional node type.
$book_node_type = array(
'type' => 'book',
'name' => t('Book page'),
......@@ -149,7 +149,7 @@ function book_update_6000() {
}
elseif ($_SESSION['book_update_6000_orphans']) {
// Do the first batched part of the update - collect orphans.
$update_count = 400; // Update this many at a time
$update_count = 400; // Update this many at a time.
$result = db_query_range("SELECT * FROM {book_temp}", $_SESSION['book_update_6000_orphans']['from'], $update_count);
$has_rows = FALSE;
......@@ -175,7 +175,6 @@ function book_update_6000() {
$_SESSION['book_update_6000_orphans']['from'] += $update_count;
}
else {
// Done with this part
if (!empty($_SESSION['book_update_6000_orphans']['book'])) {
// The orphans' parent is added last, so it will be processed first.
$_SESSION['book_update_6000'][] = $_SESSION['book_update_6000_orphans']['book'];
......@@ -183,17 +182,18 @@ function book_update_6000() {
$_SESSION['book_update_6000_orphans'] = FALSE;
}
$ret['#finished'] = FALSE;
return $ret;
}
else {
// Do the next batched part of the update
// Run the next batched part of the update.
$update_count = 100; // Update this many at a time
while ($update_count && $_SESSION['book_update_6000']) {
// Get the last node off the stack.
$book = array_pop($_SESSION['book_update_6000']);
// Add all of this node's children to the stack
// Add all of this node's children to the stack.
$result = db_query("SELECT * FROM {book_temp} WHERE parent = %d", $book['nid']);
while ($a = db_fetch_array($result)) {
$_SESSION['book_update_6000'][] = $a;
......@@ -205,7 +205,7 @@ function book_update_6000() {
$book = array_merge($book, $parent);
}
else {
// There is not a parent - this is a new book.
// There is no parent - this is a new book.
$book['plid'] = 0;
$book['bid'] = $book['nid'];
}
......@@ -286,5 +286,3 @@ function book_schema() {
return $schema;
}
This diff is collapsed.
......@@ -40,7 +40,6 @@ function book_render() {
* in a format determined by the $type parameter.
*/
function book_export($type, $nid) {
$type = drupal_strtolower($type);
$export_function = 'book_export_' . $type;
......@@ -79,6 +78,7 @@ function book_export_html($nid) {
$tree = book_menu_subtree_data($node->book);
$contents = book_export_traverse($tree, 'book_node_export');
}
return theme('book_export_html', $node->title, $contents, $node->book['depth']);
}
else {
......@@ -103,7 +103,6 @@ function book_outline($node) {
* @ingroup forms
*/
function book_outline_form(&$form_state, $node) {
if (!isset($node->book)) {
// The node is not part of any book yet - set default options.
$node->book = _book_link_defaults($node->nid);
......@@ -111,6 +110,7 @@ function book_outline_form(&$form_state, $node) {
else {
$node->book['original_bid'] = $node->book['bid'];
}
// Find the depth limit for the parent select.
if (!isset($node->book['parent_depth_limit'])) {
$node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book);
......@@ -158,6 +158,7 @@ function book_outline_form_submit($form, &$form_state) {
$book_link = $form_state['values']['book'];
if (!$book_link['bid']) {
drupal_set_message(t('No changes were made'));
return;
}
......@@ -244,7 +245,6 @@ function book_form_update() {
// Get the new options and update the cache.
$form['book']['plid'] = _book_parent_select($book_link);
cache_set($cid, $form, 'cache_form', $cache->expire);
// Build and render the new select element, then return it in JSON format.
$form_state = array();
$form['#post'] = array();
......
......@@ -68,11 +68,16 @@ class BookTestCase extends DrupalWebTestCase {
/**
* Check the outline of sub-pages; previous, up, and next; and printer friendly version.
*
* @param Node $node Node to check.
* @param array $nodes Nodes that should be in outline.
* @param Node $previous Previous link node.
* @param Node $up Up link node.
* @param Node $next Next link node.
* @param Node $node
* Node to check.
* @param array $nodes
* Nodes that should be in outline.
* @param Node $previous
* Previous link node.
* @param Node $up
* Up link node.
* @param Node $next
* Next link node.
*/
function checkBookNode($node, $nodes, $previous = false, $up = false, $next = false) {
static $number = 0;
......@@ -90,9 +95,11 @@ class BookTestCase extends DrupalWebTestCase {
if ($previous) {
$this->assertRaw(l('‹ ' . $previous->title, 'node/' . $previous->nid, array('attributes' => array('class' => 'page-previous', 'title' => t('Go to previous page')))), t('Prevoius page link found.'));
}
if ($up) {
$this->assertRaw(l('up', 'node/' . $up->nid, array('attributes' => array('class' => 'page-up', 'title' => t('Go to parent page')))), t('Up page link found.'));
}
if ($next) {
$this->assertRaw(l($next->title . ' ›', 'node/' . $next->nid, array('attributes' => array('class' => 'page-next', 'title' => t('Go to next page')))), t('Next page link found.'));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment