Browse Source

Tripal Views: Made Views filter No Results handler D7 compatible

Lacey Sanderson 11 years ago
parent
commit
a737ecb842

+ 3 - 5
tripal_views/tripal_views.views.inc

@@ -84,13 +84,11 @@ function tripal_views_views_handlers() {
       'tripal_views_handler_filter_textarea' => array(
         'parent' => 'views_handler_filter',
       ),
-      /** D7 @todo: get handlers working
       'tripal_views_handler_filter_file_upload' => array(
         'parent' => 'views_handler_filter',
       ),
-      'tripal_views_handler_filter_textarea' => array(
-        'parent' => 'views_handler_filter',
-      ),
+      /** D7 @todo: get handlers working
+
       */
       /** CANT FIX UNTIL Tripal Feature is working
       'tripal_views_handler_filter_sequence' => array(
@@ -145,7 +143,7 @@ function tripal_views_views_data() {
   // Filter handler that lets the admin say:
   // "Show no results until they enter search parameters"
   $data['views']['search_results'] = array(
-    'title' => t('Search Results'),
+    'title' => t('Delay Results'),
     'help' => t('Delay results until Apply/Search is clicked by the user.'),
     'filter' => array(
       'handler' => 'tripal_views_handler_filter_no_results',

+ 2 - 0
tripal_views/views/handlers/tripal_views_handler_field_aggregate.inc

@@ -7,6 +7,8 @@
  * Handles fields which may be aggregated during the chado join process. This field
  * will render an aggregated field as a pre_rendered list and will dynamically detect
  * whether the field is aggregated or not.
+ *
+ * D7: still not compatible
  */
 class tripal_views_handler_field_aggregate extends chado_views_handler_field {
 

+ 3 - 1
tripal_views/views/handlers/tripal_views_handler_filter_file_upload.inc

@@ -5,6 +5,8 @@
  * Purpose: This Handler provides a file upload field by extending the
  * views_handler_filter object.
  *
+ * D7: still not compatible
+ *
  * @ingroup tripal_views_integration
  */
 class tripal_views_handler_filter_file_upload extends views_handler_filter {
@@ -71,7 +73,7 @@ class tripal_views_handler_filter_file_upload extends views_handler_filter {
     $field = "$this->table.$this->real_field";
 
     // get the form element values
-    $value = $this->value[0]; 
+    $value = $this->value[0];
     $values = $value['items_array'];
 
     // iterate through all of the values and generate the corresponding

+ 10 - 37
tripal_views/views/handlers/tripal_views_handler_filter_no_results.inc

@@ -22,7 +22,7 @@ class tripal_views_handler_filter_no_results extends views_handler_filter {
 
     $form['msg'] = array(
       '#type' => 'item',
-      '#value' => t('This filter ensures that when the page is first loaded, there are no results '
+      '#markup' => t('This filter ensures that when the page is first loaded, there are no results '
         .'(query is not run). This imitates an advanced search form allowing users to first enter '
         .'filter values and then retrieve results. This is especially suited for views with a very '
         .'large number of results if left unfiltered since it removes the long load time before '
@@ -30,16 +30,18 @@ class tripal_views_handler_filter_no_results extends views_handler_filter {
     );
 
     $form['apply_button'] = array(
-      '#type' => 'textfield',
-      '#title' => 'Apply Button Text',
-      '#default_value' => isset($this->options['apply_button']) ? $this->options['apply_button'] : 'Search'
+      '#type' => 'item',
+      '#title' => t('Apply Button Text'),
+      '#markup' => t('This can now to be changed through the Views UI in the "Advanced" '
+        . 'area by clicking "Settings" for the "Exposed Form Style" when the style is "Basic".')
     );
 
     $form['no_results_text'] = array(
-      '#type' => 'textarea',
-      '#title' => 'Header Text before Search',
-      '#description' => 'This text will replace the no results text when the view is first loaded (before the user clicks Apply/Search)',
-      '#default_value' => isset($this->options['no_results_text']) ? $this->options['no_results_text'] : ''
+      '#type' => 'item',
+      '#title' => t('Header Text before Search'),
+      '#markup' => t('When the view is first loaded (before any filters are applied), '
+        . 'the "No Results Behaviour" textare added in the "Advanced" are of the Views '
+        . 'UI will be shown to the user.'),
     );
 
   }
@@ -65,36 +67,7 @@ class tripal_views_handler_filter_no_results extends views_handler_filter {
 
     if (empty($this->view->exposed_input) && !$all_arrays) {
       $this->view->executed = TRUE;
-
       $jquery_loaded = FALSE;
-
-      // If set, change the no_results text
-      if (!empty($this->options['apply_button'])) {
-        if (!$jquery_loaded) {
-          drupal_add_html_head('<script type="text/javascript" src="' . $base_url . '/misc/jquery.js"></script>');
-          $jquery_loaded = TRUE;
-        }
-        $javascript = '<script type="text/javascript">'."\n"
-          ."$(document).ready(function(){\n"
-          ."  $('div.view-empty').html('" . addslashes($this->options['no_results_text']) . "');\n"
-          ."});\n"
-          .'</script>'."\n";
-        drupal_add_html_head($javascript);
-      }
-    }
-
-    // Set the Apply button text
-    if (!empty($this->options['apply_button'])) {
-      if (!$jquery_loaded) {
-        drupal_add_html_head('<script type="text/javascript" src="' . $base_url . '/misc/jquery.js"></script>');
-        $jquery_loaded = TRUE;
-      }
-      $javascript = '<script type="text/javascript">'."\n"
-        ."$(document).ready(function(){\n"
-        ."  $('div.views-submit-button').html(" . '"' . "<input type='submit' id='edit-submit-all-analysis' value='" . $this->options['apply_button'] . "' class='form-submit'>" . '"' . ");\n"
-        ."});\n"
-        .'</script>' . "\n";
-      drupal_add_html_head($javascript);
     }
   }