"book_find", "page" => "book_page", "user" => "book_user", "admin" => "book_admin"); class Book { function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) { $this->nid = $nid; $this->userid = $userid; $this->title = $title; $this->body = $body; $this->parent = $parent; $this->weight = $weight; $this->timestamp = $timestamp; } } function book_navigation($node) { if ($node->nid && $node->parent && $node->weight) { $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC")); $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC")); } $output .= "
". ($prev ? "nid\">". t("previous") ."" : t("previous")) ." | index | ". ($next ? "nid\">". t("next") ."" : t("next")) ." |
". ($prev ? "". check_output($prev->title) ."" : "") ." | ". ($node->parent ? "parent\">". t("up") ."" : t("up")) ." | ". ($next ? "". check_output($next->title) ."" : "") ." |
". check_output($node->title) ."". ($node->body ? " Last updated by ". format_username($node->userid) ." on ". format_date($node->timestamp) ." " : "") ." | ". node_info($node) ." |
". check_output($node->body, 1) ."
"; } $theme->box(t("Handbook"), $output ."". book_tree($node->nid) ."". book_navigation($node)); } function book_view($node, $page = 1) { if ($page) { global $theme; $theme->header(); theme_book($node); $theme->footer(); } else { theme_book($node); } } function book_find($keys) { global $status, $user; $find = array(); $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); while ($node = db_fetch_object($result)) { array_push($find, array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp)); } return $find; } function book_search() { global $keys, $mod; print search_form($keys); print search_data($keys, $mod); } function book_toc($parent = 0, $offset = "", $toc = array()) { global $status; $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); while ($node = db_fetch_object($result)) { $toc[$node->nid] = "$offset $node->title"; if ($node->pid) $toc = book_toc($node->pid, "$offset-", $toc); $toc = book_toc($node->nid, "$offset-", $toc); } return $toc; } function book_form($edit = array()) { global $allowed_html, $PHP_SELF, $REQUEST_URI, $user; $output .= "\n"; return $output; } function book_save($edit) { node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "book")), array(userid => $edit[userid]))); } function book_tree($parent = "") { global $PHP_SELF, $status; $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); $output .= "