Tripal v1.0 (6.x-1.0)
|
00001 <?php 00002 00018 /************************************************************************* 00019 * Implements hook_views_data() 00020 * Purpose: Describe chado/tripal tables & fields to views 00021 * 00022 * @return: a data array which follows the structure outlined in the 00023 * views2 documentation for this hook. Essentially, it's an array of table 00024 * definitions keyed by chado/tripal table name. Each table definition 00025 * includes basic details about the table, fields in that table and 00026 * relationships between that table and others (joins) 00027 */ 00028 function tripal_genetic_views_data() { 00029 $data = array(); 00030 00031 if (module_exists('tripal_views')) { 00032 $tables = array( 00033 'environment', 00034 'genotype', 00035 'phenstatement' 00036 ); 00037 foreach ($tables as $tablename) { 00038 $priority = 9; 00039 00040 // check to see if the table is integrated. If it is then integrate it's 00041 // corresponding 'chado_[table]' table. 00042 if (!tripal_views_is_integrated($tablename, $priority)) { 00043 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority); 00044 $status = tripal_views_integration_add_entry($table_integration_array); 00045 if (!$status) { 00046 drupal_set_message(t('Tripal Genetic is unable to integrate %table', array('%table' => $tablename)), 'error'); 00047 } 00048 } 00049 } 00050 00051 $tables = array( 00052 'environment_cvterm', 00053 'feature_genotype', 00054 'phendesc', 00055 'phenotype_comparison' 00056 ); 00057 foreach ($tables as $tablename) { 00058 $priority = 9; 00059 if (!tripal_views_is_integrated($tablename, $priority)) { 00060 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority); 00061 $status = tripal_views_integration_add_entry($table_integration_array); 00062 if (!$status) { 00063 drupal_set_message(t('Tripal Genetic is unable to integrate %table', array('%table' => $tablename)), 'error'); 00064 } 00065 } 00066 } 00067 } 00068 00069 return $data; 00070 } 00071 00072 /************************************************************************* 00073 * Implements hook_views_handlers() 00074 * Purpose: Register all custom handlers with views 00075 * where a handler describes either "the type of field", 00076 * "how a field should be filtered", "how a field should be sorted" 00077 * 00078 * @return: An array of handler definitions 00079 */ 00080 function tripal_genetic_views_handlers() { 00081 return array( 00082 'info' => array( 00083 'path' => drupal_get_path('module', 'tripal_genetic') . '/views/handlers', 00084 ), 00085 'handlers' => array( 00086 00087 ), 00088 ); 00089 } 00090 00095 function tripal_genetic_views_default_views() { 00096 $views = array(); 00097 00098 if (!module_exists('tripal_views')) { 00099 return $views; 00100 } 00101 00102 // Main default view 00103 $view = new view; 00104 $view->name = 'genotype_listing'; 00105 $view->description = 'A listing of observed genotypes and the features displaying them'; 00106 $view->tag = 'chado default'; 00107 $view->base_table = 'genotype'; 00108 $view->core = 6; 00109 $view->api_version = '2'; 00110 $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ 00111 $handler = $view->new_display('default', 'Defaults', 'default'); 00112 $handler->override_option('fields', array( 00113 'uniquename' => array( 00114 'label' => 'Uniquename', 00115 'alter' => array( 00116 'alter_text' => 0, 00117 'text' => '', 00118 'make_link' => 0, 00119 'path' => '', 00120 'absolute' => 0, 00121 'link_class' => '', 00122 'alt' => '', 00123 'rel' => '', 00124 'prefix' => '', 00125 'suffix' => '', 00126 'target' => '', 00127 'help' => '', 00128 'trim' => 0, 00129 'max_length' => '', 00130 'word_boundary' => 1, 00131 'ellipsis' => 1, 00132 'html' => 0, 00133 'strip_tags' => 0, 00134 ), 00135 'empty' => '', 00136 'hide_empty' => 0, 00137 'empty_zero' => 0, 00138 'hide_alter_empty' => 1, 00139 'type' => 'separator', 00140 'separator' => ', ', 00141 'exclude' => 0, 00142 'id' => 'uniquename', 00143 'table' => 'genotype', 00144 'field' => 'uniquename', 00145 'relationship' => 'none', 00146 ), 00147 'name' => array( 00148 'label' => 'Name', 00149 'alter' => array( 00150 'alter_text' => 0, 00151 'text' => '', 00152 'make_link' => 0, 00153 'path' => '', 00154 'absolute' => 0, 00155 'link_class' => '', 00156 'alt' => '', 00157 'rel' => '', 00158 'prefix' => '', 00159 'suffix' => '', 00160 'target' => '', 00161 'help' => '', 00162 'trim' => 0, 00163 'max_length' => '', 00164 'word_boundary' => 1, 00165 'ellipsis' => 1, 00166 'html' => 0, 00167 'strip_tags' => 0, 00168 ), 00169 'empty' => '', 00170 'hide_empty' => 0, 00171 'empty_zero' => 0, 00172 'hide_alter_empty' => 1, 00173 'type' => 'separator', 00174 'separator' => ', ', 00175 'exclude' => 0, 00176 'id' => 'name', 00177 'table' => 'genotype', 00178 'field' => 'name', 00179 'relationship' => 'none', 00180 ), 00181 'description' => array( 00182 'label' => 'Description', 00183 'alter' => array( 00184 'alter_text' => 0, 00185 'text' => '', 00186 'make_link' => 0, 00187 'path' => '', 00188 'absolute' => 0, 00189 'link_class' => '', 00190 'alt' => '', 00191 'rel' => '', 00192 'prefix' => '', 00193 'suffix' => '', 00194 'target' => '', 00195 'help' => '', 00196 'trim' => 0, 00197 'max_length' => '', 00198 'word_boundary' => 1, 00199 'ellipsis' => 1, 00200 'html' => 0, 00201 'strip_tags' => 0, 00202 ), 00203 'empty' => '', 00204 'hide_empty' => 0, 00205 'empty_zero' => 0, 00206 'hide_alter_empty' => 1, 00207 'type' => 'separator', 00208 'separator' => ', ', 00209 'exclude' => 0, 00210 'id' => 'description', 00211 'table' => 'genotype', 00212 'field' => 'description', 00213 'relationship' => 'none', 00214 ), 00215 )); 00216 $handler->override_option('filters', array( 00217 'uniquename' => array( 00218 'operator' => '~', 00219 'value' => '', 00220 'group' => '0', 00221 'exposed' => TRUE, 00222 'expose' => array( 00223 'use_operator' => 0, 00224 'operator' => 'uniquename_op', 00225 'identifier' => 'uniquename', 00226 'label' => 'Unique Name Contains', 00227 'remember' => 0, 00228 ), 00229 'case' => 0, 00230 'id' => 'uniquename', 00231 'table' => 'genotype', 00232 'field' => 'uniquename', 00233 'relationship' => 'none', 00234 'agg' => array( 00235 'records_with' => 1, 00236 'aggregates_with' => 1, 00237 ), 00238 ), 00239 'description' => array( 00240 'operator' => '~', 00241 'value' => '', 00242 'group' => '0', 00243 'exposed' => TRUE, 00244 'expose' => array( 00245 'use_operator' => 0, 00246 'operator' => 'description_op', 00247 'identifier' => 'description', 00248 'label' => 'Description Contains', 00249 'remember' => 0, 00250 ), 00251 'case' => 0, 00252 'id' => 'description', 00253 'table' => 'genotype', 00254 'field' => 'description', 00255 'relationship' => 'none', 00256 'agg' => array( 00257 'records_with' => 1, 00258 'aggregates_with' => 1, 00259 ), 00260 ), 00261 'search_results' => array( 00262 'operator' => '=', 00263 'value' => '', 00264 'group' => '0', 00265 'exposed' => FALSE, 00266 'expose' => array( 00267 'operator' => FALSE, 00268 'label' => '', 00269 ), 00270 'id' => 'search_results', 00271 'table' => 'views', 00272 'field' => 'search_results', 00273 'relationship' => 'none', 00274 'apply_button' => 'Show', 00275 '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.', 00276 ), 00277 )); 00278 $handler->override_option('access', array( 00279 'type' => 'perm', 00280 'perm' => 'access content', 00281 )); 00282 $handler->override_option('cache', array( 00283 'type' => 'none', 00284 )); 00285 $handler->override_option('title', 'Genotypes Observed'); 00286 $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.'); 00287 $handler->override_option('header_format', '2'); 00288 $handler->override_option('header_empty', 0); 00289 $handler->override_option('empty', 'No genotypes match the current criteria.'); 00290 $handler->override_option('empty_format', '2'); 00291 $handler->override_option('items_per_page', 50); 00292 $handler->override_option('use_pager', '1'); 00293 $handler->override_option('style_plugin', 'table'); 00294 $handler->override_option('style_options', array( 00295 'grouping' => '', 00296 'override' => 1, 00297 'sticky' => 0, 00298 'order' => 'asc', 00299 'summary' => '', 00300 'columns' => array( 00301 'uniquename' => 'uniquename', 00302 'name' => 'name', 00303 'description' => 'description', 00304 ), 00305 'info' => array( 00306 'uniquename' => array( 00307 'sortable' => 1, 00308 'separator' => '', 00309 ), 00310 'name' => array( 00311 'sortable' => 1, 00312 'separator' => '', 00313 ), 00314 'description' => array( 00315 'sortable' => 1, 00316 'separator' => '', 00317 ), 00318 ), 00319 'default' => 'uniquename', 00320 )); 00321 $handler = $view->new_display('page', 'Page', 'page_1'); 00322 $handler->override_option('path', 'chado/genotypes'); 00323 $handler->override_option('menu', array( 00324 'type' => 'normal', 00325 'title' => 'Genotypes', 00326 'description' => 'A genotype is defined by a collection of features, mutations, balancers, deficiencies, haplotype blocks, or engineered constructs.', 00327 'weight' => '10', 00328 'name' => 'navigation', 00329 )); 00330 $handler->override_option('tab_options', array( 00331 'type' => 'none', 00332 'title' => '', 00333 'description' => '', 00334 'weight' => 0, 00335 'name' => 'navigation', 00336 )); 00337 $views[$view->name] = $view; 00338 00339 return $views; 00340 }