Index: apachesolr_views_query.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr_views/apachesolr_views_query.inc,v
retrieving revision 1.3
diff -u -p -r1.3 apachesolr_views_query.inc
--- apachesolr_views_query.inc	21 Apr 2009 00:46:35 -0000	1.3
+++ apachesolr_views_query.inc	23 Apr 2009 22:38:45 -0000
@@ -1,6 +1,6 @@
 <?php
 
-// $Id: apachesolr_views_query.inc,v 1.3 2009/04/21 00:46:35 scottreynolds Exp $ 
+// $Id: apachesolr_views_query.inc,v 1.1 2009/04/03 17:28:59 scottreynolds Exp $ 
 
 // TODO: Spellchecker field? What todo about spellchecker...
 
@@ -68,13 +68,11 @@ class apachesolr_views_query extends vie
   // latitudes and longitudes
   protected $_extra_query = array();
   
-  
-  /*
-   * Functions required by the views query class interface
-   */
+  // array to store the sorts for get_available_sorts() call
+  protected $_available_sorts = array();
   
   /**
-   * Constructor. Grab the PHP solr client wrapper
+   * Views init() function
    */
   public function init($base_table, $base_field) {
     $this->_solr_service = apachesolr_get_solr();
@@ -82,6 +80,21 @@ class apachesolr_views_query extends vie
   }
   
   /**
+   * Constructor build up the avialable sorts
+   */
+  public function __construct() {
+    $data = _views_fetch_data('apachesolr');
+    foreach ($data as $field_name => $field) {
+      if (!empty($field['sort'])) {
+        $this->_available_sorts[$field_name] = array(
+          'name' => $field['title'],
+          'default' => 'asc', // TODO: make this part of the handler def? So it will be in the Views data defintion
+        );
+      }
+    }
+  }
+  
+  /**
    * copy constructor... what else to do?
    */
   public function __clone() {
@@ -217,7 +230,7 @@ class apachesolr_views_query extends vie
   public function alter(&$view) {
     foreach (module_implements('apachesolr_modify_query') as $module) {
       $function = $module . '_apachesolr_modify_query';
-      $function($this, $this->_params);
+      $function($this, $this->_params, 'apachesolr_views');
     }
   }
   
@@ -542,9 +555,12 @@ class apachesolr_views_query extends vie
   /**
    * return an array of filters
    *
+   * @param string $name
+   * the name of the filter applied to the query
+   * 
    * Compabatiablity layer with Solr_Base_Query
    */
-  function get_filters() {
+  function get_filters( $name = NULL) {
     $filters = array();
     foreach ($this->_facets as $type => $fields) {
       foreach ($fields as $data) {
@@ -553,6 +569,16 @@ class apachesolr_views_query extends vie
       }
     }
     
+    // if we are looking for a specific one
+    // remove all those that don't match and return the array
+    if (!empty($name)) {
+      foreach ($filters as $key => $filter) {
+        if ($filters['#name'] != $name) {
+          unset($filters[$key]);
+        }
+      }
+    }
+    
     return $filters;
   }
   
@@ -614,6 +640,34 @@ class apachesolr_views_query extends vie
     $this->_extra_query[$field] = $value;
   }
   
+  public function get_available_sorts() {
+    return $this->_available_sorts;
+  }
+  
+  /**
+   * Remove a specific subquery
+   *
+   * @param Drupal_Solr_Query_Interface $query
+   * the query to remove
+   */
+  function remove_subquery(Drupal_Solr_Query_Interface $query) {
+    unset($this->_subqueries[$query->id]);
+  }
+  
+  /**
+   * remove all subqueries
+   */
+  function remove_subqueries() {
+    $this->_subqueries = array();    
+  }
+  
+  /**
+   * make a sort available
+   */
+  function set_available_sort($field, $sort) {
+    // TODO: hmm.. wierd... we pull in all the sorts from Views data fields
+  }
+  
   /**
    * build up the filter query params that are passed to Solr
    */
