Browse Source

Tripal Library adheres to Drupal coding standards

Pubudu Basnayaka 12 years ago
parent
commit
46778e0bb4

+ 25 - 25
tripal_library/tripal_library.api.inc

@@ -5,7 +5,7 @@
  * @ingroup tripal_api
  * @ingroup tripal_library
  */
- 
+
 /**
  * Implements hook_chado_library_schema()
  * Purpose: To add descriptions and foreign keys to default table description
@@ -18,7 +18,7 @@
  */
 function tripal_library_chado_library_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_schema()
 
   $description['foreign keys']['organism'] = array(
@@ -26,24 +26,24 @@ function tripal_library_chado_library_schema() {
         'columns' => array(
           'organism_id' => 'organism_id',
         ),
-  );  
-  
+  );
+
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
         'columns' => array(
           'type_id' => 'cvterm_id',
         ),
   );
-  
+
   $referring_tables = array(
       'library_cvterm',
       'library_feature',
       'library_pub',
       'library_synonym',
-      'libraryprop' 
+      'libraryprop'
   );
   $description['referring_tables'] = $referring_tables;
-  
+
   return $description;
 }
 
@@ -59,7 +59,7 @@ function tripal_library_chado_library_schema() {
  */
 function tripal_library_chado_library_feature_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_library_feature_schema()
 
   $description['foreign keys']['library'] = array(
@@ -67,15 +67,15 @@ function tripal_library_chado_library_feature_schema() {
         'columns' => array(
           'library_id' => 'library_id',
         ),
-  );  
-  
+  );
+
   $description['foreign keys']['feature'] = array(
         'table' => 'feature',
         'columns' => array(
           'feature_id' => 'feature_id',
         ),
   );
-  
+
   return $description;
 }
 /**
@@ -90,7 +90,7 @@ function tripal_library_chado_library_feature_schema() {
  */
 function tripal_library_chado_libraryprop_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_library_feature_schema()
 
   $description['foreign keys']['library'] = array(
@@ -98,15 +98,15 @@ function tripal_library_chado_libraryprop_schema() {
         'columns' => array(
           'library_id' => 'library_id',
         ),
-  );  
-  
+  );
+
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
         'columns' => array(
           'type_id' => 'cvterm_id',
         ),
   );
-  
+
   return $description;
 }
 
@@ -123,8 +123,8 @@ function tripal_library_chado_libraryprop_schema() {
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_get_property($library_id,$property){
-   return tripal_core_get_property('library',$library_id,$property,'tripal');
+function tripal_library_get_property($library_id, $property) {
+   return tripal_core_get_property('library', $library_id, $property, 'tripal');
 }
 
 /**
@@ -144,8 +144,8 @@ function tripal_library_get_property($library_id,$property){
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_insert_property($library_id,$property,$value,$update_if_present = 0){
-   return tripal_core_insert_property('library',$library_id,$property,'tripal',$value,$update_if_present);
+function tripal_library_insert_property($library_id, $property, $value, $update_if_present = 0) {
+   return tripal_core_insert_property('library', $library_id, $property, 'tripal', $value, $update_if_present);
 }
 
 /**
@@ -157,7 +157,7 @@ function tripal_library_insert_property($library_id,$property,$value,$update_if_
  *   The cvterm name of the property to update
  * @param $value
  *   The value of the property to update
- * @param $insert_if_missing 
+ * @param $insert_if_missing
  *   A boolean indicated whether to insert the record if it's absent
  *
  * Note: The property will be identified using the unique combination of the $library_id and $property
@@ -168,8 +168,8 @@ function tripal_library_insert_property($library_id,$property,$value,$update_if_
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_update_property($library_id,$property,$value,$insert_if_missing = 0){
-   return tripal_core_update_property('library',$library_id,$property,'tripal',$value, $insert_if_missing);
+function tripal_library_update_property($library_id, $property, $value, $insert_if_missing = 0) {
+   return tripal_core_update_property('library', $library_id, $property, 'tripal', $value, $insert_if_missing);
 }
 /**
  * Delete a given property
@@ -183,10 +183,10 @@ function tripal_library_update_property($library_id,$property,$value,$insert_if_
  * and then it will be deleted
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_delete_property($library_id,$property){
-   return tripal_core_delete_property('library',$library_id,$property,'tripal');
+function tripal_library_delete_property($library_id, $property) {
+   return tripal_core_delete_property('library', $library_id, $property, 'tripal');
 }

+ 18 - 18
tripal_library/tripal_library.install

@@ -5,7 +5,7 @@
 *
 * @ingroup tripal_library
 */
-function tripal_library_install(){
+function tripal_library_install() {
    // create the module's data directory
    tripal_create_moddir('tripal_library');
 
@@ -16,14 +16,14 @@ function tripal_library_install(){
    // Insert cvterm 'library_description' into cvterm table of chado
    // database. This CV term is used to keep track of the library
    // description in the libraryprop table.
-   tripal_cv_add_cvterm(array('name' => 'library_description','def' => 'Description of a library'),'tripal',0,1,'tripal');
-   
+   tripal_cv_add_cvterm(array('name' => 'library_description', 'def' => 'Description of a library'), 'tripal', 0, 1, 'tripal');
+
    // Add CVTerms for the library types
-   tripal_cv_add_cvterm(array('name' => 'cdna_library','def' => 'cDNA Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'bac_library','def' => 'BAC Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'fosmid_library','def' => 'FOSMID Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'cosmid_library','def' => 'COSMID Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'yac_library','def' => 'YAC Library'),'tripal',0,1,'tripal');
+   tripal_cv_add_cvterm(array('name' => 'cdna_library', 'def' => 'cDNA Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'bac_library', 'def' => 'BAC Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'fosmid_library', 'def' => 'FOSMID Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'cosmid_library', 'def' => 'COSMID Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'yac_library', 'def' => 'YAC Library'), 'tripal', 0, 1, 'tripal');
 
    // Add the materialized view needed to count the features for the library
    // Drop the MView table if it exists
@@ -34,12 +34,12 @@ function tripal_library_install(){
    }
    tripal_db_set_active($previous_db);
    // Create the MView
-   tripal_add_mview('library_feature_count','tripal_library',
+   tripal_add_mview('library_feature_count', 'tripal_library',
       'library_feature_count',
       'library_id integer, name character varying(255), '.
-		'  num_features integer, feature_type character varying(255)',
-	   'library_id',
-	   'SELECT '.
+    '  num_features integer, feature_type character varying(255)',
+     'library_id',
+     'SELECT '.
       '   L.library_id, '.
       '   L.name, '.
       '    count(F.feature_id) as num_features, '.
@@ -49,7 +49,7 @@ function tripal_library_install(){
       '    INNER JOIN Feature F           ON LF.feature_id = F.feature_id '.
       '    INNER JOIN Cvterm CVT          ON F.type_id = CVT.cvterm_id '.
       'GROUP BY L.library_id, L.name, CVT.name',
-	   ''
+     ''
    );
 
 }
@@ -69,7 +69,7 @@ function tripal_library_schema() {
  *
  * @ingroup tripal_library
  */
-function tripal_library_uninstall(){
+function tripal_library_uninstall() {
    drupal_uninstall_schema('tripal_library');
 
    // remove the materialized view
@@ -78,8 +78,8 @@ function tripal_library_uninstall(){
 
    if (db_table_exists('tripal_mviews')) {
       $mview = db_fetch_object(db_query($sql));
-      if($mview){
-         tripal_mviews_action('delete',$mview->mview_id);
+      if ($mview) {
+         tripal_mviews_action('delete', $mview->mview_id);
       }
    }
 
@@ -101,7 +101,7 @@ function tripal_library_uninstall(){
  *
  * @ingroup tripal_library
  */
-function tripal_library_get_schemas (){
+function tripal_library_get_schemas() {
   $schema = array();
   $schema['chado_library'] = array(
       'fields' => array(
@@ -127,7 +127,7 @@ function tripal_library_get_schemas (){
          'library_id' => array('library_id')
       ),
       'unique keys' => array(
-         'nid_vid' => array('nid','vid'),
+         'nid_vid' => array('nid', 'vid'),
          'vid' => array('vid')
       ),
       'primary key' => array('nid'),

File diff suppressed because it is too large
+ 209 - 199
tripal_library/tripal_library.module


+ 11 - 11
tripal_library/tripal_library.views.inc

@@ -6,7 +6,7 @@
  *  chado/tripal organism tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
@@ -18,13 +18,13 @@
 
 require_once('views/library.views.inc');
 require_once('views/chado_library.views.inc');
-require_once('views/misc_tables.views.inc'); 
+require_once('views/misc_tables.views.inc');
 /*************************************************************************
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views
  * @return: a data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  *
@@ -32,18 +32,18 @@ require_once('views/misc_tables.views.inc');
  */
 function tripal_library_views_data()  {
   $data = array();
-  
+
   $data = array_merge($data, retrieve_library_views_data());
   $data = array_merge($data, retrieve_chado_library_views_data());
   $data = array_merge($data, retrieve_library_misc_tables_views_data());
-  
+
   return $data;
 }
 
 /*************************************************************************
  * Implements hook_views_handlers()
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  * @return: An array of handler definitions
  *
@@ -67,7 +67,7 @@ function tripal_library_views_handlers() {
  */
 function tripal_library_views_data_alter(&$data) {
 
-  if( !(is_array($db_url) and array_key_exists('chado',$db_url)) ){
+  if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
 
     // Add featuer relationship to node
     $data['node']['library_chado_nid'] = array(
@@ -85,7 +85,7 @@ function tripal_library_views_data_alter(&$data) {
       ),
     );
   }
-  
+
 }
 
 /**
@@ -93,9 +93,9 @@ function tripal_library_views_data_alter(&$data) {
  *
  * @ingroup tripal_library_views
  */
-function tripal_library_views_default_views () {
+function tripal_library_views_default_views() {
   $views = array();
-  
+
   // Main default view
   // List all cvterms based on cv
   $view = new view;
@@ -389,6 +389,6 @@ function tripal_library_views_default_views () {
     'name' => 'navigation',
   ));
   $views[$view->name] = $view;
-  
+
   return $views;
 }

+ 24 - 23
tripal_library/views/chado_library.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the chado_library drupal table, it's fields and any joins between it and other tables
  * @see tripal_library_views_data() --in tripal_library.views.inc
  *
@@ -9,14 +10,14 @@
  *
  * @ingroup tripal_library_views
  */
-function retrieve_chado_library_views_data () {
-	global $db_url;
+function retrieve_chado_library_views_data() {
+  global $db_url;
   $data = array();
-  
+
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
      // return empty data array b/c if chado is external then no join to the nodetable can be made
      return $data;
   }
@@ -26,42 +27,42 @@ function retrieve_chado_library_views_data () {
     'field' => 'nid',
     'group' => 'Chado Library'
   );
-  
+
   $data['chado_library']['nid'] = array(
     'title' => t('Library Node ID'),
     'help' => t('The node ID for this library'),
     'field' => array(
-     	'handler' => 'views_handler_field_numeric',
- 		  'click sortable' => TRUE,
+       'handler' => 'views_handler_field_numeric',
+       'click sortable' => TRUE,
     ),
     'filter' => array(
-     	'handler' => 'views_handler_filter_numeric',
+       'handler' => 'views_handler_filter_numeric',
     ),
     'sort' => array(
-     	'handler' => 'views_handler_sort',
+       'handler' => 'views_handler_sort',
     ),
   );
 
   // Note: No joins need to be made from $data['library']['table']
-  
+
   // Join the chado library table to library
   $data['chado_library']['table']['join']['library'] = array(
-  	'left_field' => 'library_id',
-  	'field' => 'library_id',
+    'left_field' => 'library_id',
+    'field' => 'library_id',
   );
-  
+
   // Join the node table to chado library
   $data['node']['table']['join']['chado_library'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
+    'left_field' => 'nid',
+    'field' => 'nid',
   );
-  
+
   // Join the node table to library
   $data['node']['table']['join']['library'] = array(
-  	'left_table' => 'chado_library',
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );  
+    'left_table' => 'chado_library',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
   // Add relationship between chado_library and library
   $data['chado_library']['library_nid'] = array(
@@ -94,6 +95,6 @@ function retrieve_chado_library_views_data () {
       'base field' => 'nid'
     ),
   );
-  
-	return $data;
+
+  return $data;
 }

+ 12 - 12
tripal_library/views/handlers/views_handler_field_computed_library_nid.inc

@@ -1,17 +1,17 @@
 <?php
 
 class views_handler_field_computed_library_nid extends views_handler_field_numeric {
-	function construct() {
-		parent::construct();
-		$this->additional_fields['library_id'] = array('table' => 'library', 'field' => 'library_id');
-	}
+  function construct() {
+    parent::construct();
+    $this->additional_fields['library_id'] = array('table' => 'library', 'field' => 'library_id');
+  }
 
-	function query() { 
-		$this->ensure_my_table();
-		$this->add_additional_fields(); 
-	}
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
 
-	function render($values) { 
-		return $values->library_nid;
-	}
-} 
+  function render($values) {
+    return $values->library_nid;
+  }
+}

+ 131 - 129
tripal_library/views/library.views.inc

@@ -1,6 +1,7 @@
 <?php
-	/**
- * Purpose: this function returns the portion of the data array 
+  /**
+ *@file
+ * Purpose: this function returns the portion of the data array
  *   which describes the library table, it's fields and any joins between it and other tables
  * @see tripal_library_views_data() --in tripal_library.views.inc
  *
@@ -29,28 +30,28 @@
  * @ingroup tripal_library_views
  */
 function retrieve_library_views_data() {
-	global $db_url;
+  global $db_url;
   $data = array();
 
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
      $database = 'chado';
   }
-  
+
   // Basic table definition
-	$data['library']['table']['group'] = 'Chado Library';
-	$data['library']['table']['base'] = array(
-	  'field' => 'library_id',
-	  'title' => 'Chado Library',
-	  'help' => 'Library existing in the Chado Database',                                                                                                                                                                          
-	);
-	if($database){
-	  $data['library']['table']['base']['database'] = $database;
-	}
-	
-	// Define relationships between this table and others
+  $data['library']['table']['group'] = 'Chado Library';
+  $data['library']['table']['base'] = array(
+    'field' => 'library_id',
+    'title' => 'Chado Library',
+    'help' => 'Library existing in the Chado Database',
+  );
+  if ($database) {
+    $data['library']['table']['base']['database'] = $database;
+  }
+
+  // Define relationships between this table and others
   $data['library']['table']['join'] = array(
     'library_feature' => array(
       'left_field' => 'library_id',
@@ -70,36 +71,37 @@ function retrieve_library_views_data() {
       'field' => 'feature_id',
     ),
   );
-	
-	// Table Field Definitions----------------------
-	// Field: library_id (primary key)
-	$data['library']['library_id'] = array(
-	  'title' => 'Library ID',
-	  'help' => 'The primary key of the library table.',
-	  'field' => array(
-	    'handler' => 'views_handler_field_numeric',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_numeric',
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort',
-	  ),
-	);
-	
+
+  // Table Field Definitions----------------------
+  // Field: library_id (primary key)
+  $data['library']['library_id'] = array(
+    'title' => 'Library ID',
+    'help' => 'The primary key of the library table.',
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
   // Calculated Field: Node ID
   //  use custom field handler to query drupal for the node ID
   //  this is only needed if chado is in a separate database from drupal
-  if($database){
-		$data['library']['library_nid'] = array(
-	  	'title' => 'Node ID',
-	  	'help' => 'The node ID for the current library',
-	  	'field' => array(
-	    	'handler' => 'views_handler_field_computed_library_nid',
-	  	),
-		);
-  } else {
+  if ($database) {
+    $data['library']['library_nid'] = array(
+      'title' => 'Node ID',
+      'help' => 'The node ID for the current library',
+      'field' => array(
+        'handler' => 'views_handler_field_computed_library_nid',
+      ),
+    );
+  }
+  else {
     // Add relationship between chado_library and library
     $data['library']['library_nid'] = array(
       'group' => 'Library',
@@ -117,100 +119,100 @@ function retrieve_library_views_data() {
     );
 
   }
-	
-	// Field: organism_id (forgeign key)
+
+  // Field: organism_id (forgeign key)
   //  join between organism table and this one in tripal_organism/views/organism.views.inc
-	
-	// Field: type_id (forgeign key)
+
+  // Field: type_id (forgeign key)
   //  join between cvterm table and this one in tripal_cv/views/cvterm.views.inc
-  
-	// Field: Name (varchar 255)
-	$data['library']['name'] = array(
-	  'title' => 'Name',
-	  'help' => 'The human-readable name of the current library.',
-	  'field' => array(
-	    'handler' => 'views_handler_field',
-	    'click sortable' => TRUE,
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort',
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_chado_select_string',
-	  ),
-	  'argument' => array(
-	    'handler' => 'views_handler_argument_string',
-	  ),
-	);
-  // if joined to the node table add a "Link to Node" option for the field  
+
+  // Field: Name (varchar 255)
+  $data['library']['name'] = array(
+    'title' => 'Name',
+    'help' => 'The human-readable name of the current library.',
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_chado_select_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+  // if joined to the node table add a "Link to Node" option for the field
   if (!$database) {
     $data['library']['name']['field']['handler'] = 'views_handler_field_node_optional';
   }
-	
-	// Field: Unique name (text)
-	$data['library']['uniquename'] = array(
-	  'title' => 'Unique Name',
-	  'help' => 'The unique name of the current library.',
-	  'field' => array(
-	    'handler' => 'views_handler_field',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_string',
-	  ),
-	  'argument' => array(
-	    'handler' => 'views_handler_argument_string',
-	  ),
-	);
-  // if joined to the node table add a "Link to Node" option for the field  
+
+  // Field: Unique name (text)
+  $data['library']['uniquename'] = array(
+    'title' => 'Unique Name',
+    'help' => 'The unique name of the current library.',
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+  // if joined to the node table add a "Link to Node" option for the field
   if (!$database) {
     $data['library']['uniquename']['field']['handler'] = 'views_handler_field_node_optional';
   }
-	
-	// Field: Is obsolete (integer 0/1)
-	$data['library']['is_obsolete'] = array(
-	  'title' => t('Is Obsolete?'),
-	  'help' => t('Indicates whether a given library is obsolete or not.'),
-	  'field' => array(
-	    'handler' => 'views_handler_field_boolean',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
+
+  // Field: Is obsolete (integer 0/1)
+  $data['library']['is_obsolete'] = array(
+    'title' => t('Is Obsolete?'),
+    'help' => t('Indicates whether a given library is obsolete or not.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
        'handler' => 'views_handler_filter_chado_boolean',
        'label' => t('Is Obsolete?'),
        'type' => 'yes-no',
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort',
-	  ),
-	);
-	
-	// Field: time accessioned (datetime)
-	$data['library']['timeaccessioned'] = array(
-	  'title' => t('Date Accessioned'),
-	  'help' => t('Indicates the date a given library was accessioned (entered into the database).'),
-	  'field' => array(
-	    'handler' => 'views_handler_field_readable_date',
-	    'click sortable' => TRUE,
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort_date',
-	  ),
-	);
-	
-	// Field: time last modified (datetime)
-	$data['library']['timelastmodified'] = array(
-	  'title' => t('Date Last Modified'),
-	  'help' => t('Indicates the date that a given library was last modified.'),
-	  'field' => array(
-	    'handler' => 'views_handler_field_readable_date',
-	    'click sortable' => TRUE,
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort_date',
-	  ),
-	);
-	
-	return $data;
-	
-}
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
+  // Field: time accessioned (datetime)
+  $data['library']['timeaccessioned'] = array(
+    'title' => t('Date Accessioned'),
+    'help' => t('Indicates the date a given library was accessioned (entered into the database).'),
+    'field' => array(
+      'handler' => 'views_handler_field_readable_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+
+  // Field: time last modified (datetime)
+  $data['library']['timelastmodified'] = array(
+    'title' => t('Date Last Modified'),
+    'help' => t('Indicates the date that a given library was last modified.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readable_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+
+  return $data;
+
+}

+ 7 - 6
tripal_library/views/misc_tables.views.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: Allows the library module to add fields to other module views
  *
  *   For example, a field counting the number of libraries associted with a given feature would be
@@ -13,14 +14,14 @@
           'handler' => 'views_handler_field_chado_count',
           'table_to_query' => 'library_feature',
         ),
-      ); 
+      );
  *   @endcode
  *
  * @ingroup tripal_library_views
  */
 function retrieve_library_misc_tables_views_data() {
   $data = array();
- 
+
   // Table: Feature---------------------------------------------------------------------------------
   // Calculated Field: Number of Libraries (Count -Int)
   // Provides the number of libraries for a given feature
@@ -31,7 +32,7 @@ function retrieve_library_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'library_feature',
     ),
-  ); 
+  );
 
   // Table: Organism--------------------------------------------------------------------------------
   // Calculated Field: Number of Libraries (Count -Int)
@@ -43,7 +44,7 @@ function retrieve_library_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'library',
     ),
-  );  
-  
+  );
+
   return $data;
-}
+}

+ 28 - 28
tripal_library/views/template.node_join.views.inc

@@ -5,18 +5,18 @@
  *
  *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
  *    (ie: If you want to join features to their drupal nodes then XXX=feature)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
  *        retrieve_XXX_views_data() function from ../tripal_library.views.inc:tripal_library_views_data()
  *        by adding the following line:
  *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
+ *        to the function and including the file directly above the function (blow the function
  *        header by adding:
  *           require_once('views/XXX.views.inc');
  *
  *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
+ */
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -24,31 +24,31 @@
  *  with this module in:
  *  @see tripal_library.views.inc --in tripal_library_views_data()
  *
- *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table.
  *        This file simply defines this linking table and joins the three tables together.
  *        No modification of XXX.views.inc is needed.
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
- 
+
 /**
- * Purpose: this function returns the portion of the data array 
- *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ * Purpose: this function returns the portion of the data array
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it
  *   and other tables
  * @see tripal_library_views_data() --in tripal_library.views.inc
  *
  * The main need for description of this table to views is to join chado data with drupal nodes
  *
  */
-function retrieve_chado_XXX_views_data () {
-	global $db_url;
+function retrieve_chado_XXX_views_data() {
+  global $db_url;
   $data = array();
-  
+
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
      // return empty data array b/c if chado is external then no join to the nodetable can be made
      return $data;
   }
@@ -57,28 +57,28 @@ function retrieve_chado_XXX_views_data () {
   $data['chado_XXX']['table'] = array(
     'field' => 'nid',
   );
-  
+
   //Relationship Definitions---------------------------------
   // Note: No joins need to be made from $data['XXX']['table']
-  
+
   // Join the chado_XXX table to XXX
   $data['chado_XXX']['table']['join']['XXX'] = array(
-  	'left_field' => 'XXX_id',
-  	'field' => 'XXX_id',
+    'left_field' => 'XXX_id',
+    'field' => 'XXX_id',
   );
-  
+
   // Join the node table to chado_XXX
   $data['node']['table']['join']['chado_XXX'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
+    'left_field' => 'nid',
+    'field' => 'nid',
   );
-  
+
   // Join the node table to XXX
   $data['node']['table']['join']['XXX'] = array(
-  	'left_table' => 'chado_XXX',
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );  
+    'left_table' => 'chado_XXX',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
-	return $data;
-}
+  return $data;
+}

+ 27 - 27
tripal_library/views/template.table_defn.views.inc

@@ -5,7 +5,7 @@
  *
  *   - Every instance of XXX should be replaced with the name of your table
  *   - If this is a base table (you want a view where every row is a row from this table)
- *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base']
  *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
  *   - Relationships between this table and others: YYY is the table you are trying to join to this
  *     one. You want to join a table to this one if this table contains a foreign key to the other
@@ -15,18 +15,18 @@
  *   - Create a field definition for each field in this table using the example fields already
  *     listed. Match the type of the database field to the field definition listed below.
  *     (ie: for a text/varchar field from the database use plain_text_field below)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
  *        retrieve_XXX_views_data() function from ../tripal_library.views.inc:tripal_library_views_data()
  *        by adding the following line:
  *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
+ *        to the function and including the file directly above the function (blow the function
  *        header by adding:
  *           require_once('views/XXX.views.inc');
  *
  *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
+ */
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -34,12 +34,12 @@
  *  with this module in:
  *  @see tripal_library.views.inc --in tripal_library_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
 /*************************************************************************
- * Purpose: this function returns the portion of the data array 
+ * Purpose: this function returns the portion of the data array
  *   which describes the XXX table, it's fields and any joins between it and other tables
  * @see tripal_library_views_data() --in tripal_library.views.inc
  *
@@ -55,23 +55,23 @@
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['XXX']['table']['group'] = t('Chado XXX');
-  
+
   $data['XXX']['table'] = array(
     'field' => 'primary_id',
     'title' => t('Chado XXX'),
     'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
   );
-  if($database){
+  if ($database) {
      $data['XXX']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: YYY => XXX
   // Notice that this relationship tells the primary table to show it's fields to the
@@ -80,16 +80,16 @@
   $data['XXX']['table']['join']['YYY'] = array(
     'left_field' => 'foreign key in YYY table',
     'field' => 'primary key in XXX table',
-  );  
-  
+  );
+
   //Join: XXX => XY => YYY
   // This relationship should be described in both directions
-  // in the appropriate files (ie: for feature => library 
+  // in the appropriate files (ie: for feature => library
   // describe in both feature.views.inc and library.views.inc)
   $data['XXX']['table']['join']['XY'] = array(
     'left_field' => 'matching XXX key in the XY table',
     'field' => 'primary key in XXX table',
-  );  
+  );
   $data['XXX']['table']['join']['YYY'] = array(
     'left_table' => 'XY',
     'left_field' => 'matching XXX key in the XY table',
@@ -99,9 +99,9 @@
     'left_field' => 'primary key in YYY table',
     'field' => 'matching YYY key in the XY table',
   );
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: XXX_id (primary key)
   $data['XXX']['field_name'] = array(
     'title' => t('XXX Primary Key'),
@@ -123,7 +123,7 @@
    * Remove this section when done
    */
 
-  //Field: plain_text_field (chado datatype)   
+  //Field: plain_text_field (chado datatype)
   $data['XXX']['plain_text_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -142,7 +142,7 @@
     ),
   );
 
-  //Field: numeric_field (chado datatype)   
+  //Field: numeric_field (chado datatype)
   $data['XXX']['numeric_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -158,7 +158,7 @@
     ),
   );
 
-  //Field: boolean_field (chado datatype)   
+  //Field: boolean_field (chado datatype)
   $data['XXX']['boolean_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -174,7 +174,7 @@
     ),
   );
 
-  //Field: unix_timestamp (chado datatype)   
+  //Field: unix_timestamp (chado datatype)
   $data['XXX']['unix_timestamp'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -190,7 +190,7 @@
     ),
   );
 
-  //Field: human_readable_date (chado datatype)   
+  //Field: human_readable_date (chado datatype)
   $data['XXX']['human_readable_date'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -202,10 +202,10 @@
       'handler' => 'views_handler_sort_date',
     ),
   );
-   
+
    /*
     * End of Example Field definitions
     */
-    
+
   return $data;
-}
+}

Some files were not shown because too many files changed in this diff