Browse Source

Genotypes: Added entire admin menu including default admin view

Lacey Sanderson 11 years ago
parent
commit
14c01a96cd

+ 31 - 0
tripal_genetic/includes/tripal_genetic.admin.inc

@@ -0,0 +1,31 @@
+<?php
+
+function tripal_genetic_admin_genetics_listing() {
+  $output = '';
+
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
+  $breadcrumb[] = l('Genetics', 'admin/tripal/chado/tripal_genetic');
+  drupal_set_breadcrumb($breadcrumb);
+
+  // Add the view
+  $view = views_embed_view('tripal_genetic_admin_genetics','default');
+  if (isset($view)) {
+    $output .= $view;
+  }
+  else {
+    $output .= '<p>The Tripal Genetic Module uses primarily views to provide an '
+      . 'administrative interface. Currently one or more views needed for this '
+      . 'administrative interface are disabled. <strong>Click each of the following links to '
+      . 'enable the pertinent views</strong>:</p>';
+    $output .= '<ul>';
+      $output .= '<li>'.l('Genetic Admin', 'admin/tripal/chado/tripal_genetic/views/genetics/enable').'</li>';
+    $output .= '</ul>';
+  }
+
+  return $output;
+}

+ 0 - 0
tripal_genetic/theme/tripal_genetic_help.tpl.php


+ 46 - 2
tripal_genetic/tripal_genetic.module

@@ -14,9 +14,48 @@
 
 require('api/tripal_genetic.api.inc');
 require('includes/tripal_genetic.schema.inc');
+require('includes/tripal_genetic.admin.inc');
 
+/**
+ *  Menu items are automatically added for the new node types created
+ *  by this module to the 'Create Content' Navigation menu item.  This function
+ *  adds more menu items needed for this module.
+ *
+ * @ingroup tripal_genetic
+ */
+function tripal_genetic_menu() {
+  $items = array();
+
+    // the administative settings menu
+  $items['admin/tripal/chado/tripal_genetic'] = array(
+   'title' => 'Genetics',
+   'description' => 'Genetic data including Genotypes.',
+   'page callback' => 'tripal_genetic_admin_genetics_listing',
+   'access arguments' => array('adminster tripal genetic'),
+   'type' => MENU_NORMAL_ITEM,
+  );
+
+  $items['admin/tripal/chado/tripal_genetic/help'] = array(
+   'title' => 'Help',
+   'description' => "A description of the Tripal genetic module including a short description of it's usage.",
+   'page callback' => 'theme',
+   'page arguments' => array('tripal_genetic_help'),
+   'access arguments' => array('adminster tripal genetic'),
+   'type' => MENU_LOCAL_TASK,
+  );
 
-/*************************************************************************
+  $items['admin/tripal/chado/tripal_genetic/views/genetics/enable'] = array(
+    'title' => 'Enable genetic Administrative View',
+    'page callback' => 'tripal_views_admin_enable_view',
+    'page arguments' => array('tripal_genetic_admin_genetics', 'admin/tripal/chado/tripal_genetic'),
+    'access arguments' => array('administer tripal genetic'),
+    'type' => MENU_CALLBACK,
+  );
+
+  return $items;
+}
+
+/**
  * Implements hook_views_api()
  * Purpose: Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_genetic.views.inc where all the
@@ -26,7 +65,7 @@ require('includes/tripal_genetic.schema.inc');
  */
 function tripal_genetic_views_api() {
   return array(
-      'api' => 2.0,
+      'api' => 3.0,
   );
 }
 
@@ -48,6 +87,11 @@ function tripal_genetic_theme() {
       'template' => 'tripal_stock_genotypes',
       'path' => "$theme_path/tripal_stock",
     ),
+    'tripal_genetic_help' => array(
+      'template' => 'tripal_genetic_help',
+      'variables' =>  array(NULL),
+      'path' => "$theme_path",
+    ),
   );
   return $items;
 }

+ 106 - 231
tripal_genetic/tripal_genetic.views_default.inc

@@ -8,246 +8,121 @@
 function tripal_genetic_views_default_views() {
   $views = array();
 
-  if (!module_exists('tripal_views')) {
-    return $views;
-  }
+  $view = tripal_genetic_defaultviews_admin_genotypes();
+  $views[$view->name] = $view;
+
+  return $views;
+}
+
+function tripal_genetic_defaultviews_admin_genotypes() {
 
-  // Main default view
-  $view = new view;
-  $view->name = 'genotype_listing';
-  $view->description = 'A listing of observed genotypes and the features displaying them';
-  $view->tag = 'chado default';
+  $view = new view();
+  $view->name = 'tripal_genetic_admin_genetics';
+  $view->description = 'DO NOT DISABLE';
+  $view->tag = 'tripal admin';
   $view->base_table = 'genotype';
-  $view->core = 6;
-  $view->api_version = '2';
+  $view->human_name = 'Genotype Admin';
+  $view->core = 7;
+  $view->api_version = '3.0';
   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Defaults */
   $handler = $view->new_display('default', 'Defaults', 'default');
-  $handler->override_option('fields', array(
+  $handler->display->display_options['title'] = 'Genotypes Observed';
+  $handler->display->display_options['use_more_always'] = FALSE;
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Filter';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '25';
+  $handler->display->display_options['pager']['options']['offset'] = '0';
+  $handler->display->display_options['pager']['options']['id'] = '0';
+  $handler->display->display_options['pager']['options']['quantity'] = '9';
+  $handler->display->display_options['style_plugin'] = 'table';
+  $handler->display->display_options['style_options']['grouping'] = '';
+  $handler->display->display_options['style_options']['columns'] = array(
+    'uniquename' => 'uniquename',
+    'name' => 'name',
+    'description' => 'description',
+  );
+  $handler->display->display_options['style_options']['default'] = 'uniquename';
+  $handler->display->display_options['style_options']['info'] = array(
     'uniquename' => array(
-      'label' => 'Uniquename',
-      'alter' => array(
-        'alter_text' => 0,
-        'text' => '',
-        'make_link' => 0,
-        'path' => '',
-        'absolute' => 0,
-        'link_class' => '',
-        'alt' => '',
-        'rel' => '',
-        'prefix' => '',
-        'suffix' => '',
-        'target' => '',
-        'help' => '',
-        'trim' => 0,
-        'max_length' => '',
-        'word_boundary' => 1,
-        'ellipsis' => 1,
-        'html' => 0,
-        'strip_tags' => 0,
-      ),
-      'empty' => '',
-      'hide_empty' => 0,
-      'empty_zero' => 0,
-      'hide_alter_empty' => 1,
-      'type' => 'separator',
-      'separator' => ', ',
-      'exclude' => 0,
-      'id' => 'uniquename',
-      'table' => 'genotype',
-      'field' => 'uniquename',
-      'relationship' => 'none',
+      'sortable' => 1,
+      'separator' => '',
     ),
     'name' => array(
-      'label' => 'Name',
-      'alter' => array(
-        'alter_text' => 0,
-        'text' => '',
-        'make_link' => 0,
-        'path' => '',
-        'absolute' => 0,
-        'link_class' => '',
-        'alt' => '',
-        'rel' => '',
-        'prefix' => '',
-        'suffix' => '',
-        'target' => '',
-        'help' => '',
-        'trim' => 0,
-        'max_length' => '',
-        'word_boundary' => 1,
-        'ellipsis' => 1,
-        'html' => 0,
-        'strip_tags' => 0,
-      ),
-      'empty' => '',
-      'hide_empty' => 0,
-      'empty_zero' => 0,
-      'hide_alter_empty' => 1,
-      'type' => 'separator',
-      'separator' => ', ',
-      'exclude' => 0,
-      'id' => 'name',
-      'table' => 'genotype',
-      'field' => 'name',
-      'relationship' => 'none',
+      'sortable' => 1,
+      'separator' => '',
     ),
     'description' => array(
-      'label' => 'Description',
-      'alter' => array(
-        'alter_text' => 0,
-        'text' => '',
-        'make_link' => 0,
-        'path' => '',
-        'absolute' => 0,
-        'link_class' => '',
-        'alt' => '',
-        'rel' => '',
-        'prefix' => '',
-        'suffix' => '',
-        'target' => '',
-        'help' => '',
-        'trim' => 0,
-        'max_length' => '',
-        'word_boundary' => 1,
-        'ellipsis' => 1,
-        'html' => 0,
-        'strip_tags' => 0,
-      ),
-      'empty' => '',
-      'hide_empty' => 0,
-      'empty_zero' => 0,
-      'hide_alter_empty' => 1,
-      'type' => 'separator',
-      'separator' => ', ',
-      'exclude' => 0,
-      'id' => 'description',
-      'table' => 'genotype',
-      'field' => 'description',
-      'relationship' => 'none',
-    ),
-  ));
-  $handler->override_option('filters', array(
-    'uniquename' => array(
-      'operator' => '~',
-      'value' => '',
-      'group' => '0',
-      'exposed' => TRUE,
-      'expose' => array(
-        'use_operator' => 0,
-        'operator' => 'uniquename_op',
-        'identifier' => 'uniquename',
-        'label' => 'Unique Name Contains',
-        'remember' => 0,
-      ),
-      'case' => 0,
-      'id' => 'uniquename',
-      'table' => 'genotype',
-      'field' => 'uniquename',
-      'relationship' => 'none',
-      'agg' => array(
-        'records_with' => 1,
-        'aggregates_with' => 1,
-      ),
+      'sortable' => 1,
+      'separator' => '',
     ),
-    'description' => array(
-      'operator' => '~',
-      'value' => '',
-      'group' => '0',
-      'exposed' => TRUE,
-      'expose' => array(
-        'use_operator' => 0,
-        'operator' => 'description_op',
-        'identifier' => 'description',
-        'label' => 'Description Contains',
-        'remember' => 0,
-      ),
-      'case' => 0,
-      'id' => 'description',
-      'table' => 'genotype',
-      'field' => 'description',
-      'relationship' => 'none',
-      'agg' => array(
-        'records_with' => 1,
-        'aggregates_with' => 1,
-      ),
-    ),
-    'search_results' => array(
-      'operator' => '=',
-      'value' => '',
-      'group' => '0',
-      'exposed' => FALSE,
-      'expose' => array(
-        'operator' => FALSE,
-        'label' => '',
-      ),
-      'id' => 'search_results',
-      'table' => 'views',
-      'field' => 'search_results',
-      'relationship' => 'none',
-      'apply_button' => 'Show',
-      'no_results_text' => 'Click "Show" to see a list of all genotypes matching the entered criteria. If you leave a any of the criteria blank then the genotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all genotypes will be listed.',
-    ),
-  ));
-  $handler->override_option('access', array(
-    'type' => 'perm',
-    'perm' => 'access content',
-  ));
-  $handler->override_option('cache', array(
-    'type' => 'none',
-  ));
-  $handler->override_option('title', 'Genotypes Observed');
-  $handler->override_option('header', 'Click "Show" to see a list of all genotypes matching the entered criteria. If you leave a any of the criteria blank then the genotypes will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all genotypes will be listed.');
-  $handler->override_option('header_format', '2');
-  $handler->override_option('header_empty', 0);
-  $handler->override_option('empty', 'No genotypes match the current criteria.');
-  $handler->override_option('empty_format', '2');
-  $handler->override_option('items_per_page', 50);
-  $handler->override_option('use_pager', '1');
-  $handler->override_option('style_plugin', 'table');
-  $handler->override_option('style_options', array(
-    'grouping' => '',
-    'override' => 1,
-    'sticky' => 0,
-    'order' => 'asc',
-    'summary' => '',
-    'columns' => array(
-      'uniquename' => 'uniquename',
-      'name' => 'name',
-      'description' => 'description',
-    ),
-    'info' => array(
-      'uniquename' => array(
-        'sortable' => 1,
-        'separator' => '',
-      ),
-      'name' => array(
-        'sortable' => 1,
-        'separator' => '',
-      ),
-      'description' => array(
-        'sortable' => 1,
-        'separator' => '',
-      ),
-    ),
-    'default' => 'uniquename',
-  ));
+  );
+  /* No results behavior: Global: Text area */
+  $handler->display->display_options['empty']['text']['id'] = 'area';
+  $handler->display->display_options['empty']['text']['table'] = 'views';
+  $handler->display->display_options['empty']['text']['field'] = 'area';
+  $handler->display->display_options['empty']['text']['content'] = 'No genotypes match the current criteria.';
+  $handler->display->display_options['empty']['text']['format'] = '2';
+  /* Field: Chado Genotype: Uniquename */
+  $handler->display->display_options['fields']['uniquename']['id'] = 'uniquename';
+  $handler->display->display_options['fields']['uniquename']['table'] = 'genotype';
+  $handler->display->display_options['fields']['uniquename']['field'] = 'uniquename';
+  /* Field: Chado Genotype: Name */
+  $handler->display->display_options['fields']['name']['id'] = 'name';
+  $handler->display->display_options['fields']['name']['table'] = 'genotype';
+  $handler->display->display_options['fields']['name']['field'] = 'name';
+  /* Field: Chado Genotype: Description */
+  $handler->display->display_options['fields']['description']['id'] = 'description';
+  $handler->display->display_options['fields']['description']['table'] = 'genotype';
+  $handler->display->display_options['fields']['description']['field'] = 'description';
+  /* Filter criterion: Chado Genotype: Uniquename */
+  $handler->display->display_options['filters']['uniquename']['id'] = 'uniquename';
+  $handler->display->display_options['filters']['uniquename']['table'] = 'genotype';
+  $handler->display->display_options['filters']['uniquename']['field'] = 'uniquename';
+  $handler->display->display_options['filters']['uniquename']['operator'] = 'contains';
+  $handler->display->display_options['filters']['uniquename']['group'] = '0';
+  $handler->display->display_options['filters']['uniquename']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['uniquename']['expose']['operator_id'] = 'uniquename_op';
+  $handler->display->display_options['filters']['uniquename']['expose']['label'] = 'Unique Name Contains';
+  $handler->display->display_options['filters']['uniquename']['expose']['operator'] = 'uniquename_op';
+  $handler->display->display_options['filters']['uniquename']['expose']['identifier'] = 'uniquename';
+  $handler->display->display_options['filters']['uniquename']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
+  /* Filter criterion: Chado Genotype: Description */
+  $handler->display->display_options['filters']['description']['id'] = 'description';
+  $handler->display->display_options['filters']['description']['table'] = 'genotype';
+  $handler->display->display_options['filters']['description']['field'] = 'description';
+  $handler->display->display_options['filters']['description']['operator'] = 'contains';
+  $handler->display->display_options['filters']['description']['group'] = '0';
+  $handler->display->display_options['filters']['description']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['description']['expose']['operator_id'] = 'description_op';
+  $handler->display->display_options['filters']['description']['expose']['label'] = 'Description Contains';
+  $handler->display->display_options['filters']['description']['expose']['operator'] = 'description_op';
+  $handler->display->display_options['filters']['description']['expose']['identifier'] = 'description';
+  $handler->display->display_options['filters']['description']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
+
+  /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->override_option('path', 'chado/genotypes');
-  $handler->override_option('menu', array(
-    'type' => 'normal',
-    'title' => 'Genotypes',
-    'description' => 'A genotype is defined by a collection of features, mutations, balancers, deficiencies, haplotype blocks, or engineered constructs.',
-    'weight' => '10',
-    'name' => 'navigation',
-  ));
-  $handler->override_option('tab_options', array(
-    'type' => 'none',
-    'title' => '',
-    'description' => '',
-    'weight' => 0,
-    'name' => 'navigation',
-  ));
-  $views[$view->name] = $view;
+  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_genetic/genotypes';
+  $handler->display->display_options['menu']['type'] = 'default tab';
+  $handler->display->display_options['menu']['title'] = 'Genotypes';
+  $handler->display->display_options['menu']['description'] = 'A genotype is defined by a collection of features, mutations, etc.';
+  $handler->display->display_options['menu']['weight'] = '-10';
+  $handler->display->display_options['menu']['context'] = 0;
+  $handler->display->display_options['menu']['context_only_inline'] = 0;
+  $handler->display->display_options['tab_options']['weight'] = '0';
 
-  return $views;
-}
+  return $view;
+}

+ 1 - 1
tripal_phenotype/tripal_phenotype.module

@@ -81,7 +81,7 @@ function tripal_phenotype_theme($existing, $type, $theme, $path) {
  */
 function tripal_phenotype_views_api() {
   return array(
-      'api' => 2.0,
+      'api' => 3.0,
   );
 }