123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578 |
- <?php
- /**
- * @file
- * The Tripal Core module
- */
- // Import the full Tripal API into scope.
- tripal_import_api();
- require_once "includes/tripal.field_storage.inc";
- require_once "includes/tripal.fields.inc";
- require_once "includes/tripal.entity.inc";
- require_once "includes/TripalVocab.inc";
- require_once "includes/TripalVocabController.inc";
- require_once "includes/TripalVocabViewsController.inc";
- require_once "includes/TripalTerm.inc";
- require_once "includes/TripalTermController.inc";
- require_once "includes/TripalTermViewsController.inc";
- require_once "includes/TripalEntity.inc";
- require_once "includes/TripalEntityController.inc";
- require_once "includes/TripalEntityUIController.inc";
- require_once "includes/TripalEntityViewsController.inc";
- require_once "includes/TripalBundle.inc";
- require_once "includes/TripalBundleController.inc";
- require_once "includes/TripalBundleUIController.inc";
- require_once "includes/TripalField.inc";
- require_once "includes/TripalFieldWidget.inc";
- require_once "includes/TripalFieldFormatter.inc";
- require_once "includes/TripalFieldQuery.inc";
- /**
- * @defgroup tripal Tripal Core Module
- * @ingroup tripal_modules
- * @{
- * Functionality useful for all other Tripal modules including the Tripal jobs, files,
- * materialized views and custom table functions.
- * @}
- */
- /**
- * Implements hook_views_api().
- */
- function tripal_views_api() {
- return array(
- 'api' => 3,
- );
- }
- /**
- * Implements hook_init().
- * Used to set the search_path, create default content and set default variables.
- *
- * @ingroup tripal
- */
- function tripal_init() {
- global $base_url;
- // add some variables for all javasript to use for building URLs
- $clean_urls = variable_get('clean_url', 0);
- $tripal_path = url(drupal_get_path('module', 'tripal'));
- drupal_add_js("
- var baseurl = '$base_url';
- var isClean = $clean_urls;
- var tripal_path = '$tripal_path';",
- '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'));
- }
- /**
- * Implements hook_menu().
- * Defines all menu items needed by Tripal Core
- *
- * @ingroup tripal
- */
- function tripal_menu() {
- $items = array();
- // Tripal setting groups
- $items['admin/tripal'] = array(
- 'title' => 'Tripal',
- 'description' => t("Manage the behavior or Tripal and its various modules."),
- 'weight' => -8,
- 'page callback' => 'system_admin_menu_block_page',
- 'access arguments' => array('administer tripal'),
- 'file' => 'system.admin.inc',
- 'file path' => drupal_get_path('module', 'system'),
- );
- $items['admin/tripal/tripal_jobs'] = array(
- 'title' => 'Jobs',
- 'description' => t('Provides tools for managing jobs submitted to Tripal. In some
- cases, long-running tasks are too slow to complete within a single
- browser session. The Tripal jobs system allows long-running tasks
- to be submitted to a queue that can be executed manually by the
- site admin or automatically using a module such as the ') .
- l('Tripal Daemon', 'https://www.drupal.org/project/tripal_daemon', array('attributes' => array('target' => '_blank'))) .
- ' extension module.',
- 'page callback' => 'tripal_jobs_admin_view',
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => 0,
- 'file' => 'includes/tripal.jobs.inc',
- 'file path' => drupal_get_path('module', 'tripal'),
- );
- $items['admin/tripal/storage'] = array(
- 'title' => 'Data Storage',
- 'description' => t("Tripal is designed to access biological
- data in any data storage back-end. A storage back-end must have a
- module that can be installed that interfaces with Tripal. By default
- the base Tripal package provides The Tripal Chado module for storing
- data in the GMOD Chado database schema. All available storage backends
- and their administrative tools are found here."),
- 'weight' => 8,
- 'access arguments' => array('administer tripal'),
- );
- $items['admin/tripal/terms'] = array(
- 'title' => 'Vocabularies',
- 'description' => t("Vocabulary terms are essential to creating content
- in Tripal. This allows data to be shared more easily with others
- using technologies such as the semantic web and web services.
- Before creating content you must have loaded vocabularies and their
- terms."),
- 'weight' => 8,
- 'access arguments' => array('administer tripal'),
- );
- $items['admin/tripal/terms/import'] = array(
- 'title' => 'Import Vocabulary',
- 'description' => t("Import vocabularies and terms in OBO format."),
- 'access arguments' => array('administer tripal'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_vocabulary_import_form'),
- 'file' => 'includes/tripal.admin.inc',
- 'file path' => drupal_get_path('module', 'tripal'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/extension'] = array(
- 'title' => 'Extensions',
- 'description' => t("Configuration and management pages for Tripal extension modules."),
- 'weight' => 8,
- 'access arguments' => array('administer tripal'),
- );
- // Menu items for facilitating import of extension modules.
- $items['admin/tripal/extension/available'] = array(
- 'title' => 'Available Extensions',
- 'description' => t('Look for extensions to add new functionality to this
- site. Tripal can be extended with new functionality developed
- by other Tripal site developers. These include modules with new or
- different functionality, bulk loading templates, or materialized
- views. Anyone can create new extensions and share those for
- others to use. Once shared they will appear in this list.'),
- 'access arguments' => array('administer tripal'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_extensions_form'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'includes/tripal.extensions.inc',
- 'file path' => drupal_get_path('module', 'tripal'),
- 'weight' => -100
- );
- // $items['admin/tripal/extension/import'] = array(
- // 'title' => 'Import Extensions',
- // 'description' => 'Provides a list of the available extensions that are registered at the tripal.info site. From this page you can easily import or install extensions to your site.',
- // 'page callback' => 'drupal_get_form',
- // 'page arguments' => array('tripal_extensions_form'),
- // 'access arguments' => array('administer tripal'),
- // 'type' => MENU_NORMAL_ITEM,
- // 'file' => 'includes/tripal.extensions.inc',
- // 'file path' => drupal_get_path('module', 'tripal'),
- // 'weight' => -100,
- // );
- /*
- $items['admin/tripal/setup/customize'] = array(
- 'title' => 'Customize Tripal',
- 'description' => t('Information on how to customize tripal'),
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_customize'),
- 'access arguments' => array('administer tripal'),
- 'weight' => 10
- );
- */
- // Jobs Management
- $items['admin/tripal/tripal_jobs/help'] = array(
- 'title' => 'Help',
- 'description' => t('Help for the tripal job management system'),
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_job_help'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 10
- );
- $items['admin/tripal/tripal_jobs/cancel/%'] = array(
- 'title' => 'Jobs',
- 'description' => t('Cancel a pending job'),
- 'page callback' => 'tripal_cancel_job',
- 'page arguments' => array(4),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/tripal_jobs/rerun/%'] = array(
- 'title' => 'Jobs',
- 'description' => t('Re-run an existing job.'),
- 'page callback' => 'tripal_rerun_job',
- 'page arguments' => array(4),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/tripal_jobs/view/%'] = array(
- 'title' => 'Jobs Details',
- 'description' => t('View job details.'),
- 'page callback' => 'tripal_jobs_view',
- 'page arguments' => array(4),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- );
- $items['admin/tripal/tripal_jobs/views/jobs/enable'] = array(
- 'title' => 'Enable Jobs Administrative View',
- 'page callback' => 'tripal_enable_view',
- 'page arguments' => array('tripal_admin_jobs', 'admin/tripal/tripal_jobs'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_CALLBACK,
- );
- /*
- * AJAX Callbacks.
- */
- $items['bio_data/ajax/field_attach/%'] = array(
- 'page callback' => 'tripal_ajax_attach_field',
- 'page arguments' => array(3),
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- 'file' => 'includes/tripal.entity.inc',
- 'file path' => drupal_get_path('module', 'tripal'),
- );
- /*
- * Term Lookup
- */
- $items['cv/lookup'] = array(
- 'title' => 'Vocabulary Lookup',
- 'description' => t("Provides a tool to discover controlled vocabularies and their terms used by this site."),
- 'access arguments' => array('access content'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_vocabulary_lookup_form'),
- 'file' => 'includes/tripal.term_lookup.inc',
- 'file path' => drupal_get_path('module', 'tripal'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['cv/lookup/%/%'] = array(
- 'title' => 'Vocabulary Lookup',
- 'description' => t("Provides a tool to discover controlled vocabularies and their terms used by this site."),
- 'access arguments' => array('access content'),
- 'page callback' => 'tripal_vocabulary_lookup_term_page',
- 'page arguments' => array(2, 3),
- 'file' => 'includes/tripal.term_lookup.inc',
- 'file path' => drupal_get_path('module', 'tripal'),
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- /**
- * Implements hook_permission().
- */
- function tripal_permission() {
- return array(
- 'administer tripal' => array(
- 'title' => t('Administer Tripal'),
- 'description' => t('Allow the user to access administrative pages of Tripal.')
- ),
- 'view dev helps' => array(
- 'title' => t('View Developer Hints'),
- 'description' => t('Tripal will provide blue shaded boxes that provide
- instructions for how to customize or setup specific pages on a
- site. This permission should be enabled for developers. But can
- be disabled once developers are accustomed to these hints.'),
- 'restrict access' => TRUE,
- ),
- 'administer tripal data types' => array(
- 'title' => t('Administer Tripal data types'),
- 'description' => t('Create and delete fields for Tripal data types, and set their permissions.'),
- ),
- 'administer tripal data' => array(
- 'title' => t('Administer Tripal data'),
- 'description' => t('Edit and delete all tripal data'),
- ),
- 'administer controlled vocabularies' => array(
- 'title' => t('Administer controlled vocabularies (CVs).'),
- 'description' => t('Allow a user to add, edit and delete controlled vocabularies as well as add and edit terms.')
- ),
- );
- }
- /**
- * Implements hook_theme().
- * Registers template files/functions used by this module.
- *
- * @ingroup tripal
- */
- function tripal_theme($existing, $type, $theme, $path) {
- $themes = array(
- 'tripal_customize' => array(
- 'arguments' => array('job_id' => NULL),
- 'template' => 'tripal_customize',
- 'path' => "$path/theme/templates"
- ),
- 'theme_file_upload_combo' => array(
- 'render element' => 'element',
- ),
- 'theme_sequence_combo' => array(
- 'render element' => 'element',
- ),
- 'tripal_jobs_help' => array(
- 'template' => 'tripal_jobs_help',
- 'variables' => array(NULL),
- 'path' => "$path/theme/templates"
- ),
- 'tripal_customtables_help' => array(
- 'template' => 'tripal_customtables_help',
- 'variables' => array(NULL),
- 'path' => "$path/theme/templates"
- ),
- // Admin messages theme
- 'tripal_admin_message' => array(
- 'function' => 'theme_tripal_admin_message',
- 'variables' => array('message' => NULL),
- ),
- 'tripal_entity' => array(
- 'render element' => 'elements',
- 'template' => 'tripal_entity',
- 'path' => "$path/theme/templates"
- ),
- 'tripal_add_list' => array(
- 'variables' => array('content' => NULL),
- ),
- );
- return $themes;
- }
- /**
- * Implements hook_coder_ignore().
- * Defines the path to the file (tripal.coder_ignores.txt) where ignore rules for coder are stored
- */
- function tripal_coder_ignore() {
- return array(
- 'path' => drupal_get_path('module', 'tripal'),
- 'line prefix' => drupal_get_path('module', 'tripal'),
- );
- }
- /**
- * Implements hook_libraries_info().
- */
- function tripal_libraries_info() {
- $libraries = array();
- $libraries['d3'] = array(
- 'name' => 'D3.js',
- 'vendor url' => 'http://d3js.org/',
- 'download url' => 'https://github.com/mbostock/d3',
- 'version arguments' => array(
- 'file' => 'd3.js',
- 'pattern' => '/\s*version: "(\d+\.\d+\.\d+)"/',
- ),
- 'files' => array(
- 'js' => array(
- 'd3.min.js',
- ),
- ),
- );
- return $libraries;
- }
- /**
- * Implements hook_admin_paths().
- * Define administrative paths.
- */
- function tripal_admin_paths() {
- if (variable_get('node_admin_theme')) {
- $paths = array(
- 'bio_data/*/edit' => TRUE,
- 'bio_data/*/delete' => TRUE,
- 'bio_data/add' => TRUE,
- 'bio_data/add/*' => TRUE,
- );
- return $paths;
- }
- }
- /**
- * Implements hook_menu_local_tasks_alter().
- *
- * Used to add action links to pages.
- */
- function tripal_menu_local_tasks_alter(&$data, $router_item, $root_path) {
- // Add an "Add Tripal Content" action link to the Admin >> Content >>
- // Biological Content page.
- if ($root_path == 'admin/content/bio_data') {
- $item = menu_get_item('bio_data/add');
- if ($item['access']) {
- $data['actions']['output'][] = array(
- '#theme' => 'menu_local_action',
- '#link' => $item,
- );
- }
- }
- }
- /**
- * Implements hook_shortcut_default_set().
- * Modify the shortcut menu to include Biological content links.
- *
- * @param object $account
- * The user account whose default shortcut set will be returned. If not provided, the
- * function will return the currently logged-in user's default shortcut set.
- *
- * @return
- * An object representing the default shortcut set.
- */
- function tripal_shortcut_default_set($account) {
- $sets = shortcut_sets();
- $found = FALSE;
- foreach ($sets as $set) {
- if ($set->title == 'TripalDefault') {
- $found = TRUE;
- }
- }
- if (!$found) {
- $t = get_t();
- // Create an initial default shortcut set.
- $shortcut_set = new stdClass();
- $shortcut_set->title = $t('TripalDefault');
- $shortcut_set->links = array(
- array(
- 'link_path' => 'node/add',
- 'link_title' => $t('Add content'),
- 'weight' => -35,
- ),
- array(
- 'link_path' => 'bio_data/add',
- 'link_title' => 'Add Tripal Content',
- 'weight' => -30,
- ),
- array(
- 'link_path' => 'admin/content',
- 'link_title' => $t('Find content'),
- 'weight' => -25,
- ),
- array(
- 'link_path' => 'admin/content/bio_data',
- 'link_title' => 'Find Tripal Content',
- 'weight' => -20,
- ),
- );
- shortcut_set_save($shortcut_set);
- }
- $sets = shortcut_sets();
- foreach ($sets as $set) {
- if ($set->title == 'TripalDefault') {
- return $set->set_name;
- }
- }
- }
- /**
- * Menu argument loader; Load a tripal data type by string.
- *
- * This function is not meant to be used as an API function. It is only meant
- * for use in the menu to resolve the %tripal_bundle wildcard.
- *
- * @param $type
- * The machine-readable name of a tripal data type to load.
- * @return
- * A tripal data type array or FALSE if $type does not exist.
- */
- function TripalBundle_load($bundle_type, $reset = FALSE) {
- // Get the type of entity by the ID.
- $bundle = db_select('tripal_bundle', 'tdt')
- ->fields('tdt')
- ->condition('name', $bundle_type)
- ->execute()
- ->fetchObject();
- if ($bundle) {
- $entity = entity_load('TripalBundle', array($bundle->id), array(), $reset);
- return reset($entity);
- }
- return FALSE;
- }
- /**
- * Allows the menu system to use a wildcard to fetch the entity.
- *
- * Make sure that the wildcard you choose in the tripal_entity entity
- * definition fits the function name here.
- *
- * This function is not meant to be used as an API function. It is only meant
- * for use in the menu to resolve the %tripal_entity wildcard.
- *
- * @param $id
- * Integer specifying the tripal_entity id.
- * @param $reset
- * A boolean indicating that the internal cache should be reset.
- * @return
- * A fully-loaded $tripal_entity object or FALSE if it cannot be loaded.
- *
- * @see tripal_entity_load_multiple()
- */
- function TripalEntity_load($id, $reset = TRUE) {
- // $entity = entity_load('TripalEntity', array($id), array(), $reset);
- $entity = tripal_load_entity('TripalEntity', array($id), $reset);
- return reset($entity);
- }
- /**
- * Implements hook_menu_alter().
- */
- function tripal_menu_alter(&$items) {
- // We don't want to allow deletion of fields added by the storage backend.
- // TODO: this shouldn't be hardcoded here. These settings
- // should be part of the field and handled by the tripal_entity module.
- $items['admin/structure/bio_data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page callback'] = 'tripal_field_no_delete';
- $items['admin/structure/bio_data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page arguments'] = array();
- }
- /**
- * Imports all of the Tripal API into scope.
- *
- * Typically this function call is not necessary as all of the API is
- * automaticaly included by the tripal module. However this function can
- * be useful in the .install files during a site upgrade when the tripal
- * module is not enabld.
- *
- * Example usage:
- * @code
- * module_load_include('module', 'tripal', 'tripal');
- * tripal_import_api();
- * @endcode
- *
- */
- function tripal_import_api() {
- module_load_include('inc', 'tripal', 'api/tripal.d3js.api');
- module_load_include('inc', 'tripal', 'api/tripal.fields.api');
- module_load_include('inc', 'tripal', 'api/tripal.terms.api');
- module_load_include('inc', 'tripal', 'api/tripal.entities.api');
- module_load_include('inc', 'tripal', 'api/tripal.files.api');
- module_load_include('inc', 'tripal', 'api/tripal.jobs.api');
- module_load_include('inc', 'tripal', 'api/tripal.notice.api');
- module_load_include('inc', 'tripal', 'api/tripal.variables.api');
- }
- /**
- * Implements hook_form_alter().
- */
- function tripal_form_alter(&$form, $form_state, $form_id) {
- // If this i the field_ui_field_edit_form (i.e. the form that appears
- // when editing a field that is attached to an entity). Then we want
- // to add semantic web settings.
- if ($form_id == 'field_ui_field_edit_form') {
- tripal_field_instance_settings_form_alter($form, $form_state);
- }
- }
|