Parcourir la source

Tripal Views (base directory) aheres to coding standards

Lacey Sanderson il y a 12 ans
Parent
commit
2e83e3c3c1

+ 73 - 43
tripal_views/tripal_views.api.inc

@@ -1,5 +1,10 @@
 <?php
 
+/**
+ * @file
+ * API functions for Tripal Views Integration
+ */
+
 /**
  * Retrieve the views integration setup with the lightest priority for a given table
  *
@@ -7,19 +12,20 @@
  * and -10 is of highest priority.
  *
  * @param $table_name
- *   The name of the table to retrieve the setup ID for. This can be either a materialized 
+ *   The name of the table to retrieve the setup ID for. This can be either a materialized
  *   view or a chado table
  *
  * @return
  *   On success, the setup_id to use for integration of this table; otherwise FALSE
  */
-function tripal_views_get_lightest_priority_setup ($table_name) {
+function tripal_views_get_lightest_priority_setup($table_name) {
 
   $sql = "SELECT setup_id FROM {tripal_views} WHERE table_name='%s' ORDER BY priority ASC";
   $setup = db_fetch_object(db_query($sql, $table_name));
   if ($setup) {
-    return $setup->setup_id;  
-  } else {
+    return $setup->setup_id;
+  }
+  else {
     return FALSE;
   }
 }
@@ -27,13 +33,16 @@ function tripal_views_get_lightest_priority_setup ($table_name) {
 /**
  * Checks if you are dealing with the lightest priority setup for a given table
  */
-function tripal_views_is_lightest_priority_setup ($setup_id, $table_name) {
-  $lightest_priority_setup_id = tripal_views_get_lightest_priority_setup ($table_name);
+function tripal_views_is_lightest_priority_setup($setup_id, $table_name) {
+
+  $lightest_priority_setup_id = tripal_views_get_lightest_priority_setup($table_name);
   if ($lightest_priority_setup_id == $setup_id) {
     return TRUE;
-  } else {
+  }
+  else {
     return FALSE;
   }
+
 }
 
 /**
@@ -79,7 +88,7 @@ function tripal_views_is_lightest_priority_setup ($setup_id, $table_name) {
  */
 function tripal_views_integration_add_entry($defn_array) {
   $no_errors = TRUE;
-  
+
   // First insert into tripal_views
   $view_record = array(
     'table_name' => $defn_array['table'],
@@ -88,29 +97,29 @@ function tripal_views_integration_add_entry($defn_array) {
     'priority' => $defn_array['priority'],
   );
   if ($defn_array['type'] == 'mview') {
-      $mview = db_fetch_object(db_query("SELECT mview_id FROM tripal_mviews WHERE mv_table='%s'",$defn_array['table']));
+      $mview = db_fetch_object(db_query("SELECT mview_id FROM {tripal_mviews} WHERE mv_table='%s'", $defn_array['table']));
       $view_record['mview_id'] = $mview->mview_id;
       if (!$mview->mview_id) {
         return FALSE;
       }
   }
-  $status = drupal_write_record('tripal_views',$view_record);
-  
+  $status = drupal_write_record('tripal_views', $view_record);
+
   if ($status) {
-    
+
     // Insert Field Definitions
     foreach ($defn_array['fields'] as $field) {
       $field_record = array(
-      	'setup_id' => $view_record['setup_id'],
+        'setup_id' => $view_record['setup_id'],
         'column_name' => $field['name'],
         'name' => $field['title'],
         'description' => $field['description'],
         'type' => $field['type'],
       );
-      $status = drupal_write_record('tripal_views_field',$field_record);
-      
+      $status = drupal_write_record('tripal_views_field', $field_record);
+
       if ($status) {
-      
+
         // Insert Handler Definitions
         foreach ($field['handlers'] as $handler_type => $handler) {
           $handler_record = array(
@@ -120,16 +129,18 @@ function tripal_views_integration_add_entry($defn_array) {
             'handler_name' => $handler['name'],
             'arguments' => serialize($handler)
           );
-          $status = drupal_write_record('tripal_views_handlers',$handler_record);
+          $status = drupal_write_record('tripal_views_handlers', $handler_record);
           if (!$status) {
-            drupal_set_message('Unable to integrate '.$handler_type.' handler: '.$handler['name'], 'error');
+            drupal_set_message(t('Unable to integrate %handler_type handler: %handler_name', array('%handler_type' => $handler_type, '%handler_name' => $handler['name'])), 'error');
             $no_errors = FALSE;
           }
         }
-        
+
         // Insert Joins
-        if (!is_array($field['joins'])) { $field['joins'] = array(); }
-        foreach($field['joins'] as $join) {
+        if (!is_array($field['joins'])) {
+          $field['joins'] = array();
+        }
+        foreach ($field['joins'] as $join) {
           $join_record = array(
             'setup_id' => $view_record['setup_id'],
             'base_table' => $defn_array['table'],
@@ -139,29 +150,43 @@ function tripal_views_integration_add_entry($defn_array) {
           );
 
           if (!empty($join['handler'])) {
-          	$join_record['handler'] = $join['handler'];
-          } else {
-          	$join_record['handler'] = 'views_join';
+            $join_record['handler'] = $join['handler'];
+          }
+          else {
+            $join_record['handler'] = 'views_join';
           }
 
-          $status = drupal_write_record('tripal_views_join',$join_record);
+          $status = drupal_write_record('tripal_views_join', $join_record);
           if (!$status) {
-            drupal_set_message('Unable to join '.$join['table'].'.'.$join['field'].' with '.$defn_array['table'].'.'.$field['name'], 'error');
+            drupal_set_message(
+              t(
+                'Unable to join %left_table.%left_field with %table.%field',
+                array(
+                  '%left_table' => $join['table'],
+                  '%left_field' => $join['field'],
+                  '%table' => $defn_array['table'],
+                  '%field' => $field['name']
+                )
+              ),
+              'error'
+            );
             $no_errors = FALSE;
           }
         }
-        
-      } else {
-        drupal_set_message('Unable to integrate field: '.$field['name'],'error');
+
+      }
+      else {
+        drupal_set_message(t('Unable to integrate field: %field_name', array('%field_name' => $field['name'])), 'error');
         $no_errors = FALSE;
       }
     }
-    
-  } else {
-    drupal_set_message('Unable to set default views integration','error');
+
+  }
+  else {
+    drupal_set_message(t('Unable to set default views integration'), 'error');
     $no_errors = FALSE;
   }
-  
+
   return $no_errors;
 }
 
@@ -176,16 +201,21 @@ function tripal_views_integration_add_entry($defn_array) {
  * @return
  *   TRUE on Success; FALSE otherwise
  */
-function tripal_views_integration_remove_entry_by_table_name ($table_name, $priority) {
+function tripal_views_integration_remove_entry_by_table_name($table_name, $priority) {
 
-  $views = db_fetch_object(db_query("SELECT * FROM {tripal_views} WHERE table_name='%s' AND priority=%d",$table_name,$priority));
+  $views = db_fetch_object(db_query(
+    "SELECT * FROM {tripal_views} WHERE table_name='%s' AND priority=%d",
+    $table_name,
+    $priority
+  ));
   if ($views->setup_id) {
     tripal_views_integration_remove_entry_by_setup_id($views->setup_id);
-    return TRUE;  
-  } else {
+    return TRUE;
+  }
+  else {
     return FALSE;
   }
-  
+
 }
 
 /**
@@ -194,11 +224,11 @@ function tripal_views_integration_remove_entry_by_table_name ($table_name, $prio
  * @param $setup_id
  *   The setup ID of the views integration entry to remove
  */
-function tripal_views_integration_remove_entry_by_setup_id ($setup_id) {
+function tripal_views_integration_remove_entry_by_setup_id($setup_id) {
 
-    db_query('DELETE FROM {tripal_views} WHERE setup_id=%d',$setup_id);
-    db_query('DELETE FROM {tripal_views_field} WHERE setup_id=%d',$setup_id);
-    db_query('DELETE FROM {tripal_views_handlers} WHERE setup_id=%d',$setup_id);
-    db_query('DELETE FROM {tripal_views_join} WHERE setup_id=%d',$setup_id);
+    db_query('DELETE FROM {tripal_views} WHERE setup_id=%d', $setup_id);
+    db_query('DELETE FROM {tripal_views_field} WHERE setup_id=%d', $setup_id);
+    db_query('DELETE FROM {tripal_views_handlers} WHERE setup_id=%d', $setup_id);
+    db_query('DELETE FROM {tripal_views_join} WHERE setup_id=%d', $setup_id);
 
 }

+ 10 - 0
tripal_views/tripal_views.coder_ignores.txt

@@ -0,0 +1,10 @@
+; The file should be formatted this way :
+; file:line:warning-type
+; where warning-type is one of security, style, sql, i18n, comment, etc.
+
+; All <?php should be closed with a ?> in theme template files
+tripal_views_integration_fields_form.tpl.php:48:style
+tripal_views_data_export_download_form.tpl.php:8:style
+
+; All variables are set through the code and thus don't need to be filtered
+tripal_views_integration.inc:734:security

+ 266 - 252
tripal_views/tripal_views.install

@@ -1,279 +1,293 @@
 <?php
 
-/************************************************************************
-*  Implementation of hook_install();
-* 
-* @ingroup tripal_views
-*/
-function tripal_views_install(){
+/**
+ * @file
+ * Functions related to installing/uninstalling this module
+ */
 
-   // create the module's data directory
-   tripal_create_moddir('tripal_views');
+/**
+ * Implementation of hook_install().
+ *
+ * @ingroup tripal_views
+ */
+function tripal_views_install() {
+
+  // create the module's data directory
+  tripal_create_moddir('tripal_views');
 
   // create the tables that manage materialized views and jobs
   drupal_install_schema('tripal_views');
 
 }
 
-/************************************************************************
-* Implementation of hook_schema().
-*
-* @ingroup tripal_views
-*/
+/**
+ * Implementation of hook_schema().
+ *
+ * @ingroup tripal_views
+ */
 function tripal_views_schema() {
-   $schema = tripal_views_get_schemas();
-   return $schema;
+  $schema = tripal_views_get_schemas();
+  return $schema;
 }
-/************************************************************************
-* Implementation of hook_uninstall()
-*
-* @ingroup tripal_views
-*/
-function tripal_views_uninstall(){
-   drupal_uninstall_schema('tripal_views');
+/**
+ * Implementation of hook_uninstall().
+ *
+ * @ingroup tripal_views
+ */
+function tripal_views_uninstall() {
+  drupal_uninstall_schema('tripal_views');
 }
 
-/************************************************************************
-* This function simply defines all tables needed for the module to work
-* correctly.  By putting the table definitions in a separate function we
-* can easily provide the entire list for hook_install or individual
-* tables for an update.
-*
-* @ingroup tripal_views
-*/
-function tripal_views_get_schemas (){  
-   $schema = array();
+/**
+ * This function simply defines all tables needed for the module to work
+ * correctly.  By putting the table definitions in a separate function we
+ * can easily provide the entire list for hook_install or individual
+ * tables for an update.
+ *
+ * @ingroup tripal_views
+ */
+function tripal_views_get_schemas() {
+  $schema = array();
 
-   $temp = tripal_views_views_schema();
-   foreach ($temp as $table => $arr){ 
-      $schema[$table] = $arr; 
-   } 
+  $temp = tripal_views_views_schema();
+  foreach ($temp as $table => $arr) {
+    $schema[$table] = $arr;
+  }
 
-	return $schema;
+  return $schema;
 }
 
-/** 
- *
+/**
+ * Tripal Views Update for 6.x-0.4
+ *   - Add priority field to tripal_views
+ *   - Add handler field to tripal_views_join
+ *   - Add tripal_views_field table to keep track of fields for views integration
  */
-function tripal_views_update_6040 () {
-	$ret = array();
-	
-	// Add Priority to tripal_views
+function tripal_views_update_6040() {
+  $ret = array();
+
+  // Add Priority to tripal_views
   db_add_field($ret, 'tripal_views', 'priority', array('type' => 'int'));
-  db_add_unique_key($ret,'tripal_views', 'priority', array('table_name','priority'));
-	db_add_index($ret,'tripal_views', 'priority', array('table_name','priority'));
-	
-	// Add handler to tripal_views_join
-	db_add_field($ret, 'tripal_views_join', 'handler', array('type' => 'varchar','length' => '255','not null' => TRUE,'default' => ''));
+  db_add_unique_key($ret, 'tripal_views', 'priority', array('table_name', 'priority'));
+  db_add_index($ret, 'tripal_views', 'priority', array('table_name', 'priority'));
+
+  // Add handler to tripal_views_join
+  db_add_field($ret, 'tripal_views_join', 'handler', array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''));
+
+  // Add tripal_views_field to keep track of fields for views integration
+  $schema = tripal_views_views_schema();
+  db_create_table(&$ret, 'tripal_views_field', $schema['tripal_views_field']);
 
-	// Add tripal_views_field to keep track of fields for views integration
-	$schema = tripal_views_views_schema();
-	db_create_table(&$ret, 'tripal_views_field', $schema['tripal_views_field']);
-	
   return $ret;
 }
 
-/************************************************************************
-* 
-*
-* @ingroup tripal_views
-*/
-function tripal_views_views_schema(){
-   $schema = array();
-	$schema['tripal_views'] = array(
-		'description' => 'contains the setupes, their materialized view id and base table name that was used.',
-		'fields' => array(
-			'setup_id' => array(
-				'description' => 'the id of the setup',
-				'type' => 'serial',
-				'unsigned' => TRUE,
-				'not null' => TRUE,
-			),
-			'mview_id' => array(
-				'description' => 'the materialized view used for this setup',
-				'type' => 'int',
-				'unsigned' => TRUE,
-			),
-			'table_name' => array(
-				'description' => 'the base table name to be used when using this setup. Use this field when not using a materialized view',
-				'type' => 'varchar',
-				'length' => 255,
-				'not null' => TRUE,
-				'default' => '',
-			),
-			'priority' => array(
-				'description' => 'when there are 2+ entries for the same table, the entry with the lightest (drupal-style) priority is used.',
-				'type' => 'int',
-			),
-			'name' => array(
-				'description' => 'Human readable name of this setup',
-				'type' => 'varchar',
-				'length' => 255,
-				'not null' => TRUE,
-				'default' => '',
-			),
-			'comment' => array(
-				'description' => 'add notes about this views setup',
-				'type' => 'text',
-				'size' => 'normal',
-				'not null' => FALSE,
-				'default' => '',
-			),
-		),
-		'unique_keys' => array(
-			'setup_id' => array('setup_id'),
-			'priority' => array('table_name','priority'),
-		),
-		'indexes' => array(
-			'priority' => array('table_name','priority'),
-		),
-		'primary key' => array('setup_id'),
-	);
+/**
+ * Describe the Tripal Views Schema
+ *
+ * Tables include:
+ *   - tripal_views: main table for views integration setups
+ *   - tripal_views_field: keeps track of all fields related to a given views integration setup
+ *   - tripal_views_join: keeps track of joins between the current views integration setup
+ *       and other tables.
+ *   - tripal_views_handlers: keeps track of which handlers to use for a given field
+ *
+ * @ingroup tripal_views
+ */
+function tripal_views_views_schema() {
+  $schema = array();
+  $schema['tripal_views'] = array(
+    'description' => 'contains the setupes, their materialized view id and base table name that was used.',
+    'fields' => array(
+      'setup_id' => array(
+        'description' => 'the id of the setup',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'mview_id' => array(
+        'description' => 'the materialized view used for this setup',
+        'type' => 'int',
+        'unsigned' => TRUE,
+      ),
+      'table_name' => array(
+        'description' => 'the base table name to be used when using this setup. Use this field when not using a materialized view',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'priority' => array(
+        'description' => 'when there are 2+ entries for the same table, the entry with the lightest (drupal-style) priority is used.',
+        'type' => 'int',
+      ),
+      'name' => array(
+        'description' => 'Human readable name of this setup',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'comment' => array(
+        'description' => 'add notes about this views setup',
+        'type' => 'text',
+        'size' => 'normal',
+        'not null' => FALSE,
+        'default' => '',
+      ),
+    ),
+    'unique_keys' => array(
+      'setup_id' => array('setup_id'),
+      'priority' => array('table_name', 'priority'),
+    ),
+    'indexes' => array(
+      'priority' => array('table_name', 'priority'),
+    ),
+    'primary key' => array('setup_id'),
+  );
+
+  $schema['tripal_views_field'] = array(
+    'description' => 'keep track of fields available for a given table',
+    'fields' => array(
+      'setup_id' => array(
+        'description' => 'the id of the setup',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'column_name' => array(
+        'description' => 'the name of the field in the database',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+      ),
+      'name' => array(
+        'description' => 'the human-readable name of the field',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+      ),
+      'description' => array(
+        'description' => 'A short description of the field -seen under the field in the views UI',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+      ),
+      'type' => array(
+        'description' => 'the database type of this field (ie: int, varchar)',
+        'type' => 'varchar',
+        'length' => '50',
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array('setup_id', 'column_name')
+  );
 
-	$schema['tripal_views_field'] = array(
-		'description' => 'keep track of fields available for a given table',
-		'fields' => array(
-			'setup_id' => array(
-				'description' => 'the id of the setup',
-				'type' => 'int',
-				'unsigned' => TRUE,
-				'not null' => TRUE,
-			),
-			'column_name' => array(
-				'description' => 'the name of the field in the database',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-			),
-			'name' => array(
-				'description' => 'the human-readable name of the field',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-			),
-			'description' => array(
-				'description' => 'A short description of the field -seen under the field in the views UI',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-			),
-			'type' => array(
-				'description' => 'the database type of this field (ie: int, varchar)',
-				'type' => 'varchar',
-				'length' => '50',
-				'not null' => TRUE,
-			),
-		),
-		'primary key' => array('setup_id','column_name')
-	);
-	
-	$schema['tripal_views_join'] = array(
-		'description' => 'coordinate the joining of tables',
-		'fields' => array(
-		  'view_join_id' => array(
-				'description' => 'the id of the join',
-				'type' => 'serial',
-				'unsigned' => TRUE,
-				'not null' => TRUE,
-		  ),
-			'setup_id' => array(
-				'description' => 'setup id from tripal_views table',
-				'type' => 'int',
-				'unsigned' => TRUE,
-				'not null'=> TRUE,
-			),
-			'base_table' => array(
-			   'description' => 'the name of the base table',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-				'default' => '',
-	      ),
-			'base_field' => array(
-				'description' => 'the name of the base table column that will be joined',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-				'default' => '',
-			),
-			'left_table' => array(
-				'description' => 'the table on which to perform a left join',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-				'default' => '',
-			),
-			'left_field' => array(
-				'description' => 'the column on which to perform a left join',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-				'default' => '',
-	      ),
-	      'handler' => array(
-					'description' => 'the name of the handler',
-					'type' => 'varchar',
-					'length' => '255',
-					'not null' => TRUE,
-					'default' => '',
-	      ),
-		),
-		'unique_keys' => array(
-			'setup_id' => array('view_join_id'),
-		),
-		'primary key' => array('view_join_id'),
-	);
+  $schema['tripal_views_join'] = array(
+    'description' => 'coordinate the joining of tables',
+    'fields' => array(
+      'view_join_id' => array(
+        'description' => 'the id of the join',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'setup_id' => array(
+        'description' => 'setup id from tripal_views table',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'base_table' => array(
+         'description' => 'the name of the base table',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+        'default' => '',
+        ),
+      'base_field' => array(
+        'description' => 'the name of the base table column that will be joined',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'left_table' => array(
+        'description' => 'the table on which to perform a left join',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'left_field' => array(
+        'description' => 'the column on which to perform a left join',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+        'default' => '',
+        ),
+        'handler' => array(
+          'description' => 'the name of the handler',
+          'type' => 'varchar',
+          'length' => '255',
+          'not null' => TRUE,
+          'default' => '',
+        ),
+    ),
+    'unique_keys' => array(
+      'setup_id' => array('view_join_id'),
+    ),
+    'primary key' => array('view_join_id'),
+  );
 
-	$schema['tripal_views_handlers'] = array(
-		'description' => 'in formation for views: column and views handler name',
-		'fields' => array(
-			'handler_id' => array(
-				'description' => 'the id of the handler',
-				'type' => 'serial',
-			   'unsigned' => TRUE,
-			   'not null' => TRUE,
-	      ),
-			'setup_id' => array(
-				'description' => 'setup id from the tripal_views table',
-				'type' => 'int',
-				'unsigned' => TRUE,
-				'not null'=> TRUE,
-			),
-			'column_name' => array(
-				'description' => '',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-				'default' => '',
-			),
-			'handler_type' => array(
-				'description' => 'identifies the type of hander (e.g. field, filter, sort, argument, relationship, etc.)',
-				'type' => 'varchar',
-				'length' => '50',
-				'not null' => TRUE,
-				'default' => '',
-			),
-			'handler_name' => array(
-				'description' => 'the name of the handler',
-				'type' => 'varchar',
-				'length' => '255',
-				'not null' => TRUE,
-				'default' => '',
-			),
-			'arguments' => array(
-				'description' => 'arguments that may get passed to the handler',
-				'type' => 'text',
-				'size' => 'normal',
-				'not null' => FALSE,
-				'default' => '',
-			),
-		),
-		'unique_keys' => array(
-		   'setup_id' => array('handler_id'),
-	   ),
-		'primary key' => array('handler_id'),
-	);
+  $schema['tripal_views_handlers'] = array(
+    'description' => 'in formation for views: column and views handler name',
+    'fields' => array(
+      'handler_id' => array(
+        'description' => 'the id of the handler',
+        'type' => 'serial',
+         'unsigned' => TRUE,
+         'not null' => TRUE,
+        ),
+      'setup_id' => array(
+        'description' => 'setup id from the tripal_views table',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'column_name' => array(
+        'description' => '',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'handler_type' => array(
+        'description' => 'identifies the type of hander (e.g. field, filter, sort, argument, relationship, etc.)',
+        'type' => 'varchar',
+        'length' => '50',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'handler_name' => array(
+        'description' => 'the name of the handler',
+        'type' => 'varchar',
+        'length' => '255',
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'arguments' => array(
+        'description' => 'arguments that may get passed to the handler',
+        'type' => 'text',
+        'size' => 'normal',
+        'not null' => FALSE,
+        'default' => '',
+      ),
+    ),
+    'unique_keys' => array(
+       'setup_id' => array('handler_id'),
+    ),
+    'primary key' => array('handler_id'),
+  );
 
-   return $schema;
+  return $schema;
 }
-?>

+ 12 - 2
tripal_views/tripal_views.module

@@ -14,7 +14,6 @@ require_once "tripal_views_form_elements.inc";
 function tripal_views_menu() {
   $items = array();
 
-/**
   $items['admin/tripal/views'] = array(
     'title' => 'Views Integration',
     'description' => 'Integration with Drupal Views',
@@ -54,7 +53,7 @@ function tripal_views_menu() {
     'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
     'type' => MENU_CALLBACK,
   );
-*/
+
   return $items;
 }
 
@@ -109,3 +108,14 @@ function tripal_views_theme() {
     ),
   );
 }
+
+/**
+ * Implements hook_coder_ignore().
+ * Defines the path to the file (tripal_views.coder_ignores.txt) where ignore rules for coder are stored
+ */
+function tripal_views_coder_ignore() {
+  return array(
+    'path' => drupal_get_path('module', 'tripal_views'),
+    'line prefix' => drupal_get_path('module', 'tripal_views'),
+  );
+}

Fichier diff supprimé car celui-ci est trop grand
+ 471 - 465
tripal_views/tripal_views.views.inc


+ 10 - 1
tripal_views/tripal_views_data_export_download_form.tpl.php

@@ -1,2 +1,11 @@
-<?php print drupal_render($form); ?>
+<?php
+
+/**
+ * @file
+ * Render the views data export form on views pages
+ * Allows you to select a download type without using Feed icons
+ */
+print drupal_render($form);
+
+?>
 

+ 56 - 48
tripal_views/tripal_views_form_elements.inc

@@ -1,72 +1,80 @@
 <?php
 
+/**
+ * @file
+ * Form elements used for tripal views
+ */
+
 /**
  * Register form elements
  */
 function tripal_views_elements() {
 
-   $type['file_upload_combo'] = array(
-      '#input' => TRUE,
-      '#process' => array('expand_file_upload_combo'),
-      '#element_validate' => array('file_upload_combo_validate'),
-   );
-   return $type;
+  $type['file_upload_combo'] = array(
+    '#input' => TRUE,
+    '#process' => array('expand_file_upload_combo'),
+    '#element_validate' => array('file_upload_combo_validate'),
+  );
+
+  return $type;
 }
+
 /**
- * 
+ * Upload File and keep track of previously uploaded files
+ * Form element description
  */
-function expand_file_upload_combo ($element, $edit, $form_state, $complete_form) {
+function expand_file_upload_combo($element, $edit, $form_state, $complete_form) {
+
+  if (empty($element['#value'])) {
+    $element['#value'] = array(
+      'items' => '',
+      'items_file' => '',
+      'file_path' => '',
+    );
+  }
 
-	if (empty($element['#value'])) {
-    	$element['#value'] = array(
-         'items' => '',
-         'items_file' => '',
-         'file_path' => '',
-    	);
-  	}
-   //dpm($form_state);
+  $element['#tree'] = TRUE;
 
-	$element['#tree'] = TRUE;
+  $parents = $element['#parents'];
+  $parents[] = 'items';
+  $element['items'] = array(
+    '#type' => 'textarea',
+    '#default_value' => $element['#value']['items'],
+  );
+  $parents = $element['#parents'];
+  $parents[] = 'items_file';
+  $element['items_file'] = array(
+    '#type' => 'file',
+    '#title' =>  'File upload',
+    '#default_value' => $element['#value']['items_file'],
+  );
 
-	$parents = $element['#parents'];
-   $parents[] = 'items';
-   $element['items'] = array(
-      '#type' => 'textarea',
-		'#default_value' => $element['#value']['items'],
-   ); 
-	$parents = $element['#parents'];
-   $parents[] = 'items_file';
-   $element['items_file'] = array(
-      '#type' => 'file',
-      '#title' =>  'File upload',
-		'#default_value' => $element['#value']['items_file'],
-   ); 
+  $parents = $element['#parents'];
+  $parents[] = 'file_path';
+  $element['file_path'] = array(
+    '#type' => 'hidden',
+    '#default_value' => $element['#value']['file_path'],
+  );
 
-	$parents = $element['#parents'];
-   $parents[] = 'file_path';
-   $element['file_path'] = array(
-      '#type' => 'hidden',
-		'#default_value' => $element['#value']['file_path'],
-   );
-   return $element;
+  return $element;
 }
 
 /**
- * 
+ * Theme the file upload combo form element
  */
 function theme_file_upload_combo($element) {
-  	return theme('form_element', $element, '<div class="container-inline">'. $element['#children'] .'</div>');
+  return theme('form_element', $element, '<div class="container-inline">' . $element['#children'] . '</div>');
 }
 
 /**
- * 
+ * Validate all content passed into the file upload combo form element
  */
-function file_upload_combo_validate($element,&$form) {
-    $file = file_save_upload($element['#name'],array());
-    if($file) {
-       $form['values'][$element['#name']]['file_path'] = $file->filepath;
-       // we need to add our file path to the $_GET element as if it were
-       // submitted along with the rest of the form 
-       $_GET[$element['#name']]['file_path'] = $file->filepath;
-    }
+function file_upload_combo_validate($element, &$form) {
+  $file = file_save_upload($element['#name'], array());
+  if ($file) {
+    $form['values'][$element['#name']]['file_path'] = $file->filepath;
+    // we need to add our file path to the $_GET element as if it were
+    // submitted along with the rest of the form
+    $_GET[$element['#name']]['file_path'] = $file->filepath;
+  }
 }

Fichier diff supprimé car celui-ci est trop grand
+ 358 - 342
tripal_views/tripal_views_integration.inc


+ 7 - 0
tripal_views/tripal_views_integration_fields_form.tpl.php

@@ -1,3 +1,10 @@
+<?php
+/**
+ * @file
+ * Template file for the views integration fields form.
+ */
+?>
+
 <style type="text/css">
 
 #tripal-views-integration-form  .fields-new-row, .field-headers {

+ 5 - 5
tripal_views/views_data_export/theme/views-data-export-fasta-body.tpl.php

@@ -1,14 +1,14 @@
 <?php
 //print_r($themed_rows);
 print $defline;
-foreach ($themed_rows as $index => $fields){
+foreach ($themed_rows as $index => $fields) {
    $defline = array();
    $residues = '';
-   foreach ($fields as $key => $value){
-     if(strcmp($key,'residues')==0){
+   foreach ($fields as $key => $value) {
+     if (strcmp($key,'residues')==0)b{
         $residues = wordwrap($value, 60, "\r\n", true);
-     } 
-     if(strcmp($key,'defline')==0){
+     }
+     if (strcmp($key,'defline')==0) {
         $defline = $value;
      }
    }

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff