Index: template.php
===================================================================
--- template.php	(.../bluecheese/trunk/template.php)	(revision 2080)
+++ template.php	(.../sandbox/jrguitar21/bluecheese/template.php)	(revision 2082)
@@ -37,7 +37,7 @@
   if ($variables['readmore']) {
     $variables['content'] .= l(t('Read more'), 'node/'. $variables['nid'], $readmore_options);
   }
-  
+
   // News source tags
   if ($variables['node']->type == 'forum') {
     $tags = bluecheese_term_links_by_vocab($variables['node']->taxonomy);
@@ -65,7 +65,7 @@
 
   if (!empty($links_rendered)) {
     $output .= '<span class="links">'. implode(' &sdot; ', $links_rendered) .'</span>';
-    
+
     // If both links and terms will be built, add a separator between the two spans
     if (!empty($terms_rendered)) {
       $output .= ' <span class="separator">&sdot;</span> ';
@@ -131,7 +131,7 @@
  * @return array An array of taxonomy term links ordered keyed by vocabulary
  */
 function bluecheese_term_links_by_vocab($tags) {
-  
+
   if (count($tags) >= 1) {
     $links = array();
     foreach($tags as $term_id => $term) {
@@ -172,7 +172,7 @@
  */
 function bluecheese_preprocess_block(&$variables) {
   // Add block classes
-  $variables['block']->classes = 'block block-'. $variables['block']->module;
+  $variables['block']->classes .= 'block block-'. $variables['block']->module;
   if (function_exists("block_class")) {
     $variables['block']->classes .= ' '. block_class($variables['block']);
   }
@@ -190,12 +190,12 @@
   drupal_set_message('Message2');
   drupal_set_message('Message3');
   drupal_set_message('Message4');
-  
+
   drupal_set_message('Message1. Appends "messages-" to the message $type class to prevent collisions with div.warning. Adds "messages-multiple" class when more than one message of a particular type is present.', 'warning');
   drupal_set_message('Message2', 'warning');
   drupal_set_message('Message3', 'warning');
   drupal_set_message('Message4', 'warning');
-  
+
   drupal_set_message('Message1. Appends "messages-" to the message $type class to prevent collisions with div.warning. Adds "messages-multiple" class when more than one message of a particular type is present.', 'error');
   drupal_set_message('Message2', 'error');
   drupal_set_message('Message3', 'error');
@@ -237,7 +237,7 @@
 
 /**
  * function bluecheese_project_release_project_download_table($node)
- * 
+ *
  * Changes the default releases download table output
  */
 function bluecheese_project_release_project_download_table($node) {
@@ -313,7 +313,7 @@
   $result = $variables['result'];
   $variables['url'] = check_url($result['link']);
   $variables['title'] = check_plain($result['title']);
-  
+
   static $already_output = 0;
   if ($already_output < 2) {
     $already_output++;
@@ -328,7 +328,7 @@
     unset($result['user']);
     unset($result['date']);
   }
-  
+
   $matches = array();
   foreach ($result['extra'] as $key => $extra_item ) {
     // search into extras for attachments count and comments count
@@ -344,7 +344,7 @@
         break;
     }
   }
-  
+
   $info = array();
   if (isset($comments)) {
     $info['comments'] = l(format_plural($comments, '1 comment', '@count comments'), $variables['url'], array('fragment' => 'comments', 'attributes' => array('class' => 'comments')));
@@ -433,7 +433,7 @@
  * The theming of the internal links and lists in local tasks is very
  * independent, so we don't know when we theme which. It is only here, that it
  * turns out, and by this point, they are all themed into HTML blobs, so we
- * need to work backwards from the HTML blob, and alter that. 
+ * need to work backwards from the HTML blob, and alter that.
  */
 function bluecheese_menu_local_tasks() {
   $output = '';
@@ -454,3 +454,101 @@
 
   return $output;
 }
+
+/**
+ * Override theme_blocks().
+ *
+ * In certain regions, we need the theme to detect the number of blocks to display
+ * with appropriate block widths.
+ */
+function bluecheese_blocks($region) {
+  $output = '';
+  //TODO: assign better grid logic depending on number of blocks in the given region
+  if ($list = block_list($region)) {
+    $i = 0;
+    $count = count($list);
+    foreach ($list as $key => $block) {
+      // $key == <i>module</i>_<i>delta</i>
+      /* Assign 960.gs logic to sequential blocks */
+      $block->total = $count;
+      if (in_array($region, array('content_bottom', 'footer', 'content', 'content_top'))) {
+        $block->classes .= 'grid-'. intval(12 / $count) .' ';
+      }
+      if ($count > 1) {
+        if (++$i == 1) {
+          $block->classes .= 'alpha ';
+        }
+        if ($i == $count){
+          $block->classes .= 'omega ';
+        }
+      }
+      $output .= theme('block', $block);
+    }
+  }
+  ##print '</pre>';
+
+  // Add any content assigned to this region through drupal_set_content() calls.
+  $output .= drupal_get_content($region);
+
+  return $output;
+}
+
+/**
+ * Override theme_links().
+ *
+ * We need to make tokens run through the link text.
+ */
+function bluecheese_links($links, $attributes = array('class' => 'links')) {
+  global $language;
+  $output = '';
+
+  if (count($links) > 0) {
+    $output = '<ul'. drupal_attributes($attributes) .'>';
+
+    $num_links = count($links);
+    $i = 1;
+
+    foreach ($links as $key => $link) {
+      $class = $key;
+
+      // Add first, last and active classes to the list of links to help out themers.
+      if ($i == 1) {
+        $class .= ' first';
+      }
+      if ($i == $num_links) {
+        $class .= ' last';
+      }
+      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
+          && (empty($link['language']) || $link['language']->language == $language->language)) {
+        $class .= ' active';
+      }
+      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
+      if (module_exists('token')) {
+        $link['title'] = token_replace($link['title']);
+      }
+      if (isset($link['href'])) {
+        // Pass in $link as $options, they share the same keys.
+        $output .= l($link['title'], $link['href'], $link);
+      }
+      else if (!empty($link['title'])) {
+        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
+        if (empty($link['html'])) {
+          $link['title'] = check_plain($link['title']);
+        }
+        $span_attributes = '';
+        if (isset($link['attributes'])) {
+          $span_attributes = drupal_attributes($link['attributes']);
+        }
+        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
+      }
+
+      $i++;
+      $output .= "</li>\n";
+    }
+
+    $output .= '</ul>';
+  }
+
+  return $output;
+}
+
