123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <?php
- /**
- * @file
- * The Tripal Core module
- */
- /**
- * @defgroup tripal_modules Tripal Modules
- * @{
- * All documented functions for the various Tripal Modules excluding API functions and Views Integration functions.
- * @}
- */
- /**
- * @defgroup tripal_api Tripal API
- * @{
- * Provides an application programming interface (API) for Tripal
- *
- * The Tripal API currently provides generic insert/update/select functions for all chado content as
- * well as some module specific functions that insert/update/delete/select specific chado content.
- *
- * This API is currently in its infancy and some necessary functions might be missing. If you find
- * a missing function that you think should be included go to the sourceforge feature request
- * page and request it's inclusion in the API. Such feature requests with a working function
- * definition will be given priority.
- * @}
- */
- /**
- * @defgroup tripal_core_api Core Module API
- * @ingroup tripal_api
- */
- /**
- * @defgroup tripal_core Tripal Core Module
- * @ingroup tripal_modules
- */
- require_once "api/tripal_core_chado.api.inc";
- require_once "api/tripal_core_files.api.inc";
- require_once "api/tripal_core_ahah.api.inc";
- require_once "api/tripal_core_custom_tables.api.inc";
- require_once "api/tripal_core_jobs.api.inc";
- require_once "api/tripal_core_mviews.api.inc";
- require_once "api/tripal_core_misc.api.inc";
- require_once "includes/jobs.inc";
- require_once "includes/mviews.inc";
- require_once "includes/custom_tables.inc";
- require_once "includes/chado_install.inc";
- require_once "includes/form_elements.inc";
- /**
- * Implements hook_init().
- * Used to set the search_path, create default content and set default variables.
- *
- * @ingroup tripal_core
- */
- function tripal_core_init() {
- global $base_url;
- // 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 the Tripal cv is missing then add
- $results = chado_query("SELECT * FROM {cv} WHERE name = 'tripal'");
- $tripal_cv = $results->fetchObject();
- if (!$tripal_cv) {
- $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 the Tripal db is missing then add it
- $results = chado_query("SELECT * FROM {db} WHERE name = 'tripal'");
- $tripal_db = $results->fetchObject();
- if (!$tripal_db) {
- $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 :style", array(':style' => 'MDY'));
- // 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');
- }
- /**
- * Implements hook_menu().
- * Defines all menu items needed by Tripal Core
- *
- * @ingroup tripal_core
- */
- function tripal_core_menu() {
- $items = array();
- // Triapl setting groups
- $items['admin/tripal'] = array(
- 'title' => 'Tripal',
- 'description' => "Manage the behavior or Tripal and its various modules.",
- 'weight' => -8,
- 'page callback' => 'system_admin_menu_block_page',
- 'access arguments' => array('administer site configuration'),
- 'file' => 'system.admin.inc',
- 'file path' => drupal_get_path('module', 'system'),
- );
- $items['admin/tripal/schema'] = array(
- 'title' => 'Chado Schema',
- 'description' => "Tools to extend the chado schema through custom tables & materialized views.",
- 'weight' => -2,
- 'access arguments' => array('administer site configuration'),
- );
- $items['admin/tripal/chado'] = array(
- 'title' => 'Chado Modules',
- 'description' => 'Configuration for specific chado data types such as Vocabularies, Features, etc.',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -6
- );
- $items['admin/tripal/loaders'] = array(
- 'title' => 'Chado Data Loaders',
- 'description' => 'Tools facilitating loading data into the chado database. Includes a generic tab-delimited loader (Bulk Loader).',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -4
- );
- $items['admin/tripal/extension'] = array(
- 'title' => 'Extension Modules',
- 'description' => 'Configuration for Tripal extension modules.',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => 0
- );
- // Tripal Setup
- $items['admin/tripal/setup'] = array(
- 'title' => 'Setup Tripal',
- 'description' => 'Tools for initial setup of Tripal',
- 'access arguments' => array('administer site configuration'),
- 'weight' => -8
- );
- $items['admin/tripal/setup/customize'] = array(
- 'title' => 'Customize Tripal',
- 'description' => 'Information on how to customize tripal',
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_core_customize'),
- 'access arguments' => array('administer site configuration'),
- 'weight' => 10
- );
- $items['admin/tripal/setup/chado_install'] = array(
- 'title' => 'Install Chado Schema',
- 'description' => 'Installs the Chado database tables, views, etc., inside the current Drupal database',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_core_chado_load_form'),
- 'access arguments' => array('install chado'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -10
- );
- // Jobs Management
- $items['admin/tripal/tripal_jobs'] = array(
- 'title' => 'Jobs',
- 'description' => 'Jobs managed by Tripal',
- 'page callback' => 'tripal_jobs_report',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -10
- );
- $items['admin/tripal/tripal_jobs/cancel/%'] = array(
- 'title' => 'Jobs',
- 'description' => 'Cancel a pending job',
- 'page callback' => 'tripal_jobs_cancel',
- 'page arguments' => array(4),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/tripal_jobs/rerun/%'] = array(
- 'title' => 'Jobs',
- 'description' => 'Re-run an existing job.',
- 'page callback' => 'tripal_jobs_rerun',
- 'page arguments' => array(4),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/tripal_jobs/view/%'] = array(
- 'title' => 'Jobs Details',
- 'description' => 'View job details.',
- 'page callback' => 'tripal_jobs_view',
- 'page arguments' => array(4),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_CALLBACK,
- );
- // Materialized Views
- $items['admin/tripal/schema/mviews'] = array(
- 'title' => 'Materialized Views',
- 'description' => 'Materialized views are used to improve speed of large or complex queries.',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -10
- );
- $items['admin/tripal/schema/mviews/list'] = array(
- 'title' => 'List Materialized Views',
- 'description' => 'A list of existing materialized views with the ability to edit & delete existing materialized views.',
- 'page callback' => 'tripal_mviews_report',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -10
- );
- $items['admin/tripal/schema/mviews/report/%'] = array(
- 'title' => 'Materialized View',
- 'description' => 'Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.',
- 'page callback' => 'tripal_mview_report',
- 'page arguments' => array(5),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/schema/mviews/new'] = array(
- 'title' => 'Create Materialized View',
- 'description' => 'Create a new materialized view.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_mviews_form'),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/schema/mviews/edit/%'] = array(
- 'title' => 'Edit Materialized View',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_mviews_form', 5),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/schema/mviews/action/%/%'] = array(
- 'title' => 'Create Materialized View',
- 'description' => 'Materialized views are used to improve speed of large or complex queries.',
- 'page callback' => 'tripal_mviews_action',
- 'page arguments' => array(5, 6, "1"),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_CALLBACK,
- );
- // Custom Tables
- $items['admin/tripal/schema/custom_tables'] = array(
- 'title' => 'Custom Tables',
- 'description' => 'Creation of custom tables that are added to Chado database.',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -10
- );
- $items['admin/tripal/schema/custom_tables/list'] = array(
- 'title' => 'List of Custom Tables',
- 'description' => 'Provides a list of all custom tables created by Tripal and allows for editing or removing existing custom tables.',
- 'page callback' => 'tripal_custom_tables_list',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => -10
- );
- $items['admin/tripal/schema/custom_tables/view/%'] = array(
- 'title' => 'Custom Tables',
- 'description' => 'Custom tables are added to Chado.',
- 'page callback' => 'tripal_custom_table_view',
- 'page arguments' => array(4),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/schema/custom_tables/new'] = array(
- 'title' => 'Create Custom Table',
- 'description' => 'An interface for creating your own custom tables.',
- 'page callback' => 'tripal_custom_table_new_page',
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/schema/custom_tables/edit/%'] = array(
- 'title' => 'Edit Custom Table',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_custom_tables_form', 4),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/schema/custom_tables/action/%/%'] = array(
- 'title' => 'Create Custom Table',
- 'description' => 'Custom tables are added to Chado.',
- 'page callback' => 'tripal_custom_tables_action',
- 'page arguments' => array(4, 5, "1"),
- 'access arguments' => array('access administration pages'),
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- /**
- * Set the permission types that the chado module uses. Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- *
- * @ingroup tripal_core
- */
- function tripal_core_permission() {
- return array(
- 'install chado' => array(
- 'title' => t('Install Chado'),
- 'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
- ),
- );
- }
- /**
- * Implements hook_theme().
- * Registers template files/functions used by this module.
- *
- * @ingroup tripal_core
- */
- function tripal_core_theme() {
- return array(
- 'tripal_core_customize' => array(
- 'arguments' => array('job_id' => NULL),
- 'template' => 'tripal_core_customize',
- 'path' => drupal_get_path('module', 'tripal_core') . '/theme'
- ),
- 'theme_file_upload_combo' => array(
- 'render element' => 'element',
- ),
- 'theme_sequence_combo' => array(
- 'render element' => 'element',
- ),
- );
- }
- /**
- * Implements hook_job_describe_args().
- * Describes the arguements for the tripal_update_mview job to allow for greater
- * readability in the jobs details pages.
- *
- * @param $callback
- * The callback of the current tripal job (this is the function that will be executed
- * when tripal_launch_jobs.php is run.
- * @param $args
- * An array of arguments passed in when the job was registered.
- *
- * @return
- * A more readable $args array
- *
- * @ingroup tripal_core
- */
- function tripal_core_job_describe_args($callback, $args) {
- $new_args = array();
- if ($callback == 'tripal_update_mview') {
- // get this mview details
- $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = :mview_id ";
- $results = db_query($sql, array(':mview_id' => $args[0]));
- $mview = $results->fetchObject();
- $new_args['View Name'] = $mview->name;
- }
- elseif ($callback == 'tripal_core_install_chado') {
- $new_args['Action'] = $args[0];
- }
- return $new_args;
- }
- /**
- * this is just a wrapper for backwards compatibility with a naming mistake.
- * it can go away in the future as it only is useful for jobs created by v0.3b
- *
- * @todo remove this function
- */
- function tripal_core_load_gff3($gff_file, $organism_id, $analysis_id, $add_only = 0,
- $update = 0, $refresh = 0, $remove = 0, $job = NULL) {
- tripal_feature_load_gff3($gff_file, $organism_id, $analysis_id, $add_only,
- $update, $refresh, $remove, $job);
- }
- /**
- * Implements hook_coder_ignore().
- * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for coder are stored
- */
- function tripal_core_coder_ignore() {
- return array(
- 'path' => drupal_get_path('module', 'tripal_core'),
- 'line prefix' => drupal_get_path('module', 'tripal_core'),
- );
- }
|