123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544 |
- <?php
- require_once "api/tripal_pub.api.inc";
- require_once "theme/tripal_pub.theme.inc";
- require_once "includes/tripal_pub.admin.inc";
- require_once "includes/tripal_pub.pub_sync.inc";
- require_once "includes/tripal_pub.chado_node.inc";
- require_once "includes/tripal_pub.pub_importers.inc";
- require_once "includes/tripal_pub.pub_search.inc";
- require_once "includes/tripal_pub.pub_citation.inc";
- require_once "includes/importers/tripal_pub.PMID.inc";
- require_once "includes/importers/tripal_pub.AGL.inc";
- /**
- * @file
- *
- * The Tripal Publication module allows you to search the PubMed databse for academic articles,
- * that relate to user specified tpoic\s. As well, it allows management of publications so that
- * a user can enter specified details regarding a desired publication. This allows all of the important
- * information that is unique to a Academic Publication to be stored for access.
- */
- /**
- *
- * @ingroup tripal_pub
- */
- function tripal_pub_init() {
- drupal_add_css(drupal_get_path('module', 'tripal_pub') . '/theme/css/tripal_pub.css');
- drupal_add_js(drupal_get_path('module', 'tripal_pub') . '/theme/js/tripal_pub.js');
- }
- /**
- * Implementation of hook_tripal_pub_node_info().
- *
- * This node_info, is a simple node that describes the functionallity of the module.
- *
- */
- function tripal_pub_node_info() {
- return array(
- 'chado_pub' => array(
- 'name' => t('Publication'),
- 'base' => 'chado_pub',
- 'description' => t('A publication from the Chado database'),
- 'title_label' => t('Article Title'),
- 'body_label' => t('Abstract'),
- 'has_title' => TRUE,
- 'has_body' => FALSE,
- ),
- );
- }
- /**
- * Tripal-Publication-Menu
- *
- * Implements hook_menu(): Adds menu items for the tripal_pub module menu. This section
- * gives the outline for the main menu of the Tripal-Publication module
- *
- * @return
- * An array of menu items that is visible within the Drupal Menu, returned as soon
- * as the program is ran
- */
- function tripal_pub_menu() {
- $items = array();
- $items['find/publications' ]= array(
- 'title' => 'Publication Search',
- 'description' => ('Search for publications'),
- 'page callback' => 'tripal_pub_search_page',
- 'access arguments' => array('access chado_pub content'),
- 'type' => MENU_CALLBACK
- );
- $items['find/publications/criteria/%/%'] = array(
- 'page callback' => 'tripal_pub_search_page_update_criteria',
- 'page arguments' => array(5, 6),
- 'access arguments' => array('access chado_pub content'),
- 'type ' => MENU_CALLBACK,
- );
- $items['admin/tripal/chado/tripal_pub']= array(
- 'title' => 'Publications',
- 'description' => ('A documented provenance artefact - publications, documents, personal communication.'),
- 'page callback' => 'tripal_pub_admin_pub_view',
- 'access arguments' => array('administer tripal pubs'),
- 'type' => MENU_NORMAL_ITEM
- );
- $items['admin/tripal/chado/tripal_pub/help']= array(
- 'title' => 'Help',
- 'description' => ('A module for interfacing the GMOD chado database with Drupal, providing viewing of publications'),
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_pub_help'),
- 'access arguments' => array('administer tripal pubs'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 10
- );
- $items['admin/tripal/chado/tripal_pub/configuration'] = array(
- 'title' => 'Settings',
- 'description' => 'Configure the Tripal publication module.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_pub_admin'),
- 'access arguments' => array('administer tripal pubs'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 5
- );
- $items['admin/tripal/chado/tripal_pub/sync'] = array(
- 'title' => ' Sync',
- 'description' => 'Sync publications in Chado with Drupal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_pub_sync_form'),
- 'access arguments' => array('administer tripal pubs'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2
- );
- $items['admin/tripal/chado/tripal_pub/citation'] = array(
- 'title' => 'Citations',
- 'description' => 'Update publication citations',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_pub_citation_form'),
- 'access arguments' => array('administer tripal pubs'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1
- );
-
- $items['admin/tripal/chado/tripal_pub/import_list'] = array(
- 'title' => t('Importers'),
- 'description' => t('List all publication importers'),
- 'page callback' => 'tripal_pub_importers_list',
- 'access arguments' => array('administer tripal pubs'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 0
- );
-
- // add a second link for the importer on the data loaders page
- $items['admin/tripal/loaders/pub_import'] = array(
- 'title' => 'Publications Importers',
- 'description' => 'Create importers that can periodically import publications from remote online publication databases.',
- 'page callback' => 'tripal_pub_importers_list',
- 'access arguments' => array('administer tripal pubs'),
- 'type' => MENU_NORMAL_ITEM,
- );
-
- $items['admin/tripal/chado/tripal_pub/import/new'] = array(
- 'title' => t('Add an Importer'),
- 'description' => t('Add a new publication importer.'),
- 'page callback' => 'tripal_pub_importer_setup_page',
- 'access arguments' => array('administer tripal pubs'),
- 'type ' => MENU_CALLBACK,
- );
- $items['admin/tripal/chado/tripal_pub/import/raw/%'] = array(
- 'page callback' => 'tripal_pub_get_raw_data',
- 'page arguments' => array(6),
- 'access arguments' => array('administer tripal pubs'),
- 'type ' => MENU_CALLBACK,
- );
- $items['admin/tripal/chado/tripal_pub/import/edit/%'] = array(
- 'page callback' => 'tripal_pub_importer_setup_page',
- 'page arguments' => array(5, 6),
- 'access arguments' => array('administer tripal pubs'),
- 'type ' => MENU_CALLBACK,
- );
-
- $items['admin/tripal/chado/tripal_pub/import/submit/%'] = array(
- 'page callback' => 'tripal_pub_importer_submit_job',
- 'page arguments' => array(6),
- 'access arguments' => array('administer tripal pubs'),
- 'type ' => MENU_CALLBACK,
- );
- $items['admin/tripal/chado/tripal_pub/import/delete/%'] = array(
- 'page callback' => 'tripal_pub_importer_delete',
- 'page arguments' => array(5),
- 'access arguments' => array('administer tripal pubs'),
- 'type ' => MENU_CALLBACK,
- );
- $items['admin/tripal/chado/tripal_pub/import/changedb'] = array(
- 'page callback' => 'tripal_pub_importer_setup_page_update_remotedb',
- 'page arguments' => array(),
- 'access arguments' => array('administer tripal pubs'),
- 'type ' => MENU_CALLBACK,
- );
- $items['admin/tripal/chado/tripal_pub/import/criteria/%/%'] = array(
- 'page callback' => 'tripal_pub_importer_setup_page_update_criteria',
- 'page arguments' => array(5, 6),
- 'access arguments' => array('administer tripal pubs'),
- 'type ' => MENU_CALLBACK,
- );
- $items['tripal_pub/chado/properties/add'] = array(
- 'page callback' => 'tripal_pub_property_add',
- 'access arguments' => array('edit chado_pub content'),
- 'type ' => MENU_CALLBACK,
- );
- $items['tripal_pub/chado/properties/description'] = array(
- 'page callback' => 'tripal_pub_property_get_description',
- 'access arguments' => array('edit chado_pub content'),
- 'type ' => MENU_CALLBACK,
- );
- $items['tripal_pub/chado/properties/minus/%/%'] = array(
- 'page callback' => 'tripal_pub_property_delete',
- 'page arguments' => array(3, 4),
- 'access arguments' => array('edit chado_pub content'),
- 'type ' => MENU_CALLBACK,
- );
- return $items;
- }
- /**
- * Implements hook_theme(): Register themeing functions for this module
- *
- *
- * @return
- * An array of themeing functions to register
- *
- */
- function tripal_pub_theme($existing, $type, $theme, $path) {
- $core_path = drupal_get_path('module', 'tripal_core');
-
- $items = array(
- 'node__chado_pub' => array(
- 'template' => 'node--chado-generic',
- 'render element' => 'node',
- 'base hook' => 'node',
- 'path' => "$core_path/theme",
- ),
- // node templates
- 'tripal_pub_authors' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_authors',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_base' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_base',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_featuremaps' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_featuremaps',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_features' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_features',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_libraries' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_libraries',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_projects' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_projects',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_properties' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_properties',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_references' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_references',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_relationships' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_relationships',
- 'path' => "$path/theme/tripal_pub",
- ),
- 'tripal_pub_stocks' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_pub_stocks',
- 'path' => "$path/theme/tripal_pub",
- ),
- // instructions page for the pub module
- 'tripal_pub_help' => array(
- 'template' => 'tripal_pub_help',
- 'arguments' => array(NULL),
- 'path' => "$path/theme",
- ),
- // themed forms
- 'tripal_pub_importer_setup_form_elements' => array(
- 'render element' => 'form',
- ),
- 'tripal_pub_search_setup_form_elements' => array(
- 'render element' => 'form',
- ),
-
- // teaser
- 'tripal_pub_teaser' => array(
- 'variables' => array('node' => NULL),
- 'template' => 'tripal_pub_teaser',
- 'path' => "$path/theme/tripal_pub",
- ),
- );
- return $items;
- }
- /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
- */
- function tripal_pub_help ($path, $arg) {
- if ($path == 'admin/help#tripal_pub') {
- return theme('tripal_pub_help', array());
- }
- }
- /**
- * 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_pub
- */
- function tripal_pub_views_api() {
- return array(
- 'api' => 3.0,
- );
- }
- /**
- * Implement hook_permissions().
- */
- function tripal_pub_permissions() {
- return array(
- 'access chado_pub content' => array(
- 'title' => t('View Publications'),
- 'description' => t('Allow users to view publication pages.'),
- ),
- 'create chado_pub content' => array(
- 'title' => t('Create Publication'),
- 'description' => t('Allow users to create new publication pages.'),
- ),
- 'delete chado_pub content' => array(
- 'title' => t('Delete Publication'),
- 'description' => t('Allow users to delete publication pages.'),
- ),
- 'edit chado_pub content' => array(
- 'title' => t('Edit Publications'),
- 'description' => t('Allow users to edit publication pages.'),
- ),
- 'adminster tripal pub' => array(
- 'title' => t('Administer Publications'),
- 'description' => t('Allow users to administer all publications.'),
- ),
- );
- }
- /**
- *
- */
- function tripal_pub_mail($key, &$message, $params) {
- $language = $message['language'];
- $variables = user_mail_tokens($params['account'], $language);
- switch($key) {
- case 'import_report':
- $headers = array(
- 'MIME-Version' => '1.0',
- 'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
- 'Content-Transfer-Encoding' => '8Bit',
- 'X-Mailer' => 'Drupal'
- );
- foreach ($headers as $key => $value) {
- $message['headers'][$key] = $value;
- }
- $message['subject'] = t('Publication import from !site', $variables, $language->language);
- $message['body'][] = $params['message'];
- break;
- }
- }
- /**
- *
- * @ingroup tripal_feature
- */
- function tripal_pub_node_view($node, $view_mode, $langcode) {
- switch ($node->type) {
- case 'chado_pub':
- // Show feature browser and counts
- if ($view_mode == 'full') {
- $node->content['tripal_pub_authors'] = array(
- '#value' => theme('tripal_pub_authors', array('node' => $node)),
- );
- $node->content['tripal_pub_base'] = array(
- '#value' => theme('tripal_pub_base', array('node' => $node)),
- );
- $node->content['tripal_pub_featuremaps'] = array(
- '#value' => theme('tripal_pub_featuremaps', array('node' => $node)),
- );
- $node->content['tripal_pub_features'] = array(
- '#value' => theme('tripal_pub_features', array('node' => $node)),
- );
- $node->content['tripal_pub_libraries'] = array(
- '#value' => theme('tripal_pub_libraries', array('node' => $node)),
- );
- $node->content['tripal_pub_projects'] = array(
- '#value' => theme('tripal_pub_projects', array('node' => $node)),
- );
- $node->content['tripal_pub_properties'] = array(
- '#value' => theme('tripal_pub_properties', array('node' => $node)),
- );
- $node->content['tripal_pub_references'] = array(
- '#value' => theme('tripal_pub_references', array('node' => $node)),
- );
- $node->content['tripal_pub_relationships'] = array(
- '#value' => theme('tripal_pub_relationships', array('node' => $node)),
- );
- $node->content['tripal_pub_stocks'] = array(
- '#value' => theme('tripal_pub_stocks', array('node' => $node)),
- );
- }
- if ($view_mode == 'teaser') {
- $node->content['tripal_pub_teaser'] = array(
- '#value' => theme('tripal_pub_teaser', array('node' => $node)),
- );
- }
- break;
- }
- }
- /**
- *
- * @param $node
- */
- function tripal_pub_node_insert($node) {
- // we want the publications to always have a URL of http://[base url]/pub/[pub id]
- // where [pub id] is the Chado publication ID. This will allow for easy linking
- // into the publication without needing to know the node. Of course if you know the
- // node that will still work too (e.g. http://[base url]/node/[node id]
- // so the nodeapi function ensures that the URL path is set after insert or update
- // of the node and when the node is loaded if it hasn't yet been set.
- if ($node->type == 'chado_pub') {
- $pub_id = chado_get_id_for_node('pub', $node->nid);
- tripal_pub_set_pub_url($node, $pub_id);
- }
- }
- /**
- *
- * @param $node
- * @param $types
- */
- function tripal_pub_node_load($nodes, $types) {
- // we want the publications to always have a URL of http://[base url]/pub/[pub id]
- // where [pub id] is the Chado publication ID. This will allow for easy linking
- // into the publication without needing to know the node. Of course if you know the
- // node that will still work too (e.g. http://[base url]/node/[node id]
- // so the nodeapi function ensures that the URL path is set after insert or update
- // of the node and when the node is loaded if it hasn't yet been set.
- if (count(array_intersect(array('chado_pub'), $types))) {
- foreach ($nodes as $nid => $node) {
- if ($node->type == 'chado_pub' and !property_exists($node, 'path')) {
- $pub_id = chado_get_id_for_node('pub', $node->nid);
- $path = tripal_pub_set_pub_url($node, $pub_id);
- }
- }
- }
- }
- /**
- *
- * @param $node
- */
- function tripal_pub_node_update($node) {
- // we want the publications to always have a URL of http://[base url]/pub/[pub id]
- // where [pub id] is the Chado publication ID. This will allow for easy linking
- // into the publication without needing to know the node. Of course if you know the
- // node that will still work too (e.g. http://[base url]/node/[node id]
- // so the nodeapi function ensures that the URL path is set after insert or update
- // of the node and when the node is loaded if it hasn't yet been set.
- if ($node->type == 'chado_pub') {
- $pub_id = chado_get_id_for_node('pub', $node->nid);
- tripal_pub_set_pub_url($node, $pub_id);
- }
- }
- /**
- * Implementation of hook_form_alter()
- *
- * @param $form
- * @param $form_state
- * @param $form_id
- */
- function tripal_pub_form_alter(&$form, &$form_state, $form_id) {
- // turn of preview button for insert/updates
- if ($form_id == "chado_pub_node_form") {
- $form['actions']['preview']['#access'] = FALSE;
- }
- if ($form_id == "tripal_pub_importer_setup_form") {
- /* // updating the form through the ahah callback sets the action of
- // the form to the ahah callback URL. We need to set it back
- // to the normal form URL
- if (array_key_exists('values', $form_state) and $form_state['values']['action'] == 'edit') {
- $form['#action'] = url("admin/tripal/chado/tripal_pub/import/edit/" . $form_state['values']['pub_import_id']);
- }
- if (array_key_exists('values', $form_state) and $form_state['values']['action'] == 'new') {
- $form['#action'] = url("admin/tripal/chado/tripal_pub/import/new");
- }
- */
- }
- if ($form_id == "tripal_pub_search_form") {
- $form['#action'] = url("find/publications");
- }
- if ($form_id == "chado_pub_node_form") {
- }
- }
- /**
- *
- * @param $callback
- * @param $args
- */
- function tripal_pub_job_describe_args($callback, $args) {
- $new_args = array();
- if ($callback == 'tripal_pub_import_publications_by_import_id') {
- // get all of the loaders
- $qargs = array(':import_id' => $args[0]);
- $sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :import_id ";
- $import = db_query($sql, $qargs)->fetchObject();
-
- $new_args['Importer'] = $import->name;
- }
- return $new_args;
- }
|