cvs diff: Diffing drupalorg
Index: drupalorg/drupalorg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalorg/drupalorg/drupalorg.module,v
retrieving revision 1.42
diff -u -p -u -p -r1.42 drupalorg.module
--- drupalorg/drupalorg.module	27 Jul 2010 20:58:56 -0000	1.42
+++ drupalorg/drupalorg.module	6 Aug 2010 10:09:37 -0000
@@ -591,3 +591,49 @@ function drupalorg_download_drupal_link_
   return l('<span>'. check_plain("$text $release->version") .'</span>', "node/$release->nid", array('html' => TRUE, 'attributes' => array('class' => 'link-button')));
 }
 
+/**
+ * Render the HTML for a given block.
+ *
+ * This function takes a module and a delta, loads the block info from the DB,
+ * invokes the function to compute the block content, and then renders the
+ * block to HTML via theme('block'). This is basically a heavily pared back
+ * implementation of block_list() for a single block.
+ *
+ * @param string $module
+ *   The module that defines the block we're rendering.
+ * 
+ * @param string $delta
+ *   The delta of the block that we're rendering.
+ * 
+ * @return
+ *   The rendered HTML for the given block.
+ * 
+ * @see block_list()
+ * @see theme_block()
+ */
+function drupalorg_block_render($module, $delta) {
+  // Load the title, since that can be modified administratively.  
+  $title = db_result(db_query("SELECT title FROM {blocks} WHERE module = '%s' AND delta = '%s')", $module, $delta));
+
+  $block_output = module_invoke($module, 'block', 'view', $delta);
+  foreach ($block_output as $k => $v) {
+    $block->$k = $v;
+  }
+
+  // Set the module and delta so that the blocks contain
+  // at least the minimum of expected information.
+  $block->module = $module;
+  $block->delta = $delta;
+
+  if (isset($block->content) && $block->content) {
+    // Override default block title if a custom display title is present.
+    if ($title) {
+      // Check plain admin-generated titles, but not titles set in code.
+      $block->subject = $title == '<none>' ? '' : check_plain($title);
+    }
+    if (!isset($block->subject)) {
+      $block->subject = '';
+    }    
+  }
+  return theme('block', $block);
+}
cvs diff: Diffing drupalorg/js
cvs diff: Diffing drupalorg/views
cvs diff: Diffing drupalorg_search
Index: drupalorg_search/drupalorg_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalorg/drupalorg_search/drupalorg_search.module,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 drupalorg_search.module
--- drupalorg_search/drupalorg_search.module	6 Aug 2010 08:43:42 -0000	1.17
+++ drupalorg_search/drupalorg_search.module	6 Aug 2010 10:09:37 -0000
@@ -67,15 +67,18 @@ function drupalorg_search_apachesolr_upd
  * Returns an array keyed by block delta.
  */
 function drupalorg_search_apachesolr_facets() {
-  $facets = array();
-
-  $facets['meta_type'] = array(
-    'info' => t('Drupalorg Search: Filter by meta type'),
-    'facet_field' => '{!ex=meta_type}ss_meta_type',
-    'exclude_filter' => '',
+  return array(
+    'meta_type' => array(
+      'info' => t('Drupalorg Search: Filter by meta type'),
+      'facet_field' => '{!ex=meta_type}ss_meta_type',
+      'exclude_filter' => '',
+    ),
+    'sort_created' => array(
+      'info' => t('New content'),
+      'facet_field' => 'created',
+      'direction' => 'desc',
+    ),
   );
-
-  return $facets;
 }
 
 /**
@@ -326,6 +329,72 @@ function drupalorg_search_block_form_sub
 }
 
 /**
+ * Base query required for creating the download page context for solr-related
+ * blocks. Creates and caches a solr query for use by block elements.
+ */
+function drupalorg_search_execute_base_query() {
+  // Build a simple query.
+  $base_path = 'project/modules';
+  $query = apachesolr_drupal_query('', '', '', $base_path);
+
+  $params = array(
+    // The fields to return.
+    'fl' => 'id,nid,title',
+    'start' => 0,
+    // We don't actually need to return rows.
+    'rows' => 1,
+    // We need to be able to facet on the project vid value
+    // so we can pull project categories.
+    'facet.field' => array(
+      'im_vid_' . _project_get_vid(),
+    ),
+    // Additional criterias.
+    'fq' => array(
+      'type:project_project',
+      'im_vid_' . _project_get_vid() . ':' . DRUPALORG_MODULE_TID,
+    ),
+    'facet' => 'true',
+    'facet.mincount' => 1,
+    'facet.sort' => 'true',
+  );
+
+  apachesolr_search_add_facet_params($params, $query);
+
+  // Cache the built query. Since all the built queries go through
+  // this process, all the hook_invocations will happen later.
+  apachesolr_current_query($query);
+
+  // This hook allows modules to modify the query and params objects.
+  apachesolr_modify_query($query, $params, 'drupalorg_search_execute_base_query');
+
+  $solr = apachesolr_get_solr();
+  $response = $solr->search($query->get_query_basic(), $params['start'], $params['rows'], $params);
+
+  apachesolr_static_response_cache($response);
+  apachesolr_has_searched(TRUE);
+}
+
+/**
+ * Theme preprocess function for the drupalorg_download search page.
+ */
+function drupalorg_search_preprocess_drupalorg_download(&$variables) {
+  drupalorg_search_execute_base_query();
+  
+  // Since we control what facets we're building, we can just utilize the
+  // delta as the unique key for the sake of brevity (both here and in the
+  // $variables array).
+  $facets = array(
+    'sort_most_installed' => 'drupalorg_order_facet',
+    'project_solr_categories' => 'project_solr',
+    'sort_created' => 'drupalorg_order_facet',
+  );
+  // Render and save the facet blocks.  
+  foreach ($facets as $delta => $module) {
+    $variables[$delta] = drupalorg_block_render($module, $delta);
+  }  
+}
+
+/**
  * Get the taxonomy term for the project type (if any) in a given Solr search.
  *
  * This function loops over all of the active facets in the given Solr query
