|
Tripal 0.3b
|
00001 <?php 00002 00003 /** 00004 * @file 00005 * This file contains the basic functions for views integration of 00006 * chado/tripal db tables. Supplementary functions can be found in 00007 * ./views/ 00008 * 00009 * Documentation on views integration can be found at 00010 * http://views2.logrus.com/doc/html/index.html. 00011 */ 00012 00013 /** 00014 * @defgroup tripal_db_views External Database Views Integration 00015 * @ingroup views 00016 * @ingroup tripal_db 00017 */ 00018 00019 require_once('views/dbxref.views.inc'); 00020 require_once('views/db.views.inc'); 00021 /** 00022 * Implements hook_views_data() 00023 * Purpose: Describe chado/tripal tables & fields to views 00024 * @return: a data array which follows the structure outlined in the 00025 * views2 documentation for this hook. Essentially, it's an array of table 00026 * definitions keyed by chado/tripal table name. Each table definition 00027 * includes basic details about the table, fields in that table and 00028 * relationships between that table and others (joins) 00029 * 00030 * @ingroup tripal_db_views 00031 */ 00032 function tripal_db_views_data() { 00033 00034 $data = array(); 00035 $data = array_merge($data, retrieve_dbxref_views_data()); 00036 $data = array_merge($data, retrieve_db_views_data()); 00037 return $data; 00038 00039 } 00040 00041 /** 00042 * Implements hook_views_handlers() 00043 * Purpose: Register all custom handlers with views 00044 * where a handler describes either "the type of field", 00045 * "how a field should be filtered", "how a field should be sorted" 00046 * @return: An array of handler definitions 00047 * 00048 * @ingroup tripal_db_views 00049 */ 00050 function tripal_db_views_handlers() { 00051 return array( 00052 'info' => array( 00053 'path' => drupal_get_path('module', 'tripal_db') . '/views/handlers', 00054 ), 00055 'handlers' => array( 00056 'views_handler_field_dbxref_accession_link' => array( 00057 'parent' => 'views_handler_field', 00058 ), 00059 ), 00060 ); 00061 } 00062 00063 /** 00064 * 00065 * @ingroup tripal_db_views 00066 */ 00067 function tripal_db_views_default_views () { 00068 $views = array(); 00069 00070 // Main default view 00071 // List all cvterms based on cv 00072 $view = new view; 00073 $view = new view; 00074 $view->name = 'all_dbxrefs'; 00075 $view->description = 'A listing of all database references filtered by database'; 00076 $view->tag = 'chado'; 00077 $view->view_php = ''; 00078 $view->base_table = 'dbxref'; 00079 $view->is_cacheable = FALSE; 00080 $view->api_version = 2; 00081 $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ 00082 $handler = $view->new_display('default', 'Defaults', 'default'); 00083 $handler->override_option('fields', array( 00084 'name' => array( 00085 'label' => 'Database', 00086 'alter' => array( 00087 'alter_text' => 0, 00088 'text' => '', 00089 'make_link' => 0, 00090 'path' => '', 00091 'link_class' => '', 00092 'alt' => '', 00093 'prefix' => '', 00094 'suffix' => '', 00095 'target' => '', 00096 'help' => '', 00097 'trim' => 0, 00098 'max_length' => '', 00099 'word_boundary' => 1, 00100 'ellipsis' => 1, 00101 'html' => 0, 00102 'strip_tags' => 0, 00103 ), 00104 'empty' => '', 00105 'hide_empty' => 0, 00106 'empty_zero' => 0, 00107 'exclude' => 0, 00108 'id' => 'name', 00109 'table' => 'db', 00110 'field' => 'name', 00111 'relationship' => 'none', 00112 ), 00113 'accession' => array( 00114 'label' => 'Accession', 00115 'alter' => array( 00116 'alter_text' => 0, 00117 'text' => '', 00118 'make_link' => 0, 00119 'path' => '', 00120 'link_class' => '', 00121 'alt' => '', 00122 'prefix' => '', 00123 'suffix' => '', 00124 'target' => '', 00125 'help' => '', 00126 'trim' => 0, 00127 'max_length' => '', 00128 'word_boundary' => 1, 00129 'ellipsis' => 1, 00130 'html' => 0, 00131 'strip_tags' => 0, 00132 ), 00133 'empty' => '', 00134 'hide_empty' => 0, 00135 'empty_zero' => 0, 00136 'exclude' => 0, 00137 'id' => 'accession', 00138 'table' => 'dbxref', 00139 'field' => 'accession', 00140 'relationship' => 'none', 00141 ), 00142 'description' => array( 00143 'label' => 'Description', 00144 'alter' => array( 00145 'alter_text' => 0, 00146 'text' => '', 00147 'make_link' => 0, 00148 'path' => '', 00149 'link_class' => '', 00150 'alt' => '', 00151 'prefix' => '', 00152 'suffix' => '', 00153 'target' => '', 00154 'help' => '', 00155 'trim' => 0, 00156 'max_length' => '', 00157 'word_boundary' => 1, 00158 'ellipsis' => 1, 00159 'html' => 0, 00160 'strip_tags' => 0, 00161 ), 00162 'empty' => '', 00163 'hide_empty' => 0, 00164 'empty_zero' => 0, 00165 'exclude' => 0, 00166 'id' => 'description', 00167 'table' => 'dbxref', 00168 'field' => 'description', 00169 'relationship' => 'none', 00170 ), 00171 'version' => array( 00172 'label' => 'Version', 00173 'alter' => array( 00174 'alter_text' => 0, 00175 'text' => '', 00176 'make_link' => 0, 00177 'path' => '', 00178 'link_class' => '', 00179 'alt' => '', 00180 'prefix' => '', 00181 'suffix' => '', 00182 'target' => '', 00183 'help' => '', 00184 'trim' => 0, 00185 'max_length' => '', 00186 'word_boundary' => 1, 00187 'ellipsis' => 1, 00188 'html' => 0, 00189 'strip_tags' => 0, 00190 ), 00191 'empty' => '', 00192 'hide_empty' => 0, 00193 'empty_zero' => 0, 00194 'exclude' => 0, 00195 'id' => 'version', 00196 'table' => 'dbxref', 00197 'field' => 'version', 00198 'relationship' => 'none', 00199 ), 00200 'accession_link' => array( 00201 'label' => 'External Link', 00202 'alter' => array( 00203 'alter_text' => 1, 00204 'text' => 'link', 00205 'make_link' => 1, 00206 'path' => '[accession_link]', 00207 'link_class' => '', 00208 'alt' => '', 00209 'prefix' => '', 00210 'suffix' => '', 00211 'target' => '', 00212 'help' => '', 00213 'trim' => 0, 00214 'max_length' => '', 00215 'word_boundary' => 1, 00216 'ellipsis' => 1, 00217 'html' => 0, 00218 'strip_tags' => 0, 00219 ), 00220 'empty' => '', 00221 'hide_empty' => 1, 00222 'empty_zero' => 0, 00223 'exclude' => 0, 00224 'id' => 'accession_link', 00225 'table' => 'dbxref', 00226 'field' => 'accession_link', 00227 'relationship' => 'none', 00228 ), 00229 )); 00230 $handler->override_option('filters', array( 00231 'name' => array( 00232 'operator' => '=', 00233 'value' => '<select db>', 00234 'group' => '0', 00235 'exposed' => TRUE, 00236 'expose' => array( 00237 'use_operator' => 0, 00238 'operator' => 'name_op', 00239 'identifier' => 'db', 00240 'label' => 'Database', 00241 'optional' => 1, 00242 'remember' => 0, 00243 ), 00244 'case' => 1, 00245 'id' => 'name', 00246 'table' => 'db', 00247 'field' => 'name', 00248 'relationship' => 'none', 00249 ), 00250 'accession' => array( 00251 'operator' => 'contains', 00252 'value' => '', 00253 'group' => '0', 00254 'exposed' => TRUE, 00255 'expose' => array( 00256 'use_operator' => 0, 00257 'operator' => 'accession_op', 00258 'identifier' => 'accession', 00259 'label' => 'Accession Contains', 00260 'optional' => 1, 00261 'remember' => 0, 00262 ), 00263 'case' => 0, 00264 'id' => 'accession', 00265 'table' => 'dbxref', 00266 'field' => 'accession', 00267 'relationship' => 'none', 00268 ), 00269 )); 00270 $handler->override_option('access', array( 00271 'type' => 'perm', 00272 'perm' => 'access chado_db content', 00273 )); 00274 $handler->override_option('cache', array( 00275 'type' => 'none', 00276 )); 00277 $handler->override_option('title', 'Database References'); 00278 $handler->override_option('empty', 'There are no database references matching the above criteria. Please select a database in order to display all references to that database.'); 00279 $handler->override_option('empty_format', '1'); 00280 $handler->override_option('items_per_page', 50); 00281 $handler->override_option('use_pager', '1'); 00282 $handler->override_option('style_plugin', 'table'); 00283 $handler->override_option('style_options', array( 00284 'grouping' => '', 00285 'override' => 1, 00286 'sticky' => 0, 00287 'order' => 'asc', 00288 'columns' => array( 00289 'name' => 'name', 00290 'accession' => 'accession', 00291 'description' => 'description', 00292 'version' => 'version', 00293 ), 00294 'info' => array( 00295 'name' => array( 00296 'sortable' => 1, 00297 'separator' => '', 00298 ), 00299 'accession' => array( 00300 'sortable' => 1, 00301 'separator' => '', 00302 ), 00303 'description' => array( 00304 'sortable' => 1, 00305 'separator' => '', 00306 ), 00307 'version' => array( 00308 'sortable' => 1, 00309 'separator' => '', 00310 ), 00311 ), 00312 'default' => '-1', 00313 )); 00314 $handler = $view->new_display('page', 'Page', 'page_1'); 00315 $handler->override_option('path', 'admin/tripal/tripal_db/list_dbxrefs'); 00316 $handler->override_option('menu', array( 00317 'type' => 'normal', 00318 'title' => 'DB Reference Listing', 00319 'description' => 'A listing of all database references associated with a given database', 00320 'weight' => '0', 00321 'name' => 'navigation', 00322 )); 00323 $handler->override_option('tab_options', array( 00324 'type' => 'none', 00325 'title' => '', 00326 'description' => '', 00327 'weight' => 0, 00328 'name' => 'navigation', 00329 )); 00330 $views[$view->name] = $view; 00331 00332 return $views; 00333 }