nid) { case 43633: // Handbook pages with comments $extra = handbook_with_comments(); break; case 43639: // Most popular handbooks $extra = handbook_most_popular(); break; case 322: // Mailing list subscription $extra = drupal_get_form('lists_subscribe_form'); break; case 13355: // Site maintainers $extra = handbook_site_maintainers(); break; case 109372: // Handbook maintainers $extra = handbook_maintainers(); break; case 14205: // Book contributors $extra = handbook_book_contributors(); break; case 263594: // Revision maintainers $extra = handbook_revision_maintainers(); break; case 23192: // Recent updates $extra = handbook_recent_updates(); break; } $node->content['body']['#value'] .= $extra; } } /** * List handbook pages with comments in descending comment order. */ function handbook_with_comments() { $header = array( array('data' => 'Page'), array('data' => 'Comments', 'field' => 'comment_count', 'sort' => 'desc'), array('data' => 'Last comment', 'field' => 'last_comment_timestamp'), ); $result = db_query("SELECT n.nid, n.title, s.comment_count, s.last_comment_timestamp FROM {node} n LEFT JOIN {node_comment_statistics} s ON n.nid = s.nid WHERE n.type = 'book' AND s.comment_count >= 1 AND n.status = 1" . tablesort_sql($header)); while ($node = db_fetch_object($result)) { $rows[] = array(l($node->title, "node/$node->nid"), $node->comment_count, format_interval(time() - $node->last_comment_timestamp) .' ago'); } return theme('table', $header, $rows); } /** * List pages ordered by visit number descending order. */ function handbook_most_popular() { $header = array('Rank', 'Page', 'Visits today', 'Total visits'); $result = db_query("SELECT n.nid, n.title, c.daycount, c.totalcount FROM {node} n INNER JOIN {node_counter} c ON n.nid = c.nid WHERE n.type = 'book' AND n.status = 1 ORDER BY c.daycount DESC LIMIT 0, 100"); while ($node = db_fetch_object($result)) { $rows[] = array(++$rank, l($node->title, "node/$node->nid"), $node->daycount, $node->totalcount); } return theme('table', $header, $rows); } /** * List usernames with site maintainer role. */ function handbook_site_maintainers() { $output = 'If you have been around for a while, and you want to help maintain Drupal.org and are willing to accept the added responsibilities that come with it, sign up on the Infrastructure team list.'; $output .= '
    '; $result = db_query("SELECT DISTINCT(u.uid), u.name FROM {users} u INNER JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid = 3 OR r.rid = 4 OR r.rid = 9 ORDER BY u.name "); // 3 = site maintainer, 4 = administrator while ($account = db_fetch_object($result)) { $output .= "
  1. ". theme('username', $account) ."
  2. "; } $output .= '
'; return $output; } /** * List usernames with handbook maintainer role. */ function handbook_maintainers() { $output = '

If you are interested in helping maintain/update/correct the documentation on Drupal.org, read up on the many ways to get involved.

'; $output .= '

Note: Many of our site maintainers also participate on the documentation team and are not listed here. Due to their broader responsibilities on drupal.org, site maintainers are listed separately.

'; $output .= '
    '; $result = db_query("SELECT DISTINCT(u.uid), u.name FROM {users} u INNER JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid = 5 OR r.rid = 9 ORDER BY u.name "); // 3 = site maintainer, 4 = administrator 5 = document maintainer while ($account = db_fetch_object($result)) { $output .= "
  1. ". theme('username', $account) ."
  2. "; } $output .= '
'; return $output; } /** * Count and list contributors to the books. */ function handbook_book_contributors() { $result = db_query("SELECT u.uid, u.name, COUNT(n.nid) AS pages FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'book' AND n.status = 1 AND n.moderate = 0 GROUP BY u.name ORDER BY pages DESC"); $output .= ""; return $output; } /** * Collect and cache revision maintainers (those who made revisions to books). */ function handbook_revision_maintainers() { if ($cache = cache_get('node_263594')) { return $cache->data; } $result = db_query("SELECT u.uid, u.name, COUNT(nr.vid) AS pages FROM {node} n INNER JOIN {node_revisions} nr ON n.nid = nr.nid INNER JOIN {users} u ON u.uid = n.uid WHERE n.type = 'book' AND n.status = 1 AND n.moderate = 0 GROUP BY u.name ORDER BY pages DESC"); $list = array(); while ($contributor = db_fetch_object($result)) { $list[] = theme('username', $contributor) ." (". format_plural($contributor->pages, "@count revision", "@count revisions") .")"; } $output = theme('item_list', $list); cache_set('node_263594', $output, 'cache', 300); return $output; } /** * List most recent updates to book pages for moderation reasons. */ function handbook_recent_updates() { $result = db_query_range("SELECT n.nid, n.title, n.changed, r.log, u.uid, u.name FROM {node} n INNER JOIN {book} b ON n.nid = b.nid INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE n.status = 1 ORDER BY n.changed DESC", 0, 50); while ($page = db_fetch_object($result)) { $rows[] = array( l($page->title, "node/$page->nid") .' '. theme('mark', node_mark($page->nid, $page->changed)) . ($page->log ? "
". check_plain($page->log) : ''), theme('username', $page), t('%time ago', array('%time' => format_interval(time() - $page->changed))), l(t('Diff'), "node/$page->nid/revisions/view/latest"), ); } $header = array('Page', 'Edited', 'Updated', 'Diff'); $output = theme('table', $header, $rows); return $output; } /** * License and quick links blocks for docs. */ function handbook_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[0]['info'] = t('Handbook License'); $blocks[1]['info'] = t('Documentation Quick Links'); return $blocks; case 'view': switch($delta) { case 0: if (handbook_block_is_visible()) { $block['subject'] = t('Handbook license'); $block['content'] = handbook_license(); return $block; } case 1: if (handbook_block_is_visible()) { $block['subject'] = t('Documentation Quick Links'); $block['content'] = handbook_doc_quick_links(); return $block; } } } } /** * Check whether the current node is a block module. * * Based on Drupal 6 code from book_block(). */ function handbook_block_is_visible() { return ($node = menu_get_object()) && !empty($node->book['bid']); } /** * Quick links on handbook pages. */ function handbook_doc_quick_links() { $output = <<
  • Module documentation
  • Customization and theming
  • Search drupal.org
  • Support forums
  • View other handbooks
  • Suggest documentation improvements
  • Join the doc team
  • EOT; return $output; } /** * License block for the handbook pages. */ function handbook_license() { return t('The Drupal handbook pages are © 2000-!year by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License', array('!year' => date('Y'), '@contributors_link' => url('node/14205'), '@ccl_url' => url('node/14307'), '@gpl_url' => url('http://www.gnu.org/licenses/old-licenses/gpl-2.0.html'))); }