Tripal v1.0 (6.x-1.0)
tripal_core.module
Go to the documentation of this file.
00001 <?php
00041 require_once "api/tripal_core_chado.api.inc";
00042 require_once "api/tripal_core_files.api.inc";
00043 require_once "api/tripal_core_ahah.api.inc";
00044 require_once "api/tripal_core_custom_tables.api.inc";
00045 require_once "api/tripal_core_jobs.api.inc";
00046 require_once "api/tripal_core_mviews.api.inc";
00047 require_once "includes/jobs.php";
00048 require_once "includes/mviews.php";
00049 require_once "includes/custom_tables.php";
00050 require_once "includes/chado_install.php";
00051 
00058 function tripal_core_init() {
00059   global $base_url;     
00060   
00061   // we need to declare here the persistent_chado global variable
00062   global $persistent_chado;
00063   global $prepared_statements;
00064   $persistent_chado = NULL;
00065   $prepared_statements = array();
00066   
00067   // add javascript files 
00068   drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal.ahah.js');
00069   
00070   // create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and
00071   // only if the chado database is present.
00072   if (tripal_core_is_chado_installed()) {
00073   
00074     // make sure the current version of chado is set
00075     tripal_core_set_chado_version();  
00076   
00077     if (!db_fetch_object(chado_query("SELECT * FROM {cv} WHERE name = 'tripal'"))) {
00078       $results = chado_query(
00079         "INSERT INTO {cv} (name,definition) ".
00080         "VALUES ('tripal', 'Terms used by Tripal for modules to manage data such as that stored in property tables like featureprop, analysisprop, etc')");
00081     }
00082     if (!db_fetch_object(chado_query("SELECT * FROM {db} WHERE name = 'tripal'"))) {
00083       $results = chado_query(
00084         "INSERT INTO {db} (name,description) ".
00085         "VALUES ('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms')");
00086     }
00087   }
00088 
00089   // add some variables for all javasript to use for building URLs
00090   global $base_url;
00091   $theme_dir = drupal_get_path('theme', 'tripal');
00092   $clean_urls = variable_get('clean_url', 0);
00093   drupal_add_js(
00094     " var baseurl  = '$base_url';
00095       var themedir = '$theme_dir';
00096       var isClean  =  $clean_urls;",
00097     'inline', 'header');
00098 
00099   // make sure the date time settings are the way Tripal will insert them
00100   // otherwise PostgreSQL version that may have a different datestyle setting
00101   // will fail when inserting or updating a date column in a table.
00102   db_query("SET DATESTYLE TO '%s'", 'MDY'); 
00103 
00104   // in the event that an errant Tripal or extension function fails to
00105   // set the postgres search_path back to noraml we do it here on 
00106   // init of the core
00107   tripal_db_set_default_search_path(); 
00108   
00109   // create a persistent connection
00110   $connection = tripal_db_persistent_chado();
00111 }
00112 
00119 function tripal_core_menu() {
00120   $items = array();
00121 
00122   // Triapl setting groups
00123   $items['admin/tripal'] = array(
00124     'title' => 'Tripal Management',
00125     'description' => "Manage the behavior or Tripal and its various modules.",
00126     'position' => 'right',
00127     'weight' => -5,
00128     'page callback' => 'system_admin_menu_block_page',
00129     'access arguments' => array('administer site configuration'),
00130     'file' => 'system.admin.inc',
00131     'file path' => drupal_get_path('module', 'system'),
00132   );
00133   $items['admin/tripal/customize'] = array(
00134     'title' => 'Customize Tripal',
00135     'position' => 'right',
00136     'page callback' => 'theme',
00137     'page arguments' => array('tripal_core_customize'),
00138     'access arguments' => array('administer site configuration'),
00139   );
00140   $items['tripal_toggle_box_menu/%/%/%'] = array(
00141     'title' => 'Toggle Box',
00142     'page callback' => 'tripal_toggle_box_menu',
00143     'page arguments' => array(1, 2, 3),
00144     'access arguments' => array('access administration pages'),
00145     'type' => MENU_CALLBACK | MENU_LINKS_TO_PARENT
00146   );
00147   $items['admin/tripal/chado_install'] = array(
00148     'title' => 'Install Chado Schema',
00149     'description' => 'Installs the Chado database tables, views, etc., inside the current Drupal database',
00150     'page callback' => 'drupal_get_form',
00151     'page arguments' => array('tripal_core_chado_load_form'),
00152     'access arguments' => array('install chado'),
00153     'type' => MENU_NORMAL_ITEM,
00154   );
00155 
00156   // Jobs Management
00157   $items['admin/tripal/tripal_jobs'] = array(
00158     'title' => 'Jobs',
00159     'description' => 'Jobs managed by Tripal',
00160     'page callback' => 'tripal_jobs_report',
00161     'access arguments' => array('access administration pages'),
00162     'type' => MENU_NORMAL_ITEM,
00163   );
00164   $items['admin/tripal/tripal_jobs/cancel/%'] = array(
00165     'title' => 'Jobs',
00166     'description' => 'Cancel a pending job',
00167     'page callback' => 'tripal_jobs_cancel',
00168     'page arguments' => array(4),
00169     'access arguments' => array('access administration pages'),
00170     'type' => MENU_CALLBACK,
00171   );
00172   $items['admin/tripal/tripal_jobs/rerun/%'] = array(
00173     'title' => 'Jobs',
00174     'description' => 'Re-run an existing job.',
00175     'page callback' => 'tripal_jobs_rerun',
00176     'page arguments' => array(4),
00177     'access arguments' => array('access administration pages'),
00178     'type' => MENU_CALLBACK,
00179   );
00180   $items['admin/tripal/tripal_jobs/view/%'] = array(
00181     'title' => 'Jobs Details',
00182     'description' => 'View job details.',
00183     'page callback' => 'tripal_jobs_view',
00184     'page arguments' => array(4),
00185     'access arguments' => array('access administration pages'),
00186     'type' => MENU_CALLBACK,
00187   );
00188 
00189   // Materialized Views
00190   $items['admin/tripal/mviews'] = array(
00191     'title' => 'MViews',
00192     'description' => 'Materialized views are used to improve speed of large or complex queries.',
00193     'page callback' => 'tripal_mviews_report',
00194     'access arguments' => array('access administration pages'),
00195     'type' => MENU_NORMAL_ITEM,
00196   );
00197   $items['admin/tripal/mviews/report/%'] = array(
00198     'title' => 'Materialized View',
00199     'description' => 'Materialized views are used to improve speed of large or complex queries.',
00200     'page callback' => 'tripal_mview_report',
00201     'page arguments' => array(4),
00202     'access arguments' => array('access administration pages'),
00203     'type' => MENU_NORMAL_ITEM,
00204   );
00205   $items['admin/tripal/mviews/new'] = array(
00206     'title' => 'Create MView',
00207     'description' => 'Materialized views are used to improve speed of large or complex queries.',
00208     'page callback' => 'drupal_get_form',
00209     'page arguments' => array('tripal_mviews_form'),
00210     'access arguments' => array('access administration pages'),
00211     'type' => MENU_CALLBACK,
00212   );
00213   $items['admin/tripal/mviews/edit/%'] = array(
00214     'title' => 'Edit MView',
00215     'page callback' => 'drupal_get_form',
00216     'page arguments' => array('tripal_mviews_form', 4),
00217     'access arguments' => array('access administration pages'),
00218     'type' => MENU_NORMAL_ITEM,
00219   );
00220   $items['admin/tripal/mviews/action/%/%'] = array(
00221     'title' => 'Create MView',
00222     'description' => 'Materialized views are used to improve speed of large or complex queries.',
00223     'page callback' => 'tripal_mviews_action',
00224     'page arguments' => array(4, 5, "1"),
00225     'access arguments' => array('access administration pages'),
00226     'type' => MENU_CALLBACK,
00227   );
00228   
00229   // Custom Tables
00230   $items['admin/tripal/custom_tables'] = array(
00231     'title' => 'Custom Tables',
00232     'description' => 'Custom tables are added to Chado.',
00233     'page callback' => 'tripal_custom_tables_list',
00234     'access arguments' => array('access administration pages'),
00235     'type' => MENU_NORMAL_ITEM,
00236   );
00237   $items['admin/tripal/custom_tables/view/%'] = array(
00238     'title' => 'Custom Tables',
00239     'description' => 'Custom tables are added to Chado.',
00240     'page callback' => 'tripal_custom_table_view',
00241     'page arguments' => array(4),
00242     'access arguments' => array('access administration pages'),
00243     'type' => MENU_NORMAL_ITEM,
00244   );
00245   $items['admin/tripal/custom_tables/new'] = array(
00246     'title' => 'Create Custom Table',
00247     'description' => 'Custom tables are added to Chado.',
00248     'page callback' => 'drupal_get_form',
00249     'page arguments' => array('tripal_custom_tables_form'),
00250     'access arguments' => array('access administration pages'),
00251     'type' => MENU_CALLBACK,
00252   );
00253   $items['admin/tripal/custom_tables/edit/%'] = array(
00254     'title' => 'Edit Custom Table',
00255     'page callback' => 'drupal_get_form',
00256     'page arguments' => array('tripal_custom_tables_form', 4),
00257     'access arguments' => array('access administration pages'),
00258     'type' => MENU_NORMAL_ITEM,
00259   );
00260   $items['admin/tripal/custom_tables/action/%/%'] = array(
00261     'title' => 'Create Custom TAble',
00262     'description' => 'Custom tables are added to Chado.',
00263     'page callback' => 'tripal_custom_tables_action',
00264     'page arguments' => array(4, 5, "1"),
00265     'access arguments' => array('access administration pages'),
00266     'type' => MENU_CALLBACK,
00267   );
00268 
00269   return $items;
00270 }
00271 
00279 function tripal_core_perm() {
00280   return array('install chado');
00281 }
00282 
00289 function tripal_core_theme() {
00290   return array(
00291     'tripal_core_job_view' => array(
00292       'arguments' => array('job_id' => NULL),
00293       'template' => 'tripal_core_job_view',
00294     ),
00295     'tripal_core_customize' => array(
00296       'arguments' => array('job_id' => NULL),
00297       'template' => 'tripal_core_customize',
00298       'path' => drupal_get_path('module', 'tripal_core') . '/theme'
00299     ),
00300   );
00301 }
00302 
00319 function tripal_core_job_describe_args($callback, $args) {
00320   $new_args = array();
00321   if ($callback == 'tripal_update_mview') {
00322     // get this mview details
00323     $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = %d ";
00324     $mview = db_fetch_object(db_query($sql, $args[0]));
00325     $new_args['View Name'] = $mview->name;
00326   }
00327 
00328   elseif ($callback == 'tripal_core_install_chado') {
00329      $new_args['Action'] = $args[0];
00330   }
00331   return $new_args;
00332 }
00333 
00340 function tripal_core_load_gff3($gff_file, $organism_id, $analysis_id, $add_only = 0,
00341   $update = 0, $refresh = 0, $remove = 0, $job = NULL) {
00342 
00343   tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id, $add_only,
00344     $update, $refresh, $remove, $job);
00345 }
00346 
00351 function tripal_core_coder_ignore() {
00352   return array(
00353     'path' => drupal_get_path('module', 'tripal_core'),
00354     'line prefix' => drupal_get_path('module', 'tripal_core'),
00355   );
00356 }
 All Classes Files Functions Variables