123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- <?php
- require_once "api/tripal_organism.api.inc";
- require_once "includes/tripal_organism.admin.inc";
- require_once "includes/tripal_organism.chado_node.inc";
- /**
- * @defgroup tripal_organism Organism Module
- * @ingroup tripal_modules
- * @{
- * Provides functions for managing chado organisms including creating details pages for each one
- * @}
- */
- /**
- *
- * @ingroup tripal_organism
- */
- function tripal_organism_init() {
- // add the jGCharts JS and CSS
- drupal_add_css(drupal_get_path('module', 'tripal_organism') . '/theme/css/tripal_organism.css');
- drupal_add_js(drupal_get_path('module', 'tripal_organism') . '/theme/js/tripal_organism.js');
- }
- /**
- *
- * @ingroup tripal_organism
- */
- function tripal_organism_block_info() {
- $blocks['base']['info'] = t('Tripal Organism Details');
- $blocks['base']['cache'] = DRUPAL_NO_CACHE;
- $blocks['description']['info'] = t('Tripal Organism Description');
- $blocks['description']['cache'] = DRUPAL_NO_CACHE;
- $blocks['image']['info'] = t('Tripal Organism Image');
- $blocks['image']['cache'] = DRUPAL_NO_CACHE;
- return $blocks;
- }
- /**
- *
- * @ingroup tripal_organism
- */
- function tripal_organism_block_view($delta = '') {
- if (user_access('access chado_feature content') and arg(0) == 'node' and is_numeric(arg(1))) {
- $nid = arg(1);
- $node = node_load($nid);
- $block = array();
- switch ($delta) {
- case 'base':
- $block['subject'] = t('Organism Details');
- $block['content'] = theme('tripal_organism_base', $node);
- break;
- case 'description':
- $block['subject'] = t('Organism Description');
- $block['content'] = theme('tripal_organism_description', $node);
- break;
- case 'image':
- $block['subject'] = t('Organism Image');
- $block['content'] = theme('tripal_organism_image', $node);
- break;
- default:
- }
- return $block;
- }
- }
- /**
- * Menu items are automatically added for the new node types created
- * by this module to the 'Create Content' Navigation menu item. This function
- * adds more menu items needed for this module.
- *
- * @ingroup tripal_organism
- */
- function tripal_organism_menu() {
- $items = array();
- // the administative settings menu
- $items['admin/tripal/chado/tripal_organism'] = array(
- 'title' => 'Organisms',
- 'description' => 'Any living biological entity, such as an animal, plant, fungus, or bacterium.',
- 'page callback' => 'tripal_organism_admin_organism_view',
- 'access arguments' => array('adminster tripal organism'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/chado/tripal_organism/help'] = array(
- 'title' => 'Help',
- 'description' => "A description of the Tripal Organism module including a short description of it's usage.",
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_organism_help'),
- 'access arguments' => array('adminster tripal organism'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 10
- );
- $items['admin/tripal/chado/tripal_organism/configuration'] = array(
- 'title' => 'Settings',
- 'description' => 'Manage integration of Chado organisms including associated features',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_organism_admin'),
- 'access arguments' => array('adminster tripal organism'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 5
- );
- $items['admin/tripal/chado/tripal_organism/sync'] = array(
- 'title' => ' Sync',
- 'description' => 'Create pages on this site for organisms stored in Chado',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_organism', 'chado_organism'),
- 'access arguments' => array('administer tripal organism'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2
- );
- $items['admin/tripal/chado/tripal_organism/views/organisms/enable'] = array(
- 'title' => 'Enable Organism Administrative View',
- 'page callback' => 'tripal_views_admin_enable_view',
- 'page arguments' => array('tripal_organism_admin_organisms', 'admin/tripal/chado/tripal_organism'),
- 'access arguments' => array('administer tripal organism'),
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
- */
- function tripal_organism_help ($path, $arg) {
- if ($path == 'admin/help#tripal_organism') {
- return theme('tripal_organism_help', array());
- }
- }
- /**
- * We need to let drupal know about our theme functions and their arguments.
- * We create theme functions to allow users of the module to customize the
- * look and feel of the output generated in this module
- *
- * @ingroup tripal_organism
- */
- function tripal_organism_theme($existing, $type, $theme, $path) {
- $core_path = drupal_get_path('module', 'tripal_core');
- $items = array(
- 'node__chado_organism' => array(
- 'template' => 'node--chado-generic',
- 'render element' => 'node',
- 'base hook' => 'node',
- 'path' => "$core_path/theme",
- ),
- 'tripal_organism_base' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_organism_base',
- 'path' => "$path/theme/tripal_organism",
- ),
- 'tripal_organism_description' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_organism_description',
- 'path' => "$path/theme/tripal_organism",
- ),
- 'tripal_organism_image' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_organism_image',
- 'path' => "$path/theme/tripal_organism",
- ),
- 'tripal_organism_teaser' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_organism_teaser',
- 'path' => "$path/theme/tripal_organism",
- ),
- 'tripal_organism_help' => array(
- 'template' => 'tripal_organism_help',
- 'variables' => array(NULL),
- 'path' => "$path/theme",
- ),
- );
- 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_organism
- */
- function tripal_organism_permission() {
- return array(
- 'access chado_organism content' => array(
- 'title' => t('View Organisms'),
- 'description' => t('Allow users to view organism pages.'),
- ),
- 'create chado_organism content' => array(
- 'title' => t('Create Organisms'),
- 'description' => t('Allow users to create new organism pages.'),
- ),
- 'delete chado_organism content' => array(
- 'title' => t('Delete Organisms'),
- 'description' => t('Allow users to delete organism pages.'),
- ),
- 'edit chado_organism content' => array(
- 'title' => t('Edit Organisms'),
- 'description' => t('Allow users to edit organism pages.'),
- ),
- 'adminster tripal organism' => array(
- 'title' => t('Administer Organisms'),
- 'description' => t('Allow users to administer all organisms.'),
- ),
- );
- }
- /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
- * for this module which then includes tripal_db.views.inc where all the
- * views integration code is
- *
- * @ingroup tripal_organism
- */
- function tripal_organism_views_api() {
- return array(
- 'api' => 2.0,
- );
- }
- /**
- *
- *
- * @ingroup tripal_organism
- */
- function tripal_organism_job_describe_args($callback, $args) {
- $new_args = array();
- if ($callback == 'tripal_organism_sync_organisms') {
- $organism = tripal_core_chado_select('organism', array('genus', 'species'), array('organism_id' => $args[0]));
- $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
- }
- return $new_args;
- }
- /**
- * Implementation of hook_form_alter()
- *
- * @param $form
- * @param $form_state
- * @param $form_id
- */
- function tripal_organism_form_alter(&$form, &$form_state, $form_id) {
- // turn of preview button for insert/updates
- if ($form_id == "chado_organism_node_form") {
- $form['actions']['preview']['#access'] = FALSE;
- }
- }
|