123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- <?php
- /**
- * @defgroup tripal_featuremap Feature Map Module
- * @ingroup tripal_modules
- * @{
- * Provides functions for managing chado maps including creating details pages for each map
- * @}
- */
- require('api/tripal_featuremap.api.inc');
- require('theme/tripal_featuremap.theme.inc');
- require('includes/tripal_featuremap.admin.inc');
- require('includes/tripal_featuremap.chado_node.inc');
- /**
- *
- * @ingroup tripal_featuremap
- */
- function tripal_featuremap_init() {
- drupal_add_css(drupal_get_path('module', 'tripal_featuremap') . '/theme/css/tripal_featuremap.css');
- drupal_add_js(drupal_get_path('module', 'tripal_featuremap') . '/theme/js/tripal_featuremap.js');
- }
- /**
- * Display help and module information
- * @param path which path of the site we're displaying help
- * @param arg array that holds the current path as would be returned from arg()
- * function
- * @return help text for the path
- *
- * @ingroup tripal_featuremap
- */
- function tripal_featuremap_help($path, $arg) {
- $output = '';
- switch ($path) {
- case "admin/help#tripal_featuremap":
- $output = '<p>'.
- t("Displays links to nodes created on this date") .
- '</p>';
- break;
- }
- return $output;
- }
- /**
- * Provide information to drupal about the node types that we're creating
- * in this module
- *
- * @ingroup tripal_featuremap
- */
- function tripal_featuremap_node_info() {
- $nodes = array();
- $nodes['chado_featuremap'] = array(
- 'name' => t('Feature Map'),
- 'base' => 'chado_featuremap',
- 'description' => t('A map of features from the chado database (e.g. genetic map)'),
- 'has_title' => FALSE,
- 'title_label' => t('Feature Map'),
- 'has_body' => FALSE,
- 'body_label' => t('Feature Map Description'),
- 'locked' => TRUE,
- 'chado_node_api' => array(
- 'base_table' => 'featuremap',
- 'hook_prefix' => 'chado_featuremap',
- 'record_type_title' => array(
- 'singular' => t('Feature Map'),
- 'plural' => t('Feature Maps')
- ),
- 'sync_filters' => array(
- 'type_id' => FALSE,
- 'organism_id' => FALSE
- ),
- )
- );
- return $nodes;
- }
- /**
- * 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_featuremap
- */
- function tripal_featuremap_permissions() {
- return array(
- 'access chado_featuremap content' => array(
- 'title' => t('View Maps'),
- 'description' => t('Allow users to view map pages.'),
- ),
- 'create chado_featuremap content' => array(
- 'title' => t('Create Maps'),
- 'description' => t('Allow users to create new map pages.'),
- ),
- 'delete chado_featuremap content' => array(
- 'title' => t('Delete Maps'),
- 'description' => t('Allow users to delete map pages.'),
- ),
- 'edit chado_featuremap content' => array(
- 'title' => t('Edit Maps'),
- 'description' => t('Allow users to edit map pages.'),
- ),
- 'adminster tripal featuremap' => array(
- 'title' => t('Administer Maps'),
- 'description' => t('Allow users to administer all maps.'),
- ),
- );
- }
- /**
- * 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_featuremap
- */
- function tripal_featuremap_menu() {
- $items = array();
- // The administative settings menu
- $items['admin/tripal/chado/tripal_featuremap'] = array(
- 'title' => 'Feature Maps',
- 'description' => 'A map of features from the chado database (e.g. genetic map)',
- 'page callback' => 'tripal_featuremap_admin_featuremaps_listing',
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/chado/tripal_featuremap/help'] = array(
- 'title' => 'Help',
- 'description' => 'Basic Description of Tripal Map Module Functionality',
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_featuremap_help'),
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 10
- );
- $items['admin/tripal/chado/tripal_featuremap/configuration'] = array(
- 'title' => 'Settings',
- 'description' => 'Manage integration of Chado maps including associated features.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_featuremap_admin'),
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2
- );
-
- $items['admin/tripal/chado/tripal_featuremap/sync'] = array(
- 'title' => ' Sync',
- 'description' => 'Sync featuremaps from Chado with Drupal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_featuremap', 'chado_featuremap'),
- 'access arguments' => array('administer tripal featuremaps'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 0
- );
- // Synchronizing maps from Chado to Drupal
- $items['chado_sync_featuremaps'] = array(
- 'title' => 'Sync Data',
- 'page callback' => 'tripal_featuremap_sync_featuremaps',
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_CALLBACK
- );
- // AJAX calls for adding/removing properties to a featuremap
- $items['tripal_featuremap/properties/add'] = array(
- 'page callback' => 'tripal_featuremap_property_add',
- 'access arguments' => array('edit chado_featuremap content'),
- 'type ' => MENU_CALLBACK,
- );
- $items['tripal_featuremap/properties/description'] = array(
- 'page callback' => 'tripal_featuremap_property_get_description',
- 'access arguments' => array('edit chado_featuremap content'),
- 'type ' => MENU_CALLBACK,
- );
- $items['tripal_featuremap/properties/minus/%/%'] = array(
- 'page callback' => 'tripal_featuremap_property_delete',
- 'page arguments' => array(3, 4),
- 'access arguments' => array('edit chado_featuremap content'),
- 'type ' => MENU_CALLBACK,
- );
- $items['admin/tripal/chado/tripal_featuremap/views/featuremaps/enable'] = array(
- 'title' => 'Enable featuremap Administrative View',
- 'page callback' => 'tripal_views_admin_enable_view',
- 'page arguments' => array('tripal_featuremap_admin_featuremaps', 'admin/tripal/chado/tripal_featuremap'),
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- /**
- * 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_featuremap
- */
- function tripal_featuremap_views_api() {
- return array(
- 'api' => 2.0,
- );
- }
- /**
- * 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_featuremap
- */
- function tripal_featuremap_theme($existing, $type, $theme, $path) {
- $core_path = drupal_get_path('module', 'tripal_core');
- $items = array(
- 'node__chado_featuremap' => array(
- 'template' => 'node--chado-generic',
- 'render element' => 'node',
- 'base hook' => 'node',
- 'path' => "$core_path/theme",
- ),
- 'tripal_featuremap_base' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_featuremap.base',
- 'path' => "$path/theme/tripal_featuremap",
- ),
- 'tripal_featuremap_properties' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_featuremap.properties',
- 'path' => "$path/theme/tripal_featuremap",
- ),
- 'tripal_featuremap_featurepos' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_featuremap.featurepos',
- 'path' => "$path/theme/tripal_featuremap",
- ),
- 'tripal_featuremap_publication' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_featuremap.publication',
- 'path' => "$path/theme/tripal_featuremap",
- ),
- 'tripal_featuremap_references' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_featuremap.references',
- 'path' => "$path/theme/tripal_featuremap",
- ),
- 'tripal_featuremap_help' => array(
- 'template' => 'tripal_featuremap.help',
- 'variables' => array(NULL),
- 'path' => "$path/theme",
- ),
- 'tripal_featuremap_teaser' => array(
- 'template' => 'tripal_featuremap.teaser',
- 'variables' => array(NULL),
- 'path' => "$path/theme/tripal_featuremap",
- ),
- );
- return $items;
- }
- /**
- *
- * @ingroup tripal_feature
- */
- function tripal_featuremap_node_view($node, $view_mode, $langcode) {
- switch ($node->type) {
- case 'chado_featuremap':
- // Show feature browser and counts
- if ($view_mode == 'full') {
- $node->content['tripal_featuremap_base'] = array(
- '#value' => theme('tripal_featuremap_base', array('node' => $node)),
- );
- $node->content['tripal_featuremap_featurepos'] = array(
- '#value' => theme('tripal_featuremap_featurepos', array('node' => $node)),
- );
- $node->content['tripal_featuremap_properties'] = array(
- '#value' => theme('tripal_featuremap_properties', array('node' => $node)),
- );
- $node->content['tripal_featuremap_publication'] = array(
- '#value' => theme('tripal_featuremap_publication', array('node' => $node)),
- );
- $node->content['tripal_featuremap_references'] = array(
- '#value' => theme('tripal_featuremap_references', array('node' => $node)),
- );
- }
- if ($view_mode == 'teaser') {
- $node->content['tripal_featuremap_teaser'] = array(
- '#value' => theme('tripal_featuremap_teaser', array('node' => $node)),
- );
- }
- break;
- }
- }
- /**
- * @ingroup tripal_library
- */
- function tripal_featuremap_block_info() {
- $blocks['mapbase']['info'] = t('Tripal Map Details');
- $blocks['mapbase']['cache'] = 'BLOCK_NO_CACHE';
- $blocks['mapprops']['info'] = t('Tripal Map Properties');
- $blocks['mapprops']['cache'] = 'BLOCK_NO_CACHE';
- $blocks['mappos']['info'] = t('Tripal Map Features');
- $blocks['mappos']['cache'] = 'BLOCK_NO_CACHE';
- $blocks['mappubs']['info'] = t('Tripal Map Publications');
- $blocks['mappubs']['cache'] = 'BLOCK_NO_CACHE';
- $blocks['maprefs']['info'] = t('Tripal Map References');
- $blocks['maprefs']['cache'] = 'BLOCK_NO_CACHE';
- return $blocks;
- }
- /**
- * @ingroup tripal_library
- */
- function tripal_featuremap_block_view($delta = '') {
- if (user_access('access chado_library content') and arg(0) == 'node' and is_numeric(arg(1))) {
- $nid = arg(1);
- $node = node_load($nid);
- $block = array();
- switch ($delta) {
- case 'mapbase':
- $block['subject'] = t('Library Details');
- $block['content'] = theme('tripal_featuremap_base', $node);
- break;
- case 'mapprops':
- $block['subject'] = t('Properties');
- $block['content'] = theme('tripal_featuremap_properties', $node);
- break;
- case 'mappos':
- $block['subject'] = t('Features');
- $block['content'] = theme('tripal_featuremap_featurepos', $node);
- break;
- case 'mappubs':
- $block['subject'] = t('Publications');
- $block['content'] = theme('tripal_featuremap_publication', $node);
- break;
- case 'maprefs':
- $block['subject'] = t('References');
- $block['content'] = theme('tripal_featuremap_references', $node);
- break;
- default :
- }
- return $block;
- }
- }
- /**
- *
- * @ingroup tripal_featuremap
- */
- function tripal_featuremap_cron() {
- }
- /**
- * Implementation of hook_form_alter()
- *
- * @param $form
- * @param $form_state
- * @param $form_id
- */
- function tripal_featuremap_form_alter(&$form, &$form_state, $form_id) {
- // turn of preview button for insert/updates
- if ($form_id == "chado_featuremap_node_form") {
- $form['actions']['preview']['#access'] = FALSE;
- }
- }
- /**
- *
- * @param $node
- */
- function tripal_featuremap_node_presave($node) {
- // if this is a chado_featuremap and the $node->featuremap object is set then we
- // are syncing and we want to set the node title to be the same as the node name
- if ($node->type == 'chado_featuremap' and property_exists($node, 'featuremap')) {
- $node->title = $node->featuremap->name;
- }
- }
|