Browse Source

Fixed Bugs in menu description & upgraded filter textarea

Lacey Sanderson 11 years ago
parent
commit
c77a87a4a9

+ 15 - 16
tripal_views/includes/tripal_views_integration.inc

@@ -43,9 +43,9 @@ function tripal_views_integration_setup_list() {
                      .'ORDER BY tv.table_name ASC, tv.priority ASC');
   foreach ($tviews as $tview) {
     $rows[] = array(
-      l(t('Edit'), "admin/tripal/views/integration/edit/" . $tview->setup_id) . "<br />"
-        . l(t('Export'), "admin/tripal/views/integration/export/" . $tview->setup_id) . "<br />"
-        . l(t('Delete'), "admin/tripal/views/integration/delete/" . $tview->setup_id),
+      l(t('Edit'), "admin/tripal/views-integration/edit/" . $tview->setup_id) . "<br />"
+        . l(t('Export'), "admin/tripal/views-integration/export/" . $tview->setup_id) . "<br />"
+        . l(t('Delete'), "admin/tripal/views-integration/delete/" . $tview->setup_id),
       $tview->name,
       $tview->table_name,
       ($tview->table_id) ? 'No' : 'Yes',
@@ -75,9 +75,9 @@ function tripal_views_integration_setup_list() {
                      .'ORDER BY table_name ASC, priority ASC');
   foreach ($tviews as $tview) {
     $rows[] = array(
-      l(t('Edit'), "admin/tripal/views/integration/edit/" . $tview->setup_id) . "<br />"
-        . l(t('Export'), "admin/tripal/views/integration/export/" . $tview->setup_id) . "<br />"
-        . l(t('Delete'), "admin/tripal/views/integration/delete/" . $tview->setup_id),
+      l(t('Edit'), "admin/tripal/views-integration/edit/" . $tview->setup_id) . "<br />"
+        . l(t('Export'), "admin/tripal/views-integration/export/" . $tview->setup_id) . "<br />"
+        . l(t('Delete'), "admin/tripal/views-integration/delete/" . $tview->setup_id),
       $tview->name,
       $tview->table_name,
       $tview->priority,
@@ -105,9 +105,9 @@ function tripal_views_integration_setup_list() {
                      .'ORDER BY table_name ASC, priority ASC');
   foreach ($tviews as $tview) {
     $rows[] = array(
-      l(t('Edit'), "admin/tripal/views/integration/edit/" . $tview->setup_id) . "<br />"
-        . l(t('Export'), "admin/tripal/views/integration/export/" . $tview->setup_id) . "<br />"
-        . l(t('Delete'), "admin/tripal/views/integration/delete/" . $tview->setup_id),
+      l(t('Edit'), "admin/tripal/views-integration/edit/" . $tview->setup_id) . "<br />"
+        . l(t('Export'), "admin/tripal/views-integration/export/" . $tview->setup_id) . "<br />"
+        . l(t('Delete'), "admin/tripal/views-integration/delete/" . $tview->setup_id),
       $tview->name,
       $tview->table_name,
       $tview->priority,
@@ -133,7 +133,7 @@ function tripal_views_integration_delete($setup_id) {
 
   tripal_views_integration_remove_entry_by_setup_id($setup_id);
   drupal_set_message(t("Record Deleted"));
-  drupal_goto('admin/tripal/views/integration');
+  drupal_goto('admin/tripal/views-integration');
 
 }
 
@@ -214,9 +214,8 @@ function tripal_views_integration_delete_all_form_submit ($form, &$form_state) {
  *
  * @ingroup tripal_views_integration
  */
-function tripal_views_integration_form($form, $form_state) {
+function tripal_views_integration_form($form, $form_state, $arg) {
 
-  $form = array();
   $data = array();
   $form['#cache'] = TRUE;
   if (isset($form_state['build_info']['args'][0])) {
@@ -317,7 +316,7 @@ function tripal_views_integration_form($form, $form_state) {
     '#description' => t('Tables from Chado, custom tables and materialized view tables (non-legacy MViews) can be selected for integration.'),
     '#default_value' => $default,
     '#ajax' => array(
-       //D6: 'path' => 'tripal/views/integration/ajax/view_setup_table',
+       //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
        'callback' => 'tripal_views_integration_ajax_view_setup_table',
        'wrapper' => 'fieldset-table-rows-wrapper',
        'effect' => 'fade',
@@ -346,7 +345,7 @@ function tripal_views_integration_form($form, $form_state) {
     '#description' => 'Which materialized view to use.',
     '#default_value' => $default,
     '#ajax' => array(
-       //D6: 'path' => 'tripal/views/integration/ajax/view_setup_table',
+       //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
        'callback' => 'tripal_views_integration_ajax_view_setup_table',
        'wrapper' => 'fieldset-table-rows-wrapper',
        'effect' => 'fade',
@@ -908,7 +907,7 @@ function tripal_views_integration_form($form, $form_state) {
     }
   }
 
-  $form['#redirect'] = 'admin/tripal/views/integration/list';
+  $form['#redirect'] = 'admin/tripal/views-integration/list';
 
   return $form;
 }
@@ -1111,7 +1110,7 @@ function tripal_views_integration_form_submit($form, &$form_state) {
     drupal_set_message(t('Record Added'));
   }
 
-  $form_state['redirect'] = 'admin/tripal/views/integration/list';
+  $form_state['redirect'] = 'admin/tripal/views-integration/list';
 
   // now clear all the caches so that Drupal views picks up our chages
   views_invalidate_cache();

+ 5 - 5
tripal_views/tripal_views.module

@@ -55,15 +55,15 @@ function tripal_views_menu() {
   $items['admin/tripal/views-integration/edit/%'] = array(
     'title' => 'Edit Views Integration',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_form', 5),
+    'page arguments' => array('tripal_views_integration_form', 4),
     'access arguments' => array('manage tripal_views_integration'),
-    'type' => MENU_CALLBACK,
+    'type' => MENU_NORMAL_ITEM,
   );
 
   $items['admin/tripal/views-integration/delete/%'] = array(
     'title' => 'Delete Views Integration',
     'page callback' => 'tripal_views_integration_delete',
-    'page arguments' => array(5),
+    'page arguments' => array(4),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
   );
@@ -90,7 +90,7 @@ function tripal_views_menu() {
     'title' => 'Export Views Integration',
     'description' => 'Export a Tripal Views Integration for use in another Tripal site',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_export_form', 5),
+    'page arguments' => array('tripal_views_integration_export_form', 4),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_NORMAL_ITEM,
     'weight' => 3,
@@ -100,7 +100,7 @@ function tripal_views_menu() {
     'title' => 'Export Views Integration',
     'description' => 'Export a Tripal Views Integration for use in another Tripal site',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_export_form', 5),
+    'page arguments' => array('tripal_views_integration_export_form', 4),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
   );

+ 12 - 0
tripal_views/tripal_views.views.inc

@@ -64,6 +64,13 @@ function tripal_views_views_handlers() {
     ),
     'handlers' => array(
 
+      // Custom Tripal Field Handlers
+      /** CANT FIX UNTIL Tripal Feature is working
+      'tripal_views_handler_field_sequence' => array(
+        'parent' => 'views_handler_field',
+      ),
+      */
+
       // Custom Tripal Filter Handlers
       'tripal_views_handler_filter_no_results' => array(
         'parent' => 'views_handler_filter'
@@ -74,6 +81,9 @@ function tripal_views_views_handlers() {
       'tripal_views_handler_filter_select_string' => array(
         'parent' => 'views_handler_filter_string',
       ),
+      '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',
@@ -81,6 +91,8 @@ function tripal_views_views_handlers() {
       'tripal_views_handler_filter_textarea' => array(
         'parent' => 'views_handler_filter',
       ),
+      */
+      /** CANT FIX UNTIL Tripal Feature is working
       'tripal_views_handler_filter_sequence' => array(
         'parent' => 'chado_views_handler_filter_string',
       ),

+ 3 - 6
tripal_views/views/handlers/tripal_views_handler_field_sequence.inc

@@ -7,12 +7,7 @@
  * Handles display of sequence data.  If will aggregate sequences that need
  * to be aggregated (e.g. coding sequences) and provide
  */
-class tripal_views_handler_field_sequence extends chado_views_handler_field {
-
-  function init(&$view, $options) {
-    parent::init($view, $options);
-
-  }
+class tripal_views_handler_field_sequence extends views_handler_field {
 
   /**
    * Defines the options form (form available to admin when they add a field to a view)
@@ -264,4 +259,6 @@ class tripal_views_handler_field_sequence extends chado_views_handler_field {
     } */
     return $residues;
   }
+
+
 }

+ 2 - 2
tripal_views/views/handlers/tripal_views_handler_filter_select_string.inc

@@ -130,7 +130,7 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
       //Select List
       $form['value'] = array(
           '#type' => 'select',
-          '#title' => t('%label', array('%label' => $this->options['label'])),
+          '#title' => t('%label', array('%label' => $this->options['expose']['label'])),
           '#options' => $this->get_select_options(),
           '#default_value' => $this->value,
       );
@@ -143,7 +143,7 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
 
       $form['value'] = array(
         '#type' => 'textfield',
-        '#title' => t('%label', array('%label' => $this->options['label'])),
+        '#title' => t('%label', array('%label' => $this->options['expose']['label'])),
         '#default_value' => $this->value,
       );
 

+ 18 - 21
tripal_views/views/handlers/tripal_views_handler_filter_textarea.inc

@@ -28,7 +28,7 @@ class tripal_views_handler_filter_textarea extends views_handler_filter {
   }
 
   /**
-   * Ensures the textarea field gets rendered when the filter is exposed. 
+   * Ensures the textarea field gets rendered when the filter is exposed.
    */
   function exposed_form(&$form, &$form_state) {
 
@@ -52,24 +52,24 @@ class tripal_views_handler_filter_textarea extends views_handler_filter {
 
   }
 
-  /**
-   *  Validates the input form
-   */
-  function exposed_validate(&$form, &$form_state) {
-     //dpm($form_state);
-  }
-
   /**
    *
    */
   function query() {
+
+    // make optional
+    // if it is not set or empty then don't restrict the query
+    if (!$this->value) {
+      return;
+    }
+
     $this->ensure_my_table();
     $field = "$this->table.$this->real_field";
 
     // get the form element value
     if (is_array($this->value)) {
       $value = $this->value[0];
-    } 
+    }
     else {
       $value = $this->value;
     }
@@ -79,20 +79,17 @@ class tripal_views_handler_filter_textarea extends views_handler_filter {
     $value = preg_replace("/\s+\n/", "\n", $value);
     $value = preg_replace("/,\n/", "\n", $value);
     $values = preg_split("/[\n,]+/", $value);
-    
-    // iterate through all of the values and generate the corresponding
-    // sprintf style holders
-    $holders = array();     
-    for ($i = 0 ; $i < count($values); $i++) {
-      $values[$i] = trim($values[$i]);
-      $holders[] = "'%s'";
+    $values = array_filter($values);
+
+    if (sizeof($values)) {
+      $operator = 'IN';
+    }
+    else {
+      $operator = '=';
     }
 
-    // if we have any values supplied then update the where clause for
-    // the views query
-    if (count($holders) > 0) {
-      $where = "$field IN (" . implode(", ", $holders) . ")";
-      $this->query->add_where($this->options['group'], $where, $values);
+    if (!empty($values)) {
+      $this->query->add_where($this->options['group'], $field, $values, $operator);
     }
   }
 }