123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- <?php
- require('api/tripal_project.api.inc');
- require('theme/tripal_project.theme.inc');
- require('includes/tripal_project.admin.inc');
- require('includes/tripal_project.chado_node.inc');
- /**
- * @file
- * This file contains the basic functions needed for this drupal module.
- * The drupal tripal_project module maps directly to the chado general module.
- *
- * For documentation regarding the Chado General module:
- * @see http://gmod.org/wiki/Chado_General_Module
- *
- * @defgroup tripal_project Project Module
- * @ingroup tripal_modules
- */
- /**
- * Implementation of hook_node_info().
- *
- * This node_info, is a simple node that describes the functionallity of the module. It specifies
- * that the title(Project Name) and body(Description) set to true so that they information can be
- * entered
- *
- *
- * @ingroup tripal_project
- */
- function tripal_project_node_info() {
- return array(
- 'chado_project' => array(
- 'name' => t('Project'),
- 'base' => 'chado_project',
- 'description' => t('A project from the Chado database'),
- 'has_title' => TRUE,
- 'title_label' => t('Project Name'),
- 'had_body' => TRUE,
- 'body_label' => t('Full Description'),
- 'chado_node_api' => array(
- 'base_table' => 'project',
- 'hook_prefix' => 'chado_project',
- 'record_type_title' => array(
- 'singular' => t('Project'),
- 'plural' => t('Projects')
- ),
- 'sync_filters' => array(
- 'type_id' => FALSE,
- 'organism_id' => FALSE
- ),
- ),
- ),
- );
- }
- /**
- * Implements hook_views_api()
- *
- * Purpose: Essentially this hook tells drupal that there is views support for
- * for this module which then includes tripal_project.views.inc where all the
- * views integration code is
- *
- * @ingroup tripal_project
- *
- */
- function tripal_project_views_api() {
- return array(
- 'api' => 2.0,
- );
- }
- /**
- * Implements hook_menu
- *
- * @ingroup tripal_project
- */
- function tripal_project_menu() {
- $items[ 'admin/tripal/chado/tripal_project' ]= array(
- 'title' => 'Projects',
- 'description' => ('A project. Can be used for grouping data such as with the natural diversity module data.'),
- 'page callback' => 'tripal_project_admin_project_view',
- 'access arguments' => array('adminster tripal projects'),
- 'type' => MENU_NORMAL_ITEM
- );
- $items['admin/tripal/chado/tripal_project/help']= array(
- 'title' => 'Help',
- 'description' => ("Basic Description of Tripal Project Module Functionality."),
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_project_help'),
- 'access arguments' => array('adminster tripal projects'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 6
- );
- $items['admin/tripal/chado/tripal_project/configuration']= array(
- 'title' => 'Settings',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_project_admin'),
- 'access arguments' => array('adminster tripal projects'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 4
- );
- $items['admin/tripal/chado/tripal_project/sync'] = array(
- 'title' => ' Sync',
- 'description' => 'Create pages on this site for projects stored in Chado',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_project', 'chado_project'),
- 'access arguments' => array('administer tripal projects'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 0
- );
-
- $items['admin/tripal/chado/tripal_project/views/projects/enable'] = array(
- 'title' => 'Enable Project Administrative View',
- 'page callback' => 'tripal_views_admin_enable_view',
- 'page arguments' => array('tripal_project_admin_projects', 'admin/tripal/chado/tripal_project'),
- 'access arguments' => array('administer tripal projects'),
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
- */
- function tripal_project_help ($path, $arg) {
- if ($path == 'admin/help#tripal_project') {
- return theme('tripal_project_help', array());
- }
- }
- /**
- * Implements hook_perm()
- *
- * This function sets the permission for the user to access the information in the database.
- * This includes creating, inserting, deleting and updating of information in the database
- *
- *
- * @ingroup tripal_project
- */
- function tripal_project_permission() {
- return array(
- 'access chado_project content' => array(
- 'title' => t('View Projects'),
- 'description' => t('Allow users to view project pages.'),
- ),
- 'create chado_project content' => array(
- 'title' => t('Create Projects'),
- 'description' => t('Allow users to create new project pages.'),
- ),
- 'delete chado_project content' => array(
- 'title' => t('Delete Projects'),
- 'description' => t('Allow users to delete project pages.'),
- ),
- 'edit chado_project content' => array(
- 'title' => t('Edit Projects'),
- 'description' => t('Allow users to edit project pages.'),
- ),
- 'adminster tripal project' => array(
- 'title' => t('Administer Projects'),
- 'description' => t('Allow users to administer all projects.'),
- ),
- );
- }
- /**
- * 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_project
- */
- function tripal_project_theme($existing, $type, $theme, $path) {
- $core_path = drupal_get_path('module', 'tripal_core');
- $items = array(
- 'node__chado_project' => array(
- 'template' => 'node--chado-generic',
- 'render element' => 'node',
- 'base hook' => 'node',
- 'path' => "$core_path/theme",
- ),
- 'tripal_project_base' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_project.base',
- 'path' => "$path/theme/tripal_project",
- ),
- 'tripal_project_contact' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_project.contact',
- 'path' => "$path/theme/tripal_project",
- ),
- 'tripal_project_properties' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_project.properties',
- 'path' => "$path/theme/tripal_project",
- ),
- 'tripal_project_publications' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_project.publications',
- 'path' => "$path/theme/tripal_project",
- ),
- 'tripal_project_relationships' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_project.relationships',
- 'path' => "$path/theme/tripal_project",
- ),
- 'tripal_project_teaser' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_project.teaser',
- 'path' => "$path/theme/tripal_project",
- ),
- 'tripal_project_help' => array(
- 'variables' => 'tripal_project.help',
- 'variables' => array(NULL),
- 'path' => "$path/theme",
- ),
- );
- return $items;
- }
- /**
- *
- * @ingroup tripal_feature
- */
- function tripal_project_node_view($node, $view_mode, $langcode) {
- switch ($node->type) {
- case 'chado_project':
- // Show feature browser and counts
- if ($view_mode == 'full') {
- $node->content['tripal_project_base'] = array(
- '#value' => theme('tripal_project_base', array('node' => $node)),
- );
- $node->content['tripal_project_contact'] = array(
- '#value' => theme('tripal_project_contact', array('node' => $node)),
- );
- $node->content['tripal_project_properties'] = array(
- '#value' => theme('tripal_project_properties', array('node' => $node)),
- );
- $node->content['tripal_project_publications'] = array(
- '#value' => theme('tripal_project_publications', array('node' => $node)),
- );
- $node->content['tripal_project_relationships'] = array(
- '#value' => theme('tripal_project_relationships', array('node' => $node)),
- );
- }
- if ($view_mode == 'teaser') {
- $node->content['tripal_project_teaser'] = array(
- '#value' => theme('tripal_project_teaser', array('node' => $node)),
- );
- }
- break;
- }
- }
- /**
- *
- * @ingroup tripal_project
- */
- function tripal_project_block_info() {
- $blocks['projectbase']['info'] = t('Tripal Project Details');
- $blocks['projectbase']['cache'] = DRUPAL_NO_CACHE;
- $blocks['projectprops']['info'] = t('Tripal Project Properties');
- $blocks['projectprops']['cache'] = DRUPAL_NO_CACHE;
- $blocks['projectpubs']['info'] = t('Tripal Project Publications');
- $blocks['projectpubs']['cache'] = DRUPAL_NO_CACHE;
- $blocks['projectcont']['info'] = t('Tripal Project Contact');
- $blocks['projectcont']['cache'] = DRUPAL_NO_CACHE;
- $blocks['projectrels']['info'] = t('Tripal Project Relationships');
- $blocks['projectrels']['cache'] = DRUPAL_NO_CACHE;
- return $blocks;
- }
- /**
- *
- * @ingroup tripal_project
- */
- function tripal_project_block_view($delta = '') {
- if (user_access('access chado_project content') and arg(0) == 'node' and is_numeric(arg(1))) {
- $nid = arg(1);
- $node = node_load($nid);
- $block = array();
- switch ($delta) {
- case 'projectbase':
- $block['subject'] = t('Project Details');
- $block['content'] = theme('tripal_project_base', $node);
- break;
- case 'projectprops':
- $block['subject'] = t('Properties');
- $block['content'] = theme('tripal_project_properties', $node);
- break;
- case 'projectpubs':
- $block['subject'] = t('Publications');
- $block['content'] = theme('tripal_project_publications', $node);
- break;
- case 'projectcont':
- $block['subject'] = t('Contact');
- $block['content'] = theme('tripal_project_contact', $node);
- break;
- case 'projectrels':
- $block['subject'] = t('Relationships');
- $block['content'] = theme('tripal_project_relationships', $node);
- break;
- default :
- }
- return $block;
- }
- }
- /**
- * Implementation of hook_form_alter()
- *
- * @param $form
- * @param $form_state
- * @param $form_id
- */
- function tripal_project_form_alter(&$form, &$form_state, $form_id) {
- // turn of preview button for insert/updates
- if ($form_id == "chado_project_node_form") {
- $form['actions']['preview']['#access'] = FALSE;
- }
- }
|