function tripal_core_init
2.x tripal_core.module | tripal_core_init() |
3.x tripal_core.module | tripal_core_init() |
1.x tripal_core.module | tripal_core_init() |
Implements hook_init(). Used to set the search_path, create default content and set default variables.
Related topics
File
- tripal_core/
tripal_core.module, line 60 - The Tripal Core module
Code
function tripal_core_init() {
global $base_url;
// we need to declare here the persistent_chado global variable
global $persistent_chado;
global $prepared_statements;
$persistent_chado = NULL;
$prepared_statements = array();
// add javascript files
drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal.ahah.js');
// create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and
// only if the chado database is present.
if (tripal_core_is_chado_installed()) {
// make sure the current version of chado is set
tripal_core_set_chado_version();
if (!db_fetch_object(chado_query("SELECT * FROM {cv} WHERE name = 'tripal'"))) {
$results = chado_query(
"INSERT INTO {cv} (name,definition) " .
"VALUES ('tripal', 'Terms used by Tripal for modules to manage data such as that stored in property tables like featureprop, analysisprop, etc')");
}
if (!db_fetch_object(chado_query("SELECT * FROM {db} WHERE name = 'tripal'"))) {
$results = chado_query(
"INSERT INTO {db} (name,description) " .
"VALUES ('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms')");
}
}
// add some variables for all javasript to use for building URLs
global $base_url;
$theme_dir = drupal_get_path('theme', 'tripal');
$clean_urls = variable_get('clean_url', 0);
drupal_add_js(
" var baseurl = '$base_url';
var themedir = '$theme_dir';
var isClean = $clean_urls;",
'inline', 'header');
// make sure the date time settings are the way Tripal will insert them
// otherwise PostgreSQL version that may have a different datestyle setting
// will fail when inserting or updating a date column in a table.
db_query("SET DATESTYLE TO '%s'", 'MDY');
// in the event that an errant Tripal or extension function fails to
// set the postgres search_path back to noraml we do it here on
// init of the core
tripal_db_set_default_search_path();
// create a persistent connection
$connection = tripal_db_persistent_chado();
// If we want AHAH elements on the node forms (e.g. chado_pub form) then we need to include
// the node.pages file. Otherwise this error message is given:
//
// warning: call_user_func_array() expects parameter 1 to be a valid callback,
// function 'node_form' not found or invalid function name
// in /var/www/includes/form.inc on line 382.
module_load_include('inc', 'node', 'node.pages');
}