? form-license-130054-11.patch
? form-license-130054-9.patch
? no-php-format-263028-2.patch
? no-php-nodes.patch
? php-blocks.php
? php-nodes.php
Index: drupalorg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalorg/drupalorg.module,v
retrieving revision 1.19
diff -u -p -r1.19 drupalorg.module
--- drupalorg.module	12 Apr 2008 19:57:55 -0000	1.19
+++ drupalorg.module	27 May 2008 02:57:03 -0000
@@ -153,3 +153,207 @@ function drupalorg_project_page_link_alt
   // Link to security handbook page.
   $all_links['support']['links']['report_security_issue'] = l(t('Report a security issue'), 'security-team');
 }
+
+/**
+ * Implemenation of hook_block().
+ *
+ * Generate dynamic content for certain blocks, so as to avoid using PHP
+ * format or PHP visibility.
+ */
+function drupalorg_block($op = 'list', $delta = 0, $edit = array()) {
+
+  if ($op == 'list') {
+    $blocks['handbook_license'] = array('info' => 'Handbook license block','enabled' => 1, 'region' => 'left');
+    $blocks['planet_drupal_subscriptions'] = array('info' => 'Planet Drupal aggregates these Drupal-related blogs', 'enabled' => 1, 'region' => 'left');
+    $blocks['contributor_links'] = array('info' => 'Contributor links block', 'enabled' => 1, 'region' => 'right');
+    return $blocks;
+  }
+  elseif ($op == 'view') {
+    $function = 'drupalorg_block_'. $delta;
+    if (function_exists($function)) {
+      return $function();
+    }
+  }
+}
+
+function drupalorg_block_handbook_license() {
+  $block['subject'] = 'Handbook license';
+  $block['content'] = NULL;
+  if (arg(0) == 'node' && is_numeric(arg(1))) {
+    $node = node_load(arg(1));
+    if ($node && isset($node->parent)) {
+      // This is in the book hierarchy
+      $block['content'] = "The Drupal handbook pages are © copyright 2000-2008 by the ". l('individual contributors', 'node/14205') ." and can be used in accordance with the ". l('Creative Commons License, Attribution-ShareAlike 2.0', 'node/14307');
+    }
+  }
+  return $block;
+}
+
+function drupalorg_block_planet_drupal_subscriptions() {
+  $block['subject'] = 'Planet Drupal subscriptions';
+
+  $output = '';
+  $feed_category = 2;
+  $output .= '<p>Planet Drupal aggregates the Drupal-related blog posts of:</p>';
+  
+  $result = db_query('SELECT f.* FROM {aggregator_feed} f JOIN {aggregator_category_feed} c ON f.fid = c.fid WHERE c.cid = %d ORDER BY f.title', $feed_category);
+  
+  $output .= '<div class="item-list"><ul>';
+  while ($feed = db_fetch_object($result)) {
+  $output .= '<li><a href="' . $feed->link . '">' . $feed->title . '</a> (<a href="' . $feed->url . '">feed</a>)</li>';
+  }
+  $output .= '</ul></div>';
+
+  $output .= theme('xml_icon', url('planet/rss.xml'));
+  $block['content'] = $output;
+  
+  return $block;
+}
+
+function drupalorg_block_contributor_links() {
+  $block['subject'] = 'Contributor links';
+  $counts = variable_get('drupalorg_issue_counts', array());
+  // Patch spotlight info:
+  $nid = 132970;
+  $title = db_result(db_query("SELECT title FROM {node} WHERE nid=%d", $nid));
+  $clean_title = str_replace('Patch spotlight: ', '', $title);
+  $output = 
+'<div class="item-list">
+<ul>
+<li><a href="http://drupal.org/search/node">Advanced search</a></li>
+<li><strong>Queues</strong>
+<ul>
+<li><a href="/project/issues/user">My issues</a></li>
+<li><a href="/project/issues?projects=3060&states=1&categories=bug&versions=156281&priorities=1,2">'. $counts['Pending bugs'] .' Pending bugs (D7)</a></li>
+<li><a href="/project/issues?projects=3060&categories=bug,task&priorities=1&states=1,8,13,14&versions=156281">'. $counts['Critical issues'] .' Critical issues (D7)</a></li>
+<li><a href="/project/issues?projects=3060&states=8,13,14&versions=156281">'. $counts['Patch queue'] .' Patch queue (D7)</a></li>
+<li><a href="/project/issues?projects=3060&states=8&versions=156281">'. $counts['Patches to review'] .' Patches to review (D7)</a></li>
+</ul></li>
+<li><strong>Patch spotlight</strong>
+<ul>
+<li>'. l($clean_title, 'node/' . $nid) .'
+</li>
+</ul>
+</li>
+<li><strong>Play patch bingo!</strong>
+<ul>
+<li><a href="/patch-bingo" title="Select a random patch for review">Drupal core</a></li>
+<li><a href="/contrib-patch-bingo" title="Select a random patch for review from the contributions">Contributions</a></li>
+</ul></li>
+<li><strong>Play bug bingo!</strong>
+<ul>
+<li><a href="/bug-bingo" title="Select a random bug to fix">Drupal core</a></li>
+<li><a href="/contrib-bug-bingo" title="Select a random bug to fix from the contributions">Contributions</a></li>
+</ul></li>
+<li><a href="/mailing-lists">Mailing list archives</a></li>
+<li><a href="/project/issues/webmasters">Drupal.org webmasters</a></li>
+<li><a href="/project/issues/infrastructure">Drupal.org server administrators</a></li>
+<li><strong>Web links</strong>
+<ul>
+<li><a href="/planet">Planet Drupal</a></li>
+<li><a href="/talk">Drupal talk</a></li>
+<li><a href="http://groups.drupal.org/drupal-dojo">Drupal dojo</a></li>
+</ul></li>
+</ul>
+</div>';
+  $block['content'] = $output;
+  
+  return $block;
+}
+
+/**
+ * Implemenation of hook_nodeapi().
+ *
+ * Generate dynamic content for certain node pages, so as to avoid using PHP
+ * format nodes.
+ */
+function drupalorg_nodeapi(&$node, $op, $teaser, $page) {
+  
+  if ($op == 'view' && !$teaser) {
+    $output = '';
+    $function = 'drupalorg_'. $node->nid .'_view';
+    if (function_exists($function)) {
+      $output .= $function($function, $node, $teaser, $page);
+    }
+    if ($output) {
+      $node->content['drupalorg'] = array(
+        '#value' => $output,
+        '#weight' => 10,
+      );
+    }
+  }
+  elseif (($op == 'insert' || $op == 'update') && $node->type == 'book') {
+    cache_clear_all('handbook:drupalorg', 'cache', TRUE);
+  }
+}
+
+/**
+ * Generate the list of handbook contributors to append to node/14205.
+ */
+function drupalorg_14205_view($function) {
+  $cid = 'handbook:'. $function;
+  $saved = cache_get($cid);
+  if (isset($saved->data)) {
+    $output = $saved->data;
+  }
+  else {
+    $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 GROUP BY u.uid ORDER BY pages DESC");
+    $list = array();
+    while ($contributor = db_fetch_object($result)) {
+      $list[] = theme('username', $contributor) ." (". format_plural($contributor->pages, "1 page", "$contributor->pages pages") .")";
+    }
+    $output = theme('item_list', $list);
+    cache_set($cid, 'cache', $output);
+  }
+  return $output;
+}
+
+/**
+ * Generate the list of Most popular handbook pages to append to node/43639.
+ */
+function drupalorg_43639_view($function) {
+  $cid = 'handbook:'. $function;
+  $saved = cache_get($cid);
+  if (isset($saved->data)) {
+    $output = $saved->data;
+  }
+  else {
+    // TODO
+    cache_set($cid, 'cache', $output);
+  }
+  return $output;
+}
+
+/**
+ * Generate the list of Handbook pages with comments to append to node/43633.
+ */
+function drupalorg_43633_view($function) {
+  $cid = 'handbook:'. $function;
+  $saved = cache_get($cid);
+  if (isset($saved->data)) {
+    $output = $saved->data;
+  }
+  else {
+    // TODO
+    cache_set($cid, 'cache', $output);
+  }
+  
+  return $output;
+}
+
+/**
+ * Generate the Coding standards to append to node/318.
+ */
+function drupalorg_318_view($function) {
+  $cid = 'handbook:'. $function;
+  $saved = cache_get($cid);
+  if (isset($saved->data)) {
+    $output = $saved->data;
+  }
+  else {
+    // TODO
+    cache_set($cid, 'cache', $output);
+  }
+  return $output;
+}
+
