Selaa lähdekoodia

Merge branch '6.x-1.x' of git.drupal.org:sandbox/spficklin/1337878 into 6.x-1.x

spficklin 12 vuotta sitten
vanhempi
commit
a6eedec511

+ 2 - 2
tripal_analysis/tripal_analysis.views.inc

@@ -362,7 +362,7 @@ function tripal_analysis_views_default_views() {
       ),
     ),
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -384,7 +384,7 @@ function tripal_analysis_views_default_views() {
       'optional' => 0,
     ),
     'sourcename' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 5 - 5
tripal_contact/tripal_contact.views.inc

@@ -28,9 +28,9 @@ function tripal_contact_views_data()  {
   if (module_exists('tripal_views')) {
 
     // Base Table: contact
-    $tablename = 'contact';    
+    $tablename = 'contact';
     $priority = 9;
-      
+
     // check to see if the table is integrated. If it is then integrate it's
     // corresponding 'chado_[table]' table.
     if (!tripal_views_is_integrated($tablename, $priority)) {
@@ -46,7 +46,7 @@ function tripal_contact_views_data()  {
       'contact_relationship',
     );
     foreach ($tables as $tablename) {
-      $priority = 9;     
+      $priority = 9;
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         $status = tripal_views_integration_add_entry($table_integration_array);
@@ -250,7 +250,7 @@ function tripal_contact_views_default_views() {
       ),
     ),
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -272,7 +272,7 @@ function tripal_contact_views_default_views() {
       ),
     ),
     'description' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 6 - 6
tripal_cv/tripal_cv.views.inc

@@ -41,7 +41,7 @@ function tripal_cv_views_data() {
     );
     foreach ($tables as $tablename) {
       $priority = 9;
-      
+
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
       if (!tripal_views_is_integrated($tablename, $priority)) {
@@ -70,7 +70,7 @@ function tripal_cv_views_data() {
       'cvtermsynonym'
     );
     foreach ($tables as $tablename) {
-      $priority = 9;     
+      $priority = 9;
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);
@@ -327,7 +327,7 @@ function tripal_cv_views_default_views() {
       ),
     ),
     'name_1' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -353,7 +353,7 @@ function tripal_cv_views_default_views() {
       ),
     ),
     'definition' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -575,7 +575,7 @@ function tripal_cv_views_default_views() {
   ));
   $handler->override_option('filters', array(
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -600,7 +600,7 @@ function tripal_cv_views_default_views() {
       ),
     ),
     'definition' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 5 - 5
tripal_db/tripal_db.views.inc

@@ -38,7 +38,7 @@ function tripal_db_views_data()  {
     );
     foreach ($tables as $tablename) {
       $priority = 9;
-      
+
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
       if (!tripal_views_is_integrated($tablename, $priority)) {
@@ -58,7 +58,7 @@ function tripal_db_views_data()  {
       'dbxrefprop'
     );
     foreach ($tables as $tablename) {
-      $priority = 9;     
+      $priority = 9;
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);
@@ -231,7 +231,7 @@ function tripal_db_views_default_views() {
   ));
   $handler->override_option('filters', array(
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -256,7 +256,7 @@ function tripal_db_views_default_views() {
       ),
     ),
     'description' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -565,7 +565,7 @@ function tripal_db_views_default_views() {
       ),
     ),
     'accession' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 2 - 2
tripal_featuremap/tripal_featuremap.views.inc

@@ -289,7 +289,7 @@ function tripal_featuremap_views_default_views() {
       ),
     ),
     'name_1' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -311,7 +311,7 @@ function tripal_featuremap_views_default_views() {
       ),
     ),
     'description' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 4 - 4
tripal_genetic/tripal_genetic.views.inc

@@ -31,7 +31,7 @@ function tripal_genetic_views_data()  {
     );
     foreach ($tables as $tablename) {
       $priority = 9;
-      
+
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
       if (!tripal_views_is_integrated($tablename, $priority)) {
@@ -50,7 +50,7 @@ function tripal_genetic_views_data()  {
       'phenotype_comparison'
     );
     foreach ($tables as $tablename) {
-      $priority = 9;     
+      $priority = 9;
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         $status = tripal_views_integration_add_entry($table_integration_array);
@@ -210,7 +210,7 @@ function tripal_genetic_views_default_views() {
   ));
   $handler->override_option('filters', array(
     'uniquename' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -232,7 +232,7 @@ function tripal_genetic_views_default_views() {
       ),
     ),
     'description' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 4 - 4
tripal_natural_diversity/tripal_natural_diversity.views.inc

@@ -245,7 +245,7 @@ function tripal_natural_diversity_views_default_views() {
     ),
     'description' => array(
       'operator' => '=',
-      'value' => 'University of Saskatchewan',
+      'value' => array(),
       'group' => '0',
       'exposed' => TRUE,
       'expose' => array(
@@ -631,7 +631,7 @@ function tripal_natural_diversity_views_default_views() {
       ),
     ),
     'description' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -775,7 +775,7 @@ function tripal_natural_diversity_views_default_views() {
   ));
   $handler->override_option('filters', array(
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -988,7 +988,7 @@ function tripal_natural_diversity_views_default_views() {
       'no_results_text' => 'Click "Show" to see a list of all reagents matching the entered criteria. If you leave a any of the criteria blank then the reagents will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all reagents will be listed.',
     ),
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 4 - 4
tripal_phenotype/tripal_phenotype.views.inc

@@ -29,7 +29,7 @@ function tripal_phenotype_views_data()  {
     );
     foreach ($tables as $tablename) {
       $priority = 9;
-        
+
       // check to see if the table is integrated. If it is then integrate it's
       // corresponding 'chado_[table]' table.
       if (!tripal_views_is_integrated($tablename, $priority)) {
@@ -54,7 +54,7 @@ function tripal_phenotype_views_data()  {
       'phenotype_cvterm'
     );
     foreach ($tables as $tablename) {
-      $priority = 9;     
+      $priority = 9;
       if (!tripal_views_is_integrated($tablename, $priority)) {
         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
         tripal_views_integration_add_entry($table_integration_array);
@@ -467,7 +467,7 @@ function tripal_phenotype_views_default_views() {
       'show_all' => 0,
     ),
     'uniquename' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -489,7 +489,7 @@ function tripal_phenotype_views_default_views() {
       ),
     ),
     'value' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 52 - 15
tripal_project/tripal_project.views.inc

@@ -92,6 +92,9 @@ function tripal_project_views_default_views() {
     return $views;
   }
 
+  $description_type_id = tripal_core_chado_select('cvterm',array('cvterm_id'),array('name' => 'project_description'));
+  $description_type_id = $description_type_id[0]->cvterm_id;
+
   // Main default view
   $view = new view;
   $view->name = 'project_listing';
@@ -100,7 +103,7 @@ function tripal_project_views_default_views() {
   $view->base_table = 'project';
   $view->core = 6;
   $view->api_version = '2';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+  $view->disabled = FALSE;
   $handler = $view->new_display('default', 'Defaults', 'default');
   $handler->override_option('fields', array(
     'name' => array(
@@ -137,7 +140,7 @@ function tripal_project_views_default_views() {
       'field' => 'name',
       'relationship' => 'none',
     ),
-    'description' => array(
+    'value' => array(
       'label' => 'Description',
       'alter' => array(
         'alter_text' => 0,
@@ -166,15 +169,18 @@ function tripal_project_views_default_views() {
       'type' => 'separator',
       'separator' => ', ',
       'exclude' => 0,
-      'id' => 'description',
-      'table' => 'project',
-      'field' => 'description',
+      'id' => 'value',
+      'table' => 'projectprop',
+      'field' => 'value',
+      'override' => array(
+        'button' => 'Override',
+      ),
       'relationship' => 'none',
     ),
   ));
   $handler->override_option('filters', array(
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
@@ -195,22 +201,52 @@ function tripal_project_views_default_views() {
         'aggregates_with' => 1,
       ),
     ),
-    'description' => array(
-      'operator' => 'contains',
+    'type_id' => array(
+      'operator' => '=',
+      'value' => $description_type_id,
+      'group' => '0',
+      'exposed' => FALSE,
+      'expose' => array(
+        'operator' => FALSE,
+        'label' => '',
+        'optional' => FALSE,
+      ),
+      'case' => 1,
+      'id' => 'type_id',
+      'table' => 'projectprop',
+      'field' => 'type_id',
+      'override' => array(
+        'button' => 'Override',
+      ),
+      'relationship' => 'none',
+      'values_form_type' => 'select',
+      'multiple' => 0,
+      'optional' => 0,
+      'show_all' => 0,
+      'agg' => array(
+        'records_with' => 0,
+        'aggregates_with' => 1,
+      ),
+    ),
+    'value' => array(
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,
       'expose' => array(
         'use_operator' => 0,
-        'operator' => 'description_op',
+        'operator' => 'value_op',
         'identifier' => 'description',
         'label' => 'Description Contains',
         'remember' => 0,
       ),
-      'case' => 1,
-      'id' => 'description',
-      'table' => 'project',
-      'field' => 'description',
+      'case' => 0,
+      'id' => 'value',
+      'table' => 'projectprop',
+      'field' => 'value',
+      'override' => array(
+        'button' => 'Override',
+      ),
       'relationship' => 'none',
       'agg' => array(
         'records_with' => 1,
@@ -270,6 +306,7 @@ function tripal_project_views_default_views() {
     'weight' => 0,
     'name' => 'navigation',
   ));
+
   // Add code specific to a local chado installation
   // NOTE: Edit $handler above to $default_handler for the default display
   if (tripal_core_chado_schema_exists()) {
@@ -326,7 +363,7 @@ function tripal_project_views_default_views() {
     $fields['name']['alter']['link_to_node'] = 1;
     $default_handler->override_option('fields', $fields);
     // Only show records with published nodes
-    /**
+/**
     $filters = $view->get_items('filter', 'default');
     $filters['status'] = array(
       'operator' => '=',
@@ -343,7 +380,7 @@ function tripal_project_views_default_views() {
       'relationship' => 'none',
     );
     $default_handler->override_option('filters', $filters);
-    */
+*/
   }
   $views[$view->name] = $view;
 

+ 1 - 1
tripal_stock/tripal_stock.views.inc

@@ -485,7 +485,7 @@ function tripal_stock_views_default_views() {
       ),
     ),
     'name' => array(
-      'operator' => 'contains',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 53 - 6
tripal_views/views/handlers/chado_views_handler_filter_string.inc

@@ -69,23 +69,70 @@ class chado_views_handler_filter_string extends views_handler_filter_string {
     }
     else {
 
-      // Only base records with value in the aggregated field
-      // This doesn't restrict the items in the aggregate field
       $this->ensure_my_table();
       $field = "$this->table_alias.$this->real_field";
-      if ($this->options['agg']['records_with']) {
-        $where = "'%s' = ANY($field)";
-        $this->query->add_where($this->options['group'], $where, $this->value);
+
+      // Want to filter both the base table and the aggregated field
+      if ($this->options['agg']['records_with'] && $this->options['agg']['aggregates_with']) {
+        $where = "$field IS NOT NULL";
+        $this->query->add_where($this->options['group'], $where);
+        $table['join']->filter[] = $field . " " . $this->operator . " '" . $this->value . "'";
       }
+      // Only base records with value in the aggregated field
+      // This doesn't restrict the items in the aggregate field
+      elseif ($this->options['agg']['records_with']) {
+        if ($this->operator == '~') {
+          // Currently postgresql doesn't support 'somevalue' ~ ANY(field) as a means of
+          // selecting all records where the field matches somevalue. Instead what this notation means
+          // is return TRUE if one of the values of field matches 'somevalue'
+          // Instead add in a subclause
+          $where = "array_to_string($field,'###') ~ '%s'";
+          $this->query->add_where($this->options['group'], $where, $this->value);
+        }
+        else {
+          $where = "'%s' " . $this->operator . " ANY($field)";
+          $this->query->add_where($this->options['group'], $where, $this->value);
+        }
 
+      }
       // To restrict the items in the aggregate...
       // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
-        $table['join']->filter[] = $field . " = '" . $this->value . "'";
+        $table['join']->filter[] = $field . " " . $this->operator . " '" . $this->value . "'";
       }
     }
 
   }
 
+  /**
+   * This kind of construct makes it relatively easy for a child class
+   * to add or remove functionality by overriding this function and
+   * adding/removing items from this array.
+   */
+  function operators() {
+    $operators = array(
+      '=' => array(
+        'title' => t('Is equal to'),
+        'short' => t('='),
+        'method' => 'op_equal',
+        'values' => 1,
+      ),
+      '!=' => array(
+        'title' => t('Is not equal to'),
+        'short' => t('!='),
+        'method' => 'op_equal',
+        'values' => 1,
+      ),
+      '~' => array(
+        'title' => t('Contains'),
+        'short' => t('contains'),
+        'method' => 'op_contains',
+        'values' => 1,
+      ),
+    );
+
+    return $operators;
+  }
+
 }

+ 11 - 1
tripal_views/views/handlers/tripal_views_handler_filter_no_results.inc

@@ -47,7 +47,17 @@ class tripal_views_handler_filter_no_results extends views_handler_filter {
   function query() {
     global $base_url;
 
-    if (empty($this->view->exposed_input)) {
+    // Check that all filter types don't return arrays
+    // If they do then just show results by default b/c there is no way to tell the
+    // different between before and after submitted
+    $all_arrays = TRUE;
+    foreach ($this->view->exposed_raw_input as $v) {
+      if (!is_array($v)) {
+        $all_arrays = FALSE;
+      }
+    }
+
+    if (empty($this->view->exposed_input) && !$all_arrays) {
       $this->view->executed = TRUE;
 
       $jquery_loaded = FALSE;

+ 9 - 2
tripal_views/views/handlers/tripal_views_handler_filter_select_cvterm.inc

@@ -206,8 +206,15 @@ class tripal_views_handler_filter_select_cvterm extends views_handler_filter_str
       // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
-        if (sizeof($this->value) == 1) {
-          $table['join']->filter[] = $field . " = '" . array_pop($this->value) . "'";
+
+        if (sizeof($this->value) == 1 && is_array($this->value)) {
+          $table['join']->filter[] = $field . " " . $this->operator . " '" . array_pop($this->value) . "'";
+        }
+        elseif (sizeof($this->value) == 1 && is_string($this->value)) {
+          $table['join']->filter[] = $field . " " . $this->operator . " '" . $this->value . "'";
+        }
+        elseif (sizeof($this->value) > 1 && is_array($this->value)) {
+          $table['join']->filter[] = $field . " IN (" . implode(',',$this->value) . ")";
         }
       }
     }

+ 1 - 1
tripal_views/views/handlers/views_handler_join_chado_aggregator.inc

@@ -243,7 +243,7 @@ class views_handler_join_chado_aggregator extends views_join {
       .' ' . implode(' ', $joins);
 
     if (!empty($opt['filter'])) {
-      $sql .= ' WHERE ' . implode(', ', $opt['filter']);
+      $sql .= ' WHERE ' . implode(' AND ', $opt['filter']);
     }
 
     $sql .= ' GROUP BY ' . $opt['field'];